diff options
author | Brian Salomon <bsalomon@google.com> | 2017-06-08 13:32:26 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-08 13:32:30 +0000 |
commit | 840ff8837bd93ee73c187890839b3f56e7c94fb7 (patch) | |
tree | e78a23cede0d4a43753519e8e98af8c853346bb7 /src/image | |
parent | b6f4767294261dca3beef6f280c4bac69df3f930 (diff) |
Revert "Revert "DeferredTextureImageData low-bit-depth/dithering support""
This reverts commit d7c681d6a7b154d276e275becc51685eac8705c2.
Reason for revert: New param already used in Chrome
Original change's description:
> Revert "DeferredTextureImageData low-bit-depth/dithering support"
>
> This reverts commit 2c075e749d1f33dea06ad2710e15c9a1d60ebced.
>
> Reason for revert: Breaking tests. e.g.: https://chromium-swarm.appspot.com/task?id=369dc44f62ce9510&refresh=10
>
> Original change's description:
> > 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>
>
> TBR=bsalomon@google.com,ericrk@chromium.org
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 720105
>
> Change-Id: I07aec722425efc62bc54f82cee9a19a9bf339f7b
> Reviewed-on: https://skia-review.googlesource.com/19039
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,reviews@skia.org,ericrk@chromium.org
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 720105
Change-Id: I91e690d0564f04209a2bd677de9ae9eb9c0f90d3
Reviewed-on: https://skia-review.googlesource.com/19041
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/image')
-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; |