| 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 void addWindowRectangles(const GrWindowRectsState& windowState) { |
| 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 fWindowRectsState = windowState; |
| 42 */ | 42 } |
| 43 void addWindowRectangle(const SkIRect& window) { | 43 |
| 44 fWindowRects.addWindow(window); | 44 void addWindowRectangles(const GrWindowRectangles& windows, const SkIPoint&
origin, |
| 45 GrWindowRectsState::Mode mode) { |
| 46 SkASSERT(fWindowRectsState.disabled()); |
| 47 fWindowRectsState.set(windows, origin, mode); |
| 45 } | 48 } |
| 46 | 49 |
| 47 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { | 50 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { |
| 48 SkASSERT(!fClipCoverageFP); | 51 SkASSERT(!fClipCoverageFP); |
| 49 fClipCoverageFP = fp; | 52 fClipCoverageFP = fp; |
| 50 } | 53 } |
| 51 | 54 |
| 52 void addStencilClip() { | 55 void addStencilClip() { |
| 53 SkASSERT(!fHasStencilClip); | 56 SkASSERT(!fHasStencilClip); |
| 54 fHasStencilClip = true; | 57 fHasStencilClip = true; |
| 55 } | 58 } |
| 56 | 59 |
| 57 /** | 60 /** |
| 58 * Returns the device bounds of the draw after clip has been applied. TODO:
Ideally this would | 61 * 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.). | 62 * consider the combined effect of all clipping techniques in play (scissor,
stencil, fp, etc.). |
| 60 */ | 63 */ |
| 61 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } | 64 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } |
| 62 | 65 |
| 63 private: | 66 private: |
| 64 GrScissorState fScissorState; | 67 GrScissorState fScissorState; |
| 65 GrWindowRectangles fWindowRects; | 68 GrWindowRectsState fWindowRectsState; |
| 66 sk_sp<GrFragmentProcessor> fClipCoverageFP; | 69 sk_sp<GrFragmentProcessor> fClipCoverageFP; |
| 67 bool fHasStencilClip; | 70 bool fHasStencilClip; |
| 68 SkRect fClippedDrawBounds; | 71 SkRect fClippedDrawBounds; |
| 69 typedef SkNoncopyable INHERITED; | 72 typedef SkNoncopyable INHERITED; |
| 70 }; | 73 }; |
| 71 | 74 |
| 72 #endif | 75 #endif |
| OLD | NEW |