From 0118e9756d92d3c56b9e05842d7c828f37f68159 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 13 Mar 2018 11:14:33 -0400 Subject: Remove calls to computeOutputColor- Type and Space Bug: b/70846442 Test: I5110881203c000474116a94a48f2afc9a9b62001 These methods were already called by the client. The client may have further overridden the SkColorType (and therefore the SkColorSpace), so respect their final decision on both. Change-Id: Iddcf618e474784b0a000fd516250c44285dacc6b Reviewed-on: https://skia-review.googlesource.com/114062 Commit-Queue: Leon Scroggins Reviewed-by: Derek Sollenberger --- bench/BitmapRegionDecoderBench.cpp | 4 +++- dm/DMSrcSink.cpp | 15 ++++++++------- src/android/SkBitmapRegionCodec.cpp | 7 ++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bench/BitmapRegionDecoderBench.cpp b/bench/BitmapRegionDecoderBench.cpp index dd60b18296..d80fc5de4d 100644 --- a/bench/BitmapRegionDecoderBench.cpp +++ b/bench/BitmapRegionDecoderBench.cpp @@ -40,8 +40,10 @@ void BitmapRegionDecoderBench::onDelayedSetup() { } void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) { + auto ct = fBRD->computeOutputColorType(fColorType); + auto cs = fBRD->computeOutputColorSpace(ct, nullptr); for (int i = 0; i < n; i++) { SkBitmap bm; - SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, fColorType, false)); + SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, ct, false, cs)); } } diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 9f7814f21f..26698bf56a 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -170,12 +170,13 @@ Error BRDSrc::draw(SkCanvas* canvas) const { return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fPath.c_str())); } - if (kRGB_565_SkColorType == colorType) { - auto recommendedCT = brd->computeOutputColorType(colorType); - if (recommendedCT != colorType) { - return Error::Nonfatal("Skip decoding non-opaque to 565."); - } + auto recommendedCT = brd->computeOutputColorType(colorType); + if (kRGB_565_SkColorType == colorType && recommendedCT != colorType) { + return Error::Nonfatal("Skip decoding non-opaque to 565."); } + colorType = recommendedCT; + + auto colorSpace = brd->computeOutputColorSpace(colorType, nullptr); const uint32_t width = brd->width(); const uint32_t height = brd->height(); @@ -187,7 +188,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const { case kFullImage_Mode: { SkBitmap bitmap; if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, width, height), - fSampleSize, colorType, false, SkColorSpace::MakeSRGB())) { + fSampleSize, colorType, false, colorSpace)) { return "Cannot decode (full) region."; } alpha8_to_gray8(&bitmap); @@ -243,7 +244,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const { SkBitmap bitmap; if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(decodeLeft, decodeTop, decodeWidth, decodeHeight), fSampleSize, colorType, false, - SkColorSpace::MakeSRGB())) { + colorSpace)) { return "Cannot decode region."; } diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp index 493e4b5672..6b17a9015d 100644 --- a/src/android/SkBitmapRegionCodec.cpp +++ b/src/android/SkBitmapRegionCodec.cpp @@ -17,8 +17,8 @@ SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec) {} bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator, - const SkIRect& desiredSubset, int sampleSize, SkColorType prefColorType, - bool requireUnpremul, sk_sp prefColorSpace) { + const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType, + bool requireUnpremul, sk_sp dstColorSpace) { // Fix the input sampleSize if necessary. if (sampleSize < 1) { @@ -50,10 +50,7 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset); // Create the image info for the decode - SkColorType dstColorType = fCodec->computeOutputColorType(prefColorType); SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul); - sk_sp dstColorSpace = fCodec->computeOutputColorSpace(dstColorType, - prefColorSpace); SkImageInfo decodeInfo = SkImageInfo::Make(scaledSize.width(), scaledSize.height(), dstColorType, dstAlphaType, dstColorSpace); -- cgit v1.2.3