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/. */
6 #ifndef GFX_CLIENTTHEBESLAYER_H
7 #define GFX_CLIENTTHEBESLAYER_H
9 #include "ClientLayerManager.h"
10 #include "ThebesLayerBuffer.h"
11 #include "mozilla/layers/ContentClient.h"
16 class ClientThebesLayer
: public ThebesLayer
,
19 typedef ThebesLayerBuffer::PaintState PaintState
;
20 typedef ThebesLayerBuffer::ContentType ContentType
;
22 ClientThebesLayer(ClientLayerManager
* aLayerManager
) :
23 ThebesLayer(aLayerManager
, static_cast<ClientLayer
*>(this)),
24 mContentClient(nullptr)
26 MOZ_COUNT_CTOR(ClientThebesLayer
);
28 virtual ~ClientThebesLayer()
31 mContentClient
->Detach();
32 mContentClient
= nullptr;
34 MOZ_COUNT_DTOR(ClientThebesLayer
);
37 virtual void SetVisibleRegion(const nsIntRegion
& aRegion
)
39 NS_ASSERTION(ClientManager()->InConstruction(),
40 "Can only set properties in construction phase");
41 ThebesLayer::SetVisibleRegion(aRegion
);
43 virtual void InvalidateRegion(const nsIntRegion
& aRegion
)
45 NS_ASSERTION(ClientManager()->InConstruction(),
46 "Can only set properties in construction phase");
47 mInvalidRegion
.Or(mInvalidRegion
, aRegion
);
48 mInvalidRegion
.SimplifyOutward(10);
49 mValidRegion
.Sub(mValidRegion
, mInvalidRegion
);
52 virtual void RenderLayer();
54 virtual void ClearCachedResources()
57 mContentClient
->Clear();
59 mValidRegion
.SetEmpty();
63 virtual void FillSpecificAttributes(SpecificLayerAttributes
& aAttrs
)
65 aAttrs
= ThebesLayerAttributes(GetValidRegion());
68 ClientLayerManager
* ClientManager()
70 return static_cast<ClientLayerManager
*>(mManager
);
73 virtual Layer
* AsLayer() { return this; }
74 virtual ShadowableLayer
* AsShadowableLayer() { return this; }
76 virtual CompositableClient
* GetCompositableClient() MOZ_OVERRIDE
78 return mContentClient
;
81 virtual void Disconnect()
83 mContentClient
= nullptr;
84 ClientLayer::Disconnect();
89 PaintBuffer(gfxContext
* aContext
,
90 const nsIntRegion
& aRegionToDraw
,
91 const nsIntRegion
& aExtendedRegionToDraw
,
92 const nsIntRegion
& aRegionToInvalidate
,
97 void DestroyBackBuffer()
99 mContentClient
= nullptr;
102 RefPtr
<ContentClient
> mContentClient
;