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>
This commit is contained in:
Greg Daniel 2020-02-05 10:45:39 -05:00 committed by Skia Commit-Bot
parent 9bfd5956de
commit d2ccbb522e
27 changed files with 144 additions and 111 deletions

View File

@ -85,7 +85,7 @@ DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, rtCtx, canvas, 512, 512,
GrBitmapTextureMaker maker(ctx, bmp); GrBitmapTextureMaker maker(ctx, bmp);
auto[view, grCT] = maker.view(GrMipMapped::kNo); auto[view, grCT] = maker.view(GrMipMapped::kNo);
std::unique_ptr<GrFragmentProcessor> imgFP = 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))); auto fp = std::unique_ptr<GrFragmentProcessor>(new SampleCoordEffect(std::move(imgFP)));
GrPaint grPaint; GrPaint grPaint;

View File

@ -146,7 +146,7 @@ protected:
} }
GrSamplerState sampler(wmx, wmy, fFilter); GrSamplerState sampler(wmx, wmy, fFilter);
const auto& caps = *context->priv().caps(); const auto& caps = *context->priv().caps();
auto fp1 = GrTextureEffect::MakeTexelSubset(view.refProxy(), auto fp1 = GrTextureEffect::MakeTexelSubset(view,
fBitmap.alphaType(), fBitmap.alphaType(),
textureMatrices[tm], textureMatrices[tm],
sampler, sampler,
@ -174,8 +174,8 @@ protected:
// Now draw with a subsetted proxy using fixed function texture sampling rather // Now draw with a subsetted proxy using fixed function texture sampling rather
// than a texture subset as a comparison. // than a texture subset as a comparison.
drawRect = localRect.makeOffset(x, y); drawRect = localRect.makeOffset(x, y);
auto fp2 = GrTextureEffect::Make(subsetView.refProxy(), auto fp2 = GrTextureEffect::Make(subsetView, fBitmap.alphaType(),
fBitmap.alphaType(), subsetTextureMatrix, subsetTextureMatrix,
GrSamplerState(wmx, wmy, fFilter), caps); GrSamplerState(wmx, wmy, fFilter), caps);
if (auto op = sk_gpu_test::test_ops::MakeRect(context, std::move(fp2), drawRect, if (auto op = sk_gpu_test::test_ops::MakeRect(context, std::move(fp2), drawRect,
localRect)) { localRect)) {

View File

@ -194,8 +194,8 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) {
// Visualize coverage count in main canvas. // Visualize coverage count in main canvas.
GrPaint paint; GrPaint paint;
paint.addColorFragmentProcessor(GrTextureEffect::Make(sk_ref_sp(ccbuff->asTextureProxy()), paint.addColorFragmentProcessor(
ccbuff->colorInfo().alphaType())); GrTextureEffect::Make(ccbuff->readSurfaceView(), ccbuff->colorInfo().alphaType()));
paint.addColorFragmentProcessor( paint.addColorFragmentProcessor(
std::make_unique<VisualizeCoverageCountFP>()); std::make_unique<VisualizeCoverageCountFP>());
paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver); paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver);

View File

@ -899,8 +899,7 @@ GrSurfaceProxyView SkBlurMaskFilterImpl::filterMaskGPU(GrRecordingContext* conte
if (!isNormalBlur) { if (!isNormalBlur) {
GrPaint paint; GrPaint paint;
// Blend pathTexture over blurTexture. // Blend pathTexture over blurTexture.
paint.addCoverageFragmentProcessor( paint.addCoverageFragmentProcessor(GrTextureEffect::Make(std::move(srcView), srcAlphaType));
GrTextureEffect::Make(srcView.detachProxy(), srcAlphaType));
if (kInner_SkBlurStyle == fBlurStyle) { if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src // inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);

View File

@ -324,11 +324,11 @@ static GrSurfaceProxyView decimate(GrRecordingContext* context,
} }
const auto& caps = *context->priv().caps(); const auto& caps = *context->priv().caps();
GrSamplerState sampler(wrapMode, GrSamplerState::Filter::kBilerp); GrSamplerState sampler(wrapMode, GrSamplerState::Filter::kBilerp);
fp = GrTextureEffect::MakeTexelSubset(srcView.detachProxy(), srcAlphaType, fp = GrTextureEffect::MakeTexelSubset(std::move(srcView), srcAlphaType, SkMatrix::I(),
SkMatrix::I(), sampler, *contentRect, caps); sampler, *contentRect, caps);
srcRect.offset(-srcOffset); srcRect.offset(-srcOffset);
} else { } else {
fp = GrTextureEffect::Make(srcView.detachProxy(), srcAlphaType, SkMatrix::I(), fp = GrTextureEffect::Make(std::move(srcView), srcAlphaType, SkMatrix::I(),
GrSamplerState::Filter::kBilerp); GrSamplerState::Filter::kBilerp);
} }
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));
@ -385,7 +385,7 @@ static std::unique_ptr<GrRenderTargetContext> reexpand(GrRecordingContext* conte
GrPaint paint; GrPaint paint;
const auto& caps = *context->priv().caps(); 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); GrSamplerState::Filter::kBilerp, srcBounds, caps);
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -167,7 +167,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
} }
auto textureFP = GrTextureEffect::Make( auto textureFP = GrTextureEffect::Make(
inputView.detachProxy(), input->alphaType(), std::move(inputView), input->alphaType(),
SkMatrix::MakeTrans(input->subset().x(), input->subset().y())); SkMatrix::MakeTrans(input->subset().x(), input->subset().y()));
textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(), textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(),
input->alphaType(), ctx.colorSpace()); input->alphaType(), ctx.colorSpace());

View File

@ -357,9 +357,8 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
SkMatrix backgroundMatrix = SkMatrix::MakeTrans( SkMatrix backgroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX), SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY)); SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
bgFP = GrTextureEffect::MakeTexelSubset(backgroundView.detachProxy(), bgFP = GrTextureEffect::MakeTexelSubset(std::move(backgroundView), background->alphaType(),
background->alphaType(), backgroundMatrix, sampler, backgroundMatrix, sampler, bgSubset, caps);
bgSubset, caps);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(), bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(), background->alphaType(),
ctx.colorSpace()); ctx.colorSpace());
@ -373,9 +372,9 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
SkMatrix foregroundMatrix = SkMatrix::MakeTrans( SkMatrix foregroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX), SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY)); SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
auto fgFP = GrTextureEffect::MakeTexelSubset(foregroundView.detachProxy(), auto fgFP =
foreground->alphaType(), foregroundMatrix, GrTextureEffect::MakeTexelSubset(std::move(foregroundView), foreground->alphaType(),
sampler, fgSubset, caps); foregroundMatrix, sampler, fgSubset, caps);
fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP), fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP),
foreground->getColorSpace(), foreground->getColorSpace(),
foreground->alphaType(), foreground->alphaType(),

View File

@ -267,9 +267,8 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
SkMatrix bgMatrix = SkMatrix::MakeTrans( SkMatrix bgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX), SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY)); SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
bgFP = GrTextureEffect::MakeTexelSubset(backgroundView.detachProxy(), bgFP = GrTextureEffect::MakeTexelSubset(std::move(backgroundView), background->alphaType(),
background->alphaType(), bgMatrix, sampler, bgMatrix, sampler, bgSubset, caps);
bgSubset, caps);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(), bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(), background->alphaType(),
ctx.colorSpace()); ctx.colorSpace());
@ -283,9 +282,9 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
SkMatrix fgMatrix = SkMatrix::MakeTrans( SkMatrix fgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX), SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY)); SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
auto fgFP = GrTextureEffect::MakeTexelSubset(foregroundView.detachProxy(), auto fgFP =
foreground->alphaType(), fgMatrix, sampler, GrTextureEffect::MakeTexelSubset(std::move(foregroundView), foreground->alphaType(),
fgSubset, caps); fgMatrix, sampler, fgSubset, caps);
fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP), fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP),
foreground->getColorSpace(), foreground->getColorSpace(),
foreground->alphaType(), foreground->alphaType(),

View File

@ -49,7 +49,7 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext,
-SkIntToScalar(maskRect.fTop)); -SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix); matrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor( 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(), renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(maskRect), inverse); SkRect::Make(maskRect), inverse);

View File

@ -2036,7 +2036,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
std::copy_n(baseM + 0, 5, yM + 15); std::copy_n(baseM + 0, 5, yM + 15);
GrPaint yPaint; GrPaint yPaint;
yPaint.addColorFragmentProcessor( 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); auto yFP = GrColorMatrixFragmentProcessor::Make(yM, false, true, false);
yPaint.addColorFragmentProcessor(std::move(yFP)); yPaint.addColorFragmentProcessor(std::move(yFP));
yPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); yPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -2058,8 +2058,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
std::copy_n(baseM + 5, 5, uM + 15); std::copy_n(baseM + 5, 5, uM + 15);
GrPaint uPaint; GrPaint uPaint;
uPaint.addColorFragmentProcessor(GrTextureEffect::Make( uPaint.addColorFragmentProcessor(GrTextureEffect::Make(
srcView.refProxy(), this->colorInfo().alphaType(), texMatrix, srcView, this->colorInfo().alphaType(), texMatrix, GrSamplerState::Filter::kBilerp));
GrSamplerState::Filter::kBilerp));
auto uFP = GrColorMatrixFragmentProcessor::Make(uM, false, true, false); auto uFP = GrColorMatrixFragmentProcessor::Make(uM, false, true, false);
uPaint.addColorFragmentProcessor(std::move(uFP)); uPaint.addColorFragmentProcessor(std::move(uFP));
uPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); uPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -2079,9 +2078,9 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
std::fill_n(vM, 15, 0.f); std::fill_n(vM, 15, 0.f);
std::copy_n(baseM + 10, 5, vM + 15); std::copy_n(baseM + 10, 5, vM + 15);
GrPaint vPaint; GrPaint vPaint;
vPaint.addColorFragmentProcessor(GrTextureEffect::Make( vPaint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(srcView),
srcView.detachProxy(), this->colorInfo().alphaType(), texMatrix, this->colorInfo().alphaType(), texMatrix,
GrSamplerState::Filter::kBilerp)); GrSamplerState::Filter::kBilerp));
auto vFP = GrColorMatrixFragmentProcessor::Make(vM, false, true, false); auto vFP = GrColorMatrixFragmentProcessor::Make(vM, false, true, false);
vPaint.addColorFragmentProcessor(std::move(vFP)); vPaint.addColorFragmentProcessor(std::move(vFP));
vPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); vPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -2628,7 +2627,11 @@ bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, const SkIRect& srcR
GrPaint paint; GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); 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) { if (!fp) {
return false; return false;
} }

View File

@ -163,8 +163,12 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX), SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX),
SkIntToScalar(-textureOriginInDeviceSpace.fY)); SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix); maskMatrix.preConcat(viewMatrix);
GrSurfaceOrigin origin = proxy->origin();
GrSwizzle swizzle = proxy->textureSwizzle();
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
paint.addCoverageFragmentProcessor(GrTextureEffect::Make( 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(), DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert); dstRect, invert);
} }

View File

@ -218,8 +218,8 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
std::unique_ptr<GrFragmentProcessor> fp; std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) { if (canvas2DFastPath) {
fp = direct->priv().createPMToUPMEffect(GrTextureEffect::Make( fp = direct->priv().createPMToUPMEffect(
sk_ref_sp(srcProxy->asTextureProxy()), this->colorInfo().alphaType())); GrTextureEffect::Make(this->readSurfaceView(), this->colorInfo().alphaType()));
if (dstInfo.colorType() == GrColorType::kBGRA_8888) { if (dstInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA()); fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
dstInfo = dstInfo.makeColorType(GrColorType::kRGBA_8888); dstInfo = dstInfo.makeColorType(GrColorType::kRGBA_8888);
@ -229,8 +229,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
// double unpremul. // double unpremul.
dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType); dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType);
} else { } else {
fp = GrTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()), fp = GrTextureEffect::Make(this->readSurfaceView(), this->colorInfo().alphaType());
this->colorInfo().alphaType());
} }
if (!fp) { if (!fp) {
return false; return false;
@ -397,7 +396,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
} }
SkASSERT(tempProxy->textureSwizzle() == tempReadSwizzle); SkASSERT(tempProxy->textureSwizzle() == tempReadSwizzle);
GrSurfaceProxyView tempView(tempProxy, tempOrigin, tempReadSwizzle); GrSurfaceProxyView tempView(tempProxy, tempOrigin, tempReadSwizzle);
GrSurfaceContext tempCtx(direct, std::move(tempView), colorType, alphaType, GrSurfaceContext tempCtx(direct, tempView, colorType, alphaType,
this->colorInfo().refColorSpace()); this->colorInfo().refColorSpace());
// In the fast path we always write the srcData to the temp context as though it were RGBA. // 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<GrFragmentProcessor> fp; std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) { if (canvas2DFastPath) {
fp = direct->priv().createUPMToPMEffect( fp = direct->priv().createUPMToPMEffect(
GrTextureEffect::Make(std::move(tempProxy), alphaType)); GrTextureEffect::Make(std::move(tempView), alphaType));
// Important: check the original src color type here! // Important: check the original src color type here!
if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) { if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA()); fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
} }
} else { } else {
fp = GrTextureEffect::Make(std::move(tempProxy), alphaType); fp = GrTextureEffect::Make(std::move(tempView), alphaType);
} }
if (!fp) { if (!fp) {
return false; return false;

View File

@ -23,7 +23,7 @@ public:
: fProxy(proxy), fOrigin(origin), fSwizzle(swizzle) {} : fProxy(proxy), fOrigin(origin), fSwizzle(swizzle) {}
// This entry point is used when we don't care about the origin or the 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) {} : fProxy(proxy), fOrigin(kTopLeft_GrSurfaceOrigin) {}
GrSurfaceProxyView(GrSurfaceProxyView&& view) = default; GrSurfaceProxyView(GrSurfaceProxyView&& view) = default;

View File

@ -61,7 +61,7 @@ GrSurfaceProxyView GrTextureProducer::CopyOnGpu(GrRecordingContext* context,
GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, copyParams.fFilter); GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, copyParams.fFilter);
auto boundsRect = SkIRect::MakeSize(proxy->dimensions()); 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); SkMatrix::I(), sampler, boundsRect, localRect, caps);
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -202,10 +202,10 @@ std::unique_ptr<GrFragmentProcessor> GrTextureProducer::createFragmentProcessorF
: GrSamplerState::WrapMode::kClamp; : GrSamplerState::WrapMode::kClamp;
GrSamplerState samplerState(wrapMode, *filterOrNullForBicubic); GrSamplerState samplerState(wrapMode, *filterOrNullForBicubic);
if (kNoDomain_DomainMode == domainMode) { if (kNoDomain_DomainMode == domainMode) {
return GrTextureEffect::Make(view.detachProxy(), srcAlphaType, textureMatrix, return GrTextureEffect::Make(std::move(view), srcAlphaType, textureMatrix, samplerState,
samplerState, caps); caps);
} }
return GrTextureEffect::MakeSubset(view.detachProxy(), srcAlphaType, textureMatrix, return GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, textureMatrix,
samplerState, domain, caps); samplerState, domain, caps);
} else { } else {
static const GrSamplerState::WrapMode kClampClamp[] = { static const GrSamplerState::WrapMode kClampClamp[] = {

View File

@ -955,8 +955,11 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
static constexpr auto kDir = GrBicubicEffect::Direction::kXY; static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain, kDir, srcAlphaType); fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain, kDir, srcAlphaType);
} else { } else {
fp = GrTextureEffect::MakeSubset(std::move(proxy), srcAlphaType, texMatrix, GrSurfaceOrigin origin = proxy->origin();
samplerState, domain, caps); 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) { } else if (bicubic) {
SkASSERT(GrSamplerState::Filter::kNearest == samplerState.filter()); SkASSERT(GrSamplerState::Filter::kNearest == samplerState.filter());
@ -964,7 +967,10 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
static constexpr auto kDir = GrBicubicEffect::Direction::kXY; static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode, kDir, srcAlphaType); fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode, kDir, srcAlphaType);
} else { } 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(), 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); 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(), fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorInfo().colorSpace()); fRenderTargetContext->colorInfo().colorSpace());
if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) { if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) {
@ -1074,8 +1080,12 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
std::unique_ptr<GrFragmentProcessor> cfp; std::unique_ptr<GrFragmentProcessor> cfp;
if (clipProxy && ctm.invert(&inverseClipMatrix)) { if (clipProxy && ctm.invert(&inverseClipMatrix)) {
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType()); 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) { if (srcColorType != GrColorType::kAlpha_8) {
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA()); cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
} }

View File

@ -80,7 +80,7 @@
std::unique_ptr<GrFragmentProcessor> upmToPM( std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(PMConversion::kToPremul)); new GrConfigConversionEffect(PMConversion::kToPremul));
paint1.addColorFragmentProcessor(GrTextureEffect::Make(dataView.detachProxy(), paint1.addColorFragmentProcessor(GrTextureEffect::Make(std::move(dataView),
kPremul_SkAlphaType)); kPremul_SkAlphaType));
paint1.addColorFragmentProcessor(pmToUPM->clone()); paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -95,14 +95,16 @@
// draw // draw
tempRTC->discard(); tempRTC->discard();
paint2.addColorFragmentProcessor(GrTextureEffect::Make(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType)); paint2.addColorFragmentProcessor(GrTextureEffect::Make(readRTC->readSurfaceView(),
kUnpremul_SkAlphaType));
paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect, tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect,
kRect); kRect);
paint3.addColorFragmentProcessor(GrTextureEffect::Make(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType)); paint3.addColorFragmentProcessor(GrTextureEffect::Make(tempRTC->readSurfaceView(),
kPremul_SkAlphaType));
paint3.addColorFragmentProcessor(std::move(pmToUPM)); paint3.addColorFragmentProcessor(std::move(pmToUPM));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -149,68 +149,69 @@ bool GrTextureEffect::Sampling::usesDecal() const {
fHWSampler.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder; 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, SkAlphaType alphaType,
const SkMatrix& matrix, const SkMatrix& matrix,
GrSamplerState::Filter filter) { GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>( 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, SkAlphaType alphaType,
const SkMatrix& matrix, const SkMatrix& matrix,
GrSamplerState sampler, GrSamplerState sampler,
const GrCaps& caps) { const GrCaps& caps) {
Sampling sampling(sampler, proxy->dimensions(), caps); Sampling sampling(sampler, view.proxy()->dimensions(), caps);
return std::unique_ptr<GrFragmentProcessor>( 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, SkAlphaType alphaType,
const SkMatrix& matrix, const SkMatrix& matrix,
GrSamplerState sampler, GrSamplerState sampler,
const SkIRect& subset, const SkIRect& subset,
const GrCaps& caps) { 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>( 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, SkAlphaType alphaType,
const SkMatrix& matrix, const SkMatrix& matrix,
GrSamplerState sampler, GrSamplerState sampler,
const SkIRect& subset, const SkIRect& subset,
const SkRect& domain, const SkRect& domain,
const GrCaps& caps) { 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>( 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, SkAlphaType alphaType,
const SkMatrix& matrix, const SkMatrix& matrix,
GrSamplerState sampler, GrSamplerState sampler,
const SkRect& subset, const SkRect& subset,
const GrCaps& caps) { 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>( 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, SkAlphaType alphaType,
const SkMatrix& matrix, const SkMatrix& matrix,
GrSamplerState sampler, GrSamplerState sampler,
const SkRect& subset, const SkRect& subset,
const SkRect& domain, const SkRect& domain,
const GrCaps& caps) { 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>( 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 { GrGLSLFragmentProcessor* GrTextureEffect::onCreateGLSLInstance() const {
@ -408,12 +409,12 @@ bool GrTextureEffect::onIsEqual(const GrFragmentProcessor& other) const {
fSubset == that.fSubset; fSubset == that.fSubset;
} }
GrTextureEffect::GrTextureEffect(sk_sp<GrSurfaceProxy> texture, SkAlphaType alphaType, GrTextureEffect::GrTextureEffect(GrSurfaceProxyView view, SkAlphaType alphaType,
const SkMatrix& matrix, const Sampling& sampling) const SkMatrix& matrix, const Sampling& sampling)
: GrFragmentProcessor(kGrTextureEffect_ClassID, : GrFragmentProcessor(kGrTextureEffect_ClassID,
ModulateForSamplerOptFlags(alphaType, sampling.usesDecal())) ModulateForSamplerOptFlags(alphaType, sampling.usesDecal()))
, fCoordTransform(matrix, texture.get()) , fCoordTransform(matrix, view.proxy())
, fSampler(std::move(texture), sampling.fHWSampler) , fSampler(std::move(view), sampling.fHWSampler)
, fSubset(sampling.fShaderSubset) , fSubset(sampling.fShaderSubset)
, fShaderModes{sampling.fShaderModes[0], sampling.fShaderModes[1]} { , 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 // 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<GrFragmentProcessor> GrTextureEffect::TestCreate(GrProcessorTest
: GrSamplerState::Filter::kNearest); : GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom); 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 #endif

View File

@ -17,7 +17,7 @@ class GrTextureEffect : public GrFragmentProcessor {
public: public:
/** Make from a filter. The sampler will be configured with clamp mode. */ /** Make from a filter. The sampler will be configured with clamp mode. */
static std::unique_ptr<GrFragmentProcessor> Make( static std::unique_ptr<GrFragmentProcessor> Make(
sk_sp<GrSurfaceProxy>, GrSurfaceProxyView,
SkAlphaType, SkAlphaType,
const SkMatrix& = SkMatrix::I(), const SkMatrix& = SkMatrix::I(),
GrSamplerState::Filter = GrSamplerState::Filter::kNearest); GrSamplerState::Filter = GrSamplerState::Filter::kNearest);
@ -26,11 +26,8 @@ public:
* Make from a full GrSamplerState. Caps are required to determine support for kClampToBorder. * 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. * This will be emulated in the shader if there is no hardware support.
*/ */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy>, static std::unique_ptr<GrFragmentProcessor> Make(
SkAlphaType, GrSurfaceProxyView, SkAlphaType, const SkMatrix&, GrSamplerState, const GrCaps& caps);
const SkMatrix&,
GrSamplerState,
const GrCaps& caps);
/** /**
* Makes a texture effect that samples a subset of a texture. The wrap modes of the * 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 * 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. * 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, SkAlphaType,
const SkMatrix&, const SkMatrix&,
GrSamplerState, GrSamplerState,
@ -54,7 +51,7 @@ public:
* knowledge of how this effect will be nested into a paint, the local coords used with the * 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. * 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, SkAlphaType,
const SkMatrix&, const SkMatrix&,
GrSamplerState, GrSamplerState,
@ -68,7 +65,7 @@ public:
* unmodified subset. The subset should be unnormalized. The effect will apply texture * unmodified subset. The subset should be unnormalized. The effect will apply texture
* coordinate normalization after subset restriction (logically). * coordinate normalization after subset restriction (logically).
*/ */
static std::unique_ptr<GrFragmentProcessor> MakeSubset(sk_sp<GrSurfaceProxy>, static std::unique_ptr<GrFragmentProcessor> MakeSubset(GrSurfaceProxyView,
SkAlphaType, SkAlphaType,
const SkMatrix&, const SkMatrix&,
GrSamplerState, GrSamplerState,
@ -81,7 +78,7 @@ public:
* knowledge of how this effect will be nested into a paint, the local coords used with the * 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. * 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, SkAlphaType,
const SkMatrix&, const SkMatrix&,
GrSamplerState, GrSamplerState,
@ -122,7 +119,7 @@ private:
SkRect fSubset; SkRect fSubset;
ShaderMode fShaderModes[2]; 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); GrTextureEffect(const GrTextureEffect& src);

View File

@ -65,16 +65,19 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(const sk_sp<GrTextur
planeDomain = *domain; planeDomain = *domain;
} }
GrSurfaceOrigin origin = proxies[i]->origin();
GrSwizzle swizzle = proxies[i]->textureSwizzle();
GrSurfaceProxyView view(proxies[i], origin, swizzle);
if (domain) { if (domain) {
SkASSERT(planeFilter != GrSamplerState::Filter::kMipMap); SkASSERT(planeFilter != GrSamplerState::Filter::kMipMap);
if (planeFilter != GrSamplerState::Filter::kNearest) { if (planeFilter != GrSamplerState::Filter::kNearest) {
// Inset by half a pixel for bilerp, after scaling to the size of the plane // Inset by half a pixel for bilerp, after scaling to the size of the plane
planeDomain.inset(0.5f, 0.5f); 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); *planeMatrix, planeFilter, planeDomain, caps);
} else { } else {
planeFPs[i] = GrTextureEffect::Make(proxies[i], kUnknown_SkAlphaType, *planeMatrix, planeFPs[i] = GrTextureEffect::Make(std::move(view), kUnknown_SkAlphaType, *planeMatrix,
planeFilter); planeFilter);
} }
} }

View File

@ -90,7 +90,7 @@ public:
new GrConfigConversionEffect(PMConversion::kToPremul)); new GrConfigConversionEffect(PMConversion::kToPremul));
paint1.addColorFragmentProcessor( paint1.addColorFragmentProcessor(
GrTextureEffect::Make(dataView.detachProxy(), kPremul_SkAlphaType)); GrTextureEffect::Make(std::move(dataView), kPremul_SkAlphaType));
paint1.addColorFragmentProcessor(pmToUPM->clone()); paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -105,7 +105,7 @@ public:
tempRTC->discard(); tempRTC->discard();
paint2.addColorFragmentProcessor( paint2.addColorFragmentProcessor(
GrTextureEffect::Make(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType)); GrTextureEffect::Make(readRTC->readSurfaceView(), kUnpremul_SkAlphaType));
paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -113,7 +113,7 @@ public:
kRect); kRect);
paint3.addColorFragmentProcessor( paint3.addColorFragmentProcessor(
GrTextureEffect::Make(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType)); GrTextureEffect::Make(tempRTC->readSurfaceView(), kPremul_SkAlphaType));
paint3.addColorFragmentProcessor(std::move(pmToUPM)); paint3.addColorFragmentProcessor(std::move(pmToUPM));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -1069,7 +1069,6 @@ std::unique_ptr<GrDrawOp> GrTextureOp::Make(GrRecordingContext* context,
paint.setColor4f(color); paint.setColor4f(color);
paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode)); paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode));
GrSurfaceProxy* proxy = proxyView.proxy();
std::unique_ptr<GrFragmentProcessor> fp; std::unique_ptr<GrFragmentProcessor> fp;
if (domain) { if (domain) {
// Update domain to match what GrTextureOp would do for bilerp, but don't do any // Update domain to match what GrTextureOp would do for bilerp, but don't do any
@ -1078,14 +1077,14 @@ std::unique_ptr<GrDrawOp> GrTextureOp::Make(GrRecordingContext* context,
const auto& caps = *context->priv().caps(); const auto& caps = *context->priv().caps();
SkRect localRect; SkRect localRect;
if (localQuad.asRect(&localRect)) { if (localQuad.asRect(&localRect)) {
fp = GrTextureEffect::MakeSubset(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter, fp = GrTextureEffect::MakeSubset(std::move(proxyView), alphaType, SkMatrix::I(),
correctedDomain, localRect, caps); filter, correctedDomain, localRect, caps);
} else { } else {
fp = GrTextureEffect::MakeSubset(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter, fp = GrTextureEffect::MakeSubset(std::move(proxyView), alphaType, SkMatrix::I(),
correctedDomain, caps); filter, correctedDomain, caps);
} }
} else { } 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)); fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(textureXform));
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));
@ -1093,8 +1092,8 @@ std::unique_ptr<GrDrawOp> GrTextureOp::Make(GrRecordingContext* context,
paint.addColorFragmentProcessor(GrClampFragmentProcessor::Make(false)); paint.addColorFragmentProcessor(GrClampFragmentProcessor::Make(false));
} }
return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags, return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags, deviceQuad,
deviceQuad, localQuad); localQuad);
} }
} }

View File

@ -94,8 +94,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con
GrPaint paint; GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(context); paint.addColorFragmentProcessor(GrTextureEffect::Make(*this->view(context), this->alphaType()));
paint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(proxy), this->alphaType()));
if (xform) { if (xform) {
paint.addColorFragmentProcessor(std::move(xform)); paint.addColorFragmentProcessor(std::move(xform));
} }

View File

@ -247,8 +247,10 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes, domainX, domainY, inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes, domainX, domainY,
kDir, srcAlphaType); kDir, srcAlphaType);
} else { } else {
inner = GrTextureEffect::Make(std::move(proxy), srcAlphaType, lmInverse, samplerState, GrSurfaceOrigin origin = proxy->origin();
caps); 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, inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(), srcAlphaType,
args.fDstColorInfo->colorSpace()); args.fDstColorInfo->colorSpace());

View File

@ -168,8 +168,11 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image); cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
return; return;
} }
auto surfaceContext = GrSurfaceContext::Make(context0, std::move(texProxy), colorType, GrSwizzle swizzle =
alphaType, nullptr); 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) { if (!surfaceContext) {
ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext."); ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext.");

View File

@ -446,10 +446,13 @@ static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject
rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); 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) { for (int i = 0; i < 3; ++i) {
SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize); SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize);
auto fp = GrTextureEffect::Make(atlasProxy, atlasAlphaType); auto fp = GrTextureEffect::Make(atlasView, atlasAlphaType);
GrPaint paint; GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); 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); SkMatrix t = SkMatrix::MakeTrans(-i*3*kDrawnTileSize, 0);
GrPaint paint; 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.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));

View File

@ -237,8 +237,10 @@ void test_draw_op(GrContext* context,
sk_sp<GrTextureProxy> inputDataProxy, sk_sp<GrTextureProxy> inputDataProxy,
SkAlphaType inputAlphaType) { SkAlphaType inputAlphaType) {
GrPaint paint; GrPaint paint;
paint.addColorFragmentProcessor( GrSurfaceOrigin origin = inputDataProxy->origin();
GrTextureEffect::Make(std::move(inputDataProxy), inputAlphaType)); 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.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -32,12 +32,15 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* cont
SkAlphaType alphaType, uint32_t expectedPixelValues[]) { SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
auto rtContext = GrRenderTargetContext::Make( auto rtContext = GrRenderTargetContext::Make(
context, colorType, nullptr, SkBackingFit::kExact, rectProxy->dimensions()); 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, for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp, GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) { GrSamplerState::Filter::kMipMap}) {
rtContext->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA), rtContext->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA),
GrRenderTargetContext::CanClearFullscreen::kYes); GrRenderTargetContext::CanClearFullscreen::kYes);
auto fp = GrTextureEffect::Make(rectProxy, alphaType, SkMatrix::I(), filter); auto fp = GrTextureEffect::Make(view, alphaType, SkMatrix::I(), filter);
GrPaint paint; GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));