OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 <cstddef> | 8 #include <cstddef> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <type_traits> | 10 #include <type_traits> |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 for (int generatedMipLevelIndex = 0; generatedMipLevelIndex < mipMapLeve
lCount - 1; | 618 for (int generatedMipLevelIndex = 0; generatedMipLevelIndex < mipMapLeve
lCount - 1; |
619 generatedMipLevelIndex++) { | 619 generatedMipLevelIndex++) { |
620 SkISize mipSize = SkMipMap::ComputeLevelSize(scaledSize.width(), sca
ledSize.height(), | 620 SkISize mipSize = SkMipMap::ComputeLevelSize(scaledSize.width(), sca
ledSize.height(), |
621 generatedMipLevelIndex)
; | 621 generatedMipLevelIndex)
; |
622 | 622 |
623 SkImageInfo mipInfo = SkImageInfo::MakeN32(mipSize.fWidth, mipSize.f
Height, at); | 623 SkImageInfo mipInfo = SkImageInfo::MakeN32(mipSize.fWidth, mipSize.f
Height, at); |
624 SkMipMap::Level mipLevel; | 624 SkMipMap::Level mipLevel; |
625 mipmaps->getLevel(generatedMipLevelIndex, &mipLevel); | 625 mipmaps->getLevel(generatedMipLevelIndex, &mipLevel); |
626 | 626 |
627 // Make sure the mipmap data is after the start of the buffer | 627 // Make sure the mipmap data is after the start of the buffer |
628 SkASSERT_RELEASE(mipLevelPtr > bufferAsInt); | 628 SkASSERT(mipLevelPtr > bufferAsInt); |
629 // Make sure the mipmap data starts before the end of the buffer | 629 // Make sure the mipmap data starts before the end of the buffer |
630 SkASSERT_RELEASE(static_cast<size_t>(mipLevelPtr) < bufferAsInt + pi
xelOffset + pixelSize); | 630 SkASSERT(static_cast<size_t>(mipLevelPtr) < bufferAsInt + pixelOffse
t + pixelSize); |
631 // Make sure the mipmap data ends before the end of the buffer | 631 // Make sure the mipmap data ends before the end of the buffer |
632 SkASSERT_RELEASE(mipLevelPtr + mipLevel.fPixmap.getSafeSize() <= | 632 SkASSERT(mipLevelPtr + mipLevel.fPixmap.getSafeSize() <= |
633 bufferAsInt + pixelOffset + pixelSize); | 633 bufferAsInt + pixelOffset + pixelSize); |
634 | 634 |
635 // getSafeSize includes rowbyte padding except for the last row, | 635 // getSafeSize includes rowbyte padding except for the last row, |
636 // right? | 636 // right? |
637 | 637 |
638 memcpy(reinterpret_cast<void*>(mipLevelPtr), mipLevel.fPixmap.addr()
, | 638 memcpy(reinterpret_cast<void*>(mipLevelPtr), mipLevel.fPixmap.addr()
, |
639 mipLevel.fPixmap.getSafeSize()); | 639 mipLevel.fPixmap.getSafeSize()); |
640 | 640 |
641 memcpy(reinterpret_cast<void*>(bufferAsInt + | 641 memcpy(reinterpret_cast<void*>(bufferAsInt + |
642 offsetof(DeferredTextureImage, fMipMapLevelData) + | 642 offsetof(DeferredTextureImage, fMipMapLevelData) + |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 } | 708 } |
709 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 709 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
710 if (!texture) { | 710 if (!texture) { |
711 return nullptr; | 711 return nullptr; |
712 } | 712 } |
713 texture->texturePriv().setGammaTreatment(gammaTreatment); | 713 texture->texturePriv().setGammaTreatment(gammaTreatment); |
714 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 714 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
715 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), | 715 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), |
716 budgeted); | 716 budgeted); |
717 } | 717 } |
OLD | NEW |