diff options
author | Brian Osman <brianosman@google.com> | 2018-07-12 14:44:27 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-12 20:54:14 +0000 |
commit | b62f50cf763279fa0d0aa2f80624de02c7a1c2fb (patch) | |
tree | a4aba5466ff7e3136bd97c35718a678354b430ea /src/core/SkConvertPixels.cpp | |
parent | 5bc4fc8f3f26e9e14cccee4d200309e4b500b8d3 (diff) |
Replace nearly all kRespect with kIgnore
- Encoders and decoders always assume kIgnore.
- They are less opinionated about F16 and color space,
we just trust the color space that's passed in, and
put that directly in the image (no sRGB encoding).
- SkBitmap and SkPixmap read/write pixels functions were
defaulting to kResepct, those are now always kIgnore.
- Many other bits of plumbing are simplified, and I
added a default of kIgnore to SkImage::makeColorSpace,
so we can phase out that argument entirely.
- Still need to add defaults to other public APIs that
take SkTransferFunctionBehavior.
- This makes gold think that we've dramatically changed
the contents of all F16 images, but that's because
it doesn't understand the (now linear) color space
that's embedded. Once we triage them all once, they
will work fine (and they'll look perfect in the browser).
Bug: skia:
Change-Id: I62fa090f96cae1b67d181ce14bd91f34ff2ed747
Reviewed-on: https://skia-review.googlesource.com/140570
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/core/SkConvertPixels.cpp')
-rw-r--r-- | src/core/SkConvertPixels.cpp | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp index 0434b92c2e..ac96f20c86 100644 --- a/src/core/SkConvertPixels.cpp +++ b/src/core/SkConvertPixels.cpp @@ -87,13 +87,10 @@ void swizzle_and_multiply(const SkImageInfo& dstInfo, void* dstPixels, size_t ds } // Fast Path 3: Color space xform. -static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo, - SkTransferFunctionBehavior behavior) { +static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo) { // Unpremultiplication is unsupported by SkColorSpaceXform. Note that if |src| is non-linearly // premultiplied, we're always going to have to unpremultiply before doing anything. - if (kPremul_SkAlphaType == srcInfo.alphaType() && - (kUnpremul_SkAlphaType == dstInfo.alphaType() || - SkTransferFunctionBehavior::kIgnore == behavior)) { + if (kPremul_SkAlphaType == srcInfo.alphaType()) { return false; } @@ -119,7 +116,7 @@ static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkIma static inline bool apply_color_xform(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, const SkImageInfo& srcInfo, const void* srcPixels, - size_t srcRB, SkTransferFunctionBehavior behavior) { + size_t srcRB) { SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType()); SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(srcInfo.colorType()); SkAlphaType xformAlpha; @@ -146,8 +143,8 @@ static inline bool apply_color_xform(const SkImageInfo& dstInfo, void* dstPixels break; } - std::unique_ptr<SkColorSpaceXform> xform = - SkMakeColorSpaceXform(srcInfo.colorSpace(), dstInfo.colorSpace(), behavior); + std::unique_ptr<SkColorSpaceXform> xform = SkMakeColorSpaceXform(srcInfo.colorSpace(), + dstInfo.colorSpace()); if (!xform) { return false; } @@ -250,7 +247,7 @@ static void convert_to_alpha8(uint8_t* dst, size_t dstRB, const SkImageInfo& src // Default: Use the pipeline. static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size_t dstRB, const SkImageInfo& srcInfo, const void* srcRow, size_t srcRB, - bool isColorAware, SkTransferFunctionBehavior behavior) { + bool isColorAware) { SkJumper_MemoryCtx src = { (void*)srcRow, (int)(srcRB / srcInfo.bytesPerPixel()) }, dst = { (void*)dstRow, (int)(dstRB / dstInfo.bytesPerPixel()) }; @@ -295,7 +292,7 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size } SkAlphaType premulState = srcInfo.alphaType(); - if (kPremul_SkAlphaType == premulState && SkTransferFunctionBehavior::kIgnore == behavior) { + if (kPremul_SkAlphaType == premulState) { pipeline.append(SkRasterPipeline::unpremul); premulState = kUnpremul_SkAlphaType; } @@ -318,17 +315,6 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size srcInfo.colorSpace(), dstInfo.colorSpace(), premulState); } - SkAlphaType dat = dstInfo.alphaType(); - if (SkTransferFunctionBehavior::kRespect == behavior) { - if (kPremul_SkAlphaType == premulState && kUnpremul_SkAlphaType == dat) { - pipeline.append(SkRasterPipeline::unpremul); - premulState = kUnpremul_SkAlphaType; - } else if (kUnpremul_SkAlphaType == premulState && kPremul_SkAlphaType == dat) { - pipeline.append(SkRasterPipeline::premul); - premulState = kPremul_SkAlphaType; - } - } - SkColorSpaceTransferFn dstFn; if (isColorAware && dstInfo.gammaCloseToSRGB()) { pipeline.append(SkRasterPipeline::to_srgb); @@ -342,8 +328,8 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size } } - if (kUnpremul_SkAlphaType == premulState && kPremul_SkAlphaType == dat && - SkTransferFunctionBehavior::kIgnore == behavior) + SkAlphaType dat = dstInfo.alphaType(); + if (kUnpremul_SkAlphaType == premulState && kPremul_SkAlphaType == dat) { pipeline.append(SkRasterPipeline::premul); premulState = kPremul_SkAlphaType; @@ -415,8 +401,7 @@ static bool swizzle_and_multiply_color_type(SkColorType ct) { } void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, - const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB, - SkTransferFunctionBehavior behavior) { + const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB) { SkASSERT(dstInfo.dimensions() == srcInfo.dimensions()); SkASSERT(SkImageInfoValidConversion(dstInfo, srcInfo)); @@ -437,8 +422,8 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, } // Fast Path 3: Color space xform. - if (isColorAware && optimized_color_xform(dstInfo, srcInfo, behavior)) { - if (apply_color_xform(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, behavior)) { + if (isColorAware && optimized_color_xform(dstInfo, srcInfo)) { + if (apply_color_xform(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB)) { return; } } @@ -450,6 +435,5 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, } // Default: Use the pipeline. - convert_with_pipeline(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware, - behavior); + convert_with_pipeline(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware); } |