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

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

Issue 857193003: remove legacy flags for old image filtering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | « src/core/SkBitmapProcState.cpp ('k') | no next file » | 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 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 "SkMipMap.h" 8 #include "SkMipMap.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 srcBM = dstBM; 218 srcBM = dstBM;
219 addr += height * rowBytes; 219 addr += height * rowBytes;
220 } 220 }
221 SkASSERT(addr == baseAddr + size); 221 SkASSERT(addr == baseAddr + size);
222 222
223 return mipmap; 223 return mipmap;
224 } 224 }
225 225
226 /////////////////////////////////////////////////////////////////////////////// 226 ///////////////////////////////////////////////////////////////////////////////
227 227
228 #ifdef SK_SUPPORT_LEGACY_MIPLEVELCHOICE
229 static SkFixed compute_level(SkScalar scale) {
230 SkScalar inv = SkScalarAbs(SkScalarInvert(scale));
231 if (inv > 32767) { // Watch out for SkFixed overflow.
232 inv = 32767;
233 }
234 SkFixed s = SkScalarToFixed(inv);
235
236 if (s < SK_Fixed1) {
237 return 0;
238 }
239 int clz = SkCLZ(s);
240 SkASSERT(clz >= 1 && clz <= 15);
241 return SkIntToFixed(15 - clz) + ((unsigned)(s << (clz + 1)) >> 16);
242 }
243 #endif
244
245 bool SkMipMap::extractLevel(SkScalar scale, Level* levelPtr) const { 228 bool SkMipMap::extractLevel(SkScalar scale, Level* levelPtr) const {
246 if (NULL == fLevels) { 229 if (NULL == fLevels) {
247 return false; 230 return false;
248 } 231 }
249 232
250 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { 233 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) {
251 return false; 234 return false;
252 } 235 }
253 236
254 #ifdef SK_SUPPORT_LEGACY_MIPLEVELCHOICE
255 int level = compute_level(scale) >> 16;
256 #else
257 SkScalar L = -SkScalarLog2(scale); 237 SkScalar L = -SkScalarLog2(scale);
258 if (!SkScalarIsFinite(L)) { 238 if (!SkScalarIsFinite(L)) {
259 return false; 239 return false;
260 } 240 }
261 SkASSERT(L >= 0); 241 SkASSERT(L >= 0);
262 int level = SkScalarRoundToInt(L); 242 int level = SkScalarRoundToInt(L);
263 // SkDebugf("mipmap scale=%g L=%g level=%d\n", scale, L, level); 243 // SkDebugf("mipmap scale=%g L=%g level=%d\n", scale, L, level);
264 #endif
265 244
266 SkASSERT(level >= 0); 245 SkASSERT(level >= 0);
267 if (level <= 0) { 246 if (level <= 0) {
268 return false; 247 return false;
269 } 248 }
270 249
271 if (level > fCount) { 250 if (level > fCount) {
272 level = fCount; 251 level = fCount;
273 } 252 }
274 if (levelPtr) { 253 if (levelPtr) {
275 *levelPtr = fLevels[level - 1]; 254 *levelPtr = fLevels[level - 1];
276 } 255 }
277 return true; 256 return true;
278 } 257 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698