diff options
author | 2017-06-06 15:16:05 -0700 | |
---|---|---|
committer | 2017-06-07 20:19:46 +0000 | |
commit | 2c075e749d1f33dea06ad2710e15c9a1d60ebced (patch) | |
tree | b98fcebd6af3119219c0693a1a32f2bc8fdefc7a /src/image/SkImage_Gpu.cpp | |
parent | 33deb7ed4d583c88187ba240efb749e9a1fd6843 (diff) |
DeferredTextureImageData low-bit-depth/dithering support
Cause DeferredTextureImageData functionality to support low bit depth
(4444, 565) image formats (with dithering).
Bug: 720105
Change-Id: Ie3b5768ebc393d9b0a5322461c722bf37c80b791
Reviewed-on: https://skia-review.googlesource.com/18945
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 55ceba06d2..4c89e8e0fc 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -657,7 +657,8 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox SkAutoPixmapStorage pixmap; SkImageInfo info; size_t pixelSize = 0; - if (!isScaled && this->peekPixels(&pixmap) && !pixmap.ctable()) { + if (!isScaled && this->peekPixels(&pixmap) && !pixmap.ctable() && + pixmap.info().colorType() == params[0].fColorType) { info = pixmap.info(); pixelSize = SkAlign8(pixmap.getSafeSize()); if (!dstColorSpace) { @@ -680,24 +681,35 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox info = info.makeColorSpace(nullptr); } } - if (kIndex_8_SkColorType == info.colorType()) { - // Force Index8 to be N32 instead. Index8 is unsupported in Ganesh. - info = info.makeColorType(kN32_SkColorType); - } + // Force color type to be the requested type. + info = info.makeColorType(params->fColorType); pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr)); if (fillMode) { - pixmap.alloc(info); + // Always decode to N32 and convert to the requested type if necessary. + SkImageInfo decodeInfo = info.makeColorType(kN32_SkColorType); + SkAutoPixmapStorage decodePixmap; + decodePixmap.alloc(decodeInfo); + if (isScaled) { - if (!this->scalePixels(pixmap, scaleFilterQuality, + if (!this->scalePixels(decodePixmap, scaleFilterQuality, SkImage::kDisallow_CachingHint)) { return 0; } } else { - if (!this->readPixels(pixmap, 0, 0, SkImage::kDisallow_CachingHint)) { + if (!this->readPixels(decodePixmap, 0, 0, SkImage::kDisallow_CachingHint)) { return 0; } } - SkASSERT(!pixmap.ctable()); + SkASSERT(!decodePixmap.ctable()); + + if (decodeInfo.colorType() != info.colorType()) { + pixmap.alloc(info); + // Convert and copy the decoded pixmap to the target pixmap. + decodePixmap.readPixels(pixmap.info(), pixmap.writable_addr(), pixmap.rowBytes(), 0, + 0); + } else { + pixmap = std::move(decodePixmap); + } } } int mipMapLevelCount = 1; |