OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkBitmapProcState.h" | 8 #include "SkBitmapProcState.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFilterProc.h" | 10 #include "SkFilterProc.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // the scanline proc handle it. | 152 // the scanline proc handle it. |
153 return true; | 153 return true; |
154 | 154 |
155 } | 155 } |
156 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, | 156 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, |
157 invScaleX, | 157 invScaleX, |
158 invScaleY, | 158 invScaleY, |
159 fScaledBitmap); | 159 fScaledBitmap); |
160 } | 160 } |
161 fScaledBitmap.lockPixels(); // wonder if Resize() should have locked thi
s | 161 fScaledBitmap.lockPixels(); // wonder if Resize() should have locked thi
s |
| 162 if (!fScaledBitmap.getPixel()) { |
| 163 return false; |
| 164 } |
162 fBitmap = &fScaledBitmap; | 165 fBitmap = &fScaledBitmap; |
163 | 166 |
164 // set the inv matrix type to translate-only; | 167 // set the inv matrix type to translate-only; |
165 fInvMatrix.setTranslate(fInvMatrix.getTranslateX() / fInvMatrix.getScale
X(), | 168 fInvMatrix.setTranslate(fInvMatrix.getTranslateX() / fInvMatrix.getScale
X(), |
166 fInvMatrix.getTranslateY() / fInvMatrix.getScale
Y()); | 169 fInvMatrix.getTranslateY() / fInvMatrix.getScale
Y()); |
167 | 170 |
168 // no need for any further filtering; we just did it! | 171 // no need for any further filtering; we just did it! |
169 fFilterLevel = SkPaint::kNone_FilterLevel; | 172 fFilterLevel = SkPaint::kNone_FilterLevel; |
170 return true; | 173 return true; |
171 } | 174 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, | 289 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, |
287 SK_Scalar1, SK_Scala
r1, | 290 SK_Scalar1, SK_Scala
r1, |
288 fScaledBitmap); | 291 fScaledBitmap); |
289 if (!fScaledCacheID) { | 292 if (!fScaledCacheID) { |
290 fScaledBitmap.reset(); | 293 fScaledBitmap.reset(); |
291 return false; | 294 return false; |
292 } | 295 } |
293 } | 296 } |
294 } | 297 } |
295 fScaledBitmap.lockPixels(); // just 'cause the cache made a copy :( | 298 fScaledBitmap.lockPixels(); // just 'cause the cache made a copy :( |
| 299 if (!fScaledBitmap.getPixel()) { |
| 300 return false; |
| 301 } |
296 fBitmap = &fScaledBitmap; | 302 fBitmap = &fScaledBitmap; |
297 return true; | 303 return true; |
298 } | 304 } |
299 | 305 |
300 void SkBitmapProcState::endContext() { | 306 void SkBitmapProcState::endContext() { |
301 SkDELETE(fBitmapFilter); | 307 SkDELETE(fBitmapFilter); |
302 fBitmapFilter = NULL; | 308 fBitmapFilter = NULL; |
303 fScaledBitmap.reset(); | 309 fScaledBitmap.reset(); |
304 | 310 |
305 if (fScaledCacheID) { | 311 if (fScaledCacheID) { |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 } else { | 974 } else { |
969 size >>= 2; | 975 size >>= 2; |
970 } | 976 } |
971 | 977 |
972 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 978 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
973 size >>= 1; | 979 size >>= 1; |
974 } | 980 } |
975 | 981 |
976 return size; | 982 return size; |
977 } | 983 } |
OLD | NEW |