Remove asTextureProxyRef from SkSpecialImage.

We replace all uses of the function with asSurfaceProxyViewRef.

Bug: skia:9556
Change-Id: I23d425531d78e30fc401b04169d5dc96072cdd80
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267181
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-01-29 11:11:03 -05:00 committed by Skia Commit-Bot
parent a2a0c8a2c4
commit 8354717302
14 changed files with 140 additions and 137 deletions

View File

@ -52,8 +52,6 @@ public:
virtual SkColorSpace* onGetColorSpace() const = 0;
#if SK_SUPPORT_GPU
virtual sk_sp<GrTextureProxy> onAsTextureProxyRef(GrRecordingContext* context) const = 0;
virtual GrSurfaceProxyView onAsSurfaceProxyViewRef(GrRecordingContext* context) const = 0;
#endif
@ -157,10 +155,6 @@ SkColorSpace* SkSpecialImage::getColorSpace() const {
}
#if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> SkSpecialImage::asTextureProxyRef(GrRecordingContext* context) const {
return as_SIB(this)->onAsTextureProxyRef(context);
}
GrSurfaceProxyView SkSpecialImage::asSurfaceProxyViewRef(GrRecordingContext* context) const {
return as_SIB(this)->onAsSurfaceProxyViewRef(context);
}
@ -268,18 +262,6 @@ public:
}
#if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> onAsTextureProxyRef(GrRecordingContext* context) const override {
if (context) {
auto view = GrMakeCachedBitmapProxyView(context, fBitmap);
sk_sp<GrSurfaceProxy> proxy = view.detachProxy();
if (proxy->asTextureProxy()) {
GrSurfaceProxy* sProxy = proxy.release();
return sk_ref_sp<GrTextureProxy>(sProxy->asTextureProxy());
}
}
return nullptr;
}
GrSurfaceProxyView onAsSurfaceProxyViewRef(GrRecordingContext* context) const override {
if (context) {
return GrMakeCachedBitmapProxyView(context, fBitmap);
@ -442,10 +424,6 @@ public:
GrRecordingContext* onGetContext() const override { return fContext; }
sk_sp<GrTextureProxy> onAsTextureProxyRef(GrRecordingContext*) const override {
return fView.asTextureProxyRef();
}
GrSurfaceProxyView onAsSurfaceProxyViewRef(GrRecordingContext* context) const override {
return fView;
}

View File

@ -142,14 +142,6 @@ public:
GrRecordingContext* getContext() const;
#if SK_SUPPORT_GPU
/**
* Regardless of how the underlying backing data is stored, returns the contents as a
* GrTextureProxy. The returned proxy represents the entire backing image, so texture
* coordinates must be mapped from the content rect (e.g. relative to 'subset()') to the proxy's
* space (offset by subset().topLeft()).
*/
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const;
/**
* Regardless of how the underlying backing data is stored, returns the contents as a
* GrSurfaceProxyView. The returned view's proxy represents the entire backing image, so texture

View File

@ -149,9 +149,9 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
if (ctx.gpuBacked()) {
auto context = ctx.getContext();
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
const GrProtected isProtected = inputProxy->isProtected();
GrSurfaceProxyView inputView = (input->asSurfaceProxyViewRef(context));
SkASSERT(inputView.asTextureProxy());
const GrProtected isProtected = inputView.proxy()->isProtected();
offset->fX = bounds.left();
offset->fY = bounds.top();
@ -167,7 +167,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
}
auto textureFP = GrTextureEffect::Make(
std::move(inputProxy), input->alphaType(),
inputView.detachProxy(), input->alphaType(),
SkMatrix::MakeTrans(input->subset().x(), input->subset().y()));
textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(),
input->alphaType(), ctx.colorSpace());

View File

@ -332,17 +332,19 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
auto context = ctx.getContext();
sk_sp<GrTextureProxy> backgroundProxy, foregroundProxy;
GrSurfaceProxyView backgroundView, foregroundView;
GrProtected isProtected = GrProtected::kNo;
if (background) {
backgroundProxy = background->asTextureProxyRef(context);
isProtected = backgroundProxy->isProtected();
backgroundView = background->asSurfaceProxyViewRef(context);
SkASSERT(backgroundView.proxy());
isProtected = backgroundView.proxy()->isProtected();
}
if (foreground) {
foregroundProxy = foreground->asTextureProxyRef(context);
isProtected = foregroundProxy->isProtected();
foregroundView = foreground->asSurfaceProxyViewRef(context);
SkASSERT(foregroundView.proxy());
isProtected = foregroundView.proxy()->isProtected();
}
GrPaint paint;
@ -351,13 +353,14 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
GrSamplerState sampler(GrSamplerState::WrapMode::kClampToBorder,
GrSamplerState::Filter::kNearest);
if (backgroundProxy) {
if (background) {
SkIRect bgSubset = background->subset();
SkMatrix backgroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
bgFP = GrTextureEffect::MakeTexelSubset(std::move(backgroundProxy), background->alphaType(),
backgroundMatrix, sampler, bgSubset, caps);
bgFP = GrTextureEffect::MakeTexelSubset(backgroundView.detachProxy(),
background->alphaType(), backgroundMatrix, sampler,
bgSubset, caps);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(),
ctx.colorSpace());
@ -366,12 +369,12 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
GrConstColorProcessor::InputMode::kIgnore);
}
if (foregroundProxy) {
if (foreground) {
SkIRect fgSubset = foreground->subset();
SkMatrix foregroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
auto fgFP = GrTextureEffect::MakeTexelSubset(std::move(foregroundProxy),
auto fgFP = GrTextureEffect::MakeTexelSubset(foregroundView.detachProxy(),
foreground->alphaType(), foregroundMatrix,
sampler, fgSubset, caps);
fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP),

View File

@ -643,8 +643,8 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
auto context = ctx.getContext();
sk_sp<GrTextureProxy> inputTexture(input->asTextureProxyRef(context));
if (!inputTexture) {
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context);
if (!inputView.asTextureProxy()) {
return nullptr;
}
@ -653,7 +653,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
inputBounds.offset(input->subset().topLeft());
auto renderTargetContext = SkGpuBlurUtils::GaussianBlur(
context,
std::move(inputTexture),
inputView.asTextureProxyRef(), // TODO: Move view once GaussianBlur updated to use view
SkColorTypeToGrColorType(input->colorType()),
input->alphaType(),
ctx.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,

View File

@ -192,8 +192,8 @@ class GrDisplacementMapEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(
SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkVector scale,
sk_sp<GrTextureProxy> displacement, const SkIRect& displSubset,
const SkMatrix& offsetMatrix, sk_sp<GrTextureProxy> color, const SkIRect& colorSubset) {
GrSurfaceProxyView displacement, const SkIRect& displSubset,
const SkMatrix& offsetMatrix, GrSurfaceProxyView color, const SkIRect& colorSubset) {
return std::unique_ptr<GrFragmentProcessor>(new GrDisplacementMapEffect(
xChannelSelector, yChannelSelector, scale, std::move(displacement), displSubset,
offsetMatrix, std::move(color), colorSubset));
@ -225,9 +225,9 @@ private:
GrDisplacementMapEffect(SkColorChannel xChannelSelector,
SkColorChannel yChannelSelector,
const SkVector& scale, sk_sp<GrTextureProxy> displacement,
const SkVector& scale, GrSurfaceProxyView displacement,
const SkIRect& displSubset, const SkMatrix& offsetMatrix,
sk_sp<GrTextureProxy> color, const SkIRect& colorSubset);
GrSurfaceProxyView color, const SkIRect& colorSubset);
const TextureSampler& onTextureSampler(int i) const override {
return IthTextureSampler(i, fDisplacementSampler, fColorSampler);
@ -335,12 +335,12 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
if (ctx.gpuBacked()) {
auto context = ctx.getContext();
sk_sp<GrTextureProxy> colorProxy(color->asTextureProxyRef(context));
sk_sp<GrTextureProxy> displProxy(displ->asTextureProxyRef(context));
if (!colorProxy || !displProxy) {
GrSurfaceProxyView colorView = color->asSurfaceProxyViewRef(context);
GrSurfaceProxyView displView = displ->asSurfaceProxyViewRef(context);
if (!colorView.proxy() || !displView.proxy()) {
return nullptr;
}
const auto isProtected = colorProxy->isProtected();
const auto isProtected = colorView.proxy()->isProtected();
SkMatrix offsetMatrix = SkMatrix::MakeTrans(SkIntToScalar(colorOffset.fX - displOffset.fX),
SkIntToScalar(colorOffset.fY - displOffset.fY));
@ -349,10 +349,10 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
GrDisplacementMapEffect::Make(fXChannelSelector,
fYChannelSelector,
scale,
std::move(displProxy),
std::move(displView),
displ->subset(),
offsetMatrix,
std::move(colorProxy),
std::move(colorView),
color->subset());
fp = GrColorSpaceXformEffect::Make(std::move(fp), color->getColorSpace(),
color->alphaType(), ctx.colorSpace());
@ -476,24 +476,24 @@ GrDisplacementMapEffect::GrDisplacementMapEffect(
SkColorChannel xChannelSelector,
SkColorChannel yChannelSelector,
const SkVector& scale,
sk_sp<GrTextureProxy> displacement,
GrSurfaceProxyView displacement,
const SkIRect& displSubset,
const SkMatrix& offsetMatrix,
sk_sp<GrTextureProxy> color,
GrSurfaceProxyView color,
const SkIRect& colorSubset)
: INHERITED(kGrDisplacementMapEffect_ClassID,
GrFragmentProcessor::kNone_OptimizationFlags)
, fDisplacementTransform(
SkMatrix::Concat(SkMatrix::MakeTrans(displSubset.x(), displSubset.y()),
offsetMatrix),
displacement.get())
, fDisplacementSampler(displacement)
, fColorTransform(SkMatrix::MakeTrans(colorSubset.x(), colorSubset.y()), color.get())
, fDomain(color.get(),
displacement.proxy())
, fDisplacementSampler(std::move(displacement))
, fColorTransform(SkMatrix::MakeTrans(colorSubset.x(), colorSubset.y()), color.proxy())
, fDomain(color.proxy(),
GrTextureDomain::MakeTexelDomain(colorSubset,
GrTextureDomain::kDecal_Mode),
GrTextureDomain::kDecal_Mode, GrTextureDomain::kDecal_Mode)
, fColorSampler(color)
, fColorSampler(std::move(color))
, fXChannelSelector(xChannelSelector)
, fYChannelSelector(yChannelSelector)
, fScale(scale) {
@ -549,11 +549,20 @@ std::unique_ptr<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProce
colorDimensions.fWidth = d->fRandom->nextRangeU(0, colorProxy->width());
colorDimensions.fHeight = d->fRandom->nextRangeU(0, colorProxy->height());
SkIRect dispRect = SkIRect::MakeSize(dispProxy->dimensions());
GrSurfaceOrigin origin = dispProxy->origin();
GrSwizzle swizzle = dispProxy->textureSwizzle();
GrSurfaceProxyView dispView(std::move(dispProxy), origin, swizzle);
origin = colorProxy->origin();
swizzle = colorProxy->textureSwizzle();
GrSurfaceProxyView colorView(std::move(colorProxy), origin, swizzle);
return GrDisplacementMapEffect::Make(xChannelSelector, yChannelSelector, scale,
std::move(dispProxy),
std::move(dispView),
dispRect,
SkMatrix::I(),
std::move(colorProxy), SkIRect::MakeSize(colorDimensions));
std::move(colorView), SkIRect::MakeSize(colorDimensions));
}
#endif

View File

@ -434,7 +434,7 @@ protected:
const SkIRect& bounds,
const SkMatrix& matrix) const;
virtual std::unique_ptr<GrFragmentProcessor> makeFragmentProcessor(
sk_sp<GrTextureProxy>,
GrSurfaceProxyView,
const SkMatrix&,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const = 0;
@ -443,7 +443,7 @@ protected:
private:
#if SK_SUPPORT_GPU
void drawRect(GrRenderTargetContext*,
sk_sp<GrTextureProxy> srcProxy,
GrSurfaceProxyView srcView,
const SkMatrix& matrix,
const GrClip& clip,
const SkRect& dstRect,
@ -460,7 +460,7 @@ private:
#if SK_SUPPORT_GPU
void SkLightingImageFilterInternal::drawRect(GrRenderTargetContext* renderTargetContext,
sk_sp<GrTextureProxy> srcProxy,
GrSurfaceProxyView srcView,
const SkMatrix& matrix,
const GrClip& clip,
const SkRect& dstRect,
@ -469,7 +469,7 @@ void SkLightingImageFilterInternal::drawRect(GrRenderTargetContext* renderTarget
const SkIRect& bounds) const {
SkRect srcRect = dstRect.makeOffset(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()));
GrPaint paint;
auto fp = this->makeFragmentProcessor(std::move(srcProxy), matrix, srcBounds, boundaryMode);
auto fp = this->makeFragmentProcessor(std::move(srcView), matrix, srcBounds, boundaryMode);
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(), dstRect,
@ -485,12 +485,12 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
auto context = ctx.getContext();
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context);
SkASSERT(inputView.asTextureProxy());
auto renderTargetContext = GrRenderTargetContext::Make(
context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox,
offsetBounds.size(), 1, GrMipMapped::kNo, inputProxy->isProtected(),
offsetBounds.size(), 1, GrMipMapped::kNo, inputView.proxy()->isProtected(),
kBottomLeft_GrSurfaceOrigin);
if (!renderTargetContext) {
return nullptr;
@ -514,23 +514,23 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height() - 1, 1, 1);
const SkIRect* pSrcBounds = inputBounds.contains(offsetBounds) ? nullptr : &inputBounds;
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, topLeft,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, topLeft,
kTopLeft_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, top,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, top,
kTop_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, topRight,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, topRight,
kTopRight_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, left,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, left,
kLeft_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, interior,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, interior,
kInterior_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, right,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, right,
kRight_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, bottomLeft,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, bottomLeft,
kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, bottom,
this->drawRect(renderTargetContext.get(), inputView, matrix, clip, bottom,
kBottom_BoundaryMode, pSrcBounds, offsetBounds);
this->drawRect(renderTargetContext.get(), inputProxy, matrix, clip, bottomRight,
this->drawRect(renderTargetContext.get(), std::move(inputView), matrix, clip, bottomRight,
kBottomRight_BoundaryMode, pSrcBounds, offsetBounds);
return SkSpecialImage::MakeDeferredFromGpu(
@ -562,7 +562,7 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> makeFragmentProcessor(sk_sp<GrTextureProxy>,
std::unique_ptr<GrFragmentProcessor> makeFragmentProcessor(GrSurfaceProxyView,
const SkMatrix&,
const SkIRect* bounds,
BoundaryMode) const override;
@ -596,7 +596,7 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> makeFragmentProcessor(sk_sp<GrTextureProxy>,
std::unique_ptr<GrFragmentProcessor> makeFragmentProcessor(GrSurfaceProxyView,
const SkMatrix&,
const SkIRect* bounds,
BoundaryMode) const override;
@ -622,7 +622,7 @@ public:
const GrTextureDomain& domain() const { return fDomain; }
protected:
GrLightingEffect(ClassID classID, sk_sp<GrTextureProxy>, sk_sp<const SkImageFilterLight> light,
GrLightingEffect(ClassID classID, GrSurfaceProxyView, sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale, const SkMatrix& matrix, BoundaryMode boundaryMode,
const SkIRect* srcBounds);
@ -646,7 +646,7 @@ private:
class GrDiffuseLightingEffect : public GrLightingEffect {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView view,
sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale,
const SkMatrix& matrix,
@ -654,7 +654,7 @@ public:
BoundaryMode boundaryMode,
const SkIRect* srcBounds) {
return std::unique_ptr<GrFragmentProcessor>(
new GrDiffuseLightingEffect(std::move(proxy), std::move(light), surfaceScale,
new GrDiffuseLightingEffect(std::move(view), std::move(light), surfaceScale,
matrix, kd, boundaryMode, srcBounds));
}
@ -673,7 +673,7 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override;
GrDiffuseLightingEffect(sk_sp<GrTextureProxy>,
GrDiffuseLightingEffect(GrSurfaceProxyView view,
sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale,
const SkMatrix& matrix,
@ -691,7 +691,7 @@ private:
class GrSpecularLightingEffect : public GrLightingEffect {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView view,
sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale,
const SkMatrix& matrix,
@ -700,7 +700,7 @@ public:
BoundaryMode boundaryMode,
const SkIRect* srcBounds) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSpecularLightingEffect(std::move(proxy), std::move(light), surfaceScale,
new GrSpecularLightingEffect(std::move(view), std::move(light), surfaceScale,
matrix, ks, shininess, boundaryMode, srcBounds));
}
@ -720,7 +720,7 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override;
GrSpecularLightingEffect(sk_sp<GrTextureProxy>,
GrSpecularLightingEffect(GrSurfaceProxyView,
sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale,
const SkMatrix& matrix,
@ -1312,12 +1312,12 @@ sk_sp<SkSpecialImage> SkDiffuseLightingImageFilter::onFilterImage(const Context&
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkDiffuseLightingImageFilter::makeFragmentProcessor(
sk_sp<GrTextureProxy> proxy,
GrSurfaceProxyView view,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = this->surfaceScale() * 255;
return GrDiffuseLightingEffect::Make(std::move(proxy), this->refLight(), scale, matrix,
return GrDiffuseLightingEffect::Make(std::move(view), this->refLight(), scale, matrix,
this->kd(), boundaryMode, srcBounds);
}
#endif
@ -1446,12 +1446,12 @@ sk_sp<SkSpecialImage> SkSpecularLightingImageFilter::onFilterImage(const Context
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkSpecularLightingImageFilter::makeFragmentProcessor(
sk_sp<GrTextureProxy> proxy,
GrSurfaceProxyView view,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = this->surfaceScale() * 255;
return GrSpecularLightingEffect::Make(std::move(proxy), this->refLight(), scale, matrix,
return GrSpecularLightingEffect::Make(std::move(view), this->refLight(), scale, matrix,
this->ks(), this->shininess(), boundaryMode, srcBounds);
}
#endif
@ -1596,7 +1596,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
static GrTextureDomain create_domain(GrTextureProxy* proxy, const SkIRect* srcBounds,
static GrTextureDomain create_domain(GrSurfaceProxy* proxy, const SkIRect* srcBounds,
GrTextureDomain::Mode mode) {
if (srcBounds) {
SkRect texelDomain = GrTextureDomain::MakeTexelDomain(*srcBounds, mode);
@ -1607,7 +1607,7 @@ static GrTextureDomain create_domain(GrTextureProxy* proxy, const SkIRect* srcBo
}
GrLightingEffect::GrLightingEffect(ClassID classID,
sk_sp<GrTextureProxy> proxy,
GrSurfaceProxyView view,
sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale,
const SkMatrix& matrix,
@ -1615,9 +1615,9 @@ GrLightingEffect::GrLightingEffect(ClassID classID,
const SkIRect* srcBounds)
// Perhaps this could advertise the opaque or coverage-as-alpha optimizations?
: INHERITED(classID, kNone_OptimizationFlags)
, fCoordTransform(proxy.get())
, fDomain(create_domain(proxy.get(), srcBounds, GrTextureDomain::kDecal_Mode))
, fTextureSampler(std::move(proxy))
, fCoordTransform(view.proxy())
, fDomain(create_domain(view.proxy(), srcBounds, GrTextureDomain::kDecal_Mode))
, fTextureSampler(std::move(view))
, fLight(std::move(light))
, fSurfaceScale(surfaceScale)
, fFilterMatrix(matrix)
@ -1648,14 +1648,14 @@ bool GrLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
///////////////////////////////////////////////////////////////////////////////
GrDiffuseLightingEffect::GrDiffuseLightingEffect(sk_sp<GrTextureProxy> proxy,
GrDiffuseLightingEffect::GrDiffuseLightingEffect(GrSurfaceProxyView view,
sk_sp<const SkImageFilterLight>light,
SkScalar surfaceScale,
const SkMatrix& matrix,
SkScalar kd,
BoundaryMode boundaryMode,
const SkIRect* srcBounds)
: INHERITED(kGrDiffuseLightingEffect_ClassID, std::move(proxy), std::move(light),
: INHERITED(kGrDiffuseLightingEffect_ClassID, std::move(view), std::move(light),
surfaceScale, matrix, boundaryMode, srcBounds)
, fKD(kd) {}
@ -1718,7 +1718,12 @@ std::unique_ptr<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProce
d->fRandom->nextRangeU(0, proxy->width()),
d->fRandom->nextRangeU(0, proxy->height()));
BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
return GrDiffuseLightingEffect::Make(std::move(proxy), std::move(light), surfaceScale, matrix,
GrSurfaceOrigin origin = proxy->origin();
GrSwizzle swizzle = proxy->textureSwizzle();
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
return GrDiffuseLightingEffect::Make(std::move(view), std::move(light), surfaceScale, matrix,
kd, mode, &srcBounds);
}
#endif
@ -1885,7 +1890,7 @@ void GrGLDiffuseLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
///////////////////////////////////////////////////////////////////////////////
GrSpecularLightingEffect::GrSpecularLightingEffect(sk_sp<GrTextureProxy> proxy,
GrSpecularLightingEffect::GrSpecularLightingEffect(GrSurfaceProxyView view,
sk_sp<const SkImageFilterLight> light,
SkScalar surfaceScale,
const SkMatrix& matrix,
@ -1893,7 +1898,7 @@ GrSpecularLightingEffect::GrSpecularLightingEffect(sk_sp<GrTextureProxy> proxy,
SkScalar shininess,
BoundaryMode boundaryMode,
const SkIRect* srcBounds)
: INHERITED(kGrSpecularLightingEffect_ClassID, std::move(proxy), std::move(light),
: INHERITED(kGrSpecularLightingEffect_ClassID, std::move(view), std::move(light),
surfaceScale, matrix, boundaryMode, srcBounds)
, fKS(ks)
, fShininess(shininess) {}
@ -1935,7 +1940,12 @@ std::unique_ptr<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProc
d->fRandom->nextRangeU(0, proxy->height()),
d->fRandom->nextRangeU(0, proxy->width()),
d->fRandom->nextRangeU(0, proxy->height()));
return GrSpecularLightingEffect::Make(std::move(proxy), std::move(light), surfaceScale, matrix,
GrSurfaceOrigin origin = proxy->origin();
GrSwizzle swizzle = proxy->textureSwizzle();
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
return GrSpecularLightingEffect::Make(std::move(view), std::move(light), surfaceScale, matrix,
ks, shininess, mode, &srcBounds);
}
#endif

View File

@ -122,10 +122,10 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilterImpl::onFilterImage(const Context& c
if (ctx.gpuBacked()) {
auto context = ctx.getContext();
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context);
SkASSERT(inputView.asTextureProxy());
const auto isProtected = inputProxy->isProtected();
const auto isProtected = inputView.proxy()->isProtected();
offset->fX = bounds.left();
offset->fY = bounds.top();
@ -137,7 +137,8 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilterImpl::onFilterImage(const Context& c
SkRect srcRect = fSrcRect.makeOffset((1.f - invXZoom) * input->subset().x(),
(1.f - invYZoom) * input->subset().y());
auto fp = GrMagnifierEffect::Make(std::move(inputProxy),
// TODO: Update generated fp file Make functions to take views instead of proxies
auto fp = GrMagnifierEffect::Make(inputView.detachProxy(),
bounds,
srcRect,
invXZoom,

View File

@ -419,10 +419,10 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(const Co
// fall-back, which saves us from having to do the xform during the filter itself.
input = ImageToColorSpace(input.get(), ctx.colorType(), ctx.colorSpace());
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context);
SkASSERT(inputView.asTextureProxy());
const auto isProtected = inputProxy->isProtected();
const auto isProtected = inputView.proxy()->isProtected();
offset->fX = dstBounds.left();
offset->fY = dstBounds.top();
@ -431,7 +431,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(const Co
// Map srcBounds from input's logical image domain to that of the proxy
srcBounds.offset(input->subset().x(), input->subset().y());
auto fp = GrMatrixConvolutionEffect::Make(std::move(inputProxy),
auto fp = GrMatrixConvolutionEffect::Make(std::move(inputView),
srcBounds,
fKernelSize,
fKernel,

View File

@ -246,14 +246,14 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
auto context = ctx.getContext();
sk_sp<GrTextureProxy> backgroundProxy, foregroundProxy;
GrSurfaceProxyView backgroundView, foregroundView;
if (background) {
backgroundProxy = background->asTextureProxyRef(context);
backgroundView = background->asSurfaceProxyViewRef(context);
}
if (foreground) {
foregroundProxy = foreground->asTextureProxyRef(context);
foregroundView = foreground->asSurfaceProxyViewRef(context);
}
GrPaint paint;
@ -262,13 +262,14 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
GrSamplerState sampler(GrSamplerState::WrapMode::kClampToBorder,
GrSamplerState::Filter::kNearest);
if (backgroundProxy) {
if (backgroundView.asTextureProxy()) {
SkIRect bgSubset = background->subset();
SkMatrix bgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
bgFP = GrTextureEffect::MakeTexelSubset(std::move(backgroundProxy), background->alphaType(),
bgMatrix, sampler, bgSubset, caps);
bgFP = GrTextureEffect::MakeTexelSubset(backgroundView.detachProxy(),
background->alphaType(), bgMatrix, sampler,
bgSubset, caps);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(),
ctx.colorSpace());
@ -277,12 +278,12 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
GrConstColorProcessor::InputMode::kIgnore);
}
if (foregroundProxy) {
if (foregroundView.asTextureProxy()) {
SkIRect fgSubset = foreground->subset();
SkMatrix fgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
auto fgFP = GrTextureEffect::MakeTexelSubset(std::move(foregroundProxy),
auto fgFP = GrTextureEffect::MakeTexelSubset(foregroundView.detachProxy(),
foreground->alphaType(), fgMatrix, sampler,
fgSubset, caps);
fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP),

View File

@ -1020,8 +1020,8 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
}
SkASSERT(result->isTextureBacked());
sk_sp<GrTextureProxy> proxy = result->asTextureProxyRef(this->context());
if (!proxy) {
GrSurfaceProxyView view = result->asSurfaceProxyViewRef(this->context());
if (!view.proxy()) {
return;
}
@ -1035,7 +1035,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
tmpUnfiltered.setImageFilter(nullptr);
auto fp = GrTextureEffect::Make(std::move(proxy), special->alphaType());
auto fp = GrTextureEffect::Make(view.detachProxy(), special->alphaType());
fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorInfo().colorSpace());
if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) {

View File

@ -143,7 +143,7 @@ void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdma
fDomain.setData(pdman, conv.domain(), view, conv.textureSampler(0).samplerState());
}
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrSurfaceProxy> srcProxy,
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrSurfaceProxyView srcView,
const SkIRect& srcBounds,
const SkISize& kernelSize,
const SkScalar* kernel,
@ -155,10 +155,10 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrSurfaceProxy> srcPr
// To advertise either the modulation or opaqueness optimizations we'd have to examine the
// parameters.
: INHERITED(kGrMatrixConvolutionEffect_ClassID, kNone_OptimizationFlags)
, fCoordTransform(srcProxy.get())
, fDomain(srcProxy.get(), GrTextureDomain::MakeTexelDomain(srcBounds, tileMode),
, fCoordTransform(srcView.proxy())
, fDomain(srcView.proxy(), GrTextureDomain::MakeTexelDomain(srcBounds, tileMode),
tileMode, tileMode)
, fTextureSampler(std::move(srcProxy))
, fTextureSampler(std::move(srcView))
, fKernelSize(kernelSize)
, fGain(SkScalarToFloat(gain))
, fBias(SkScalarToFloat(bias) / 255.0f)
@ -308,8 +308,12 @@ std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(
fill_in_2D_gaussian_kernel(kernel, kernelSize.width(), kernelSize.height(), sigmaX, sigmaY);
GrSurfaceOrigin origin = srcProxy->origin();
GrSwizzle swizzle = srcProxy->textureSwizzle();
GrSurfaceProxyView view(std::move(srcProxy), origin, swizzle);
return std::unique_ptr<GrFragmentProcessor>(
new GrMatrixConvolutionEffect(std::move(srcProxy), srcBounds, kernelSize, kernel,
new GrMatrixConvolutionEffect(std::move(view), srcBounds, kernelSize, kernel,
gain, bias, kernelOffset, tileMode, convolveAlpha));
}
@ -337,7 +341,12 @@ std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrPro
GrTextureDomain::Mode tileMode =
static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2));
bool convolveAlpha = d->fRandom->nextBool();
return GrMatrixConvolutionEffect::Make(std::move(proxy),
GrSurfaceOrigin origin = proxy->origin();
GrSwizzle swizzle = proxy->textureSwizzle();
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
return GrMatrixConvolutionEffect::Make(std::move(view),
bounds,
kernelSize,
kernel.get(),

View File

@ -16,7 +16,7 @@
class GrMatrixConvolutionEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> srcProxy,
static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView srcView,
const SkIRect& srcBounds,
const SkISize& kernelSize,
const SkScalar* kernel,
@ -26,7 +26,7 @@ public:
GrTextureDomain::Mode tileMode,
bool convolveAlpha) {
return std::unique_ptr<GrFragmentProcessor>(
new GrMatrixConvolutionEffect(std::move(srcProxy), srcBounds, kernelSize, kernel,
new GrMatrixConvolutionEffect(std::move(srcView), srcBounds, kernelSize, kernel,
gain, bias, kernelOffset, tileMode, convolveAlpha));
}
@ -57,7 +57,7 @@ public:
private:
// srcProxy is the texture that is going to be convolved
// srcBounds is the subset of 'srcProxy' that will be used (e.g., for clamp mode)
GrMatrixConvolutionEffect(sk_sp<GrSurfaceProxy> srcProxy,
GrMatrixConvolutionEffect(GrSurfaceProxyView srcView,
const SkIRect& srcBounds,
const SkISize& kernelSize,
const SkScalar* kernel,

View File

@ -71,10 +71,10 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked());
//--------------
// Test asTextureProxyRef - as long as there is a context this should succeed
// Test asSurfaceProxyViewRef - as long as there is a context this should succeed
if (context) {
sk_sp<GrTextureProxy> proxy(img->asTextureProxyRef(context));
REPORTER_ASSERT(reporter, proxy);
GrSurfaceProxyView view = img->asSurfaceProxyViewRef(context);
REPORTER_ASSERT(reporter, view.asTextureProxy());
}
//--------------