Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: src/core/SkBitmapController.cpp

Issue 1174293005: change Resize to take pixmap for src (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkBitmapScaler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapScaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698