michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ClientLayerManager.h" // for ClientLayerManager, etc michael@0: #include "Layers.h" // for ColorLayer, etc michael@0: #include "mozilla/layers/LayersMessages.h" // for ColorLayerAttributes, etc michael@0: #include "mozilla/mozalloc.h" // for operator new michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nsCOMPtr.h" // for already_AddRefed michael@0: #include "nsDebug.h" // for NS_ASSERTION michael@0: #include "nsISupportsImpl.h" // for Layer::AddRef, etc michael@0: #include "nsRegion.h" // for nsIntRegion michael@0: michael@0: using namespace mozilla::gfx; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class ClientColorLayer : public ColorLayer, michael@0: public ClientLayer { michael@0: public: michael@0: ClientColorLayer(ClientLayerManager* aLayerManager) : michael@0: ColorLayer(aLayerManager, michael@0: static_cast(MOZ_THIS_IN_INITIALIZER_LIST())) michael@0: { michael@0: MOZ_COUNT_CTOR(ClientColorLayer); michael@0: } michael@0: virtual ~ClientColorLayer() michael@0: { michael@0: MOZ_COUNT_DTOR(ClientColorLayer); michael@0: } michael@0: michael@0: virtual void SetVisibleRegion(const nsIntRegion& aRegion) michael@0: { michael@0: NS_ASSERTION(ClientManager()->InConstruction(), michael@0: "Can only set properties in construction phase"); michael@0: ColorLayer::SetVisibleRegion(aRegion); michael@0: } michael@0: michael@0: virtual void RenderLayer() michael@0: { michael@0: if (GetMaskLayer()) { michael@0: ToClientLayer(GetMaskLayer())->RenderLayer(); michael@0: } michael@0: } michael@0: michael@0: virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) michael@0: { michael@0: aAttrs = ColorLayerAttributes(GetColor(), GetBounds()); michael@0: } michael@0: michael@0: virtual Layer* AsLayer() { return this; } michael@0: virtual ShadowableLayer* AsShadowableLayer() { return this; } michael@0: michael@0: virtual void Disconnect() michael@0: { michael@0: ClientLayer::Disconnect(); michael@0: } michael@0: michael@0: protected: michael@0: ClientLayerManager* ClientManager() michael@0: { michael@0: return static_cast(mManager); michael@0: } michael@0: }; michael@0: michael@0: already_AddRefed michael@0: ClientLayerManager::CreateColorLayer() michael@0: { michael@0: NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); michael@0: nsRefPtr layer = michael@0: new ClientColorLayer(this); michael@0: CREATE_SHADOW(Color); michael@0: return layer.forget(); michael@0: } michael@0: michael@0: } michael@0: }