OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapController.h" | 9 #include "SkBitmapController.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (SkScalarNearlyEqual(invScaleX, 1) && SkScalarNearlyEqual(invScaleY, 1))
{ | 115 if (SkScalarNearlyEqual(invScaleX, 1) && SkScalarNearlyEqual(invScaleY, 1))
{ |
116 return false; // no need for HQ | 116 return false; // no need for HQ |
117 } | 117 } |
118 | 118 |
119 SkScalar trueDestWidth = origBitmap.width() / invScaleX; | 119 SkScalar trueDestWidth = origBitmap.width() / invScaleX; |
120 SkScalar trueDestHeight = origBitmap.height() / invScaleY; | 120 SkScalar trueDestHeight = origBitmap.height() / invScaleY; |
121 SkScalar roundedDestWidth = SkScalarRoundToScalar(trueDestWidth); | 121 SkScalar roundedDestWidth = SkScalarRoundToScalar(trueDestWidth); |
122 SkScalar roundedDestHeight = SkScalarRoundToScalar(trueDestHeight); | 122 SkScalar roundedDestHeight = SkScalarRoundToScalar(trueDestHeight); |
123 | 123 |
124 if (!SkBitmapCache::Find(origBitmap, roundedDestWidth, roundedDestHeight, &f
ResultBitmap)) { | 124 if (!SkBitmapCache::Find(origBitmap, roundedDestWidth, roundedDestHeight, &f
ResultBitmap)) { |
125 if (!SkBitmapScaler::Resize(&fResultBitmap, | 125 SkAutoPixmapUnlock src; |
126 origBitmap, | 126 if (!origBitmap.requestLock(&src)) { |
127 SkBitmapScaler::RESIZE_BEST, | 127 return false; |
128 roundedDestWidth, | 128 } |
129 roundedDestHeight, | 129 if (!SkBitmapScaler::Resize(&fResultBitmap, src.pixmap(), SkBitmapScaler
::RESIZE_BEST, |
| 130 roundedDestWidth, roundedDestHeight, |
130 SkResourceCache::GetAllocator())) { | 131 SkResourceCache::GetAllocator())) { |
131 return false; // we failed to create fScaledBitmap | 132 return false; // we failed to create fScaledBitmap |
132 } | 133 } |
133 | 134 |
134 SkASSERT(fResultBitmap.getPixels()); | 135 SkASSERT(fResultBitmap.getPixels()); |
135 fResultBitmap.setImmutable(); | 136 fResultBitmap.setImmutable(); |
136 SkBitmapCache::Add(origBitmap, roundedDestWidth, roundedDestHeight, fRes
ultBitmap); | 137 SkBitmapCache::Add(origBitmap, roundedDestWidth, roundedDestHeight, fRes
ultBitmap); |
137 } | 138 } |
138 | 139 |
139 SkASSERT(fResultBitmap.getPixels()); | 140 SkASSERT(fResultBitmap.getPixels()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 fResultBitmap.getColorTable()); | 217 fResultBitmap.getColorTable()); |
217 } | 218 } |
218 | 219 |
219 SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi
tmap& bm, | 220 SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi
tmap& bm, |
220 const SkMa
trix& inverse, | 221 const SkMa
trix& inverse, |
221 SkFilterQu
ality quality, | 222 SkFilterQu
ality quality, |
222 void* stor
age, size_t size) { | 223 void* stor
age, size_t size) { |
223 return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm,
inverse, quality); | 224 return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm,
inverse, quality); |
224 } | 225 } |
225 | 226 |
OLD | NEW |