/work/obj-fuzz/dist/include/BasicImplData.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 file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef GFX_BASICIMPLDATA_H |
8 | | #define GFX_BASICIMPLDATA_H |
9 | | |
10 | | #include "Layers.h" // for Layer (ptr only), etc |
11 | | #include "gfxContext.h" // for gfxContext, etc |
12 | | #include "nsDebug.h" // for NS_ASSERTION |
13 | | #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc |
14 | | #include "mozilla/gfx/Types.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace layers { |
18 | | |
19 | | class ReadbackProcessor; |
20 | | |
21 | | /** |
22 | | * This is the ImplData for all Basic layers. It also exposes methods |
23 | | * private to the Basic implementation that are common to all Basic layer types. |
24 | | * In particular, there is an internal Paint() method that we can use |
25 | | * to paint the contents of non-PaintedLayers. |
26 | | * |
27 | | * The class hierarchy for Basic layers is like this: |
28 | | * BasicImplData |
29 | | * Layer | | | |
30 | | * | | | | |
31 | | * +-> ContainerLayer | | | |
32 | | * | | | | | |
33 | | * | +-> BasicContainerLayer <--+ | | |
34 | | * | | | |
35 | | * +-> PaintedLayer | | |
36 | | * | | | | |
37 | | * | +-> BasicPaintedLayer <---------+ | |
38 | | * | | |
39 | | * +-> ImageLayer | |
40 | | * | | |
41 | | * +-> BasicImageLayer <--------------+ |
42 | | */ |
43 | | class BasicImplData { |
44 | | public: |
45 | | BasicImplData() : mHidden(false), |
46 | | mClipToVisibleRegion(false), |
47 | | mDrawAtomically(false), |
48 | | mOperator(gfx::CompositionOp::OP_OVER) |
49 | | { |
50 | | MOZ_COUNT_CTOR(BasicImplData); |
51 | | } |
52 | | virtual ~BasicImplData() |
53 | | { |
54 | | MOZ_COUNT_DTOR(BasicImplData); |
55 | | } |
56 | | |
57 | | /** |
58 | | * Layers that paint themselves, such as ImageLayers, should paint |
59 | | * in response to this method call. aContext will already have been |
60 | | * set up to account for all the properties of the layer (transform, |
61 | | * opacity, etc). |
62 | | */ |
63 | | virtual void Paint(gfx::DrawTarget* aDT, |
64 | | const gfx::Point& aDeviceOffset, |
65 | | Layer* aMaskLayer) {} |
66 | | |
67 | | /** |
68 | | * Like Paint() but called for PaintedLayers with the additional parameters |
69 | | * they need. |
70 | | * If mClipToVisibleRegion is set, then the layer must clip to its |
71 | | * effective visible region (snapped or unsnapped, it doesn't matter). |
72 | | */ |
73 | | virtual void PaintThebes(gfxContext* aContext, |
74 | | Layer* aMasklayer, |
75 | | LayerManager::DrawPaintedLayerCallback aCallback, |
76 | | void* aCallbackData) {} |
77 | | |
78 | | virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback, |
79 | | void* aCallbackData, |
80 | | ReadbackProcessor* aReadback) {} |
81 | | |
82 | | /** |
83 | | * Layers will get this call when their layer manager is destroyed, this |
84 | | * indicates they should clear resources they don't really need after their |
85 | | * LayerManager ceases to exist. |
86 | | */ |
87 | | virtual void ClearCachedResources() {} |
88 | | |
89 | | /** |
90 | | * This variable is set by MarkLayersHidden() before painting. It indicates |
91 | | * that the layer should not be composited during this transaction. |
92 | | */ |
93 | | void SetHidden(bool aCovered) { mHidden = aCovered; } |
94 | | bool IsHidden() const { return false; } |
95 | | /** |
96 | | * This variable is set by MarkLayersHidden() before painting. This is |
97 | | * the operator to be used when compositing the layer in this transaction. It must |
98 | | * be OVER or SOURCE. |
99 | | */ |
100 | | void SetOperator(gfx::CompositionOp aOperator) |
101 | | { |
102 | | NS_ASSERTION(aOperator == gfx::CompositionOp::OP_OVER || |
103 | | aOperator == gfx::CompositionOp::OP_SOURCE, |
104 | | "Bad composition operator"); |
105 | | mOperator = aOperator; |
106 | | } |
107 | | |
108 | | gfx::CompositionOp GetOperator() const { return mOperator; } |
109 | | |
110 | | /** |
111 | | * Return a surface for this layer. Will use an existing surface, if |
112 | | * possible, or may create a temporary surface. Implement this |
113 | | * method for any layers that might be used as a mask. Should only |
114 | | * return false if a surface cannot be created. If true is |
115 | | * returned, only one of |aSurface| or |aDescriptor| is valid. |
116 | | */ |
117 | | virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; } |
118 | | |
119 | 0 | bool GetClipToVisibleRegion() { return mClipToVisibleRegion; } |
120 | | void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; } |
121 | | |
122 | | void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; } |
123 | | |
124 | | protected: |
125 | | bool mHidden; |
126 | | bool mClipToVisibleRegion; |
127 | | bool mDrawAtomically; |
128 | | gfx::CompositionOp mOperator; |
129 | | }; |
130 | | |
131 | | } // namespace layers |
132 | | } // namespace mozilla |
133 | | |
134 | | #endif |