diff options
author | Brian Osman <brianosman@google.com> | 2018-06-14 11:44:02 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-14 17:02:07 +0000 |
commit | 653f34da95f3717d048b1961760f09dc28138321 (patch) | |
tree | 3140ad390554d377b57015cefe961f6893a1b2e9 /src/gpu | |
parent | 5538c1390649811eb6498eeca53cc1db00877503 (diff) |
Remove GrPixelConfig argument to GrColorSpaceXform[Effect]::Make
This was for sRGB configs, which are no longer treated special.
Pulling this out of https://skia-review.googlesource.com/c/skia/+/132090
to land separately.
Change-Id: Id04c4e82ad4ffe375cfd384490839b0488e54d44
Reviewed-on: https://skia-review.googlesource.com/134843
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrColorSpaceXform.cpp | 53 | ||||
-rw-r--r-- | src/gpu/GrColorSpaceXform.h | 13 | ||||
-rw-r--r-- | src/gpu/GrTestUtils.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrTextureAdjuster.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrTextureMaker.cpp | 3 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 7 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice_drawTexture.cpp | 3 |
7 files changed, 30 insertions, 59 deletions
diff --git a/src/gpu/GrColorSpaceXform.cpp b/src/gpu/GrColorSpaceXform.cpp index 84c6bdba0e..1256023c00 100644 --- a/src/gpu/GrColorSpaceXform.cpp +++ b/src/gpu/GrColorSpaceXform.cpp @@ -62,8 +62,7 @@ GrColorSpaceXform::GrColorSpaceXform(const SkColorSpaceTransferFn& srcTransferFn static SkSpinlock gColorSpaceXformCacheSpinlock; -sk_sp<GrColorSpaceXform> GrColorSpaceXform::Make(SkColorSpace* src, GrPixelConfig srcConfig, - SkColorSpace* dst) { +sk_sp<GrColorSpaceXform> GrColorSpaceXform::Make(SkColorSpace* src, SkColorSpace* dst) { if (!dst) { // No transformation is performed in legacy mode return nullptr; @@ -71,47 +70,22 @@ sk_sp<GrColorSpaceXform> GrColorSpaceXform::Make(SkColorSpace* src, GrPixelConfi // Treat null sources as sRGB if (!src) { - if (GrPixelConfigIsFloatingPoint(srcConfig)) { - src = SkColorSpace::MakeSRGBLinear().get(); - } else { - src = SkColorSpace::MakeSRGB().get(); - } + src = SkColorSpace::MakeSRGB().get(); } uint32_t flags = 0; SkColorSpaceTransferFn srcTransferFn; - // kUnknown_GrPixelConfig is a sentinel that means we don't care about transfer functions, - // just the gamut xform. - if (kUnknown_GrPixelConfig != srcConfig) { - // Determine if src transfer function is needed, based on src config and color space - if (GrPixelConfigIsSRGB(srcConfig)) { - // Source texture is sRGB, will be converted to linear when we sample - if (src->gammaCloseToSRGB()) { - // Hardware linearize does the right thing - } else if (src->gammaIsLinear()) { - // Oops, need to undo the (extra) linearize - flags |= kApplyInverseSRGB_Flag; - } else if (src->isNumericalTransferFn(&srcTransferFn)) { - // Need to undo the (extra) linearize, then apply the correct transfer function - flags |= (kApplyInverseSRGB_Flag | kApplyTransferFn_Flag); - } else { - // We don't (yet) support more complex transfer functions - return nullptr; - } - } else { - // Source texture is some non-sRGB format, we consider it linearly encoded - if (src->gammaIsLinear()) { - // Linear sampling does the right thing - } else if (src->isNumericalTransferFn(&srcTransferFn)) { - // Need to manually apply some transfer function (including sRGB) - flags |= kApplyTransferFn_Flag; - } else { - // We don't (yet) support more complex transfer functions - return nullptr; - } - } + if (src->gammaIsLinear()) { + // Linear sampling does the right thing + } else if (src->isNumericalTransferFn(&srcTransferFn)) { + // Need to manually apply some transfer function + flags |= kApplyTransferFn_Flag; + } else { + // We don't (yet) support more complex transfer functions + return nullptr; } + if (src == dst && (0 == flags)) { // Quick equality check - no conversion (or transfer function) needed in this case return nullptr; @@ -290,13 +264,12 @@ GrFragmentProcessor::OptimizationFlags GrColorSpaceXformEffect::OptFlags( std::unique_ptr<GrFragmentProcessor> GrColorSpaceXformEffect::Make( std::unique_ptr<GrFragmentProcessor> child, - SkColorSpace* src, GrPixelConfig srcConfig, - SkColorSpace* dst) { + SkColorSpace* src, SkColorSpace* dst) { if (!child) { return nullptr; } - auto colorXform = GrColorSpaceXform::Make(src, srcConfig, dst); + auto colorXform = GrColorSpaceXform::Make(src, dst); if (colorXform) { return std::unique_ptr<GrFragmentProcessor>( new GrColorSpaceXformEffect(std::move(child), std::move(colorXform))); diff --git a/src/gpu/GrColorSpaceXform.h b/src/gpu/GrColorSpaceXform.h index b3e0587eca..b925fb2b87 100644 --- a/src/gpu/GrColorSpaceXform.h +++ b/src/gpu/GrColorSpaceXform.h @@ -21,10 +21,14 @@ class GrColorSpaceXform : public SkRefCnt { public: GrColorSpaceXform(const SkColorSpaceTransferFn&, const SkMatrix44&, uint32_t); - static sk_sp<GrColorSpaceXform> Make(SkColorSpace* src, GrPixelConfig srcConfig, - SkColorSpace* dst); + static sk_sp<GrColorSpaceXform> Make(SkColorSpace* src, SkColorSpace* dst); static sk_sp<GrColorSpaceXform> MakeGamutXform(SkColorSpace* src, SkColorSpace* dst) { - auto result = Make(src, kUnknown_GrPixelConfig, dst); + sk_sp<SkColorSpace> linearSrc = sk_ref_sp(src); + if (!linearSrc) { + linearSrc = SkColorSpace::MakeSRGBLinear(); + } + linearSrc = linearSrc->makeLinearGamma(); + auto result = Make(linearSrc.get(), dst); SkASSERT(!result || 0 == (result->fFlags & ~kApplyGamutXform_Flag)); return result; } @@ -76,8 +80,7 @@ public: * the color space of the output from src to dst. */ static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child, - SkColorSpace* src, GrPixelConfig srcConfig, - SkColorSpace* dst); + SkColorSpace* src, SkColorSpace* dst); const char* name() const override { return "ColorSpaceXform"; } std::unique_ptr<GrFragmentProcessor> clone() const override; diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp index 2aff35dad2..e29e8f596c 100644 --- a/src/gpu/GrTestUtils.cpp +++ b/src/gpu/GrTestUtils.cpp @@ -317,6 +317,7 @@ sk_sp<SkColorSpace> TestColorSpace(SkRandom* random) { } sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) { + // TODO: Add many more kinds of xforms here static sk_sp<GrColorSpaceXform> gXforms[3]; static bool gOnce; if (!gOnce) { @@ -325,10 +326,8 @@ sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) { sk_sp<SkColorSpace> spin = SkColorSpace::MakeSRGB()->makeColorSpin(); // No gamut change gXforms[0] = nullptr; - // To different gamut (with automatic transfer function) - gXforms[1] = GrColorSpaceXform::Make(srgb.get(), kSRGBA_8888_GrPixelConfig, spin.get()); - // To different gamut (with manual transfer function) - gXforms[2] = GrColorSpaceXform::Make(spin.get(), kRGBA_8888_GrPixelConfig, srgb.get()); + gXforms[1] = GrColorSpaceXform::Make(srgb.get(), spin.get()); + gXforms[2] = GrColorSpaceXform::Make(spin.get(), srgb.get()); } return gXforms[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gXforms)))]; } diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp index 05b1cf4241..4b21bac9d0 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -162,8 +162,7 @@ std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( } SkASSERT(kNoDomain_DomainMode == domainMode || (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); - GrPixelConfig config = proxy->config(); auto fp = CreateFragmentProcessorForDomainAndFilter(std::move(proxy), textureMatrix, domainMode, domain, filterOrNullForBicubic); - return GrColorSpaceXformEffect::Make(std::move(fp), fColorSpace, config, dstColorSpace); + return GrColorSpaceXformEffect::Make(std::move(fp), fColorSpace, dstColorSpace); } diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp index a8295129ef..47eeeaaeb6 100644 --- a/src/gpu/GrTextureMaker.cpp +++ b/src/gpu/GrTextureMaker.cpp @@ -154,10 +154,9 @@ std::unique_ptr<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor( DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect, proxy.get(), fmForDetermineDomain, &domain); SkASSERT(kTightCopy_DomainMode != domainMode); - GrPixelConfig config = proxy->config(); auto fp = CreateFragmentProcessorForDomainAndFilter(std::move(proxy), adjustedMatrix, domainMode, domain, filterOrNullForBicubic); - return GrColorSpaceXformEffect::Make(std::move(fp), texColorSpace.get(), config, dstColorSpace); + return GrColorSpaceXformEffect::Make(std::move(fp), texColorSpace.get(), dstColorSpace); } sk_sp<GrTextureProxy> GrTextureMaker::generateTextureProxyForParams(const CopyParams& copyParams, diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index ee8026c463..ca3d559e36 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -991,7 +991,6 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring // the rest from the SkPaint. std::unique_ptr<GrFragmentProcessor> fp; - GrPixelConfig config = proxy->config(); if (needsTextureDomain && (SkCanvas::kStrict_SrcRectConstraint == constraint)) { // Use a constrained texture domain to avoid color bleeding @@ -1022,7 +1021,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, fp = GrSimpleTextureEffect::Make(std::move(proxy), texMatrix, samplerState); } - fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), config, + fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), fRenderTargetContext->colorSpaceInfo().colorSpace()); GrPaint grPaint; if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorSpaceInfo(), paint, @@ -1092,7 +1091,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const tmpUnfiltered.setImageFilter(nullptr); auto fp = GrSimpleTextureEffect::Make(std::move(proxy), SkMatrix::I()); - fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), config, + fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), fRenderTargetContext->colorSpaceInfo().colorSpace()); if (GrPixelConfigIsAlphaOnly(config)) { fp = GrFragmentProcessor::MakeInputPremulAndMulByOutput(std::move(fp)); @@ -1416,7 +1415,7 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer, if (!proxy) { return; } - auto csxf = GrColorSpaceXform::Make(proxyColorSpace.get(), proxy->config(), dstColorSpace); + auto csxf = GrColorSpaceXform::Make(proxyColorSpace.get(), dstColorSpace); fRenderTargetContext->drawImageLattice(this->clip(), std::move(grPaint), this->ctm(), std::move(proxy), std::move(csxf), filter, diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp index 96472814c5..af397cd431 100644 --- a/src/gpu/SkGpuDevice_drawTexture.cpp +++ b/src/gpu/SkGpuDevice_drawTexture.cpp @@ -111,8 +111,7 @@ static void draw_texture(const SkPaint& paint, const SkMatrix& ctm, const SkRect SkAssertResult(srcRect.intersect(SkRect::MakeIWH(proxy->width(), proxy->height()))); srcToDst.mapRect(&dstRect, srcRect); } - auto csxf = GrColorSpaceXform::Make(colorSpace, proxy->config(), - rtc->colorSpaceInfo().colorSpace()); + auto csxf = GrColorSpaceXform::Make(colorSpace, rtc->colorSpaceInfo().colorSpace()); GrSamplerState::Filter filter; switch (paint.getFilterQuality()) { case kNone_SkFilterQuality: |