OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "SkDeviceLooper.h" | 8 #include "SkDeviceLooper.h" |
9 | 9 |
10 SkDeviceLooper::SkDeviceLooper(const SkPixmap& base, const SkRasterClip& rc, con
st SkIRect& bounds, | 10 SkDeviceLooper::SkDeviceLooper(const SkPixmap& base, const SkRasterClip& rc, con
st SkIRect& bounds, |
11 bool aa) | 11 bool aa) |
12 : fBaseDst(base) | 12 : fBaseDst(base) |
13 , fBaseRC(rc) | 13 , fBaseRC(rc) |
14 , fSubsetRC(rc.isForceConservativeRects()) | 14 , fSubsetRC(rc.isForceConservativeRects()) |
15 , fDelta(aa ? kAA_Delta : kBW_Delta) | 15 , fDelta(aa ? kAA_Delta : kBW_Delta) |
16 { | 16 { |
17 // sentinels that next() has not yet been called, and so our mapper function
s | 17 // sentinels that next() has not yet been called, and so our mapper function
s |
18 // should not be called either. | 18 // should not be called either. |
19 fCurrDst = NULL; | 19 fCurrDst = nullptr; |
20 fCurrRC = NULL; | 20 fCurrRC = nullptr; |
21 | 21 |
22 if (!rc.isEmpty()) { | 22 if (!rc.isEmpty()) { |
23 // clip must be contained by the bitmap | 23 // clip must be contained by the bitmap |
24 SkASSERT(SkIRect::MakeWH(base.width(), base.height()).contains(rc.getBou
nds())); | 24 SkASSERT(SkIRect::MakeWH(base.width(), base.height()).contains(rc.getBou
nds())); |
25 } | 25 } |
26 | 26 |
27 if (rc.isEmpty() || !fClippedBounds.intersect(bounds, rc.getBounds())) { | 27 if (rc.isEmpty() || !fClippedBounds.intersect(bounds, rc.getBounds())) { |
28 fState = kDone_State; | 28 fState = kDone_State; |
29 } else if (this->fitsInDelta(fClippedBounds)) { | 29 } else if (this->fitsInDelta(fClippedBounds)) { |
30 fState = kSimple_State; | 30 fState = kSimple_State; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 bool SkDeviceLooper::next() { | 96 bool SkDeviceLooper::next() { |
97 switch (fState) { | 97 switch (fState) { |
98 case kDone_State: | 98 case kDone_State: |
99 // in theory, we should not get called here, since we must have | 99 // in theory, we should not get called here, since we must have |
100 // previously returned false, but we check anyway. | 100 // previously returned false, but we check anyway. |
101 break; | 101 break; |
102 | 102 |
103 case kSimple_State: | 103 case kSimple_State: |
104 // first time for simple | 104 // first time for simple |
105 if (NULL == fCurrDst) { | 105 if (nullptr == fCurrDst) { |
106 fCurrDst = &fBaseDst; | 106 fCurrDst = &fBaseDst; |
107 fCurrRC = &fBaseRC; | 107 fCurrRC = &fBaseRC; |
108 fCurrOffset.set(0, 0); | 108 fCurrOffset.set(0, 0); |
109 return true; | 109 return true; |
110 } | 110 } |
111 // 2nd time for simple, we are done | 111 // 2nd time for simple, we are done |
112 break; | 112 break; |
113 | 113 |
114 case kComplex_State: | 114 case kComplex_State: |
115 // need to propogate fCurrOffset through clippedbounds | 115 // need to propogate fCurrOffset through clippedbounds |
116 // left to right, until we wrap around and move down | 116 // left to right, until we wrap around and move down |
117 | 117 |
118 while (next_tile(fClippedBounds, fDelta, &fCurrOffset)) { | 118 while (next_tile(fClippedBounds, fDelta, &fCurrOffset)) { |
119 if (this->computeCurrBitmapAndClip()) { | 119 if (this->computeCurrBitmapAndClip()) { |
120 return true; | 120 return true; |
121 } | 121 } |
122 } | 122 } |
123 break; | 123 break; |
124 } | 124 } |
125 fState = kDone_State; | 125 fState = kDone_State; |
126 return false; | 126 return false; |
127 } | 127 } |
OLD | NEW |