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 "GrWindowRectangles.h" |
13 | 14 |
14 class GrDrawContext; | 15 class GrDrawContext; |
15 | 16 |
16 /** | 17 /** |
17 * 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 |
18 * create the final GrPipeline for a GrBatch. | 19 * create the final GrPipeline for a GrBatch. |
19 */ | 20 */ |
20 class GrAppliedClip : public SkNoncopyable { | 21 class GrAppliedClip : public SkNoncopyable { |
21 public: | 22 public: |
22 GrAppliedClip(const SkRect& drawBounds) | 23 GrAppliedClip(const SkRect& drawBounds) |
23 : fHasStencilClip(false) | 24 : fHasStencilClip(false) |
24 , fClippedDrawBounds(drawBounds) { | 25 , fClippedDrawBounds(drawBounds) { |
25 } | 26 } |
26 | 27 |
27 const GrScissorState& scissorState() const { return fScissorState; } | 28 const GrScissorState& scissorState() const { return fScissorState; } |
| 29 const GrWindowRectangles& windows() const { return fWindows; } |
28 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov
erageFP.get(); } | 30 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov
erageFP.get(); } |
29 bool hasStencilClip() const { return fHasStencilClip; } | 31 bool hasStencilClip() const { return fHasStencilClip; } |
30 | 32 |
31 /** | 33 /** |
32 * Intersects the applied clip with the provided rect. Returns false if the
draw became empty. | 34 * Intersects the applied clip with the provided rect. Returns false if the
draw became empty. |
33 */ | 35 */ |
34 bool addScissor(const SkIRect& irect) { | 36 bool addScissor(const SkIRect& irect) { |
35 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk
Rect::Make(irect)); | 37 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk
Rect::Make(irect)); |
36 } | 38 } |
37 | 39 |
| 40 /** |
| 41 * Adds an exclusive window rectangle to the clip. It is not currently suppo
rted to switch the |
| 42 * windows to inclusive mode. |
| 43 */ |
| 44 void addWindowRectangle(const SkIRect& window, const GrCaps& caps) { |
| 45 fWindows.addWindow(window, caps); |
| 46 } |
| 47 |
38 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { | 48 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { |
39 SkASSERT(!fClipCoverageFP); | 49 SkASSERT(!fClipCoverageFP); |
40 fClipCoverageFP = fp; | 50 fClipCoverageFP = fp; |
41 } | 51 } |
42 | 52 |
43 void addStencilClip() { | 53 void addStencilClip() { |
44 SkASSERT(!fHasStencilClip); | 54 SkASSERT(!fHasStencilClip); |
45 fHasStencilClip = true; | 55 fHasStencilClip = true; |
46 } | 56 } |
47 | 57 |
48 /** | 58 /** |
49 * Returns the device bounds of the draw after clip has been applied. TODO:
Ideally this would | 59 * Returns the device bounds of the draw after clip has been applied. TODO:
Ideally this would |
50 * consider the combined effect of all clipping techniques in play (scissor,
stencil, fp, etc.). | 60 * consider the combined effect of all clipping techniques in play (scissor,
stencil, fp, etc.). |
51 */ | 61 */ |
52 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } | 62 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } |
53 | 63 |
54 private: | 64 private: |
55 GrScissorState fScissorState; | 65 GrScissorState fScissorState; |
| 66 GrWindowRectangles fWindows; |
56 sk_sp<GrFragmentProcessor> fClipCoverageFP; | 67 sk_sp<GrFragmentProcessor> fClipCoverageFP; |
57 bool fHasStencilClip; | 68 bool fHasStencilClip; |
58 SkRect fClippedDrawBounds; | 69 SkRect fClippedDrawBounds; |
59 typedef SkNoncopyable INHERITED; | 70 typedef SkNoncopyable INHERITED; |
60 }; | 71 }; |
61 | 72 |
62 /** | 73 /** |
63 * GrClip is an abstract base class for applying a clip. It constructs a clip ma
sk if necessary, and | 74 * GrClip is an abstract base class for applying a clip. It constructs a clip ma
sk if necessary, and |
64 * fills out a GrAppliedClip instructing the caller on how to set up the draw st
ate. | 75 * fills out a GrAppliedClip instructing the caller on how to set up the draw st
ate. |
65 */ | 76 */ |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 200 |
190 private: | 201 private: |
191 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett
ings, | 202 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett
ings, |
192 GrAppliedClip* out) const final; | 203 GrAppliedClip* out) const final; |
193 | 204 |
194 GrScissorState fScissorState; | 205 GrScissorState fScissorState; |
195 bool fHasStencilClip; | 206 bool fHasStencilClip; |
196 }; | 207 }; |
197 | 208 |
198 #endif | 209 #endif |
OLD | NEW |