Remove asTextureRef from SkSpecialImage & update effects accordingly (take 2)
This CL also renames SkSpecialImage::asTextureProxy to asTextureProxyRef
This is a reland of: https://skia-review.googlesource.com/c/7995/ (Remove asTextureRef from SkSpecialImage & update effects accordingly)
It should be good to land since https://skia-review.googlesource.com/c/8701/ (Replace SkSpecialImage::makeTightSubset with asImage (take 2)) fixes the Chrome-side issue
Change-Id: I3d88b2b3d23fd69f3fb914a69dacca96cbc038a4
Reviewed-on: https://skia-review.googlesource.com/8450
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 6dde5dd..d123eb5 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -225,6 +225,19 @@
colorDimensions));
}
+ static sk_sp<GrFragmentProcessor> Make(GrContext* context,
+ SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
+ SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
+ sk_sp<GrTextureProxy> displacement, const SkMatrix& offsetMatrix,
+ sk_sp<GrTextureProxy> color,
+ sk_sp<GrColorSpaceXform> colorSpaceXform, const SkISize& colorDimensions) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrDisplacementMapEffect(context, xChannelSelector, yChannelSelector, scale,
+ std::move(displacement),
+ offsetMatrix, std::move(color), std::move(colorSpaceXform),
+ colorDimensions));
+ }
+
virtual ~GrDisplacementMapEffect();
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const {
@@ -253,6 +266,14 @@
GrTexture* color, sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkISize& colorDimensions);
+ GrDisplacementMapEffect(GrContext*,
+ SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
+ SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
+ const SkVector& scale,
+ sk_sp<GrTextureProxy> displacement, const SkMatrix& offsetMatrix,
+ sk_sp<GrTextureProxy> color, sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkISize& colorDimensions);
+
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
GrCoordTransform fDisplacementTransform;
@@ -324,9 +345,9 @@
if (source->isTextureBacked()) {
GrContext* context = source->getContext();
- sk_sp<GrTexture> colorTexture(color->asTextureRef(context));
- sk_sp<GrTexture> displTexture(displ->asTextureRef(context));
- if (!colorTexture || !displTexture) {
+ sk_sp<GrTextureProxy> colorProxy(color->asTextureProxyRef(context));
+ sk_sp<GrTextureProxy> displProxy(displ->asTextureProxyRef(context));
+ if (!colorProxy || !displProxy) {
return nullptr;
}
@@ -337,12 +358,13 @@
colorSpace);
GrPaint paint;
paint.addColorFragmentProcessor(
- GrDisplacementMapEffect::Make(fXChannelSelector,
+ GrDisplacementMapEffect::Make(context,
+ fXChannelSelector,
fYChannelSelector,
scale,
- displTexture.get(),
+ std::move(displProxy),
offsetMatrix,
- colorTexture.get(),
+ std::move(colorProxy),
std::move(colorSpaceXform),
SkISize::Make(color->width(), color->height())));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -508,6 +530,36 @@
this->addTextureSampler(&fColorSampler);
}
+GrDisplacementMapEffect::GrDisplacementMapEffect(
+ GrContext* context,
+ SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
+ SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
+ const SkVector& scale,
+ sk_sp<GrTextureProxy> displacement,
+ const SkMatrix& offsetMatrix,
+ sk_sp<GrTextureProxy> color,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkISize& colorDimensions)
+ : INHERITED(GrPixelConfigIsOpaque(color->config()) ? kPreservesOpaqueInput_OptimizationFlag
+ : kNone_OptimizationFlags)
+ , fDisplacementTransform(context, offsetMatrix, displacement.get(),
+ GrSamplerParams::kNone_FilterMode)
+ , fDisplacementSampler(context->textureProvider(), displacement)
+ , fColorTransform(context, color.get(), GrSamplerParams::kNone_FilterMode)
+ , fDomain(color.get(), GrTextureDomain::MakeTexelDomain(SkIRect::MakeSize(colorDimensions)),
+ GrTextureDomain::kDecal_Mode)
+ , fColorSampler(context->textureProvider(), color)
+ , fColorSpaceXform(std::move(colorSpaceXform))
+ , fXChannelSelector(xChannelSelector)
+ , fYChannelSelector(yChannelSelector)
+ , fScale(scale) {
+ this->initClassID<GrDisplacementMapEffect>();
+ this->addCoordTransform(&fDisplacementTransform);
+ this->addTextureSampler(&fDisplacementSampler);
+ this->addCoordTransform(&fColorTransform);
+ this->addTextureSampler(&fColorSampler);
+}
+
GrDisplacementMapEffect::~GrDisplacementMapEffect() {
}