|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef GFX_CLIENTTHEBESLAYER_H |
|
7 #define GFX_CLIENTTHEBESLAYER_H |
|
8 |
|
9 #include "ClientLayerManager.h" // for ClientLayerManager, etc |
|
10 #include "Layers.h" // for ThebesLayer, etc |
|
11 #include "RotatedBuffer.h" // for RotatedContentBuffer, etc |
|
12 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE |
|
13 #include "mozilla/RefPtr.h" // for RefPtr |
|
14 #include "mozilla/layers/ContentClient.h" // for ContentClient |
|
15 #include "mozilla/mozalloc.h" // for operator delete |
|
16 #include "nsDebug.h" // for NS_ASSERTION |
|
17 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc |
|
18 #include "nsRegion.h" // for nsIntRegion |
|
19 #include "mozilla/layers/PLayerTransaction.h" // for ThebesLayerAttributes |
|
20 |
|
21 class gfxContext; |
|
22 |
|
23 namespace mozilla { |
|
24 namespace layers { |
|
25 |
|
26 class CompositableClient; |
|
27 class ShadowableLayer; |
|
28 class SpecificLayerAttributes; |
|
29 |
|
30 class ClientThebesLayer : public ThebesLayer, |
|
31 public ClientLayer { |
|
32 public: |
|
33 typedef RotatedContentBuffer::PaintState PaintState; |
|
34 typedef RotatedContentBuffer::ContentType ContentType; |
|
35 |
|
36 ClientThebesLayer(ClientLayerManager* aLayerManager) : |
|
37 ThebesLayer(aLayerManager, |
|
38 static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST())), |
|
39 mContentClient(nullptr) |
|
40 { |
|
41 MOZ_COUNT_CTOR(ClientThebesLayer); |
|
42 } |
|
43 virtual ~ClientThebesLayer() |
|
44 { |
|
45 if (mContentClient) { |
|
46 mContentClient->OnDetach(); |
|
47 mContentClient = nullptr; |
|
48 } |
|
49 MOZ_COUNT_DTOR(ClientThebesLayer); |
|
50 } |
|
51 |
|
52 virtual void SetVisibleRegion(const nsIntRegion& aRegion) |
|
53 { |
|
54 NS_ASSERTION(ClientManager()->InConstruction(), |
|
55 "Can only set properties in construction phase"); |
|
56 ThebesLayer::SetVisibleRegion(aRegion); |
|
57 } |
|
58 virtual void InvalidateRegion(const nsIntRegion& aRegion) |
|
59 { |
|
60 NS_ASSERTION(ClientManager()->InConstruction(), |
|
61 "Can only set properties in construction phase"); |
|
62 mInvalidRegion.Or(mInvalidRegion, aRegion); |
|
63 mInvalidRegion.SimplifyOutward(20); |
|
64 mValidRegion.Sub(mValidRegion, mInvalidRegion); |
|
65 } |
|
66 |
|
67 virtual void RenderLayer(); |
|
68 |
|
69 virtual void ClearCachedResources() |
|
70 { |
|
71 if (mContentClient) { |
|
72 mContentClient->Clear(); |
|
73 } |
|
74 mValidRegion.SetEmpty(); |
|
75 DestroyBackBuffer(); |
|
76 } |
|
77 |
|
78 virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) |
|
79 { |
|
80 aAttrs = ThebesLayerAttributes(GetValidRegion()); |
|
81 } |
|
82 |
|
83 ClientLayerManager* ClientManager() |
|
84 { |
|
85 return static_cast<ClientLayerManager*>(mManager); |
|
86 } |
|
87 |
|
88 virtual Layer* AsLayer() { return this; } |
|
89 virtual ShadowableLayer* AsShadowableLayer() { return this; } |
|
90 |
|
91 virtual CompositableClient* GetCompositableClient() MOZ_OVERRIDE |
|
92 { |
|
93 return mContentClient; |
|
94 } |
|
95 |
|
96 virtual void Disconnect() |
|
97 { |
|
98 mContentClient = nullptr; |
|
99 ClientLayer::Disconnect(); |
|
100 } |
|
101 |
|
102 protected: |
|
103 void PaintThebes(); |
|
104 |
|
105 void DestroyBackBuffer() |
|
106 { |
|
107 mContentClient = nullptr; |
|
108 } |
|
109 |
|
110 RefPtr<ContentClient> mContentClient; |
|
111 }; |
|
112 |
|
113 } |
|
114 } |
|
115 |
|
116 #endif |