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