1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/client/ClientThebesLayer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_CLIENTTHEBESLAYER_H 1.10 +#define GFX_CLIENTTHEBESLAYER_H 1.11 + 1.12 +#include "ClientLayerManager.h" // for ClientLayerManager, etc 1.13 +#include "Layers.h" // for ThebesLayer, etc 1.14 +#include "RotatedBuffer.h" // for RotatedContentBuffer, etc 1.15 +#include "mozilla/Attributes.h" // for MOZ_OVERRIDE 1.16 +#include "mozilla/RefPtr.h" // for RefPtr 1.17 +#include "mozilla/layers/ContentClient.h" // for ContentClient 1.18 +#include "mozilla/mozalloc.h" // for operator delete 1.19 +#include "nsDebug.h" // for NS_ASSERTION 1.20 +#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc 1.21 +#include "nsRegion.h" // for nsIntRegion 1.22 +#include "mozilla/layers/PLayerTransaction.h" // for ThebesLayerAttributes 1.23 + 1.24 +class gfxContext; 1.25 + 1.26 +namespace mozilla { 1.27 +namespace layers { 1.28 + 1.29 +class CompositableClient; 1.30 +class ShadowableLayer; 1.31 +class SpecificLayerAttributes; 1.32 + 1.33 +class ClientThebesLayer : public ThebesLayer, 1.34 + public ClientLayer { 1.35 +public: 1.36 + typedef RotatedContentBuffer::PaintState PaintState; 1.37 + typedef RotatedContentBuffer::ContentType ContentType; 1.38 + 1.39 + ClientThebesLayer(ClientLayerManager* aLayerManager) : 1.40 + ThebesLayer(aLayerManager, 1.41 + static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST())), 1.42 + mContentClient(nullptr) 1.43 + { 1.44 + MOZ_COUNT_CTOR(ClientThebesLayer); 1.45 + } 1.46 + virtual ~ClientThebesLayer() 1.47 + { 1.48 + if (mContentClient) { 1.49 + mContentClient->OnDetach(); 1.50 + mContentClient = nullptr; 1.51 + } 1.52 + MOZ_COUNT_DTOR(ClientThebesLayer); 1.53 + } 1.54 + 1.55 + virtual void SetVisibleRegion(const nsIntRegion& aRegion) 1.56 + { 1.57 + NS_ASSERTION(ClientManager()->InConstruction(), 1.58 + "Can only set properties in construction phase"); 1.59 + ThebesLayer::SetVisibleRegion(aRegion); 1.60 + } 1.61 + virtual void InvalidateRegion(const nsIntRegion& aRegion) 1.62 + { 1.63 + NS_ASSERTION(ClientManager()->InConstruction(), 1.64 + "Can only set properties in construction phase"); 1.65 + mInvalidRegion.Or(mInvalidRegion, aRegion); 1.66 + mInvalidRegion.SimplifyOutward(20); 1.67 + mValidRegion.Sub(mValidRegion, mInvalidRegion); 1.68 + } 1.69 + 1.70 + virtual void RenderLayer(); 1.71 + 1.72 + virtual void ClearCachedResources() 1.73 + { 1.74 + if (mContentClient) { 1.75 + mContentClient->Clear(); 1.76 + } 1.77 + mValidRegion.SetEmpty(); 1.78 + DestroyBackBuffer(); 1.79 + } 1.80 + 1.81 + virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) 1.82 + { 1.83 + aAttrs = ThebesLayerAttributes(GetValidRegion()); 1.84 + } 1.85 + 1.86 + ClientLayerManager* ClientManager() 1.87 + { 1.88 + return static_cast<ClientLayerManager*>(mManager); 1.89 + } 1.90 + 1.91 + virtual Layer* AsLayer() { return this; } 1.92 + virtual ShadowableLayer* AsShadowableLayer() { return this; } 1.93 + 1.94 + virtual CompositableClient* GetCompositableClient() MOZ_OVERRIDE 1.95 + { 1.96 + return mContentClient; 1.97 + } 1.98 + 1.99 + virtual void Disconnect() 1.100 + { 1.101 + mContentClient = nullptr; 1.102 + ClientLayer::Disconnect(); 1.103 + } 1.104 + 1.105 +protected: 1.106 + void PaintThebes(); 1.107 + 1.108 + void DestroyBackBuffer() 1.109 + { 1.110 + mContentClient = nullptr; 1.111 + } 1.112 + 1.113 + RefPtr<ContentClient> mContentClient; 1.114 +}; 1.115 + 1.116 +} 1.117 +} 1.118 + 1.119 +#endif