diff options
Diffstat (limited to 'src')
23 files changed, 67 insertions, 148 deletions
diff --git a/src/core/SkColorSpaceXformImageGenerator.cpp b/src/core/SkColorSpaceXformImageGenerator.cpp index d0ab53df15..0ca6ab1e04 100644 --- a/src/core/SkColorSpaceXformImageGenerator.cpp +++ b/src/core/SkColorSpaceXformImageGenerator.cpp @@ -55,7 +55,6 @@ bool SkColorSpaceXformImageGenerator::onGetPixels(const SkImageInfo& info, void* #if SK_SUPPORT_GPU #include "GrClip.h" -#include "GrColorSpaceXform.h" #include "GrContext.h" #include "GrPaint.h" #include "GrRenderTargetContext.h" @@ -95,8 +94,7 @@ sk_sp<GrTextureProxy> SkColorSpaceXformImageGenerator::onGenerateTexture( GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.addColorTextureProcessor(std::move(proxy), nullptr, - SkMatrix::MakeTrans(origin.fX, origin.fY)); + paint.addColorTextureProcessor(std::move(proxy), SkMatrix::MakeTrans(origin.fX, origin.fY)); paint.addColorFragmentProcessor(std::move(xform)); const SkRect rect = SkRect::MakeWH(info.width(), info.height()); diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp index 39857134bf..647cebd1f2 100644 --- a/src/core/SkGpuBlurUtils.cpp +++ b/src/core/SkGpuBlurUtils.cpp @@ -280,7 +280,6 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, domain.inset((i < scaleFactorX) ? SK_ScalarHalf : 0.0f, (i < scaleFactorY) ? SK_ScalarHalf : 0.0f); auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), - nullptr, SkMatrix::I(), domain, modeForScaling, @@ -289,7 +288,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, srcRect.offset(-srcOffset); srcOffset.set(0, 0); } else { - paint.addColorTextureProcessor(std::move(srcProxy), nullptr, SkMatrix::I(), + paint.addColorTextureProcessor(std::move(srcProxy), SkMatrix::I(), GrSamplerState::ClampBilerp()); } paint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -400,7 +399,6 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, if (GrTextureDomain::kIgnore_Mode != mode) { SkRect domain = SkRect::Make(localSrcBounds); auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), - nullptr, SkMatrix::I(), domain, modeForScaling, @@ -408,7 +406,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, paint.addColorFragmentProcessor(std::move(fp)); } else { // FIXME: this should be mitchell, not bilinear. - paint.addColorTextureProcessor(std::move(srcProxy), nullptr, SkMatrix::I(), + paint.addColorTextureProcessor(std::move(srcProxy), SkMatrix::I(), GrSamplerState::ClampBilerp()); } paint.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/effects/SkArithmeticImageFilter.cpp b/src/effects/SkArithmeticImageFilter.cpp index 5076ecc117..08deab20b0 100644 --- a/src/effects/SkArithmeticImageFilter.cpp +++ b/src/effects/SkArithmeticImageFilter.cpp @@ -306,7 +306,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU( SkMatrix backgroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(backgroundOffset.fX), -SkIntToScalar(backgroundOffset.fY)); bgFP = GrTextureDomainEffect::Make( - std::move(backgroundProxy), nullptr, backgroundMatrix, + std::move(backgroundProxy), backgroundMatrix, GrTextureDomain::MakeTexelDomain(background->subset()), GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest); bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(), @@ -320,7 +320,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU( SkMatrix foregroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(foregroundOffset.fX), -SkIntToScalar(foregroundOffset.fY)); auto foregroundFP = GrTextureDomainEffect::Make( - std::move(foregroundProxy), nullptr, foregroundMatrix, + std::move(foregroundProxy), foregroundMatrix, GrTextureDomain::MakeTexelDomain(foreground->subset()), GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest); foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP), diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 7da42459f4..dd2e0d8efc 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -1269,7 +1269,7 @@ sk_sp<GrTextureProxy> SkBlurMaskFilterImpl::filterMaskGPU(GrContext* context, GrPaint paint; // Blend pathTexture over blurTexture. paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(srcProxy), - nullptr, SkMatrix::I())); + SkMatrix::I())); if (kInner_SkBlurStyle == fBlurStyle) { // inner: dst = dst * src paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index b97a0c29a2..42bd697200 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -16,6 +16,7 @@ #include "SkColorData.h" #if SK_SUPPORT_GPU #include "GrClip.h" +#include "GrColorSpaceXform.h" #include "GrContext.h" #include "GrCoordTransform.h" #include "GrRenderTargetContext.h" diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index a59e1d1d91..da13beac61 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -294,7 +294,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU( if (backgroundProxy) { SkMatrix bgMatrix = SkMatrix::MakeTrans(-SkIntToScalar(backgroundOffset.fX), -SkIntToScalar(backgroundOffset.fY)); - bgFP = GrTextureDomainEffect::Make(std::move(backgroundProxy), nullptr, bgMatrix, + bgFP = GrTextureDomainEffect::Make(std::move(backgroundProxy), bgMatrix, GrTextureDomain::MakeTexelDomain(background->subset()), GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest); @@ -309,7 +309,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU( SkMatrix fgMatrix = SkMatrix::MakeTrans(-SkIntToScalar(foregroundOffset.fX), -SkIntToScalar(foregroundOffset.fY)); auto foregroundFP = GrTextureDomainEffect::Make( - std::move(foregroundProxy), nullptr, fgMatrix, + std::move(foregroundProxy), fgMatrix, GrTextureDomain::MakeTexelDomain(foreground->subset()), GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest); foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP), diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index 3a8c8ece7e..c0856735b8 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -42,8 +42,7 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext, SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop)); matrix.preConcat(viewMatrix); - paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(mask), - nullptr, matrix)); + paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(mask), matrix)); renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(), SkRect::Make(maskRect), inverse); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 2592966213..ab57456cd7 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -491,7 +491,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, } if (tempProxy) { - auto fp = GrSimpleTextureEffect::Make(tempProxy, nullptr, SkMatrix::I()); + auto fp = GrSimpleTextureEffect::Make(tempProxy, SkMatrix::I()); if (premulOnGpu) { fp = fContext->createUPMToPMEffect(std::move(fp), useConfigConversionEffect); } @@ -623,7 +623,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, if (tempRTC) { SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top)); sk_sp<GrTextureProxy> proxy = src->asTextureProxyRef(); - auto fp = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, textureMatrix); + auto fp = GrSimpleTextureEffect::Make(std::move(proxy), textureMatrix); if (unpremulOnGpu) { fp = fContext->createPMToUPMEffect(std::move(fp), useConfigConversionEffect); // We no longer need to do this on CPU after the read back. diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index 0d52a5dede..e29c464bc0 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -37,34 +37,26 @@ void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera this->setXPFactory(GrCoverageSetOpXPFactory::Get(regionOp, invertCoverage)); } -void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& matrix) { - this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), - std::move(colorSpaceXform), - matrix)); +void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix) { + this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix)); } -void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& matrix, +void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix, const GrSamplerState& samplerState) { - this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), - std::move(colorSpaceXform), - matrix, samplerState)); + this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix, + samplerState)); } void GrPaint::addCoverageTextureProcessor(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix) { - this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), - nullptr, matrix)); + this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix)); } void GrPaint::addCoverageTextureProcessor(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix, const GrSamplerState& params) { - this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), - nullptr, matrix, params)); + this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix, + params)); } bool GrPaint::isConstantBlendedColor(GrColor* constantColor) const { diff --git a/src/gpu/GrPaint.h b/src/gpu/GrPaint.h index a67c1c7525..c5b45633a7 100644 --- a/src/gpu/GrPaint.h +++ b/src/gpu/GrPaint.h @@ -17,7 +17,6 @@ #include "SkRegion.h" #include "SkTLazy.h" -class GrColorSpaceXform; class GrTextureProxy; class GrXPFactory; @@ -110,10 +109,8 @@ public: * Helpers for adding color or coverage effects that sample a texture. The matrix is applied * to the src space position to compute texture coordinates. */ - void addColorTextureProcessor(sk_sp<GrTextureProxy>, - sk_sp<GrColorSpaceXform>, const SkMatrix&); - void addColorTextureProcessor(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix&, - const GrSamplerState&); + void addColorTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&); + void addColorTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&, const GrSamplerState&); void addCoverageTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&); void addCoverageTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&, const GrSamplerState&); diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index ce3b066bee..50f402bfc2 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -22,6 +22,7 @@ class GrBackendSemaphore; class GrCCPRAtlas; class GrClip; +class GrColorSpaceXform; class GrCoverageCountingPathRenderer; class GrDrawingManager; class GrDrawOp; diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index d8d438681e..4b0f363fee 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -157,7 +157,7 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask( SkIntToScalar(-textureOriginInDeviceSpace.fY)); maskMatrix.preConcat(viewMatrix); paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make( - std::move(proxy), nullptr, maskMatrix, GrSamplerState::Filter::kNearest)); + std::move(proxy), maskMatrix, GrSamplerState::Filter::kNearest)); DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(), dstRect, invert); } diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index f8a0df7937..cf7ee7cca7 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -59,11 +59,11 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context, // better! SkASSERT(copyParams.fFilter != GrSamplerState::Filter::kMipMap); paint.addColorFragmentProcessor( - GrTextureDomainEffect::Make(std::move(inputProxy), nullptr, SkMatrix::I(), - domain, GrTextureDomain::kClamp_Mode, copyParams.fFilter)); + GrTextureDomainEffect::Make(std::move(inputProxy), SkMatrix::I(), domain, + GrTextureDomain::kClamp_Mode, copyParams.fFilter)); } else { GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, copyParams.fFilter); - paint.addColorTextureProcessor(std::move(inputProxy), nullptr, SkMatrix::I(), samplerState); + paint.addColorTextureProcessor(std::move(inputProxy), SkMatrix::I(), samplerState); } paint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -228,13 +228,12 @@ std::unique_ptr<GrFragmentProcessor> GrTextureProducer::CreateFragmentProcessorF SkASSERT(kTightCopy_DomainMode != domainMode); if (filterOrNullForBicubic) { if (kDomain_DomainMode == domainMode) { - return GrTextureDomainEffect::Make(std::move(proxy), nullptr, textureMatrix, domain, + return GrTextureDomainEffect::Make(std::move(proxy), textureMatrix, domain, GrTextureDomain::kClamp_Mode, *filterOrNullForBicubic); } else { GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, *filterOrNullForBicubic); - return GrSimpleTextureEffect::Make(std::move(proxy), nullptr, textureMatrix, - samplerState); + return GrSimpleTextureEffect::Make(std::move(proxy), textureMatrix, samplerState); } } else { if (kDomain_DomainMode == domainMode) { diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 447333566a..cf4c261451 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1006,7 +1006,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, if (bicubic) { fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain); } else { - fp = GrTextureDomainEffect::Make(std::move(proxy), nullptr, texMatrix, domain, + fp = GrTextureDomainEffect::Make(std::move(proxy), texMatrix, domain, GrTextureDomain::kClamp_Mode, samplerState.filter()); } } else if (bicubic) { @@ -1014,7 +1014,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, GrSamplerState::WrapMode wrapMode[2] = {samplerState.wrapModeX(), samplerState.wrapModeY()}; fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode); } else { - fp = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, texMatrix, samplerState); + fp = GrSimpleTextureEffect::Make(std::move(proxy), texMatrix, samplerState); } fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), @@ -1082,7 +1082,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const SkPaint tmpUnfiltered(paint); tmpUnfiltered.setImageFilter(nullptr); - auto fp = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, SkMatrix::I()); + auto fp = GrSimpleTextureEffect::Make(std::move(proxy), SkMatrix::I()); fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), fRenderTargetContext->getColorSpace()); if (GrPixelConfigIsAlphaOnly(config)) { diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp index 9c697b41cb..4c09bf468d 100644 --- a/src/gpu/effects/GrConfigConversionEffect.fp +++ b/src/gpu/effects/GrConfigConversionEffect.fp @@ -73,7 +73,7 @@ std::unique_ptr<GrFragmentProcessor> upmToPM( new GrConfigConversionEffect(kToPremul_PMConversion)); - paint1.addColorTextureProcessor(dataProxy, nullptr, SkMatrix::I()); + paint1.addColorTextureProcessor(dataProxy, SkMatrix::I()); paint1.addColorFragmentProcessor(pmToUPM->clone()); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -83,16 +83,14 @@ return false; } - paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), nullptr, - SkMatrix::I()); + paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), SkMatrix::I()); paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect, kRect); - paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), nullptr, - SkMatrix::I()); + paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), SkMatrix::I()); paint3.addColorFragmentProcessor(std::move(pmToUPM)); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h index 470f060d8b..803a4ff5e6 100644 --- a/src/gpu/effects/GrConfigConversionEffect.h +++ b/src/gpu/effects/GrConfigConversionEffect.h @@ -84,7 +84,7 @@ public: std::unique_ptr<GrFragmentProcessor> upmToPM( new GrConfigConversionEffect(kToPremul_PMConversion)); - paint1.addColorTextureProcessor(dataProxy, nullptr, SkMatrix::I()); + paint1.addColorTextureProcessor(dataProxy, SkMatrix::I()); paint1.addColorFragmentProcessor(pmToUPM->clone()); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -94,14 +94,14 @@ public: return false; } - paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), nullptr, SkMatrix::I()); + paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), SkMatrix::I()); paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect, kRect); - paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), nullptr, SkMatrix::I()); + paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), SkMatrix::I()); paint3.addColorFragmentProcessor(std::move(pmToUPM)); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index c3634f5739..595c5e6324 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -23,60 +23,37 @@ public: GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; const GrSimpleTextureEffect& _outer = args.fFp.cast<GrSimpleTextureEffect>(); (void)_outer; - auto colorXform = _outer.colorXform(); - (void)colorXform; auto matrix = _outer.matrix(); (void)matrix; - fColorSpaceHelper.emitCode(args.fUniformHandler, _outer.colorXform().get()); SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); fragBuilder->codeAppendf( - "half4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor, + "%s = %s * texture(%s, %s).%s;\n", args.fOutputColor, args.fInputColor ? args.fInputColor : "half4(1)", - fColorSpaceHelper.isValid() ? "(_tmpVar1 = " : "", fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(), sk_TransformedCoords2D_0.c_str(), - fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(), - fColorSpaceHelper.isValid() - ? SkStringPrintf(", half4(clamp((%s * half4(_tmpVar1.rgb, 1.0)).rgb, 0.0, " - "_tmpVar1.a), _tmpVar1.a))", - args.fUniformHandler->getUniformCStr( - fColorSpaceHelper.gamutXformUniform())) - .c_str() - : ""); + fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str()); } private: void onSetData(const GrGLSLProgramDataManager& pdman, - const GrFragmentProcessor& _proc) override { - const GrSimpleTextureEffect& _outer = _proc.cast<GrSimpleTextureEffect>(); - { - if (fColorSpaceHelper.isValid()) { - fColorSpaceHelper.setData(pdman, _outer.colorXform().get()); - } - } - } + const GrFragmentProcessor& _proc) override {} UniformHandle fImageVar; - GrGLSLColorSpaceXformHelper fColorSpaceHelper; }; GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const { return new GrGLSLSimpleTextureEffect(); } void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, - GrProcessorKeyBuilder* b) const { - b->add32(GrColorSpaceXform::XformKey(fColorXform.get())); -} + GrProcessorKeyBuilder* b) const {} bool GrSimpleTextureEffect::onIsEqual(const GrFragmentProcessor& other) const { const GrSimpleTextureEffect& that = other.cast<GrSimpleTextureEffect>(); (void)that; if (fImage != that.fImage) return false; - if (fColorXform != that.fColorXform) return false; if (fMatrix != that.fMatrix) return false; return true; } GrSimpleTextureEffect::GrSimpleTextureEffect(const GrSimpleTextureEffect& src) : INHERITED(kGrSimpleTextureEffect_ClassID, src.optimizationFlags()) , fImage(src.fImage) - , fColorXform(src.fColorXform) , fMatrix(src.fMatrix) , fImageCoordTransform(src.fImageCoordTransform) { this->addTextureSampler(&fImage); @@ -98,9 +75,7 @@ std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate( : GrSamplerState::Filter::kNearest); const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom); - sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom); - return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), std::move(colorSpaceXform), - matrix); + return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), matrix); } #endif #endif diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp index 456448a6ea..9e9685f626 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.fp +++ b/src/gpu/effects/GrSimpleTextureEffect.fp @@ -6,7 +6,6 @@ */ in uniform sampler2D image; -in uniform colorSpaceXform colorXform; in half4x4 matrix; @constructorParams { @@ -23,29 +22,26 @@ in half4x4 matrix; @make { static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix) { return std::unique_ptr<GrFragmentProcessor>( - new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, + new GrSimpleTextureEffect(std::move(proxy), matrix, GrSamplerState(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest))); } /* clamp mode */ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix, GrSamplerState::Filter filter) { return std::unique_ptr<GrFragmentProcessor>( - new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, + new GrSimpleTextureEffect(std::move(proxy), matrix, GrSamplerState(GrSamplerState::WrapMode::kClamp, filter))); } static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix, const GrSamplerState& p) { return std::unique_ptr<GrFragmentProcessor>( - new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p)); + new GrSimpleTextureEffect(std::move(proxy), matrix, p)); } } @@ -56,7 +52,7 @@ in half4x4 matrix; } void main() { - sk_OutColor = sk_InColor * texture(image, sk_TransformedCoords2D[0], colorXform); + sk_OutColor = sk_InColor * texture(image, sk_TransformedCoords2D[0]); } @test(testData) { @@ -69,7 +65,5 @@ void main() { : GrSamplerState::Filter::kNearest); const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom); - sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom); - return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), std::move(colorSpaceXform), - matrix); + return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), matrix); } diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index 7f98b13fd2..b0874977f2 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -17,52 +17,44 @@ #include "GrColorSpaceXform.h" class GrSimpleTextureEffect : public GrFragmentProcessor { public: - sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; } SkMatrix44 matrix() const { return fMatrix; } static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> - colorSpaceXform, const SkMatrix& matrix) { return std::unique_ptr<GrFragmentProcessor>( - new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, + new GrSimpleTextureEffect(std::move(proxy), matrix, GrSamplerState(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest))); } /* clamp mode */ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> - colorSpaceXform, const SkMatrix& matrix, GrSamplerState::Filter filter) { return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect( - std::move(proxy), std::move(colorSpaceXform), matrix, + std::move(proxy), matrix, GrSamplerState(GrSamplerState::WrapMode::kClamp, filter))); } static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> - colorSpaceXform, const SkMatrix& matrix, const GrSamplerState& p) { return std::unique_ptr<GrFragmentProcessor>( - new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p)); + new GrSimpleTextureEffect(std::move(proxy), matrix, p)); } GrSimpleTextureEffect(const GrSimpleTextureEffect& src); std::unique_ptr<GrFragmentProcessor> clone() const override; const char* name() const override { return "SimpleTextureEffect"; } private: - GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, sk_sp<GrColorSpaceXform> colorXform, - SkMatrix44 matrix, GrSamplerState samplerParams) + GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix, + GrSamplerState samplerParams) : INHERITED(kGrSimpleTextureEffect_ClassID, (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag | (GrPixelConfigIsOpaque(image->config()) ? kPreservesOpaqueInput_OptimizationFlag : kNone_OptimizationFlags)) , fImage(std::move(image), samplerParams) - , fColorXform(colorXform) , fMatrix(matrix) , fImageCoordTransform(matrix, fImage.proxy()) { this->addTextureSampler(&fImage); @@ -73,7 +65,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST TextureSampler fImage; - sk_sp<GrColorSpaceXform> fColorXform; SkMatrix44 fMatrix; GrCoordTransform fImageCoordTransform; typedef GrFragmentProcessor INHERITED; diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 9e4abeb5dd..e1da72135d 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -13,7 +13,6 @@ #include "GrSurfaceProxyPriv.h" #include "GrTexture.h" #include "SkFloatingPoint.h" -#include "glsl/GrGLSLColorSpaceXformHelper.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -67,8 +66,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, const char* outColor, const SkString& inCoords, GrGLSLFragmentProcessor::SamplerHandle sampler, - const char* inModulateColor, - GrGLSLColorSpaceXformHelper* colorXformHelper) { + const char* inModulateColor) { SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode); SkDEBUGCODE(fMode = textureDomain.mode();) @@ -87,7 +85,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, case kIgnore_Mode: { builder->codeAppendf("%s = ", outColor); builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(), - kFloat2_GrSLType, colorXformHelper); + kFloat2_GrSLType); builder->codeAppend(";"); break; } @@ -98,7 +96,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, builder->codeAppendf("%s = ", outColor); builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(), - kFloat2_GrSLType, colorXformHelper); + kFloat2_GrSLType); builder->codeAppend(";"); break; } @@ -117,7 +115,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, builder->codeAppend("half4 outside = half4(0.0, 0.0, 0.0, 0.0);"); builder->codeAppend("half4 inside = "); builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(), - kFloat2_GrSLType, colorXformHelper); + kFloat2_GrSLType); builder->codeAppend(";"); builder->codeAppendf("float x = (%s).x;", inCoords.c_str()); @@ -138,7 +136,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, builder->codeAppendf("%s = any(outside) ? half4(0.0, 0.0, 0.0, 0.0) : ", outColor); builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(), - kFloat2_GrSLType, colorXformHelper); + kFloat2_GrSLType); builder->codeAppend(";"); } break; @@ -151,7 +149,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, builder->codeAppendf("%s = ", outColor); builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(), - kFloat2_GrSLType, colorXformHelper); + kFloat2_GrSLType); builder->codeAppend(";"); break; } @@ -207,23 +205,20 @@ inline GrFragmentProcessor::OptimizationFlags GrTextureDomainEffect::OptFlags( std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make( sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix, const SkRect& domain, GrTextureDomain::Mode mode, GrSamplerState::Filter filterMode) { if (GrTextureDomain::kIgnore_Mode == mode || (GrTextureDomain::kClamp_Mode == mode && can_ignore_rect(proxy.get(), domain))) { - return GrSimpleTextureEffect::Make(std::move(proxy), - std::move(colorSpaceXform), matrix, filterMode); + return GrSimpleTextureEffect::Make(std::move(proxy), matrix, filterMode); } else { return std::unique_ptr<GrFragmentProcessor>(new GrTextureDomainEffect( - std::move(proxy), std::move(colorSpaceXform), matrix, domain, mode, filterMode)); + std::move(proxy), matrix, domain, mode, filterMode)); } } GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix, const SkRect& domain, GrTextureDomain::Mode mode, @@ -231,8 +226,7 @@ GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy, : INHERITED(kGrTextureDomainEffect_ClassID, OptFlags(proxy->config(), mode)) , fCoordTransform(matrix, proxy.get()) , fTextureDomain(proxy.get(), domain, mode) - , fTextureSampler(std::move(proxy), filterMode) - , fColorSpaceXform(std::move(colorSpaceXform)) { + , fTextureSampler(std::move(proxy), filterMode) { SkASSERT(mode != GrTextureDomain::kRepeat_Mode || filterMode == GrSamplerState::Filter::kNearest); this->addCoordTransform(&fCoordTransform); @@ -243,8 +237,7 @@ GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that) : INHERITED(kGrTextureDomainEffect_ClassID, that.optimizationFlags()) , fCoordTransform(that.fCoordTransform) , fTextureDomain(that.fTextureDomain) - , fTextureSampler(that.fTextureSampler) - , fColorSpaceXform(that.fColorSpaceXform) { + , fTextureSampler(that.fTextureSampler) { this->addCoordTransform(&fCoordTransform); this->addTextureSampler(&fTextureSampler); } @@ -252,7 +245,6 @@ GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that) void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { b->add32(GrTextureDomain::GLDomain::DomainKey(fTextureDomain)); - b->add32(GrColorSpaceXform::XformKey(this->colorSpaceXform())); } GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const { @@ -265,7 +257,6 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const { GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); - fColorSpaceHelper.emitCode(args.fUniformHandler, tde.colorSpaceXform()); fGLDomain.sampleTexture(fragBuilder, args.fUniformHandler, args.fShaderCaps, @@ -273,8 +264,7 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const { args.fOutputColor, coords2D, args.fTexSamplers[0], - args.fInputColor, - &fColorSpaceHelper); + args.fInputColor); } protected: @@ -285,14 +275,10 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const { GrSurfaceProxy* proxy = tde.textureSampler(0).proxy(); fGLDomain.setData(pdman, domain, proxy); - if (SkToBool(tde.colorSpaceXform())) { - fColorSpaceHelper.setData(pdman, tde.colorSpaceXform()); - } } private: GrTextureDomain::GLDomain fGLDomain; - GrGLSLColorSpaceXformHelper fColorSpaceHelper; }; return new GLSLProcessor; @@ -321,10 +307,8 @@ std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcess (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kModeCount); const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false; - sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(d->fRandom); return GrTextureDomainEffect::Make( std::move(proxy), - std::move(colorSpaceXform), matrix, domain, mode, diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index 6d1f4b268c..166ae2b2b7 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -10,12 +10,10 @@ #include "GrCoordTransform.h" #include "GrFragmentProcessor.h" -#include "GrColorSpaceXform.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLProgramDataManager.h" class GrGLProgramBuilder; -class GrGLSLColorSpaceXformHelper; class GrGLSLShaderBuilder; class GrInvariantOutput; class GrGLSLUniformHandler; @@ -111,8 +109,7 @@ public: const char* outColor, const SkString& inCoords, GrGLSLFragmentProcessor::SamplerHandle sampler, - const char* inModulateColor = nullptr, - GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr); + const char* inModulateColor = nullptr); /** * Call this from GrGLSLFragmentProcessor::setData() to upload uniforms necessary for the @@ -154,7 +151,6 @@ protected: class GrTextureDomainEffect : public GrFragmentProcessor { public: static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>, - sk_sp<GrColorSpaceXform>, const SkMatrix&, const SkRect& domain, GrTextureDomain::Mode, @@ -179,10 +175,8 @@ private: GrCoordTransform fCoordTransform; GrTextureDomain fTextureDomain; TextureSampler fTextureSampler; - sk_sp<GrColorSpaceXform> fColorSpaceXform; GrTextureDomainEffect(sk_sp<GrTextureProxy>, - sk_sp<GrColorSpaceXform>, const SkMatrix&, const SkRect& domain, GrTextureDomain::Mode, @@ -198,8 +192,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - const GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } - GR_DECLARE_FRAGMENT_PROCESSOR_TEST typedef GrFragmentProcessor INHERITED; diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 681d7b1c6d..18e3c1eb6b 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -1029,7 +1029,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColor GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.addColorTextureProcessor(fProxy, nullptr, SkMatrix::I()); + paint.addColorTextureProcessor(fProxy, SkMatrix::I()); paint.addColorFragmentProcessor(std::move(xform)); const SkRect rect = SkRect::MakeIWH(this->width(), this->height()); diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 8cc00791b4..55a87fbe18 100644 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -225,7 +225,7 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor( if (doBicubic) { inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes); } else { - inner = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, lmInverse, samplerState); + inner = GrSimpleTextureEffect::Make(std::move(proxy), lmInverse, samplerState); } inner = GrColorSpaceXformEffect::Make(std::move(inner), texColorSpace.get(), args.fDstColorSpace); |