| 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 GrReducedClip_DEFINED | 8 #ifndef GrReducedClip_DEFINED |
| 9 #define GrReducedClip_DEFINED | 9 #define GrReducedClip_DEFINED |
| 10 | 10 |
| 11 #include "SkClipStack.h" | 11 #include "SkClipStack.h" |
| 12 #include "SkTLList.h" | 12 #include "SkTLList.h" |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * This class takes a clip stack and produces a reduced set of elements that are
equivalent to | 15 * This class takes a clip stack and produces a reduced set of elements that are
equivalent to |
| 16 * applying that full stack within a specified query rectangle. | 16 * applying that full stack within a specified query rectangle. |
| 17 */ | 17 */ |
| 18 class SK_API GrReducedClip { | 18 class SK_API GrReducedClip { |
| 19 public: | 19 public: |
| 20 GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds); | 20 GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds); |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Uniquely identifies this reduced clip. | 23 * Uniquely identifies this reduced clip. |
| 24 */ | 24 */ |
| 25 int32_t genID() const { return fGenID; } | 25 int32_t genID() const { return fGenID; } |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Bounding box within which the reduced clip is valid. The caller must not
draw any pixels | 28 * If hasIBounds() is true, this is the bounding box within which the reduce
d clip is valid, and |
| 29 * outside this box. | 29 * the caller must not modify any pixels outside this box. Undefined if hasI
Bounds() is false. |
| 30 */ | 30 */ |
| 31 const SkIRect& iBounds() const { return fIBounds; } | 31 const SkIRect& ibounds() const { SkASSERT(fHasIBounds); return fIBounds; } |
| 32 int left() const { return this->iBounds().left(); } | 32 int left() const { return this->ibounds().left(); } |
| 33 int top() const { return this->iBounds().top(); } | 33 int top() const { return this->ibounds().top(); } |
| 34 int width() const { return this->iBounds().width(); } | 34 int width() const { return this->ibounds().width(); } |
| 35 int height() const { return this->iBounds().height(); } | 35 int height() const { return this->ibounds().height(); } |
| 36 |
| 37 /** |
| 38 * Indicates whether ibounds() are defined. They will always be defined if t
he elements() are |
| 39 * nonempty. |
| 40 */ |
| 41 bool hasIBounds() const { return fHasIBounds; } |
| 36 | 42 |
| 37 typedef SkTLList<SkClipStack::Element, 16> ElementList; | 43 typedef SkTLList<SkClipStack::Element, 16> ElementList; |
| 38 | 44 |
| 39 /** | 45 /** |
| 40 * Populated with a minimal list of elements that implement the clip. | 46 * Populated with a minimal list of elements that implement the clip. |
| 41 */ | 47 */ |
| 42 const ElementList& elements() const { return fElements; } | 48 const ElementList& elements() const { return fElements; } |
| 43 | 49 |
| 44 /** | 50 /** |
| 45 * Indicates whether antialiasing is required to process any of the clip ele
ments. | 51 * Indicates whether antialiasing is required to process any of the clip ele
ments. |
| 46 */ | 52 */ |
| 47 bool requiresAA() const { return fRequiresAA; } | 53 bool requiresAA() const { return fRequiresAA; } |
| 48 | 54 |
| 49 enum class InitialState : bool { | 55 enum class InitialState : bool { |
| 50 kAllIn, | 56 kAllIn, |
| 51 kAllOut | 57 kAllOut |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 /** | |
| 55 * The initial state of the clip within iBounds(). | |
| 56 */ | |
| 57 InitialState initialState() const { return fInitialState; } | 60 InitialState initialState() const { return fInitialState; } |
| 58 | 61 |
| 59 private: | 62 private: |
| 60 int32_t fGenID; | 63 int32_t fGenID; |
| 61 SkIRect fIBounds; | 64 SkIRect fIBounds; |
| 65 bool fHasIBounds; |
| 62 ElementList fElements; | 66 ElementList fElements; |
| 63 bool fRequiresAA; | 67 bool fRequiresAA; |
| 64 InitialState fInitialState; | 68 InitialState fInitialState; |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 #endif | 71 #endif |
| OLD | NEW |