From b62f50cf763279fa0d0aa2f80624de02c7a1c2fb Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Thu, 12 Jul 2018 14:44:27 -0400 Subject: 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 Reviewed-by: Mike Klein --- src/image/SkImage.cpp | 8 +++----- src/image/SkImage_Base.h | 3 +-- src/image/SkImage_Gpu.cpp | 8 +------- src/image/SkImage_Gpu.h | 3 +-- src/image/SkImage_Lazy.cpp | 6 ++---- src/image/SkImage_Raster.cpp | 8 +++----- 6 files changed, 11 insertions(+), 25 deletions(-) (limited to 'src/image') diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 128e693ad2..53add0e9d3 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -295,7 +295,7 @@ bool SkImage::isAlphaOnly() const { } sk_sp SkImage::makeColorSpace(sk_sp target, - SkTransferFunctionBehavior premulBehavior) const { + SkTransferFunctionBehavior) const { SkColorSpaceTransferFn fn; if (!target || !target->isNumericalTransferFn(&fn)) { return nullptr; @@ -309,13 +309,11 @@ sk_sp SkImage::makeColorSpace(sk_sp target, return sk_ref_sp(const_cast(this)); } + // TODO: Re-visit this! Keep existing color type? SkColorType targetColorType = kN32_SkColorType; - if (SkTransferFunctionBehavior::kRespect == premulBehavior && target->gammaIsLinear()) { - targetColorType = kRGBA_F16_SkColorType; - } // TODO: We might consider making this a deferred conversion? - return as_IB(this)->onMakeColorSpace(std::move(target), targetColorType, premulBehavior); + return as_IB(this)->onMakeColorSpace(std::move(target), targetColorType); } sk_sp SkImage::makeNonTextureImage() const { diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 0d54a39471..6a048ba51f 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -95,8 +95,7 @@ public: virtual bool onPinAsTexture(GrContext*) const { return false; } virtual void onUnpinAsTexture(GrContext*) const {} - virtual sk_sp onMakeColorSpace(sk_sp, SkColorType, - SkTransferFunctionBehavior) const = 0; + virtual sk_sp onMakeColorSpace(sk_sp, SkColorType) const = 0; protected: SkImage_Base(int width, int height, uint32_t uniqueID); diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 359782f745..0fcc01f0f0 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -950,13 +950,7 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx, /////////////////////////////////////////////////////////////////////////////////////////////////// -sk_sp SkImage_Gpu::onMakeColorSpace(sk_sp target, SkColorType, - SkTransferFunctionBehavior premulBehavior) const { - if (SkTransferFunctionBehavior::kRespect == premulBehavior) { - // TODO: Implement this. - return nullptr; - } - +sk_sp SkImage_Gpu::onMakeColorSpace(sk_sp target, SkColorType) const { sk_sp srcSpace = fColorSpace; if (!fColorSpace) { if (target->isSRGB()) { diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index c79e5295be..57c38c10fd 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -60,8 +60,7 @@ public: sk_sp refColorSpace() { return fColorSpace; } - sk_sp onMakeColorSpace(sk_sp, SkColorType, - SkTransferFunctionBehavior) const override; + sk_sp onMakeColorSpace(sk_sp, SkColorType) const override; typedef ReleaseContext TextureContext; typedef void (*TextureFulfillProc)(TextureContext textureContext, GrBackendTexture* outTexture); diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 8d8e95219d..402acf5d73 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -94,8 +94,7 @@ public: bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override; bool onIsLazyGenerated() const override { return true; } bool onCanLazyGenerateOnGPU() const override; - sk_sp onMakeColorSpace(sk_sp, SkColorType, - SkTransferFunctionBehavior) const override; + sk_sp onMakeColorSpace(sk_sp, SkColorType) const override; bool onIsValid(GrContext*) const override; @@ -451,8 +450,7 @@ sk_sp SkImage_Lazy::onMakeSubset(const SkIRect& subset) const { } sk_sp SkImage_Lazy::onMakeColorSpace(sk_sp target, - SkColorType targetColorType, - SkTransferFunctionBehavior premulBehavior) const { + SkColorType targetColorType) const { SkAutoExclusive autoAquire(fOnMakeColorSpaceMutex); if (target && fOnMakeColorSpaceTarget && SkColorSpace::Equals(target.get(), fOnMakeColorSpaceTarget.get())) { diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index ca01780d36..859014f398 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -110,8 +110,7 @@ public: SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable()); } - sk_sp onMakeColorSpace(sk_sp, SkColorType, - SkTransferFunctionBehavior) const override; + sk_sp onMakeColorSpace(sk_sp, SkColorType) const override; bool onIsValid(GrContext* context) const override { return true; } @@ -343,8 +342,7 @@ bool SkImage_Raster::onAsLegacyBitmap(SkBitmap* bitmap) const { /////////////////////////////////////////////////////////////////////////////// sk_sp SkImage_Raster::onMakeColorSpace(sk_sp target, - SkColorType targetColorType, - SkTransferFunctionBehavior premulBehavior) const { + SkColorType targetColorType) const { SkPixmap src; SkAssertResult(fBitmap.peekPixels(&src)); @@ -361,7 +359,7 @@ sk_sp SkImage_Raster::onMakeColorSpace(sk_sp target, SkBitmap dst; dst.allocPixels(dstInfo); - SkAssertResult(dst.writePixels(src, 0, 0, premulBehavior)); + SkAssertResult(dst.writePixels(src, 0, 0)); dst.setImmutable(); return SkImage::MakeFromBitmap(dst); } -- cgit v1.2.3