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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 proc = proc_3_2; | 444 proc = proc_3_2; |
445 } | 445 } |
446 } else { // src-width is 2 | 446 } else { // src-width is 2 |
447 proc = proc_2_2; | 447 proc = proc_2_2; |
448 } | 448 } |
449 } | 449 } |
450 width = SkTMax(1, width >> 1); | 450 width = SkTMax(1, width >> 1); |
451 height = SkTMax(1, height >> 1); | 451 height = SkTMax(1, height >> 1); |
452 rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width)); | 452 rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width)); |
453 | 453 |
454 levels[i].fPixmap = SkPixmap(SkImageInfo::Make(width, height, ct, at), a
ddr, rowBytes); | 454 new (&levels[i].fPixmap) SkPixmap(SkImageInfo::Make(width, height, ct, a
t), addr, rowBytes); |
455 levels[i].fScale = SkSize::Make(SkIntToScalar(width) / src.width(), | 455 levels[i].fScale = SkSize::Make(SkIntToScalar(width) / src.width(), |
456 SkIntToScalar(height) / src.height()); | 456 SkIntToScalar(height) / src.height()); |
457 | 457 |
458 const SkPixmap& dstPM = levels[i].fPixmap; | 458 const SkPixmap& dstPM = levels[i].fPixmap; |
459 const void* srcBasePtr = srcPM.addr(); | 459 const void* srcBasePtr = srcPM.addr(); |
460 void* dstBasePtr = dstPM.writable_addr(); | 460 void* dstBasePtr = dstPM.writable_addr(); |
461 | 461 |
462 const size_t srcRB = srcPM.rowBytes(); | 462 const size_t srcRB = srcPM.rowBytes(); |
463 for (int y = 0; y < height; y++) { | 463 for (int y = 0; y < height; y++) { |
464 proc(dstBasePtr, srcBasePtr, srcRB, width); | 464 proc(dstBasePtr, srcBasePtr, srcRB, width); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 return false; | 580 return false; |
581 } | 581 } |
582 if (index > fCount - 1) { | 582 if (index > fCount - 1) { |
583 return false; | 583 return false; |
584 } | 584 } |
585 if (levelPtr) { | 585 if (levelPtr) { |
586 *levelPtr = fLevels[index]; | 586 *levelPtr = fLevels[index]; |
587 } | 587 } |
588 return true; | 588 return true; |
589 } | 589 } |
OLD | NEW |