OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 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 /** |
| 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. |
| 17 */ |
14 class SK_API GrReducedClip { | 18 class SK_API GrReducedClip { |
15 public: | 19 public: |
| 20 GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds); |
| 21 |
| 22 /** |
| 23 * Uniquely identifies this reduced clip. |
| 24 */ |
| 25 int32_t genID() const { return fGenID; } |
| 26 |
| 27 /** |
| 28 * Bounding box within which the reduced clip is valid. The caller must not
draw any pixels |
| 29 * outside this box. |
| 30 */ |
| 31 const SkIRect& iBounds() const { return fIBounds; } |
| 32 int left() const { return this->iBounds().left(); } |
| 33 int top() const { return this->iBounds().top(); } |
| 34 int width() const { return this->iBounds().width(); } |
| 35 int height() const { return this->iBounds().height(); } |
| 36 |
16 typedef SkTLList<SkClipStack::Element, 16> ElementList; | 37 typedef SkTLList<SkClipStack::Element, 16> ElementList; |
17 | 38 |
18 enum InitialState { | 39 /** |
19 kAllIn_InitialState, | 40 * Populated with a minimal list of elements that implement the clip. |
20 kAllOut_InitialState, | 41 */ |
| 42 const ElementList& elements() const { return fElements; } |
| 43 |
| 44 /** |
| 45 * Indicates whether antialiasing is required to process any of the clip ele
ments. |
| 46 */ |
| 47 bool requiresAA() const { return fRequiresAA; } |
| 48 |
| 49 enum class InitialState : bool { |
| 50 kAllIn, |
| 51 kAllOut |
21 }; | 52 }; |
22 | 53 |
23 /** | 54 /** |
24 * This function produces a reduced set of SkClipStack::Elements that are eq
uivalent to applying | 55 * The initial state of the clip within iBounds(). |
25 * a full clip stack within a specified query rectangle. | |
26 * | |
27 * @param stack the clip stack to reduce. | |
28 * @param queryBounds bounding box of geometry the stack will clip. | |
29 * @param result populated with a minimal list of elements that impl
ement the clip | |
30 * within the provided query bounds. | |
31 * @param resultGenID uniquely identifies the resulting reduced clip. | |
32 * @param clipIBounds bounding box within which the reduced clip is valid
. The caller must | |
33 * not draw any pixels outside this box. NOTE: this bo
x may be undefined | |
34 * if no pixels are valid (e.g. empty result, "all out
" initial state.) | |
35 * @param requiresAA indicates whether anti-aliasing is required to proc
ess any of the | |
36 * elements in the element list result. Undefined if t
he result is empty. | |
37 * @return the initial clip state within clipIBounds ("all in" or "all out")
. | |
38 */ | 56 */ |
39 static InitialState ReduceClipStack(const SkClipStack& stack, | 57 InitialState initialState() const { return fInitialState; } |
40 const SkRect& queryBounds, | 58 |
41 ElementList* result, | 59 private: |
42 int32_t* resultGenID, | 60 int32_t fGenID; |
43 SkIRect* clipIBounds, | 61 SkIRect fIBounds; |
44 bool* requiresAA); | 62 ElementList fElements; |
| 63 bool fRequiresAA; |
| 64 InitialState fInitialState; |
45 }; | 65 }; |
46 | 66 |
47 #endif | 67 #endif |
OLD | NEW |