OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrAppliedClip_DEFINED |
| 9 #define GrAppliedClip_DEFINED |
| 10 |
| 11 #include "GrTypesPriv.h" |
| 12 #include "GrWindowRectangles.h" |
| 13 |
| 14 class GrFragmentProcessor; |
| 15 |
| 16 /** |
| 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. |
| 19 */ |
| 20 class GrAppliedClip : public SkNoncopyable { |
| 21 public: |
| 22 GrAppliedClip(const SkRect& drawBounds) |
| 23 : fHasStencilClip(false) |
| 24 , fClippedDrawBounds(drawBounds) { |
| 25 } |
| 26 |
| 27 const GrScissorState& scissorState() const { return fScissorState; } |
| 28 const GrWindowRectangles& windowRects() const { return fWindowRects; } |
| 29 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov
erageFP.get(); } |
| 30 bool hasStencilClip() const { return fHasStencilClip; } |
| 31 |
| 32 /** |
| 33 * Intersects the applied clip with the provided rect. Returns false if the
draw became empty. |
| 34 */ |
| 35 bool addScissor(const SkIRect& irect) { |
| 36 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk
Rect::Make(irect)); |
| 37 } |
| 38 |
| 39 /** |
| 40 * Adds an exclusive window rectangle to the clip. It is not currently suppo
rted to switch the |
| 41 * windows to inclusive mode. |
| 42 */ |
| 43 void addWindowRectangle(const SkIRect& window) { |
| 44 fWindowRects.addWindow(window); |
| 45 } |
| 46 |
| 47 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) { |
| 48 SkASSERT(!fClipCoverageFP); |
| 49 fClipCoverageFP = fp; |
| 50 } |
| 51 |
| 52 void addStencilClip() { |
| 53 SkASSERT(!fHasStencilClip); |
| 54 fHasStencilClip = true; |
| 55 } |
| 56 |
| 57 /** |
| 58 * 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.). |
| 60 */ |
| 61 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; } |
| 62 |
| 63 private: |
| 64 GrScissorState fScissorState; |
| 65 GrWindowRectangles fWindowRects; |
| 66 sk_sp<GrFragmentProcessor> fClipCoverageFP; |
| 67 bool fHasStencilClip; |
| 68 SkRect fClippedDrawBounds; |
| 69 typedef SkNoncopyable INHERITED; |
| 70 }; |
| 71 |
| 72 #endif |
OLD | NEW |