OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 GrAppliedClip_DEFINED | 8 #ifndef GrAppliedClip_DEFINED |
9 #define GrAppliedClip_DEFINED | 9 #define GrAppliedClip_DEFINED |
10 | 10 |
11 #include "GrTypesPriv.h" | 11 #include "GrScissorState.h" |
12 #include "GrWindowRectangles.h" | 12 #include "GrWindowRectsState.h" |
13 | 13 |
14 class GrFragmentProcessor; | 14 class GrFragmentProcessor; |
15 | 15 |
16 /** | 16 /** |
17 * Produced by GrClip. It provides a set of modifications to the drawing state t hat are used to | 17 * 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. | 18 * create the final GrPipeline for a GrBatch. |
19 */ | 19 */ |
20 class GrAppliedClip : public SkNoncopyable { | 20 class GrAppliedClip : public SkNoncopyable { |
21 public: | 21 public: |
22 GrAppliedClip(const SkRect& drawBounds) | 22 GrAppliedClip(const SkRect& drawBounds) |
23 : fHasStencilClip(false) | 23 : fHasStencilClip(false) |
24 , fClippedDrawBounds(drawBounds) { | 24 , fClippedDrawBounds(drawBounds) { |
25 } | 25 } |
26 | 26 |
27 const GrScissorState& scissorState() const { return fScissorState; } | 27 const GrScissorState& scissorState() const { return fScissorState; } |
28 const GrWindowRectangles& windowRects() const { return fWindowRects; } | 28 const GrWindowRectsState& windowRectsState() const { return fWindowRectsStat e; } |
29 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov erageFP.get(); } | 29 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov erageFP.get(); } |
30 bool hasStencilClip() const { return fHasStencilClip; } | 30 bool hasStencilClip() const { return fHasStencilClip; } |
31 | 31 |
32 /** | 32 /** |
33 * Intersects the applied clip with the provided rect. Returns false if the draw became empty. | 33 * Intersects the applied clip with the provided rect. Returns false if the draw became empty. |
34 */ | 34 */ |
35 bool addScissor(const SkIRect& irect) { | 35 bool addScissor(const SkIRect& irect) { |
36 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk Rect::Make(irect)); | 36 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk Rect::Make(irect)); |
37 } | 37 } |
38 | 38 |
39 /** | 39 GrWindowRectsState& SK_WARN_UNUSED_RESULT addWindowRectangles() { |
bsalomon
2016/08/31 14:40:39
Can this be a setter (or pair of setters) rather t
csmartdalton
2016/08/31 15:04:34
Done.
| |
40 * Adds an exclusive window rectangle to the clip. It is not currently suppo rted to switch the | 40 SkASSERT(fWindowRectsState.disabled()); |
41 * windows to inclusive mode. | 41 return fWindowRectsState; |
42 */ | |
43 void addWindowRectangle(const SkIRect& window) { | |
44 fWindowRects.addWindow(window); | |
45 } | 42 } |
46 | 43 |
47 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { | 44 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { |
48 SkASSERT(!fClipCoverageFP); | 45 SkASSERT(!fClipCoverageFP); |
49 fClipCoverageFP = fp; | 46 fClipCoverageFP = fp; |
50 } | 47 } |
51 | 48 |
52 void addStencilClip() { | 49 void addStencilClip() { |
53 SkASSERT(!fHasStencilClip); | 50 SkASSERT(!fHasStencilClip); |
54 fHasStencilClip = true; | 51 fHasStencilClip = true; |
55 } | 52 } |
56 | 53 |
57 /** | 54 /** |
58 * Returns the device bounds of the draw after clip has been applied. TODO: Ideally this would | 55 * Returns the device bounds of the draw after clip has been applied. TODO: Ideally this would |
59 * consider the combined effect of all clipping techniques in play (scissor, stencil, fp, etc.). | 56 * consider the combined effect of all clipping techniques in play (scissor, stencil, fp, etc.). |
60 */ | 57 */ |
61 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } | 58 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } |
62 | 59 |
63 private: | 60 private: |
64 GrScissorState fScissorState; | 61 GrScissorState fScissorState; |
65 GrWindowRectangles fWindowRects; | 62 GrWindowRectsState fWindowRectsState; |
66 sk_sp<GrFragmentProcessor> fClipCoverageFP; | 63 sk_sp<GrFragmentProcessor> fClipCoverageFP; |
67 bool fHasStencilClip; | 64 bool fHasStencilClip; |
68 SkRect fClippedDrawBounds; | 65 SkRect fClippedDrawBounds; |
69 typedef SkNoncopyable INHERITED; | 66 typedef SkNoncopyable INHERITED; |
70 }; | 67 }; |
71 | 68 |
72 #endif | 69 #endif |
OLD | NEW |