OLD | NEW |
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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 srcPM = dstPM; | 313 srcPM = dstPM; |
314 addr += height * rowBytes; | 314 addr += height * rowBytes; |
315 } | 315 } |
316 SkASSERT(addr == baseAddr + size); | 316 SkASSERT(addr == baseAddr + size); |
317 | 317 |
318 return mipmap; | 318 return mipmap; |
319 } | 319 } |
320 | 320 |
321 /////////////////////////////////////////////////////////////////////////////// | 321 /////////////////////////////////////////////////////////////////////////////// |
322 | 322 |
323 bool SkMipMap::extractLevel(SkScalar scale, Level* levelPtr) const { | 323 bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const { |
324 if (nullptr == fLevels) { | 324 if (nullptr == fLevels) { |
325 return false; | 325 return false; |
326 } | 326 } |
327 | 327 |
| 328 SkASSERT(scaleSize.width() >= 0 && scaleSize.height() >= 0); |
| 329 // Use the smallest scale to match the GPU impl. |
| 330 const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height()); |
| 331 |
328 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { | 332 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { |
329 return false; | 333 return false; |
330 } | 334 } |
331 | 335 |
332 SkScalar L = -SkScalarLog2(scale); | 336 SkScalar L = -SkScalarLog2(scale); |
333 if (!SkScalarIsFinite(L)) { | 337 if (!SkScalarIsFinite(L)) { |
334 return false; | 338 return false; |
335 } | 339 } |
336 SkASSERT(L >= 0); | 340 SkASSERT(L >= 0); |
337 // int rndLevel = SkScalarRoundToInt(L); | 341 // int rndLevel = SkScalarRoundToInt(L); |
(...skipping 22 matching lines...) Expand all Loading... |
360 return nullptr; | 364 return nullptr; |
361 } | 365 } |
362 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); | 366 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); |
363 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 | 367 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 |
364 if (nullptr == srcPixmap.addr()) { | 368 if (nullptr == srcPixmap.addr()) { |
365 sk_throw(); | 369 sk_throw(); |
366 } | 370 } |
367 return Build(srcPixmap, fact); | 371 return Build(srcPixmap, fact); |
368 } | 372 } |
369 | 373 |
OLD | NEW |