/src/mozilla-central/gfx/layers/basic/BasicPaintedLayer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef GFX_BASICPAINTEDLAYER_H |
8 | | #define GFX_BASICPAINTEDLAYER_H |
9 | | |
10 | | #include "Layers.h" // for PaintedLayer, LayerManager, etc |
11 | | #include "RotatedBuffer.h" // for RotatedBuffer, etc |
12 | | #include "BasicImplData.h" // for BasicImplData |
13 | | #include "BasicLayers.h" // for BasicLayerManager |
14 | | #include "gfxPoint.h" // for gfxPoint |
15 | | #include "mozilla/RefPtr.h" // for RefPtr |
16 | | #include "mozilla/gfx/BasePoint.h" // for BasePoint |
17 | | #include "mozilla/layers/ContentClient.h" // for ContentClientBasic |
18 | | #include "mozilla/mozalloc.h" // for operator delete |
19 | | #include "nsDebug.h" // for NS_ASSERTION |
20 | | #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc |
21 | | #include "nsRegion.h" // for nsIntRegion |
22 | | class gfxContext; |
23 | | |
24 | | namespace mozilla { |
25 | | namespace layers { |
26 | | |
27 | | class ReadbackProcessor; |
28 | | |
29 | | class BasicPaintedLayer : public PaintedLayer, public BasicImplData { |
30 | | public: |
31 | | typedef ContentClient::PaintState PaintState; |
32 | | typedef ContentClient::ContentType ContentType; |
33 | | |
34 | | explicit BasicPaintedLayer(BasicLayerManager* aLayerManager, gfx::BackendType aBackend) : |
35 | | PaintedLayer(aLayerManager, static_cast<BasicImplData*>(this)), |
36 | | mContentClient(nullptr) |
37 | | , mBackend(aBackend) |
38 | 0 | { |
39 | 0 | MOZ_COUNT_CTOR(BasicPaintedLayer); |
40 | 0 | } |
41 | | |
42 | | protected: |
43 | | virtual ~BasicPaintedLayer() |
44 | 0 | { |
45 | 0 | MOZ_COUNT_DTOR(BasicPaintedLayer); |
46 | 0 | } |
47 | | |
48 | | public: |
49 | | virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override |
50 | 0 | { |
51 | 0 | NS_ASSERTION(BasicManager()->InConstruction(), |
52 | 0 | "Can only set properties in construction phase"); |
53 | 0 | PaintedLayer::SetVisibleRegion(aRegion); |
54 | 0 | } |
55 | | virtual void InvalidateRegion(const nsIntRegion& aRegion) override |
56 | 0 | { |
57 | 0 | NS_ASSERTION(BasicManager()->InConstruction(), |
58 | 0 | "Can only set properties in construction phase"); |
59 | 0 | mInvalidRegion.Add(aRegion); |
60 | 0 | UpdateValidRegionAfterInvalidRegionChanged(); |
61 | 0 | } |
62 | | |
63 | | virtual void PaintThebes(gfxContext* aContext, |
64 | | Layer* aMaskLayer, |
65 | | LayerManager::DrawPaintedLayerCallback aCallback, |
66 | | void* aCallbackData) override; |
67 | | |
68 | | virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback, |
69 | | void* aCallbackData, |
70 | | ReadbackProcessor* aReadback) override; |
71 | | |
72 | | virtual void ClearCachedResources() override |
73 | 0 | { |
74 | 0 | if (mContentClient) { |
75 | 0 | mContentClient->Clear(); |
76 | 0 | } |
77 | 0 | ClearValidRegion(); |
78 | 0 | } |
79 | | |
80 | | virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override |
81 | 0 | { |
82 | 0 | if (!BasicManager()->IsRetained()) { |
83 | 0 | // Don't do any snapping of our transform, since we're just going to |
84 | 0 | // draw straight through without intermediate buffers. |
85 | 0 | mEffectiveTransform = GetLocalTransform() * aTransformToSurface; |
86 | 0 | if (gfxPoint(0,0) != mResidualTranslation) { |
87 | 0 | mResidualTranslation = gfxPoint(0,0); |
88 | 0 | ClearValidRegion(); |
89 | 0 | } |
90 | 0 | ComputeEffectiveTransformForMaskLayers(aTransformToSurface); |
91 | 0 | return; |
92 | 0 | } |
93 | 0 | PaintedLayer::ComputeEffectiveTransforms(aTransformToSurface); |
94 | 0 | } |
95 | | |
96 | | BasicLayerManager* BasicManager() |
97 | 0 | { |
98 | 0 | return static_cast<BasicLayerManager*>(mManager); |
99 | 0 | } |
100 | | |
101 | | protected: |
102 | | virtual void |
103 | | PaintBuffer(gfxContext* aContext, |
104 | | const nsIntRegion& aRegionToDraw, |
105 | | const nsIntRegion& aExtendedRegionToDraw, |
106 | | const nsIntRegion& aRegionToInvalidate, |
107 | | DrawRegionClip aClip, |
108 | | LayerManager::DrawPaintedLayerCallback aCallback, |
109 | | void* aCallbackData) |
110 | 0 | { |
111 | 0 | if (!aCallback) { |
112 | 0 | BasicManager()->SetTransactionIncomplete(); |
113 | 0 | return; |
114 | 0 | } |
115 | 0 | aCallback(this, aContext, aExtendedRegionToDraw, aExtendedRegionToDraw, |
116 | 0 | aClip, aRegionToInvalidate, aCallbackData); |
117 | 0 | // Everything that's visible has been validated. Do this instead of just |
118 | 0 | // OR-ing with aRegionToDraw, since that can lead to a very complex region |
119 | 0 | // here (OR doesn't automatically simplify to the simplest possible |
120 | 0 | // representation of a region.) |
121 | 0 | nsIntRegion tmp; |
122 | 0 | tmp.Or(mVisibleRegion.ToUnknownRegion(), aExtendedRegionToDraw); |
123 | 0 | AddToValidRegion(tmp); |
124 | 0 | } |
125 | | |
126 | | RefPtr<ContentClientBasic> mContentClient; |
127 | | gfx::BackendType mBackend; |
128 | | }; |
129 | | |
130 | | } // namespace layers |
131 | | } // namespace mozilla |
132 | | |
133 | | #endif |