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

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

Issue 1617183004: Anisotropic mipmap fixes (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: SkIntToScalar Created 4 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/SkMipMap.h ('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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 proc = proc_3_2; 290 proc = proc_3_2;
291 } else { // src-width is 2 291 } else { // src-width is 2
292 proc = proc_2_2; 292 proc = proc_2_2;
293 } 293 }
294 } 294 }
295 width >>= 1; 295 width >>= 1;
296 height >>= 1; 296 height >>= 1;
297 rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width)); 297 rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width));
298 298
299 levels[i].fPixmap = SkPixmap(SkImageInfo::Make(width, height, ct, at), a ddr, rowBytes); 299 levels[i].fPixmap = SkPixmap(SkImageInfo::Make(width, height, ct, at), a ddr, rowBytes);
300 levels[i].fScale = (float)width / src.width(); 300 #ifdef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAPS
301 levels[i].fScale = SkSize::Make(SkIntToScalar(width) / src.width(),
302 SkIntToScalar(width) / src.width());
303 #else
304 levels[i].fScale = SkSize::Make(SkIntToScalar(width) / src.width(),
305 SkIntToScalar(height) / src.height());
306 #endif
301 307
302 const SkPixmap& dstPM = levels[i].fPixmap; 308 const SkPixmap& dstPM = levels[i].fPixmap;
303 const void* srcBasePtr = srcPM.addr(); 309 const void* srcBasePtr = srcPM.addr();
304 void* dstBasePtr = dstPM.writable_addr(); 310 void* dstBasePtr = dstPM.writable_addr();
305 311
306 const size_t srcRB = srcPM.rowBytes(); 312 const size_t srcRB = srcPM.rowBytes();
307 for (int y = 0; y < height; y++) { 313 for (int y = 0; y < height; y++) {
308 proc(dstBasePtr, srcBasePtr, srcRB, width); 314 proc(dstBasePtr, srcBasePtr, srcRB, width);
309 srcBasePtr = (char*)srcBasePtr + srcRB * 2; // jump two rows 315 srcBasePtr = (char*)srcBasePtr + srcRB * 2; // jump two rows
310 dstBasePtr = (char*)dstBasePtr + dstPM.rowBytes(); 316 dstBasePtr = (char*)dstBasePtr + dstPM.rowBytes();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 return nullptr; 365 return nullptr;
360 } 366 }
361 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); 367 const SkPixmap& srcPixmap = srcUnlocker.pixmap();
362 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 368 // Try to catch where we might have returned nullptr for src crbug.com/49281 8
363 if (nullptr == srcPixmap.addr()) { 369 if (nullptr == srcPixmap.addr()) {
364 sk_throw(); 370 sk_throw();
365 } 371 }
366 return Build(srcPixmap, fact); 372 return Build(srcPixmap, fact);
367 } 373 }
368 374
OLDNEW
« no previous file with comments | « src/core/SkMipMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698