OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrReducedClip.h" | 9 #include "GrReducedClip.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // We initially look at whether the bounds alone is sufficient. We also use
the stack bounds to | 44 // We initially look at whether the bounds alone is sufficient. We also use
the stack bounds to |
45 // attempt to compute the tighterBounds. | 45 // attempt to compute the tighterBounds. |
46 | 46 |
47 SkClipStack::BoundsType stackBoundsType; | 47 SkClipStack::BoundsType stackBoundsType; |
48 SkRect stackBounds; | 48 SkRect stackBounds; |
49 bool iior; | 49 bool iior; |
50 stack.getBounds(&stackBounds, &stackBoundsType, &iior); | 50 stack.getBounds(&stackBounds, &stackBoundsType, &iior); |
51 | 51 |
52 const SkIRect* bounds = &queryBounds; | 52 const SkIRect* bounds = &queryBounds; |
53 | 53 |
54 SkRect scalarQueryBounds = SkRect::MakeFromIRect(queryBounds); | 54 SkRect scalarQueryBounds = SkRect::Make(queryBounds); |
55 | 55 |
56 if (iior) { | 56 if (iior) { |
57 SkASSERT(SkClipStack::kNormal_BoundsType == stackBoundsType); | 57 SkASSERT(SkClipStack::kNormal_BoundsType == stackBoundsType); |
58 SkRect isectRect; | 58 SkRect isectRect; |
59 if (stackBounds.contains(scalarQueryBounds)) { | 59 if (stackBounds.contains(scalarQueryBounds)) { |
60 *initialState = kAllIn_InitialState; | 60 *initialState = kAllIn_InitialState; |
61 if (NULL != tighterBounds) { | 61 if (NULL != tighterBounds) { |
62 *tighterBounds = queryBounds; | 62 *tighterBounds = queryBounds; |
63 } | 63 } |
64 if (NULL != requiresAA) { | 64 if (NULL != requiresAA) { |
65 *requiresAA = false; | 65 *requiresAA = false; |
66 } | 66 } |
67 } else if (isectRect.intersect(stackBounds, scalarQueryBounds)) { | 67 } else if (isectRect.intersect(stackBounds, scalarQueryBounds)) { |
68 if (NULL != tighterBounds) { | 68 if (NULL != tighterBounds) { |
69 isectRect.roundOut(tighterBounds); | 69 isectRect.roundOut(tighterBounds); |
70 SkRect scalarTighterBounds = SkRect::MakeFromIRect(*tighterBound
s); | 70 SkRect scalarTighterBounds = SkRect::Make(*tighterBounds); |
71 if (scalarTighterBounds == isectRect) { | 71 if (scalarTighterBounds == isectRect) { |
72 // the round-out didn't add any area outside the clip rect. | 72 // the round-out didn't add any area outside the clip rect. |
73 *requiresAA = false; | 73 *requiresAA = false; |
74 *initialState = kAllIn_InitialState; | 74 *initialState = kAllIn_InitialState; |
75 return; | 75 return; |
76 } | 76 } |
77 *initialState = kAllOut_InitialState; | 77 *initialState = kAllOut_InitialState; |
78 // iior should only be true if aa/non-aa status matches among al
l elements. | 78 // iior should only be true if aa/non-aa status matches among al
l elements. |
79 SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart)
; | 79 SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart)
; |
80 bool doAA = iter.prev()->isAA(); | 80 bool doAA = iter.prev()->isAA(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 *requiresAA = false; | 112 *requiresAA = false; |
113 } | 113 } |
114 return; | 114 return; |
115 } | 115 } |
116 if (NULL != tighterBounds) { | 116 if (NULL != tighterBounds) { |
117 *tighterBounds = queryBounds; | 117 *tighterBounds = queryBounds; |
118 } | 118 } |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 SkRect scalarBounds = SkRect::MakeFromIRect(*bounds); | 122 SkRect scalarBounds = SkRect::Make(*bounds); |
123 | 123 |
124 // Now that we have determined the bounds to use and filtered out the trivia
l cases, call the | 124 // Now that we have determined the bounds to use and filtered out the trivia
l cases, call the |
125 // helper that actually walks the stack. | 125 // helper that actually walks the stack. |
126 reduced_stack_walker(stack, scalarBounds, result, initialState, requiresAA); | 126 reduced_stack_walker(stack, scalarBounds, result, initialState, requiresAA); |
127 } | 127 } |
128 | 128 |
129 void reduced_stack_walker(const SkClipStack& stack, | 129 void reduced_stack_walker(const SkClipStack& stack, |
130 const SkRect& queryBounds, | 130 const SkRect& queryBounds, |
131 ElementList* result, | 131 ElementList* result, |
132 InitialState* initialState, | 132 InitialState* initialState, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 result->popHead(); | 412 result->popHead(); |
413 element = result->headIter().get(); | 413 element = result->headIter().get(); |
414 } | 414 } |
415 } | 415 } |
416 } | 416 } |
417 if (NULL != requiresAA) { | 417 if (NULL != requiresAA) { |
418 *requiresAA = numAAElements > 0; | 418 *requiresAA = numAAElements > 0; |
419 } | 419 } |
420 } | 420 } |
421 } // namespace GrReducedClip | 421 } // namespace GrReducedClip |
OLD | NEW |