diff options
author | msarett <msarett@google.com> | 2016-09-16 11:01:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-16 11:01:27 -0700 |
commit | c71a9b7f53938b4f33f36f48e867b8b72cc1cc61 (patch) | |
tree | 8fbb6b55eb00f5fb5b55e89d97076f199cc0e205 /src/codec | |
parent | 046cb56c6c1bb40779c81b115271ed0e8196b48b (diff) |
Revert of Support Float32 output from SkColorSpaceXform (patchset #7 id:140001 of https://codereview.chromium.org/2339233003/ )
Reason for revert:
Hitting an assert
Original issue's description:
> Support Float32 output from SkColorSpaceXform
>
> * Adds Float32 support to SkColorSpaceXform
> * Changes API to allows clients to ask for F32, updates clients to
> new API
> * Adds Sk4f_load4 and Sk4f_store4 to SkNx
> * Make use of new xform in SkGr.cpp
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339233003
> CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
>
> Committed: https://skia.googlesource.com/skia/+/43d6651111374b5d1e4ddd9030dcf079b448ec47
TBR=brianosman@google.com,mtklein@google.com,scroggo@google.com,mtklein@chromium.org,bsalomon@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review-Url: https://codereview.chromium.org/2347473007
Diffstat (limited to 'src/codec')
-rw-r--r-- | src/codec/SkCodecPriv.h | 18 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 3 | ||||
-rw-r--r-- | src/codec/SkPngCodec.cpp | 42 | ||||
-rw-r--r-- | src/codec/SkPngCodec.h | 9 | ||||
-rw-r--r-- | src/codec/SkWebpCodec.cpp | 5 |
5 files changed, 22 insertions, 55 deletions
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h index 830f153cba..8876b72aa7 100644 --- a/src/codec/SkCodecPriv.h +++ b/src/codec/SkCodecPriv.h @@ -144,20 +144,6 @@ static inline const SkPMColor* get_color_ptr(SkColorTable* colorTable) { return nullptr != colorTable ? colorTable->readColors() : nullptr; } -static inline SkColorSpaceXform::ColorFormat select_xform_format(SkColorType colorType) { - switch (colorType) { - case kRGBA_8888_SkColorType: - return SkColorSpaceXform::kRGBA_8888_ColorFormat; - case kBGRA_8888_SkColorType: - return SkColorSpaceXform::kBGRA_8888_ColorFormat; - case kRGBA_F16_SkColorType: - return SkColorSpaceXform::kRGBA_F16_ColorFormat; - default: - SkASSERT(false); - return SkColorSpaceXform::kRGBA_8888_ColorFormat; - } -} - /* * Given that the encoded image uses a color table, return the fill value */ @@ -176,7 +162,7 @@ static inline uint64_t get_color_table_fill_value(SkColorType colorType, SkAlpha SkASSERT(colorXform); uint64_t dstColor; uint32_t srcColor = colorPtr[fillIndex]; - colorXform->apply(&dstColor, &srcColor, 1, select_xform_format(colorType), alphaType); + colorXform->apply(&dstColor, &srcColor, 1, colorType, alphaType); return dstColor; } default: @@ -357,7 +343,7 @@ static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageIn return !isLegacy && (needsPremul || isF16 || srcDstNotEqual); } -static inline SkAlphaType select_xform_alpha(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) { +static inline SkAlphaType select_alpha_xform(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) { return (kOpaque_SkAlphaType == srcAlphaType) ? kOpaque_SkAlphaType : dstAlphaType; } diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index c865fbccd1..d2f7cdb0fa 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -517,8 +517,7 @@ int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes } if (fColorXform) { - fColorXform->apply(dst, swizzleDst, dstWidth, select_xform_format(dstInfo.colorType()), - kOpaque_SkAlphaType); + fColorXform->apply(dst, swizzleDst, dstWidth, dstInfo.colorType(), kOpaque_SkAlphaType); dst = SkTAddOffset<void>(dst, rowBytes); } diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index 1e633eaaed..04c8821203 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -267,12 +267,11 @@ bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo, int* ctableCount) // If we are not decoding to F16, we can color xform now and store the results // in the color table. if (fColorXform && kRGBA_F16_SkColorType != dstInfo.colorType()) { - SkColorSpaceXform::ColorFormat xformColorFormat = is_rgba(dstInfo.colorType()) ? - SkColorSpaceXform::kRGBA_8888_ColorFormat : - SkColorSpaceXform::kBGRA_8888_ColorFormat; - SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(), + SkColorType xformColorType = is_rgba(dstInfo.colorType()) ? + kRGBA_8888_SkColorType : kBGRA_8888_SkColorType; + SkAlphaType xformAlphaType = select_alpha_xform(dstInfo.alphaType(), this->getInfo().alphaType()); - fColorXform->apply(colorTable, colorTable, numColors, xformColorFormat, xformAlphaType); + fColorXform->apply(colorTable, colorTable, numColors, xformColorType, xformAlphaType); } // Pad the color table with the last color in the table (or black) in the case that @@ -493,18 +492,17 @@ void SkPngCodec::allocateStorage(const SkImageInfo& dstInfo) { } void SkPngCodec::applyXformRow(void* dst, const void* src) { + const SkColorType colorType = this->dstInfo().colorType(); switch (fXformMode) { case kSwizzleOnly_XformMode: fSwizzler->swizzle(dst, (const uint8_t*) src); break; case kColorOnly_XformMode: - fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, fXformColorFormat, - fXformAlphaType); + fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, colorType, fXformAlphaType); break; case kSwizzleColor_XformMode: fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); - fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, fXformColorFormat, - fXformAlphaType); + fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, colorType, fXformAlphaType); break; } } @@ -1139,23 +1137,9 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt return true; } -void SkPngCodec::initializeXformParams() { - switch (fXformMode) { - case kColorOnly_XformMode: - fXformColorFormat = select_xform_format(this->dstInfo().colorType()); - fXformAlphaType = select_xform_alpha(this->dstInfo().alphaType(), - this->getInfo().alphaType()); - fXformWidth = this->dstInfo().width(); - break; - case kSwizzleColor_XformMode: - fXformColorFormat = select_xform_format(this->dstInfo().colorType()); - fXformAlphaType = select_xform_alpha(this->dstInfo().alphaType(), - this->getInfo().alphaType()); - fXformWidth = this->swizzler()->swizzleWidth(); - break; - default: - break; - } +void SkPngCodec::initializeXformAlphaAndWidth() { + fXformAlphaType = select_alpha_xform(this->dstInfo().alphaType(), this->getInfo().alphaType()); + fXformWidth = this->swizzler() ? this->swizzler()->swizzleWidth() : this->dstInfo().width(); } static inline bool apply_xform_on_decode(SkColorType dstColorType, SkEncodedInfo::Color srcColor) { @@ -1242,7 +1226,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, } this->allocateStorage(dstInfo); - this->initializeXformParams(); + this->initializeXformAlphaAndWidth(); return this->decodeAllRows(dst, rowBytes, rowsDecoded); } @@ -1277,7 +1261,7 @@ SkCodec::Result SkPngCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo, SkCodec::Result SkPngCodec::onIncrementalDecode(int* rowsDecoded) { // FIXME: Only necessary on the first call. - this->initializeXformParams(); + this->initializeXformAlphaAndWidth(); return this->decode(rowsDecoded); } @@ -1285,7 +1269,7 @@ SkCodec::Result SkPngCodec::onIncrementalDecode(int* rowsDecoded) { uint64_t SkPngCodec::onGetFillValue(const SkImageInfo& dstInfo) const { const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); if (colorPtr) { - SkAlphaType alphaType = select_xform_alpha(dstInfo.alphaType(), + SkAlphaType alphaType = select_alpha_xform(dstInfo.alphaType(), this->getInfo().alphaType()); return get_color_table_fill_value(dstInfo.colorType(), alphaType, colorPtr, 0, fColorXform.get()); diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h index 1fc451757e..e3059ba0d5 100644 --- a/src/codec/SkPngCodec.h +++ b/src/codec/SkPngCodec.h @@ -64,7 +64,7 @@ protected: SkSwizzler* swizzler() { return fSwizzler; } // Initialize variables used by applyXformRow. - void initializeXformParams(); + void initializeXformAlphaAndWidth(); /** * Pass available input to libpng to process it. @@ -128,10 +128,9 @@ private: virtual void setRange(int firstRow, int lastRow, void* dst, size_t rowBytes) = 0; virtual Result decode(int* rowsDecoded) = 0; - XformMode fXformMode; - SkColorSpaceXform::ColorFormat fXformColorFormat; - SkAlphaType fXformAlphaType; - int fXformWidth; + XformMode fXformMode; + SkAlphaType fXformAlphaType; + int fXformWidth; #ifdef SK_GOOGLE3_PNG_HACK bool fNeedsToRereadHeader; diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp index 86bda576e4..e8b27b2178 100644 --- a/src/codec/SkWebpCodec.cpp +++ b/src/codec/SkWebpCodec.cpp @@ -307,14 +307,13 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, } if (colorXform) { - SkColorSpaceXform::ColorFormat colorFormat = select_xform_format(dstInfo.colorType()); - SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(), + SkAlphaType xformAlphaType = select_alpha_xform(dstInfo.alphaType(), this->getInfo().alphaType()); uint32_t* src = (uint32_t*) config.output.u.RGBA.rgba; size_t srcRowBytes = config.output.u.RGBA.stride; for (int y = 0; y < rowsDecoded; y++) { - colorXform->apply(dst, src, dstInfo.width(), colorFormat, xformAlphaType); + colorXform->apply(dst, src, dstInfo.width(), dstInfo.colorType(), xformAlphaType); dst = SkTAddOffset<void>(dst, rowBytes); src = SkTAddOffset<uint32_t>(src, srcRowBytes); } |