Have GrTextureEffect factories take a view as input.
Bug: skia:9556
Change-Id: I06fd7e9bc7e370a5b8891220308a6d362336be9e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268632
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/gm/fpcoordinateoverride.cpp b/gm/fpcoordinateoverride.cpp
index f7b7407..d6425b7 100644
--- a/gm/fpcoordinateoverride.cpp
+++ b/gm/fpcoordinateoverride.cpp
@@ -85,7 +85,7 @@
GrBitmapTextureMaker maker(ctx, bmp);
auto[view, grCT] = maker.view(GrMipMapped::kNo);
std::unique_ptr<GrFragmentProcessor> imgFP =
- GrTextureEffect::Make(view.detachProxy(), bmp.alphaType(), SkMatrix());
+ GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
auto fp = std::unique_ptr<GrFragmentProcessor>(new SampleCoordEffect(std::move(imgFP)));
GrPaint grPaint;
diff --git a/gm/texelsubset.cpp b/gm/texelsubset.cpp
index 0ee8db2..08f27b7 100644
--- a/gm/texelsubset.cpp
+++ b/gm/texelsubset.cpp
@@ -146,7 +146,7 @@
}
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 @@
// 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 2f78359..c617522 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -194,8 +194,8 @@
// 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<VisualizeCoverageCountFP>());
paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver);
diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp
index 1df91aa..e02f823 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -899,8 +899,7 @@
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 f08b3ef..439eac0 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -324,11 +324,11 @@
}
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 @@
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 1ea348b..ad40a11 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -167,7 +167,7 @@
}
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 06045a4..4b25966 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -357,9 +357,8 @@
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 @@
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 5cbbdad..e9fb0cd 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -267,9 +267,8 @@
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 @@
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 30084f1..6f4055c 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -49,7 +49,7 @@
-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 8497a73..446f634 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -2036,7 +2036,7 @@
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 @@
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 @@
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 @@
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 4d72e8f..8b50c2a 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -163,8 +163,12 @@
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 00cc4a8..d8067d4 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -218,8 +218,8 @@
std::unique_ptr<GrFragmentProcessor> 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 @@
// 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 @@
}
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 @@
std::unique_ptr<GrFragmentProcessor> 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 6f43ee8..ed438a3 100644
--- a/src/gpu/GrSurfaceProxyView.h
+++ b/src/gpu/GrSurfaceProxyView.h
@@ -23,7 +23,7 @@
: 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<GrSurfaceProxy> proxy)
+ explicit GrSurfaceProxyView(sk_sp<GrSurfaceProxy> proxy)
: fProxy(proxy), fOrigin(kTopLeft_GrSurfaceOrigin) {}
GrSurfaceProxyView(GrSurfaceProxyView&& view) = default;
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 9e21425..44600e4 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -61,7 +61,7 @@
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 @@
: 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 e62c59d..330deb6 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -955,8 +955,11 @@
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 @@
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 @@
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 @@
std::unique_ptr<GrFragmentProcessor> 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 2d92e09..22f4134 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -80,7 +80,7 @@
std::unique_ptr<GrFragmentProcessor> 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 d3164a3..7b4a292 100644
--- a/src/gpu/effects/GrTextureEffect.cpp
+++ b/src/gpu/effects/GrTextureEffect.cpp
@@ -149,68 +149,69 @@
fHWSampler.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder;
}
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, Sampling(filter)));
+ new GrTextureEffect(std::move(view), alphaType, matrix, Sampling(filter)));
}
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(sk_sp<GrSurfaceProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> 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<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling));
+ new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
}
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeTexelSubset(sk_sp<GrSurfaceProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> 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<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling));
+ new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
}
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeTexelSubset(sk_sp<GrSurfaceProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> 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<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling));
+ new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
}
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(sk_sp<GrSurfaceProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> 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<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling));
+ new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
}
-std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(sk_sp<GrSurfaceProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> 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<GrFragmentProcessor>(
- new GrTextureEffect(std::move(proxy), alphaType, matrix, sampling));
+ new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
}
GrGLSLFragmentProcessor* GrTextureEffect::onCreateGLSLInstance() const {
@@ -408,12 +409,12 @@
fSubset == that.fSubset;
}
-GrTextureEffect::GrTextureEffect(sk_sp<GrSurfaceProxy> 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 @@
: 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 9e62a48..513bd21 100644
--- a/src/gpu/effects/GrTextureEffect.h
+++ b/src/gpu/effects/GrTextureEffect.h
@@ -17,7 +17,7 @@
public:
/** Make from a filter. The sampler will be configured with clamp mode. */
static std::unique_ptr<GrFragmentProcessor> Make(
- sk_sp<GrSurfaceProxy>,
+ GrSurfaceProxyView,
SkAlphaType,
const SkMatrix& = SkMatrix::I(),
GrSamplerState::Filter = GrSamplerState::Filter::kNearest);
@@ -26,11 +26,8 @@
* 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<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy>,
- SkAlphaType,
- const SkMatrix&,
- GrSamplerState,
- const GrCaps& caps);
+ static std::unique_ptr<GrFragmentProcessor> 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 @@
* 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<GrFragmentProcessor> MakeTexelSubset(sk_sp<GrSurfaceProxy>,
+ static std::unique_ptr<GrFragmentProcessor> MakeTexelSubset(GrSurfaceProxyView,
SkAlphaType,
const SkMatrix&,
GrSamplerState,
@@ -54,7 +51,7 @@
* 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<GrFragmentProcessor> MakeTexelSubset(sk_sp<GrSurfaceProxy>,
+ static std::unique_ptr<GrFragmentProcessor> MakeTexelSubset(GrSurfaceProxyView,
SkAlphaType,
const SkMatrix&,
GrSamplerState,
@@ -68,7 +65,7 @@
* unmodified subset. The subset should be unnormalized. The effect will apply texture
* coordinate normalization after subset restriction (logically).
*/
- static std::unique_ptr<GrFragmentProcessor> MakeSubset(sk_sp<GrSurfaceProxy>,
+ static std::unique_ptr<GrFragmentProcessor> MakeSubset(GrSurfaceProxyView,
SkAlphaType,
const SkMatrix&,
GrSamplerState,
@@ -81,7 +78,7 @@
* 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<GrFragmentProcessor> MakeSubset(sk_sp<GrSurfaceProxy>,
+ static std::unique_ptr<GrFragmentProcessor> MakeSubset(GrSurfaceProxyView,
SkAlphaType,
const SkMatrix&,
GrSamplerState,
@@ -122,7 +119,7 @@
SkRect fSubset;
ShaderMode fShaderModes[2];
- inline GrTextureEffect(sk_sp<GrSurfaceProxy>, 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 062ef5f..569be09 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -65,16 +65,19 @@
planeDomain = *domain;
}
+ GrSurfaceOrigin origin = proxies[i]->origin();
+ 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 1704cc0..d2e186e 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -90,7 +90,7 @@
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 @@
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 @@
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 2eb257c..feae314 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -1069,7 +1069,6 @@
paint.setColor4f(color);
paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode));
- GrSurfaceProxy* proxy = proxyView.proxy();
std::unique_ptr<GrFragmentProcessor> fp;
if (domain) {
// Update domain to match what GrTextureOp would do for bilerp, but don't do any
@@ -1078,14 +1077,14 @@
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 @@
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 a5768d8..e2000e9 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -94,8 +94,7 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- sk_sp<GrTextureProxy> 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 b8fd426..e0f0b68 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -247,8 +247,10 @@
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 43729f4..6d7901c 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -168,8 +168,11 @@
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 c82f654..e38f5a6 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -446,10 +446,13 @@
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 @@
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 92776bd..86cb016 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -237,8 +237,10 @@
sk_sp<GrTextureProxy> 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 9af9676..17f19db 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -32,12 +32,15 @@
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));