OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 class SK_API GrReducedClip { | 14 class SK_API GrReducedClip { |
15 public: | 15 public: |
16 typedef SkTLList<SkClipStack::Element, 16> ElementList; | 16 typedef SkTLList<SkClipStack::Element, 16> ElementList; |
17 | 17 |
18 enum InitialState { | 18 enum InitialState { |
19 kAllIn_InitialState, | 19 kAllIn_InitialState, |
20 kAllOut_InitialState, | 20 kAllOut_InitialState, |
21 }; | 21 }; |
22 | 22 |
23 /** | 23 /** |
24 * This function takes a clip stack and a query rectangle and it produces a | 24 * This function produces a reduced set of SkClipStack::Elements that are eq
uivalent to applying |
25 * reduced set of SkClipStack::Elements that are equivalent to applying the | 25 * a full clip stack within a specified query rectangle. |
26 * full stack to the rectangle. The clip stack generation id that represents | 26 * |
27 * the list of elements is returned in resultGenID. The initial state of the | 27 * @param stack the clip stack to reduce. |
28 * query rectangle before the first clip element is applied is returned via | 28 * @param queryBounds bounding box of geometry the stack will clip. |
29 * initialState. The reducer output tighterBounds is a tighter bounds on the | 29 * @param result populated with a minimal list of elements that impl
ement the clip |
30 * clip. tighterBounds will always be contained by queryBounds after return. | 30 * within the provided query bounds. |
31 * It is assumed that the caller will not draw outside of tighterBounds. | 31 * @param resultGenID uniquely identifies the resulting reduced clip. |
32 * The requiresAA output will indicate whether anti-aliasing is required to | 32 * @param clipIBounds bounding box within which the reduced clip is valid
. The caller must |
33 * process any of the elements in the element list result. | 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")
. |
34 */ | 38 */ |
35 static void ReduceClipStack(const SkClipStack& stack, | 39 static InitialState ReduceClipStack(const SkClipStack& stack, |
36 const SkIRect& queryBounds, | 40 const SkRect& queryBounds, |
37 ElementList* result, | 41 ElementList* result, |
38 int32_t* resultGenID, | 42 int32_t* resultGenID, |
39 InitialState* initialState, | 43 SkIRect* clipIBounds, |
40 SkIRect* tighterBounds, | 44 bool* requiresAA); |
41 bool* requiresAA); | |
42 }; | 45 }; |
43 | 46 |
44 #endif | 47 #endif |
OLD | NEW |