Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; 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 MOZILLA_GFX_SINGLETILEDCONTENTCLIENT_H
7 : #define MOZILLA_GFX_SINGLETILEDCONTENTCLIENT_H
8 :
9 : #include "TiledContentClient.h"
10 :
11 : namespace mozilla {
12 : namespace layers {
13 :
14 : class ClientTiledPaintedLayer;
15 : class ClientLayerManager;
16 :
17 : /**
18 : * Provide an instance of TiledLayerBuffer backed by drawable TextureClients.
19 : * This buffer provides an implementation of ValidateTile using a
20 : * thebes callback and can support painting using a single paint buffer.
21 : * Whether a single paint buffer is used is controlled by
22 : * gfxPrefs::PerTileDrawing().
23 : */
24 : class ClientSingleTiledLayerBuffer
25 : : public ClientTiledLayerBuffer
26 : , public TextureClientAllocator
27 : {
28 0 : virtual ~ClientSingleTiledLayerBuffer() {}
29 : public:
30 : ClientSingleTiledLayerBuffer(ClientTiledPaintedLayer& aPaintedLayer,
31 : CompositableClient& aCompositableClient,
32 : ClientLayerManager* aManager);
33 :
34 : // TextureClientAllocator
35 : already_AddRefed<TextureClient> GetTextureClient() override;
36 0 : void ReturnTextureClientDeferred(TextureClient* aClient) override {}
37 0 : void ReportClientLost() override {}
38 :
39 : // ClientTiledLayerBuffer
40 : void PaintThebes(const nsIntRegion& aNewValidRegion,
41 : const nsIntRegion& aPaintRegion,
42 : const nsIntRegion& aDirtyRegion,
43 : LayerManager::DrawPaintedLayerCallback aCallback,
44 : void* aCallbackData,
45 : bool aIsProgressive = false) override;
46 :
47 0 : bool SupportsProgressiveUpdate() override { return false; }
48 0 : bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
49 : const nsIntRegion& aInvalidRegion,
50 : const nsIntRegion& aOldValidRegion,
51 : nsIntRegion& aOutDrawnRegion,
52 : BasicTiledLayerPaintData* aPaintData,
53 : LayerManager::DrawPaintedLayerCallback aCallback,
54 : void* aCallbackData) override
55 : {
56 0 : MOZ_ASSERT(false, "ProgressiveUpdate not supported!");
57 : return false;
58 : }
59 :
60 0 : void ResetPaintedAndValidState() override {
61 0 : mPaintedRegion.SetEmpty();
62 0 : mValidRegion.SetEmpty();
63 0 : mTile.DiscardBuffers();
64 0 : }
65 :
66 0 : const nsIntRegion& GetValidRegion() override {
67 0 : return mValidRegion;
68 : }
69 :
70 0 : bool IsLowPrecision() const override {
71 0 : return false;
72 : }
73 :
74 : void ReleaseTiles();
75 :
76 : void DiscardBuffers();
77 :
78 : SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
79 :
80 0 : void ClearPaintedRegion() {
81 0 : mPaintedRegion.SetEmpty();
82 0 : }
83 :
84 : private:
85 : TileClient mTile;
86 :
87 : nsIntRegion mPaintedRegion;
88 : nsIntRegion mValidRegion;
89 : bool mWasLastPaintProgressive;
90 :
91 : /**
92 : * While we're adding tiles, this is used to keep track of the position of
93 : * the top-left of the top-left-most tile. When we come to wrap the tiles in
94 : * TiledDrawTarget we subtract the value of this member from each tile's
95 : * offset so that all the tiles have a positive offset, then add a
96 : * translation to the TiledDrawTarget to compensate. This is important so
97 : * that the mRect of the TiledDrawTarget is always at a positive x/y
98 : * position, otherwise its GetSize() methods will be broken.
99 : */
100 : gfx::IntPoint mTilingOrigin;
101 : gfx::IntSize mSize;
102 : gfxImageFormat mFormat;
103 : };
104 :
105 : class SingleTiledContentClient : public TiledContentClient
106 : {
107 : public:
108 : SingleTiledContentClient(ClientTiledPaintedLayer& aPaintedLayer,
109 : ClientLayerManager* aManager);
110 :
111 : protected:
112 0 : ~SingleTiledContentClient()
113 0 : {
114 0 : MOZ_COUNT_DTOR(SingleTiledContentClient);
115 :
116 0 : mTiledBuffer->ReleaseTiles();
117 0 : }
118 :
119 : public:
120 : static bool ClientSupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager);
121 :
122 : virtual void ClearCachedResources() override;
123 :
124 : virtual void UpdatedBuffer(TiledBufferType aType) override;
125 :
126 0 : virtual ClientTiledLayerBuffer* GetTiledBuffer() override { return mTiledBuffer; }
127 0 : virtual ClientTiledLayerBuffer* GetLowPrecisionTiledBuffer() override { return nullptr; }
128 :
129 : private:
130 : RefPtr<ClientSingleTiledLayerBuffer> mTiledBuffer;
131 : };
132 :
133 : }
134 : }
135 :
136 : #endif
|