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: #ifndef GFX_CLIENTTHEBESLAYER_H michael@0: #define GFX_CLIENTTHEBESLAYER_H michael@0: michael@0: #include "ClientLayerManager.h" // for ClientLayerManager, etc michael@0: #include "Layers.h" // for ThebesLayer, etc michael@0: #include "RotatedBuffer.h" // for RotatedContentBuffer, etc michael@0: #include "mozilla/Attributes.h" // for MOZ_OVERRIDE michael@0: #include "mozilla/RefPtr.h" // for RefPtr michael@0: #include "mozilla/layers/ContentClient.h" // for ContentClient michael@0: #include "mozilla/mozalloc.h" // for operator delete michael@0: #include "nsDebug.h" // for NS_ASSERTION michael@0: #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc michael@0: #include "nsRegion.h" // for nsIntRegion michael@0: #include "mozilla/layers/PLayerTransaction.h" // for ThebesLayerAttributes michael@0: michael@0: class gfxContext; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class CompositableClient; michael@0: class ShadowableLayer; michael@0: class SpecificLayerAttributes; michael@0: michael@0: class ClientThebesLayer : public ThebesLayer, michael@0: public ClientLayer { michael@0: public: michael@0: typedef RotatedContentBuffer::PaintState PaintState; michael@0: typedef RotatedContentBuffer::ContentType ContentType; michael@0: michael@0: ClientThebesLayer(ClientLayerManager* aLayerManager) : michael@0: ThebesLayer(aLayerManager, michael@0: static_cast(MOZ_THIS_IN_INITIALIZER_LIST())), michael@0: mContentClient(nullptr) michael@0: { michael@0: MOZ_COUNT_CTOR(ClientThebesLayer); michael@0: } michael@0: virtual ~ClientThebesLayer() michael@0: { michael@0: if (mContentClient) { michael@0: mContentClient->OnDetach(); michael@0: mContentClient = nullptr; michael@0: } michael@0: MOZ_COUNT_DTOR(ClientThebesLayer); 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: ThebesLayer::SetVisibleRegion(aRegion); michael@0: } michael@0: virtual void InvalidateRegion(const nsIntRegion& aRegion) michael@0: { michael@0: NS_ASSERTION(ClientManager()->InConstruction(), michael@0: "Can only set properties in construction phase"); michael@0: mInvalidRegion.Or(mInvalidRegion, aRegion); michael@0: mInvalidRegion.SimplifyOutward(20); michael@0: mValidRegion.Sub(mValidRegion, mInvalidRegion); michael@0: } michael@0: michael@0: virtual void RenderLayer(); michael@0: michael@0: virtual void ClearCachedResources() michael@0: { michael@0: if (mContentClient) { michael@0: mContentClient->Clear(); michael@0: } michael@0: mValidRegion.SetEmpty(); michael@0: DestroyBackBuffer(); michael@0: } michael@0: michael@0: virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) michael@0: { michael@0: aAttrs = ThebesLayerAttributes(GetValidRegion()); michael@0: } michael@0: michael@0: ClientLayerManager* ClientManager() michael@0: { michael@0: return static_cast(mManager); michael@0: } michael@0: michael@0: virtual Layer* AsLayer() { return this; } michael@0: virtual ShadowableLayer* AsShadowableLayer() { return this; } michael@0: michael@0: virtual CompositableClient* GetCompositableClient() MOZ_OVERRIDE michael@0: { michael@0: return mContentClient; michael@0: } michael@0: michael@0: virtual void Disconnect() michael@0: { michael@0: mContentClient = nullptr; michael@0: ClientLayer::Disconnect(); michael@0: } michael@0: michael@0: protected: michael@0: void PaintThebes(); michael@0: michael@0: void DestroyBackBuffer() michael@0: { michael@0: mContentClient = nullptr; michael@0: } michael@0: michael@0: RefPtr mContentClient; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif