diff --git a/gm/fpcoordinateoverride.cpp b/gm/fpcoordinateoverride.cpp index f7b7407968..d6425b7f36 100644 --- a/gm/fpcoordinateoverride.cpp +++ b/gm/fpcoordinateoverride.cpp @@ -85,7 +85,7 @@ DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, rtCtx, canvas, 512, 512, GrBitmapTextureMaker maker(ctx, bmp); auto[view, grCT] = maker.view(GrMipMapped::kNo); std::unique_ptr imgFP = - GrTextureEffect::Make(view.detachProxy(), bmp.alphaType(), SkMatrix()); + GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix()); auto fp = std::unique_ptr(new SampleCoordEffect(std::move(imgFP))); GrPaint grPaint; diff --git a/gm/texelsubset.cpp b/gm/texelsubset.cpp index 0ee8db28de..08f27b7390 100644 --- a/gm/texelsubset.cpp +++ b/gm/texelsubset.cpp @@ -146,7 +146,7 @@ protected: } GrSamplerState sampler(wmx, wmy, fFilter); const auto& caps = *context->priv().caps(); - auto fp1 = GrTextureEffect::MakeTexelSubset(view.refProxy(), + auto fp1 = GrTextureEffect::MakeTexelSubset(view, fBitmap.alphaType(), textureMatrices[tm], sampler, @@ -174,8 +174,8 @@ protected: // Now draw with a subsetted proxy using fixed function texture sampling rather // than a texture subset as a comparison. drawRect = localRect.makeOffset(x, y); - auto fp2 = GrTextureEffect::Make(subsetView.refProxy(), - fBitmap.alphaType(), subsetTextureMatrix, + auto fp2 = GrTextureEffect::Make(subsetView, fBitmap.alphaType(), + subsetTextureMatrix, GrSamplerState(wmx, wmy, fFilter), caps); if (auto op = sk_gpu_test::test_ops::MakeRect(context, std::move(fp2), drawRect, localRect)) { diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index 2f7835972b..c617522e63 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -194,8 +194,8 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { // Visualize coverage count in main canvas. GrPaint paint; - paint.addColorFragmentProcessor(GrTextureEffect::Make(sk_ref_sp(ccbuff->asTextureProxy()), - ccbuff->colorInfo().alphaType())); + paint.addColorFragmentProcessor( + GrTextureEffect::Make(ccbuff->readSurfaceView(), ccbuff->colorInfo().alphaType())); paint.addColorFragmentProcessor( std::make_unique()); paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver); diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp index 1df91aaeb1..e02f823eb0 100644 --- a/src/core/SkBlurMF.cpp +++ b/src/core/SkBlurMF.cpp @@ -899,8 +899,7 @@ GrSurfaceProxyView SkBlurMaskFilterImpl::filterMaskGPU(GrRecordingContext* conte if (!isNormalBlur) { GrPaint paint; // Blend pathTexture over blurTexture. - paint.addCoverageFragmentProcessor( - GrTextureEffect::Make(srcView.detachProxy(), srcAlphaType)); + paint.addCoverageFragmentProcessor(GrTextureEffect::Make(std::move(srcView), srcAlphaType)); if (kInner_SkBlurStyle == fBlurStyle) { // inner: dst = dst * src paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp index f08b3ef2c5..439eac0e99 100644 --- a/src/core/SkGpuBlurUtils.cpp +++ b/src/core/SkGpuBlurUtils.cpp @@ -324,11 +324,11 @@ static GrSurfaceProxyView decimate(GrRecordingContext* context, } const auto& caps = *context->priv().caps(); GrSamplerState sampler(wrapMode, GrSamplerState::Filter::kBilerp); - fp = GrTextureEffect::MakeTexelSubset(srcView.detachProxy(), srcAlphaType, - SkMatrix::I(), sampler, *contentRect, caps); + fp = GrTextureEffect::MakeTexelSubset(std::move(srcView), srcAlphaType, SkMatrix::I(), + sampler, *contentRect, caps); srcRect.offset(-srcOffset); } else { - fp = GrTextureEffect::Make(srcView.detachProxy(), srcAlphaType, SkMatrix::I(), + fp = GrTextureEffect::Make(std::move(srcView), srcAlphaType, SkMatrix::I(), GrSamplerState::Filter::kBilerp); } paint.addColorFragmentProcessor(std::move(fp)); @@ -385,7 +385,7 @@ static std::unique_ptr reexpand(GrRecordingContext* conte GrPaint paint; const auto& caps = *context->priv().caps(); - auto fp = GrTextureEffect::MakeTexelSubset(srcView.detachProxy(), srcAlphaType, SkMatrix::I(), + auto fp = GrTextureEffect::MakeTexelSubset(std::move(srcView), srcAlphaType, SkMatrix::I(), GrSamplerState::Filter::kBilerp, srcBounds, caps); paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp index 1ea348b87d..ad40a1171b 100644 --- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp +++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp @@ -167,7 +167,7 @@ sk_sp SkAlphaThresholdFilterImpl::onFilterImage(const Context& c } auto textureFP = GrTextureEffect::Make( - inputView.detachProxy(), input->alphaType(), + std::move(inputView), input->alphaType(), SkMatrix::MakeTrans(input->subset().x(), input->subset().y())); textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(), input->alphaType(), ctx.colorSpace()); diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp index 06045a438a..4b25966a46 100644 --- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp +++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp @@ -357,9 +357,8 @@ sk_sp ArithmeticImageFilterImpl::filterImageGPU( SkMatrix backgroundMatrix = SkMatrix::MakeTrans( SkIntToScalar(bgSubset.left() - backgroundOffset.fX), SkIntToScalar(bgSubset.top() - backgroundOffset.fY)); - bgFP = GrTextureEffect::MakeTexelSubset(backgroundView.detachProxy(), - background->alphaType(), backgroundMatrix, sampler, - bgSubset, caps); + bgFP = GrTextureEffect::MakeTexelSubset(std::move(backgroundView), background->alphaType(), + backgroundMatrix, sampler, bgSubset, caps); bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(), background->alphaType(), ctx.colorSpace()); @@ -373,9 +372,9 @@ sk_sp ArithmeticImageFilterImpl::filterImageGPU( SkMatrix foregroundMatrix = SkMatrix::MakeTrans( SkIntToScalar(fgSubset.left() - foregroundOffset.fX), SkIntToScalar(fgSubset.top() - foregroundOffset.fY)); - auto fgFP = GrTextureEffect::MakeTexelSubset(foregroundView.detachProxy(), - foreground->alphaType(), foregroundMatrix, - sampler, fgSubset, caps); + auto fgFP = + GrTextureEffect::MakeTexelSubset(std::move(foregroundView), foreground->alphaType(), + foregroundMatrix, sampler, fgSubset, caps); fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP), foreground->getColorSpace(), foreground->alphaType(), diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp index 5cbbdadcb0..e9fb0cdd5b 100644 --- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp +++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp @@ -267,9 +267,8 @@ sk_sp SkXfermodeImageFilterImpl::filterImageGPU( SkMatrix bgMatrix = SkMatrix::MakeTrans( SkIntToScalar(bgSubset.left() - backgroundOffset.fX), SkIntToScalar(bgSubset.top() - backgroundOffset.fY)); - bgFP = GrTextureEffect::MakeTexelSubset(backgroundView.detachProxy(), - background->alphaType(), bgMatrix, sampler, - bgSubset, caps); + bgFP = GrTextureEffect::MakeTexelSubset(std::move(backgroundView), background->alphaType(), + bgMatrix, sampler, bgSubset, caps); bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(), background->alphaType(), ctx.colorSpace()); @@ -283,9 +282,9 @@ sk_sp SkXfermodeImageFilterImpl::filterImageGPU( SkMatrix fgMatrix = SkMatrix::MakeTrans( SkIntToScalar(fgSubset.left() - foregroundOffset.fX), SkIntToScalar(fgSubset.top() - foregroundOffset.fY)); - auto fgFP = GrTextureEffect::MakeTexelSubset(foregroundView.detachProxy(), - foreground->alphaType(), fgMatrix, sampler, - fgSubset, caps); + auto fgFP = + GrTextureEffect::MakeTexelSubset(std::move(foregroundView), foreground->alphaType(), + fgMatrix, sampler, fgSubset, caps); fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP), foreground->getColorSpace(), foreground->alphaType(), diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index 30084f146c..6f4055ce01 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -49,7 +49,7 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext, -SkIntToScalar(maskRect.fTop)); matrix.preConcat(viewMatrix); paint.addCoverageFragmentProcessor( - GrTextureEffect::Make(mask.detachProxy(), kUnknown_SkAlphaType, matrix)); + GrTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix)); renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(), SkRect::Make(maskRect), inverse); diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 8497a73f6c..446f634b39 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -2036,7 +2036,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC std::copy_n(baseM + 0, 5, yM + 15); GrPaint yPaint; yPaint.addColorFragmentProcessor( - GrTextureEffect::Make(srcView.refProxy(), this->colorInfo().alphaType(), texMatrix)); + GrTextureEffect::Make(srcView, this->colorInfo().alphaType(), texMatrix)); auto yFP = GrColorMatrixFragmentProcessor::Make(yM, false, true, false); yPaint.addColorFragmentProcessor(std::move(yFP)); yPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -2058,8 +2058,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC std::copy_n(baseM + 5, 5, uM + 15); GrPaint uPaint; uPaint.addColorFragmentProcessor(GrTextureEffect::Make( - srcView.refProxy(), this->colorInfo().alphaType(), texMatrix, - GrSamplerState::Filter::kBilerp)); + srcView, this->colorInfo().alphaType(), texMatrix, GrSamplerState::Filter::kBilerp)); auto uFP = GrColorMatrixFragmentProcessor::Make(uM, false, true, false); uPaint.addColorFragmentProcessor(std::move(uFP)); uPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -2079,9 +2078,9 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC std::fill_n(vM, 15, 0.f); std::copy_n(baseM + 10, 5, vM + 15); GrPaint vPaint; - vPaint.addColorFragmentProcessor(GrTextureEffect::Make( - srcView.detachProxy(), this->colorInfo().alphaType(), texMatrix, - GrSamplerState::Filter::kBilerp)); + vPaint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(srcView), + this->colorInfo().alphaType(), texMatrix, + GrSamplerState::Filter::kBilerp)); auto vFP = GrColorMatrixFragmentProcessor::Make(vM, false, true, false); vPaint.addColorFragmentProcessor(std::move(vFP)); vPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -2628,7 +2627,11 @@ bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, const SkIRect& srcR GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - auto fp = GrTextureEffect::Make(sk_ref_sp(src), kUnknown_SkAlphaType); + + GrSurfaceOrigin origin = src->origin(); + GrSwizzle swizzle = src->textureSwizzle(); + GrSurfaceProxyView view(sk_ref_sp(src), origin, swizzle); + auto fp = GrTextureEffect::Make(std::move(view), kUnknown_SkAlphaType); if (!fp) { return false; } diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 4d72e8f2bb..8b50c2a333 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -163,8 +163,12 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask( SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX), SkIntToScalar(-textureOriginInDeviceSpace.fY)); maskMatrix.preConcat(viewMatrix); + + GrSurfaceOrigin origin = proxy->origin(); + GrSwizzle swizzle = proxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(proxy), origin, swizzle); paint.addCoverageFragmentProcessor(GrTextureEffect::Make( - std::move(proxy), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest)); + std::move(view), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest)); DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(), dstRect, invert); } diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp index 00cc4a8de1..d8067d488c 100644 --- a/src/gpu/GrSurfaceContext.cpp +++ b/src/gpu/GrSurfaceContext.cpp @@ -218,8 +218,8 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz std::unique_ptr fp; if (canvas2DFastPath) { - fp = direct->priv().createPMToUPMEffect(GrTextureEffect::Make( - sk_ref_sp(srcProxy->asTextureProxy()), this->colorInfo().alphaType())); + fp = direct->priv().createPMToUPMEffect( + GrTextureEffect::Make(this->readSurfaceView(), this->colorInfo().alphaType())); if (dstInfo.colorType() == GrColorType::kBGRA_8888) { fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA()); dstInfo = dstInfo.makeColorType(GrColorType::kRGBA_8888); @@ -229,8 +229,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz // double unpremul. dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType); } else { - fp = GrTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()), - this->colorInfo().alphaType()); + fp = GrTextureEffect::Make(this->readSurfaceView(), this->colorInfo().alphaType()); } if (!fp) { return false; @@ -397,7 +396,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s } SkASSERT(tempProxy->textureSwizzle() == tempReadSwizzle); GrSurfaceProxyView tempView(tempProxy, tempOrigin, tempReadSwizzle); - GrSurfaceContext tempCtx(direct, std::move(tempView), colorType, alphaType, + GrSurfaceContext tempCtx(direct, tempView, colorType, alphaType, this->colorInfo().refColorSpace()); // In the fast path we always write the srcData to the temp context as though it were RGBA. @@ -415,13 +414,13 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s std::unique_ptr fp; if (canvas2DFastPath) { fp = direct->priv().createUPMToPMEffect( - GrTextureEffect::Make(std::move(tempProxy), alphaType)); + GrTextureEffect::Make(std::move(tempView), alphaType)); // Important: check the original src color type here! if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) { fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA()); } } else { - fp = GrTextureEffect::Make(std::move(tempProxy), alphaType); + fp = GrTextureEffect::Make(std::move(tempView), alphaType); } if (!fp) { return false; diff --git a/src/gpu/GrSurfaceProxyView.h b/src/gpu/GrSurfaceProxyView.h index 6f43ee8c56..ed438a34d0 100644 --- a/src/gpu/GrSurfaceProxyView.h +++ b/src/gpu/GrSurfaceProxyView.h @@ -23,7 +23,7 @@ public: : fProxy(proxy), fOrigin(origin), fSwizzle(swizzle) {} // This entry point is used when we don't care about the origin or the swizzle. - GrSurfaceProxyView(sk_sp proxy) + explicit GrSurfaceProxyView(sk_sp proxy) : fProxy(proxy), fOrigin(kTopLeft_GrSurfaceOrigin) {} GrSurfaceProxyView(GrSurfaceProxyView&& view) = default; diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index 9e21425775..44600e4e69 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -61,7 +61,7 @@ GrSurfaceProxyView GrTextureProducer::CopyOnGpu(GrRecordingContext* context, GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, copyParams.fFilter); auto boundsRect = SkIRect::MakeSize(proxy->dimensions()); - auto fp = GrTextureEffect::MakeTexelSubset(inputView.detachProxy(), kUnknown_SkAlphaType, + auto fp = GrTextureEffect::MakeTexelSubset(std::move(inputView), kUnknown_SkAlphaType, SkMatrix::I(), sampler, boundsRect, localRect, caps); paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -202,10 +202,10 @@ std::unique_ptr GrTextureProducer::createFragmentProcessorF : GrSamplerState::WrapMode::kClamp; GrSamplerState samplerState(wrapMode, *filterOrNullForBicubic); if (kNoDomain_DomainMode == domainMode) { - return GrTextureEffect::Make(view.detachProxy(), srcAlphaType, textureMatrix, - samplerState, caps); + return GrTextureEffect::Make(std::move(view), srcAlphaType, textureMatrix, samplerState, + caps); } - return GrTextureEffect::MakeSubset(view.detachProxy(), srcAlphaType, textureMatrix, + return GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, textureMatrix, samplerState, domain, caps); } else { static const GrSamplerState::WrapMode kClampClamp[] = { diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index e62c59d5ee..330deb6d21 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -955,8 +955,11 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, static constexpr auto kDir = GrBicubicEffect::Direction::kXY; fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain, kDir, srcAlphaType); } else { - fp = GrTextureEffect::MakeSubset(std::move(proxy), srcAlphaType, texMatrix, - samplerState, domain, caps); + GrSurfaceOrigin origin = proxy->origin(); + GrSwizzle swizzle = proxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(proxy), origin, swizzle); + fp = GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix, samplerState, + domain, caps); } } else if (bicubic) { SkASSERT(GrSamplerState::Filter::kNearest == samplerState.filter()); @@ -964,7 +967,10 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, static constexpr auto kDir = GrBicubicEffect::Direction::kXY; fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode, kDir, srcAlphaType); } else { - fp = GrTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix, samplerState, caps); + GrSurfaceOrigin origin = proxy->origin(); + GrSwizzle swizzle = proxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(proxy), origin, swizzle); + fp = GrTextureEffect::Make(std::move(view), srcAlphaType, texMatrix, samplerState, caps); } fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(), @@ -1035,7 +1041,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const tmpUnfiltered.setImageFilter(nullptr); - auto fp = GrTextureEffect::Make(view.detachProxy(), special->alphaType()); + auto fp = GrTextureEffect::Make(std::move(view), special->alphaType()); fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(), fRenderTargetContext->colorInfo().colorSpace()); if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) { @@ -1074,8 +1080,12 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const std::unique_ptr cfp; if (clipProxy && ctm.invert(&inverseClipMatrix)) { GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType()); - cfp = GrTextureEffect::Make(std::move(clipProxy), clipImage->alphaType(), - inverseClipMatrix, filter); + + GrSurfaceOrigin origin = clipProxy->origin(); + GrSwizzle swizzle = clipProxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(clipProxy), origin, swizzle); + cfp = GrTextureEffect::Make(std::move(view), clipImage->alphaType(), inverseClipMatrix, + filter); if (srcColorType != GrColorType::kAlpha_8) { cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA()); } diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp index 2d92e09aba..22f413402d 100644 --- a/src/gpu/effects/GrConfigConversionEffect.fp +++ b/src/gpu/effects/GrConfigConversionEffect.fp @@ -80,7 +80,7 @@ std::unique_ptr upmToPM( new GrConfigConversionEffect(PMConversion::kToPremul)); - paint1.addColorFragmentProcessor(GrTextureEffect::Make(dataView.detachProxy(), + paint1.addColorFragmentProcessor(GrTextureEffect::Make(std::move(dataView), kPremul_SkAlphaType)); paint1.addColorFragmentProcessor(pmToUPM->clone()); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -95,14 +95,16 @@ // draw tempRTC->discard(); - paint2.addColorFragmentProcessor(GrTextureEffect::Make(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType)); + paint2.addColorFragmentProcessor(GrTextureEffect::Make(readRTC->readSurfaceView(), + kUnpremul_SkAlphaType)); paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect, kRect); - paint3.addColorFragmentProcessor(GrTextureEffect::Make(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType)); + paint3.addColorFragmentProcessor(GrTextureEffect::Make(tempRTC->readSurfaceView(), + kPremul_SkAlphaType)); paint3.addColorFragmentProcessor(std::move(pmToUPM)); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/gpu/effects/GrTextureEffect.cpp b/src/gpu/effects/GrTextureEffect.cpp index d3164a3c30..7b4a2922b9 100644 --- a/src/gpu/effects/GrTextureEffect.cpp +++ b/src/gpu/effects/GrTextureEffect.cpp @@ -149,68 +149,69 @@ bool GrTextureEffect::Sampling::usesDecal() const { fHWSampler.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder; } -std::unique_ptr GrTextureEffect::Make(sk_sp proxy, +std::unique_ptr GrTextureEffect::Make(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, GrSamplerState::Filter filter) { return std::unique_ptr( - new GrTextureEffect(std::move(proxy), alphaType, matrix, Sampling(filter))); + new GrTextureEffect(std::move(view), alphaType, matrix, Sampling(filter))); } -std::unique_ptr GrTextureEffect::Make(sk_sp proxy, +std::unique_ptr GrTextureEffect::Make(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, GrSamplerState sampler, const GrCaps& caps) { - Sampling sampling(sampler, proxy->dimensions(), caps); + Sampling sampling(sampler, view.proxy()->dimensions(), caps); return std::unique_ptr( - new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling)); + new GrTextureEffect(std::move(view), alphaType, matrix, sampling)); } -std::unique_ptr GrTextureEffect::MakeTexelSubset(sk_sp proxy, +std::unique_ptr GrTextureEffect::MakeTexelSubset(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, GrSamplerState sampler, const SkIRect& subset, const GrCaps& caps) { - Sampling sampling(*proxy, sampler, SkRect::Make(subset), true, nullptr, caps); + Sampling sampling(*view.proxy(), sampler, SkRect::Make(subset), true, nullptr, caps); + return std::unique_ptr( - new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling)); + new GrTextureEffect(std::move(view), alphaType, matrix, sampling)); } -std::unique_ptr GrTextureEffect::MakeTexelSubset(sk_sp proxy, +std::unique_ptr GrTextureEffect::MakeTexelSubset(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, GrSamplerState sampler, const SkIRect& subset, const SkRect& domain, const GrCaps& caps) { - Sampling sampling(*proxy, sampler, SkRect::Make(subset), true, &domain, caps); + Sampling sampling(*view.proxy(), sampler, SkRect::Make(subset), true, &domain, caps); return std::unique_ptr( - new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling)); + new GrTextureEffect(std::move(view), alphaType, matrix, sampling)); } -std::unique_ptr GrTextureEffect::MakeSubset(sk_sp proxy, +std::unique_ptr GrTextureEffect::MakeSubset(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, GrSamplerState sampler, const SkRect& subset, const GrCaps& caps) { - Sampling sampling(*proxy, sampler, subset, false, nullptr, caps); + Sampling sampling(*view.proxy(), sampler, subset, false, nullptr, caps); return std::unique_ptr( - new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling)); + new GrTextureEffect(std::move(view), alphaType, matrix, sampling)); } -std::unique_ptr GrTextureEffect::MakeSubset(sk_sp proxy, +std::unique_ptr GrTextureEffect::MakeSubset(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, GrSamplerState sampler, const SkRect& subset, const SkRect& domain, const GrCaps& caps) { - Sampling sampling(*proxy, sampler, subset, false, &domain, caps); + Sampling sampling(*view.proxy(), sampler, subset, false, &domain, caps); return std::unique_ptr( - new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling)); + new GrTextureEffect(std::move(view), alphaType, matrix, sampling)); } GrGLSLFragmentProcessor* GrTextureEffect::onCreateGLSLInstance() const { @@ -408,12 +409,12 @@ bool GrTextureEffect::onIsEqual(const GrFragmentProcessor& other) const { fSubset == that.fSubset; } -GrTextureEffect::GrTextureEffect(sk_sp texture, SkAlphaType alphaType, +GrTextureEffect::GrTextureEffect(GrSurfaceProxyView view, SkAlphaType alphaType, const SkMatrix& matrix, const Sampling& sampling) : GrFragmentProcessor(kGrTextureEffect_ClassID, ModulateForSamplerOptFlags(alphaType, sampling.usesDecal())) - , fCoordTransform(matrix, texture.get()) - , fSampler(std::move(texture), sampling.fHWSampler) + , fCoordTransform(matrix, view.proxy()) + , fSampler(std::move(view), sampling.fHWSampler) , fSubset(sampling.fShaderSubset) , fShaderModes{sampling.fShaderModes[0], sampling.fShaderModes[1]} { // We always compare the range even when it isn't used so assert we have canonical don't care @@ -460,6 +461,9 @@ std::unique_ptr GrTextureEffect::TestCreate(GrProcessorTest : GrSamplerState::Filter::kNearest); const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom); - return GrTextureEffect::Make(std::move(proxy), at, matrix, params, *testData->caps()); + GrSurfaceOrigin origin = proxy->origin(); + GrSwizzle swizzle = proxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(proxy), origin, swizzle); + return GrTextureEffect::Make(std::move(view), at, matrix, params, *testData->caps()); } #endif diff --git a/src/gpu/effects/GrTextureEffect.h b/src/gpu/effects/GrTextureEffect.h index 9e62a484e4..513bd216ba 100644 --- a/src/gpu/effects/GrTextureEffect.h +++ b/src/gpu/effects/GrTextureEffect.h @@ -17,7 +17,7 @@ class GrTextureEffect : public GrFragmentProcessor { public: /** Make from a filter. The sampler will be configured with clamp mode. */ static std::unique_ptr Make( - sk_sp, + GrSurfaceProxyView, SkAlphaType, const SkMatrix& = SkMatrix::I(), GrSamplerState::Filter = GrSamplerState::Filter::kNearest); @@ -26,11 +26,8 @@ public: * Make from a full GrSamplerState. Caps are required to determine support for kClampToBorder. * This will be emulated in the shader if there is no hardware support. */ - static std::unique_ptr Make(sk_sp, - SkAlphaType, - const SkMatrix&, - GrSamplerState, - const GrCaps& caps); + static std::unique_ptr Make( + GrSurfaceProxyView, SkAlphaType, const SkMatrix&, GrSamplerState, const GrCaps& caps); /** * Makes a texture effect that samples a subset of a texture. The wrap modes of the @@ -42,7 +39,7 @@ public: * outside the window. More specifically, we treat the MIP map case exactly like the * bilerp case in terms of how the final texture coords are computed. */ - static std::unique_ptr MakeTexelSubset(sk_sp, + static std::unique_ptr MakeTexelSubset(GrSurfaceProxyView, SkAlphaType, const SkMatrix&, GrSamplerState, @@ -54,7 +51,7 @@ public: * knowledge of how this effect will be nested into a paint, the local coords used with the * draw, etc. It is only used to attempt to optimize away the shader subset calculations. */ - static std::unique_ptr MakeTexelSubset(sk_sp, + static std::unique_ptr MakeTexelSubset(GrSurfaceProxyView, SkAlphaType, const SkMatrix&, GrSamplerState, @@ -68,7 +65,7 @@ public: * unmodified subset. The subset should be unnormalized. The effect will apply texture * coordinate normalization after subset restriction (logically). */ - static std::unique_ptr MakeSubset(sk_sp, + static std::unique_ptr MakeSubset(GrSurfaceProxyView, SkAlphaType, const SkMatrix&, GrSamplerState, @@ -81,7 +78,7 @@ public: * knowledge of how this effect will be nested into a paint, the local coords used with the * draw, etc. It is only used to attempt to optimize away the shader subset calculations. */ - static std::unique_ptr MakeSubset(sk_sp, + static std::unique_ptr MakeSubset(GrSurfaceProxyView, SkAlphaType, const SkMatrix&, GrSamplerState, @@ -122,7 +119,7 @@ private: SkRect fSubset; ShaderMode fShaderModes[2]; - inline GrTextureEffect(sk_sp, SkAlphaType, const SkMatrix&, const Sampling&); + inline GrTextureEffect(GrSurfaceProxyView, SkAlphaType, const SkMatrix&, const Sampling&); GrTextureEffect(const GrTextureEffect& src); diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index 062ef5f6e2..569be09310 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -65,16 +65,19 @@ std::unique_ptr GrYUVtoRGBEffect::Make(const sk_sporigin(); + GrSwizzle swizzle = proxies[i]->textureSwizzle(); + GrSurfaceProxyView view(proxies[i], origin, swizzle); if (domain) { SkASSERT(planeFilter != GrSamplerState::Filter::kMipMap); if (planeFilter != GrSamplerState::Filter::kNearest) { // Inset by half a pixel for bilerp, after scaling to the size of the plane planeDomain.inset(0.5f, 0.5f); } - planeFPs[i] = GrTextureEffect::MakeSubset(proxies[i], kUnknown_SkAlphaType, + planeFPs[i] = GrTextureEffect::MakeSubset(std::move(view), kUnknown_SkAlphaType, *planeMatrix, planeFilter, planeDomain, caps); } else { - planeFPs[i] = GrTextureEffect::Make(proxies[i], kUnknown_SkAlphaType, *planeMatrix, + planeFPs[i] = GrTextureEffect::Make(std::move(view), kUnknown_SkAlphaType, *planeMatrix, planeFilter); } } diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h index 1704cc0267..d2e186e401 100644 --- a/src/gpu/effects/generated/GrConfigConversionEffect.h +++ b/src/gpu/effects/generated/GrConfigConversionEffect.h @@ -90,7 +90,7 @@ public: new GrConfigConversionEffect(PMConversion::kToPremul)); paint1.addColorFragmentProcessor( - GrTextureEffect::Make(dataView.detachProxy(), kPremul_SkAlphaType)); + GrTextureEffect::Make(std::move(dataView), kPremul_SkAlphaType)); paint1.addColorFragmentProcessor(pmToUPM->clone()); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -105,7 +105,7 @@ public: tempRTC->discard(); paint2.addColorFragmentProcessor( - GrTextureEffect::Make(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType)); + GrTextureEffect::Make(readRTC->readSurfaceView(), kUnpremul_SkAlphaType)); paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -113,7 +113,7 @@ public: kRect); paint3.addColorFragmentProcessor( - GrTextureEffect::Make(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType)); + GrTextureEffect::Make(tempRTC->readSurfaceView(), kPremul_SkAlphaType)); paint3.addColorFragmentProcessor(std::move(pmToUPM)); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 2eb257cbb2..feae3143f2 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -1069,7 +1069,6 @@ std::unique_ptr GrTextureOp::Make(GrRecordingContext* context, paint.setColor4f(color); paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode)); - GrSurfaceProxy* proxy = proxyView.proxy(); std::unique_ptr fp; if (domain) { // Update domain to match what GrTextureOp would do for bilerp, but don't do any @@ -1078,14 +1077,14 @@ std::unique_ptr GrTextureOp::Make(GrRecordingContext* context, const auto& caps = *context->priv().caps(); SkRect localRect; if (localQuad.asRect(&localRect)) { - fp = GrTextureEffect::MakeSubset(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter, - correctedDomain, localRect, caps); + fp = GrTextureEffect::MakeSubset(std::move(proxyView), alphaType, SkMatrix::I(), + filter, correctedDomain, localRect, caps); } else { - fp = GrTextureEffect::MakeSubset(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter, - correctedDomain, caps); + fp = GrTextureEffect::MakeSubset(std::move(proxyView), alphaType, SkMatrix::I(), + filter, correctedDomain, caps); } } else { - fp = GrTextureEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter); + fp = GrTextureEffect::Make(std::move(proxyView), alphaType, SkMatrix::I(), filter); } fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(textureXform)); paint.addColorFragmentProcessor(std::move(fp)); @@ -1093,8 +1092,8 @@ std::unique_ptr GrTextureOp::Make(GrRecordingContext* context, paint.addColorFragmentProcessor(GrClampFragmentProcessor::Make(false)); } - return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags, - deviceQuad, localQuad); + return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags, deviceQuad, + localQuad); } } diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index a5768d81c8..e2000e906b 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -94,8 +94,7 @@ sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - sk_sp proxy = this->asTextureProxyRef(context); - paint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(proxy), this->alphaType())); + paint.addColorFragmentProcessor(GrTextureEffect::Make(*this->view(context), this->alphaType())); if (xform) { paint.addColorFragmentProcessor(std::move(xform)); } diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index b8fd426e13..e0f0b6882d 100755 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -247,8 +247,10 @@ std::unique_ptr SkImageShader::asFragmentProcessor( inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes, domainX, domainY, kDir, srcAlphaType); } else { - inner = GrTextureEffect::Make(std::move(proxy), srcAlphaType, lmInverse, samplerState, - caps); + GrSurfaceOrigin origin = proxy->origin(); + GrSwizzle swizzle = proxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(proxy), origin, swizzle); + inner = GrTextureEffect::Make(std::move(view), srcAlphaType, lmInverse, samplerState, caps); } inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(), srcAlphaType, args.fDstColorInfo->colorSpace()); diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp index 43729f4f4a..6d7901cd80 100644 --- a/tests/EGLImageTest.cpp +++ b/tests/EGLImageTest.cpp @@ -168,8 +168,11 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) { cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image); return; } - auto surfaceContext = GrSurfaceContext::Make(context0, std::move(texProxy), colorType, - alphaType, nullptr); + GrSwizzle swizzle = + context0->priv().caps()->getReadSwizzle(texProxy->backendFormat(), colorType); + GrSurfaceProxyView view(std::move(texProxy), origin, swizzle); + auto surfaceContext = + GrSurfaceContext::Make(context0, std::move(view), colorType, alphaType, nullptr); if (!surfaceContext) { ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext."); diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp index c82f654d08..e38f5a6d18 100644 --- a/tests/OnFlushCallbackTest.cpp +++ b/tests/OnFlushCallbackTest.cpp @@ -446,10 +446,13 @@ static sk_sp make_upstream_image(GrContext* context, AtlasObject rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); + GrSurfaceOrigin origin = atlasProxy->origin(); + GrSwizzle swizzle = atlasProxy->textureSwizzle(); + GrSurfaceProxyView atlasView(std::move(atlasProxy), origin, swizzle); for (int i = 0; i < 3; ++i) { SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize); - auto fp = GrTextureEffect::Make(atlasProxy, atlasAlphaType); + auto fp = GrTextureEffect::Make(atlasView, atlasAlphaType); GrPaint paint; paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -568,7 +571,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) { SkMatrix t = SkMatrix::MakeTrans(-i*3*kDrawnTileSize, 0); GrPaint paint; - auto fp = GrTextureEffect::Make(std::move(proxies[i]), kPremul_SkAlphaType, t); + GrSurfaceOrigin origin = proxies[i]->origin(); + GrSwizzle swizzle = proxies[i]->textureSwizzle(); + GrSurfaceProxyView view(std::move(proxies[i]), origin, swizzle); + auto fp = GrTextureEffect::Make(std::move(view), kPremul_SkAlphaType, t); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.addColorFragmentProcessor(std::move(fp)); diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 92776bd990..86cb016726 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -237,8 +237,10 @@ void test_draw_op(GrContext* context, sk_sp inputDataProxy, SkAlphaType inputAlphaType) { GrPaint paint; - paint.addColorFragmentProcessor( - GrTextureEffect::Make(std::move(inputDataProxy), inputAlphaType)); + GrSurfaceOrigin origin = inputDataProxy->origin(); + GrSwizzle swizzle = inputDataProxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(inputDataProxy), origin, swizzle); + paint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(view), inputAlphaType)); paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index 9af9676615..17f19dbe4d 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -32,12 +32,15 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* cont SkAlphaType alphaType, uint32_t expectedPixelValues[]) { auto rtContext = GrRenderTargetContext::Make( context, colorType, nullptr, SkBackingFit::kExact, rectProxy->dimensions()); + GrSurfaceOrigin origin = rectProxy->origin(); + GrSwizzle swizzle = rectProxy->textureSwizzle(); + GrSurfaceProxyView view(std::move(rectProxy), origin, swizzle); for (auto filter : {GrSamplerState::Filter::kNearest, GrSamplerState::Filter::kBilerp, GrSamplerState::Filter::kMipMap}) { rtContext->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA), GrRenderTargetContext::CanClearFullscreen::kYes); - auto fp = GrTextureEffect::Make(rectProxy, alphaType, SkMatrix::I(), filter); + auto fp = GrTextureEffect::Make(view, alphaType, SkMatrix::I(), filter); GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.addColorFragmentProcessor(std::move(fp));