OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrClip_DEFINED | 8 #ifndef GrClip_DEFINED |
9 #define GrClip_DEFINED | 9 #define GrClip_DEFINED |
10 | 10 |
11 #include "GrFragmentProcessor.h" | 11 #include "GrFragmentProcessor.h" |
12 #include "GrTypesPriv.h" | 12 #include "GrTypesPriv.h" |
13 #include "SkClipStack.h" | 13 #include "SkClipStack.h" |
14 | 14 |
15 class GrDrawContext; | 15 class GrDrawContext; |
16 class GrPipelineBuilder; | |
17 | 16 |
18 /** | 17 /** |
19 * Produced by GrClip. It provides a set of modifications to the drawing state t
hat are used to | 18 * Produced by GrClip. It provides a set of modifications to the drawing state t
hat are used to |
20 * create the final GrPipeline for a GrBatch. | 19 * create the final GrPipeline for a GrBatch. |
21 */ | 20 */ |
22 class GrAppliedClip : public SkNoncopyable { | 21 class GrAppliedClip : public SkNoncopyable { |
23 public: | 22 public: |
24 GrAppliedClip() : fHasStencilClip(false), fDeviceBounds(SkRect::MakeLargest(
)) {} | 23 GrAppliedClip() : fHasStencilClip(false), fDeviceBounds(SkRect::MakeLargest(
)) {} |
25 GrFragmentProcessor* getClipCoverageFragmentProcessor() const { | 24 GrFragmentProcessor* getClipCoverageFragmentProcessor() const { |
26 return fClipCoverageFP.get(); | 25 return fClipCoverageFP.get(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 97 |
99 /** | 98 /** |
100 * GrClip is an abstract base class for applying a clip. It constructs a clip ma
sk if necessary, and | 99 * GrClip is an abstract base class for applying a clip. It constructs a clip ma
sk if necessary, and |
101 * fills out a GrAppliedClip instructing the caller on how to set up the draw st
ate. | 100 * fills out a GrAppliedClip instructing the caller on how to set up the draw st
ate. |
102 */ | 101 */ |
103 class GrClip { | 102 class GrClip { |
104 public: | 103 public: |
105 virtual bool quickContains(const SkRect&) const = 0; | 104 virtual bool quickContains(const SkRect&) const = 0; |
106 virtual void getConservativeBounds(int width, int height, SkIRect* devResult
, | 105 virtual void getConservativeBounds(int width, int height, SkIRect* devResult
, |
107 bool* isIntersectionOfRects = nullptr) co
nst = 0; | 106 bool* isIntersectionOfRects = nullptr) co
nst = 0; |
108 virtual bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*, | 107 virtual bool apply(GrContext*, |
109 const SkRect* devBounds, GrAppliedClip*) const = 0; | 108 GrDrawContext*, |
| 109 const SkRect* devBounds, |
| 110 bool useHWAA, |
| 111 bool hasUserStencilSettings, |
| 112 GrAppliedClip* out) const = 0; |
110 | 113 |
111 virtual ~GrClip() {} | 114 virtual ~GrClip() {} |
112 }; | 115 }; |
113 | 116 |
114 /** | 117 /** |
115 * Specialized implementation for no clip. | 118 * Specialized implementation for no clip. |
116 */ | 119 */ |
117 class GrNoClip final : public GrClip { | 120 class GrNoClip final : public GrClip { |
118 private: | 121 private: |
119 bool quickContains(const SkRect&) const final { return true; } | 122 bool quickContains(const SkRect&) const final { return true; } |
120 void getConservativeBounds(int width, int height, SkIRect* devResult, | 123 void getConservativeBounds(int width, int height, SkIRect* devResult, |
121 bool* isIntersectionOfRects) const final; | 124 bool* isIntersectionOfRects) const final; |
122 bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*, | 125 bool apply(GrContext*, |
123 const SkRect*, GrAppliedClip*) const final { return true; } | 126 GrDrawContext*, |
| 127 const SkRect* /* devBounds */, |
| 128 bool /* useHWAA */, |
| 129 bool /* hasUserStencilSettings */, |
| 130 GrAppliedClip* /* out */) const final { return true; } |
124 }; | 131 }; |
125 | 132 |
126 /** | 133 /** |
127 * GrFixedClip is a clip that can be represented by fixed-function hardware. It
never modifies the | 134 * GrFixedClip is a clip that can be represented by fixed-function hardware. It
never modifies the |
128 * stencil buffer itself, but can be configured to use whatever clip is already
there. | 135 * stencil buffer itself, but can be configured to use whatever clip is already
there. |
129 */ | 136 */ |
130 class GrFixedClip final : public GrClip { | 137 class GrFixedClip final : public GrClip { |
131 public: | 138 public: |
132 GrFixedClip() : fDeviceBounds(SkRect::MakeLargest()), fHasStencilClip(false)
{} | 139 GrFixedClip() : fDeviceBounds(SkRect::MakeLargest()), fHasStencilClip(false)
{} |
133 GrFixedClip(const SkIRect& scissorRect) | 140 GrFixedClip(const SkIRect& scissorRect) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 180 } |
174 | 181 |
175 const GrScissorState& scissorState() const { return fScissorState; } | 182 const GrScissorState& scissorState() const { return fScissorState; } |
176 bool hasStencilClip() const { return fHasStencilClip; } | 183 bool hasStencilClip() const { return fHasStencilClip; } |
177 | 184 |
178 bool quickContains(const SkRect&) const final; | 185 bool quickContains(const SkRect&) const final; |
179 void getConservativeBounds(int width, int height, SkIRect* devResult, | 186 void getConservativeBounds(int width, int height, SkIRect* devResult, |
180 bool* isIntersectionOfRects) const final; | 187 bool* isIntersectionOfRects) const final; |
181 | 188 |
182 private: | 189 private: |
183 bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*, | 190 bool apply(GrContext*, |
184 const SkRect* devBounds, GrAppliedClip* out) const final; | 191 GrDrawContext*, |
| 192 const SkRect* devBounds, |
| 193 bool useHWAA, |
| 194 bool hasUserStencilSettings, |
| 195 GrAppliedClip* out) const final; |
185 | 196 |
186 GrScissorState fScissorState; | 197 GrScissorState fScissorState; |
187 SkRect fDeviceBounds; | 198 SkRect fDeviceBounds; |
188 bool fHasStencilClip; | 199 bool fHasStencilClip; |
189 }; | 200 }; |
190 | 201 |
191 /** | 202 /** |
192 * GrClipStackClip can apply a generic SkClipStack to the draw state. It may gen
erate clip masks or | 203 * GrClipStackClip can apply a generic SkClipStack to the draw state. It may gen
erate clip masks or |
193 * write to the stencil buffer during apply(). | 204 * write to the stencil buffer during apply(). |
194 */ | 205 */ |
195 class GrClipStackClip final : public GrClip { | 206 class GrClipStackClip final : public GrClip { |
196 public: | 207 public: |
197 GrClipStackClip(const SkClipStack* stack = nullptr, const SkIPoint* origin =
nullptr) { | 208 GrClipStackClip(const SkClipStack* stack = nullptr, const SkIPoint* origin =
nullptr) { |
198 this->reset(stack, origin); | 209 this->reset(stack, origin); |
199 } | 210 } |
200 | 211 |
201 void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = null
ptr) { | 212 void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = null
ptr) { |
202 fOrigin = origin ? *origin : SkIPoint::Make(0, 0); | 213 fOrigin = origin ? *origin : SkIPoint::Make(0, 0); |
203 fStack.reset(SkSafeRef(stack)); | 214 fStack.reset(SkSafeRef(stack)); |
204 } | 215 } |
205 | 216 |
206 const SkIPoint& origin() const { return fOrigin; } | 217 const SkIPoint& origin() const { return fOrigin; } |
207 const SkClipStack* clipStack() const { return fStack; } | 218 const SkClipStack* clipStack() const { return fStack; } |
208 | 219 |
209 bool quickContains(const SkRect&) const final; | 220 bool quickContains(const SkRect&) const final; |
210 void getConservativeBounds(int width, int height, SkIRect* devResult, | 221 void getConservativeBounds(int width, int height, SkIRect* devResult, |
211 bool* isIntersectionOfRects) const final; | 222 bool* isIntersectionOfRects) const final; |
212 bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*, | 223 bool apply(GrContext*, |
213 const SkRect* devBounds, GrAppliedClip*) const final; | 224 GrDrawContext*, |
| 225 const SkRect* devBounds, |
| 226 bool useHWAA, |
| 227 bool hasUserStencilSettings, |
| 228 GrAppliedClip* out) const final; |
214 | 229 |
215 private: | 230 private: |
216 SkIPoint fOrigin; | 231 SkIPoint fOrigin; |
217 SkAutoTUnref<const SkClipStack> fStack; | 232 SkAutoTUnref<const SkClipStack> fStack; |
218 }; | 233 }; |
219 | 234 |
220 #endif | 235 #endif |
OLD | NEW |