aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkPngCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-01-18 16:13:25 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-18 16:13:42 +0000
commitdfff166db5d5226dc002a22ab3e3097ef971d615 (patch)
tree8665a7d7c849abd517ceab759afa738e9e736591 /src/codec/SkPngCodec.cpp
parent93a8a645433744858034693105459409901ec231 (diff)
Revert "Respect full precision for RGB16 PNGs"
This reverts commit 7a090c403da1dad6a2e19f2011158bd894a62d91. Reason for revert: <INSERT REASONING HERE> Original change's description: > Respect full precision for RGB16 PNGs > > BUG=skia: > > CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD > > Change-Id: If58d201daae97bce2f8efbc453c2ec452e682493 > Reviewed-on: https://skia-review.googlesource.com/7085 > Commit-Queue: Matt Sarett <msarett@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Reviewed-by: Leon Scroggins <scroggo@google.com> > Reviewed-by: Mike Reed <reed@google.com> > TBR=mtklein@chromium.org,mtklein@google.com,msarett@google.com,scroggo@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ibd9879bc4f65ca0c2457dd0bfb5eb008d9a8f672 Reviewed-on: https://skia-review.googlesource.com/7183 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkPngCodec.cpp')
-rw-r--r--src/codec/SkPngCodec.cpp38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 468b0b8731..9f5c8e6906 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -420,12 +420,8 @@ void SkPngCodec::allocateStorage(const SkImageInfo& dstInfo) {
// be created later if we are sampling. We'll go ahead and allocate
// enough memory to swizzle if necessary.
case kSwizzleColor_XformMode: {
- const int bitsPerPixel = this->getEncodedInfo().bitsPerPixel();
-
- // If we have more than 8-bits (per component) of precision, we will keep that
- // extra precision. Otherwise, we will swizzle to RGBA_8888 before transforming.
- const size_t bytesPerPixel = (bitsPerPixel > 32) ? bitsPerPixel / 8 : 4;
- const size_t colorXformBytes = dstInfo.width() * bytesPerPixel;
+ const size_t bpp = (this->getEncodedInfo().bitsPerPixel() > 32) ? 8 : 4;
+ const size_t colorXformBytes = dstInfo.width() * bpp;
fStorage.reset(colorXformBytes);
fColorXformSrcRow = fStorage.get();
break;
@@ -434,13 +430,10 @@ void SkPngCodec::allocateStorage(const SkImageInfo& dstInfo) {
}
static SkColorSpaceXform::ColorFormat png_select_xform_format(const SkEncodedInfo& info) {
- // We use kRGB and kRGBA formats because color PNGs are always RGB or RGBA.
- if (16 == info.bitsPerComponent()) {
- if (SkEncodedInfo::kRGBA_Color == info.color()) {
- return SkColorSpaceXform::kRGBA_U16_BE_ColorFormat;
- } else if (SkEncodedInfo::kRGB_Color == info.color()) {
- return SkColorSpaceXform::kRGB_U16_BE_ColorFormat;
- }
+ // We always use kRGBA because color PNGs are always RGB or RGBA.
+ // TODO (msarett): Support kRGB_U16 inputs as well.
+ if (16 == info.bitsPerComponent() && SkEncodedInfo::kRGBA_Color == info.color()) {
+ return SkColorSpaceXform::kRGBA_U16_BE_ColorFormat;
}
return SkColorSpaceXform::kRGBA_8888_ColorFormat;
@@ -1097,22 +1090,9 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
return false;
}
- // If SkColorSpaceXform directly supports the encoded PNG format, we should skip format
- // conversion in the swizzler (or skip swizzling altogether).
- bool skipFormatConversion = false;
- switch (this->getEncodedInfo().color()) {
- case SkEncodedInfo::kRGB_Color:
- if (this->getEncodedInfo().bitsPerComponent() != 16) {
- break;
- }
-
- // Fall through
- case SkEncodedInfo::kRGBA_Color:
- skipFormatConversion = this->colorXform();
- break;
- default:
- break;
- }
+ // If the image is RGBA and we have a color xform, we can skip the swizzler.
+ const bool skipFormatConversion = this->colorXform() &&
+ SkEncodedInfo::kRGBA_Color == this->getEncodedInfo().color();
if (skipFormatConversion && !options.fSubset) {
fXformMode = kColorOnly_XformMode;
return true;