Reland "Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView."
This reverts commit c5c024791bb7a587223b807e00ffba4a3eb5fdb7.
Reason for revert: Doh
Original change's description:
> Revert "Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView."
>
> This reverts commit acf5929ae0addc5188117142fd3fb39828baa8d5.
>
> Reason for revert: May be blocking Chrome roll
> Original change's description:
> > Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView.
> >
> > In future CLs I will update the Ops that create the TextureSamplers to pass
> > the GrSurfaceProxyView in.
> >
> > Bug: skia:9556
> > Change-Id: I550dab64974d32e4c3047188063efa2d0832328e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259164
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
>
> TBR=egdaniel@google.com,michaelludwig@google.com
>
> Change-Id: Ic804a52c5c6d16a13a9cc2d85bb959f305134177
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:9556
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259433
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
TBR=egdaniel@google.com,robertphillips@google.com,michaelludwig@google.com
Change-Id: If2af5b5b323858e59c0c8db3b75477d74d78abfd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9556
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259434
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 576fac6..9891815 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -254,7 +254,7 @@
std::unique_ptr<GrFragmentProcessor> clone() const override {
return std::unique_ptr<GrFragmentProcessor>(
- new ColorTableEffect(sk_ref_sp(fTextureSampler.proxy())));
+ new ColorTableEffect(sk_ref_sp(fTextureSampler.view().proxy())));
}
private:
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index f18072b..73d6af4 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -648,15 +648,15 @@
void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& proc) {
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
- GrSurfaceProxy* proxy = displacementMap.textureSampler(1).proxy();
- SkISize texDimensions = proxy->backingStoreDimensions();
+ const auto& view = displacementMap.textureSampler(1).view();
+ SkISize texDimensions = view.proxy()->backingStoreDimensions();
SkScalar scaleX = displacementMap.scale().fX / texDimensions.width();
SkScalar scaleY = displacementMap.scale().fY / texDimensions.height();
pdman.set2f(fScaleUni, SkScalarToFloat(scaleX),
- proxy->origin() == kTopLeft_GrSurfaceOrigin ?
+ view.origin() == kTopLeft_GrSurfaceOrigin ?
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
- fGLDomain.setData(pdman, displacementMap.domain(), proxy,
+ fGLDomain.setData(pdman, displacementMap.domain(), view,
displacementMap.textureSampler(1).samplerState());
}
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index e18e7ab..de96aa5 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -1840,15 +1840,15 @@
fLight = lighting.light()->createGLLight();
}
- GrSurfaceProxy* proxy = lighting.textureSampler(0).proxy();
- SkISize textureDims = proxy->backingStoreDimensions();
+ const GrSurfaceProxyView& view = lighting.textureSampler(0).view();
+ SkISize textureDims = view.proxy()->backingStoreDimensions();
- float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
+ float ySign = view.origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
pdman.set2f(fImageIncrementUni, 1.0f / textureDims.width(), ySign / textureDims.height());
pdman.set1f(fSurfaceScaleUni, lighting.surfaceScale());
sk_sp<SkImageFilterLight> transformedLight(
lighting.light()->transform(lighting.filterMatrix()));
- fDomain.setData(pdman, lighting.domain(), proxy, lighting.textureSampler(0).samplerState());
+ fDomain.setData(pdman, lighting.domain(), view, lighting.textureSampler(0).samplerState());
fLight->setData(pdman, transformedLight.get());
}
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index b039089..79b5559 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -363,7 +363,8 @@
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& proc) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
- GrSurfaceProxy* proxy = m.textureSampler(0).proxy();
+ const auto& view = m.textureSampler(0).view();
+ GrSurfaceProxy* proxy = view.proxy();
GrTexture& texture = *proxy->peekTexture();
float pixelSize = 0.0f;
@@ -382,7 +383,7 @@
if (m.useRange()) {
const float* range = m.range();
if (MorphDirection::kY == m.direction() &&
- proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
+ view.origin() == kBottomLeft_GrSurfaceOrigin) {
pdman.set2f(fRangeUni, 1.0f - (range[1]*pixelSize), 1.0f - (range[0]*pixelSize));
} else {
pdman.set2f(fRangeUni, range[0] * pixelSize, range[1] * pixelSize);
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index b836be4..6760aa7 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -50,7 +50,7 @@
void GrFragmentProcessor::visitProxies(const GrOp::VisitProxyFunc& func) {
for (auto [sampler, fp] : FPTextureSamplerRange(*this)) {
bool mipped = (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter());
- func(sampler.proxy(), GrMipMapped(mipped));
+ func(sampler.view().proxy(), GrMipMapped(mipped));
}
}
@@ -412,17 +412,39 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrSurfaceProxy> proxy,
- const GrSamplerState& samplerState) {
- this->reset(std::move(proxy), samplerState);
-}
-
-void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrSurfaceProxy> proxy,
- const GrSamplerState& samplerState) {
- SkASSERT(proxy->asTextureProxy());
- fProxy = std::move(proxy);
- fSamplerState = samplerState;
+GrFragmentProcessor::TextureSampler::TextureSampler(GrSurfaceProxyView view,
+ const GrSamplerState& samplerState)
+ : fView(std::move(view))
+ , fSamplerState(samplerState) {
+ GrSurfaceProxy* proxy = this->proxy();
fSamplerState.setFilterMode(
SkTMin(samplerState.filter(),
- GrTextureProxy::HighestFilterMode(fProxy->backendFormat().textureType())));
+ GrTextureProxy::HighestFilterMode(proxy->backendFormat().textureType())));
}
+
+GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrSurfaceProxy> proxy,
+ const GrSamplerState& samplerState) {
+ SkASSERT(proxy->asTextureProxy());
+ GrSurfaceOrigin origin = proxy->origin();
+ GrSwizzle swizzle = proxy->textureSwizzle();
+ fView = GrSurfaceProxyView(std::move(proxy), origin, swizzle);
+
+ fSamplerState = samplerState;
+ GrSurfaceProxy* surfProxy = this->proxy();
+ fSamplerState.setFilterMode(
+ SkTMin(samplerState.filter(),
+ GrTextureProxy::HighestFilterMode(surfProxy->backendFormat().textureType())));
+}
+
+#if GR_TEST_UTILS
+void GrFragmentProcessor::TextureSampler::set(GrSurfaceProxyView view,
+ const GrSamplerState& samplerState) {
+ SkASSERT(view.proxy()->asTextureProxy());
+ fView = std::move(view);
+ fSamplerState = samplerState;
+
+ fSamplerState.setFilterMode(
+ SkTMin(samplerState.filter(),
+ GrTextureProxy::HighestFilterMode(this->proxy()->backendFormat().textureType())));
+}
+#endif
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index db6e437..2622dcc 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -476,38 +476,41 @@
* This copy constructor is used by GrFragmentProcessor::clone() implementations.
*/
explicit TextureSampler(const TextureSampler& that)
- : fProxy(that.fProxy)
+ : fView(that.fView)
, fSamplerState(that.fSamplerState) {}
+ TextureSampler(GrSurfaceProxyView, const GrSamplerState& = GrSamplerState::ClampNearest());
+ // TODO: Remove this ctor once all uses have been updated to pass in a GrSurfaceProxyView
TextureSampler(sk_sp<GrSurfaceProxy>, const GrSamplerState& = GrSamplerState::ClampNearest());
TextureSampler& operator=(const TextureSampler&) = delete;
- void reset(sk_sp<GrSurfaceProxy>, const GrSamplerState&);
-
bool operator==(const TextureSampler& that) const {
- return this->proxy()->underlyingUniqueID() == that.proxy()->underlyingUniqueID() &&
- fSamplerState == that.fSamplerState;
+ return fView == that.fView && fSamplerState == that.fSamplerState;
}
bool operator!=(const TextureSampler& other) const { return !(*this == other); }
- SkDEBUGCODE(bool isInstantiated() const { return fProxy->isInstantiated(); })
+ SkDEBUGCODE(bool isInstantiated() const { return this->proxy()->isInstantiated(); })
// 'peekTexture' should only ever be called after a successful 'instantiate' call
GrTexture* peekTexture() const {
- SkASSERT(fProxy->isInstantiated());
- return fProxy->peekTexture();
+ SkASSERT(this->proxy()->isInstantiated());
+ return this->proxy()->peekTexture();
}
- GrSurfaceProxy* proxy() const { return fProxy.get(); }
+ const GrSurfaceProxyView& view() const { return fView; }
const GrSamplerState& samplerState() const { return fSamplerState; }
- const GrSwizzle& swizzle() const { return this->proxy()->textureSwizzle(); }
- bool isInitialized() const { return SkToBool(fProxy.get()); }
+ bool isInitialized() const { return SkToBool(this->proxy()); }
+#if GR_TEST_UTILS
+ void set(GrSurfaceProxyView, const GrSamplerState&);
+#endif
private:
- sk_sp<GrSurfaceProxy> fProxy;
+ GrSurfaceProxy* proxy() const { return fView.proxy(); }
+
+ GrSurfaceProxyView fView;
GrSamplerState fSamplerState;
};
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index f653542..9a44ce4 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -116,7 +116,7 @@
// This iteration includes any clip coverage FPs
for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(*this)) {
bool mipped = (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter());
- func(sampler.proxy(), GrMipMapped(mipped));
+ func(sampler.view().proxy(), GrMipMapped(mipped));
}
if (fDstProxyView.asTextureProxy()) {
func(fDstProxyView.asTextureProxy(), GrMipMapped::kNo);
diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp
index cf75415..054866b 100644
--- a/src/gpu/GrProcessorSet.cpp
+++ b/src/gpu/GrProcessorSet.cpp
@@ -255,6 +255,6 @@
void GrProcessorSet::visitProxies(const GrOp::VisitProxyFunc& func) const {
for (auto [sampler, fp] : GrFragmentProcessor::ProcessorSetTextureSamplerRange(*this)) {
bool mipped = (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter());
- func(sampler.proxy(), GrMipMapped(mipped));
+ func(sampler.view().proxy(), GrMipMapped(mipped));
}
}
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index 38161c6..c1e5cd3 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -64,9 +64,10 @@
}
for (int i = 0; i < numTextureSamplers; ++i) {
const GrFragmentProcessor::TextureSampler& sampler = fp.textureSampler(i);
- const GrBackendFormat& backendFormat = sampler.proxy()->backendFormat();
+ const GrBackendFormat& backendFormat = sampler.view().proxy()->backendFormat();
- uint32_t samplerKey = sampler_key(backendFormat.textureType(), sampler.swizzle(), caps);
+ uint32_t samplerKey = sampler_key(backendFormat.textureType(), sampler.view().swizzle(),
+ caps);
b->add32(samplerKey);
caps.addExtraSamplerKey(b, sampler.samplerState(), backendFormat);
diff --git a/src/gpu/ccpr/GrCCClipProcessor.cpp b/src/gpu/ccpr/GrCCClipProcessor.cpp
index a4656fa..76293e2 100644
--- a/src/gpu/ccpr/GrCCClipProcessor.cpp
+++ b/src/gpu/ccpr/GrCCClipProcessor.cpp
@@ -21,7 +21,7 @@
, fIsCoverageCount(IsCoverageCount::kYes == isCoverageCount)
, fMustCheckBounds(MustCheckBounds::kYes == mustCheckBounds)
, fAtlasAccess(sk_ref_sp(fClipPath->atlasLazyProxy())) {
- SkASSERT(fAtlasAccess.proxy());
+ SkASSERT(fAtlasAccess.view().proxy());
this->setTextureSamplerCnt(1);
}
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 973ef45..9235bd3 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -145,8 +145,8 @@
void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) {
const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
- GrSurfaceProxy* proxy = processor.textureSampler(0).proxy();
- SkISize textureDims = proxy->backingStoreDimensions();
+ const auto& view = processor.textureSampler(0).view();
+ SkISize textureDims = view.proxy()->backingStoreDimensions();
float dims[4] = {0, 0, 0, 0};
if (bicubicEffect.direction() != GrBicubicEffect::Direction::kY) {
@@ -158,7 +158,7 @@
dims[3] = textureDims.height();
}
pdman.set4fv(fDimensions, 1, dims);
- fDomain.setData(pdman, bicubicEffect.domain(), proxy,
+ fDomain.setData(pdman, bicubicEffect.domain(), view,
processor.textureSampler(0).samplerState());
}
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index 4228a03..a710b2d 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -253,8 +253,6 @@
if (!blurProfile) {
return nullptr;
}
-
- SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index cc6b8d2..80bc165 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -123,11 +123,12 @@
const GrFragmentProcessor& processor) {
const GrGaussianConvolutionFragmentProcessor& conv =
processor.cast<GrGaussianConvolutionFragmentProcessor>();
- GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
+ const auto& view = conv.textureSampler(0).view();
+ GrSurfaceProxy* proxy = view.proxy();
GrTexture& texture = *proxy->peekTexture();
float imageIncrement[2] = {0};
- float ySign = proxy->origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
+ float ySign = view.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
switch (conv.direction()) {
case Direction::kX:
imageIncrement[0] = 1.0f / texture.width();
@@ -153,7 +154,7 @@
bounds[1] *= inv;
} else {
SkScalar inv = SkScalarInvert(SkIntToScalar(texture.height()));
- if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
+ if (view.origin() != kTopLeft_GrSurfaceOrigin) {
float tmp = bounds[0];
bounds[0] = 1.0f - (inv * bounds[1]);
bounds[1] = 1.0f - (inv * tmp);
diff --git a/src/gpu/effects/GrMagnifierEffect.fp b/src/gpu/effects/GrMagnifierEffect.fp
index e6a9aa2..fba7807 100644
--- a/src/gpu/effects/GrMagnifierEffect.fp
+++ b/src/gpu/effects/GrMagnifierEffect.fp
@@ -47,7 +47,7 @@
{
SkScalar y = srcRect.y() * invH;
- if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ if (srcView.origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - (srcRect.height() / bounds.height()) - y;
}
@@ -57,7 +57,7 @@
{
SkScalar y = bounds.y() * invH;
SkScalar hSign = 1.f;
- if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ if (srcView.origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - bounds.y() * invH;
hSign = -1.f;
}
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 1f70a53..12decaf 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -125,11 +125,11 @@
void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) {
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
- GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
- SkISize textureDims = proxy->backingStoreDimensions();
+ const auto& view = conv.textureSampler(0).view();
+ SkISize textureDims = view.proxy()->backingStoreDimensions();
float imageIncrement[2];
- float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
+ float ySign = view.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / textureDims.width();
imageIncrement[1] = ySign / textureDims.height();
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
@@ -140,7 +140,7 @@
pdman.set4fv(fKernelUni, arrayCount, conv.kernel());
pdman.set1f(fGainUni, conv.gain());
pdman.set1f(fBiasUni, conv.bias());
- fDomain.setData(pdman, conv.domain(), proxy, conv.textureSampler(0).samplerState());
+ fDomain.setData(pdman, conv.domain(), view, conv.textureSampler(0).samplerState());
}
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrSurfaceProxy> srcProxy,
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index a61ac18..d090cbd 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -222,22 +222,24 @@
void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
const GrTextureDomain& textureDomain,
- const GrSurfaceProxy* proxy,
+ const GrSurfaceProxyView& view,
const GrSamplerState& state) {
// We want a hard transition from texture content to trans-black in nearest mode.
bool filterDecal = state.filter() != GrSamplerState::Filter::kNearest;
- this->setData(pdman, textureDomain, proxy, filterDecal);
+ this->setData(pdman, textureDomain, view.proxy(), view.origin(), filterDecal);
}
void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
const GrTextureDomain& textureDomain,
bool filterIfDecal) {
- this->setData(pdman, textureDomain, nullptr, filterIfDecal);
+ // The origin we pass here doesn't matter
+ this->setData(pdman, textureDomain, nullptr, kTopLeft_GrSurfaceOrigin, filterIfDecal);
}
void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
const GrTextureDomain& textureDomain,
const GrSurfaceProxy* proxy,
+ GrSurfaceOrigin origin,
bool filterIfDecal) {
SkASSERT(fHasMode && textureDomain.modeX() == fModeX && textureDomain.modeY() == fModeY);
if (kIgnore_Mode == textureDomain.modeX() && kIgnore_Mode == textureDomain.modeY()) {
@@ -290,7 +292,7 @@
}
// vertical flip if necessary
- if (kBottomLeft_GrSurfaceOrigin == proxy->origin()) {
+ if (kBottomLeft_GrSurfaceOrigin == origin) {
tempDomainValues[1] = h - tempDomainValues[1];
tempDomainValues[3] = h - tempDomainValues[3];
@@ -438,7 +440,11 @@
const GrFragmentProcessor& fp) override {
const GrDomainEffect& de = fp.cast<GrDomainEffect>();
const GrTextureDomain& domain = de.fDomain;
- fGLDomain.setData(pdman, domain, de.fCoordTransform.proxy(), de.fDecalIsFiltered);
+ // TODO: Update GrCoordTransform to return a view instead of proxy
+ const GrSurfaceProxy* proxy = de.fCoordTransform.proxy();
+ // If we don't have a proxy the value of the origin doesn't matter
+ GrSurfaceOrigin origin = proxy ? proxy->origin() : kTopLeft_GrSurfaceOrigin;
+ fGLDomain.setData(pdman, domain, proxy, origin, de.fDecalIsFiltered);
}
private:
@@ -559,10 +565,10 @@
const GrFragmentProcessor& fp) override {
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
- GrSurfaceProxy* proxy = dstdfp.textureSampler(0).proxy();
- SkISize textureDims = proxy->backingStoreDimensions();
+ const auto& view = dstdfp.textureSampler(0).view();
+ SkISize textureDims = view.proxy()->backingStoreDimensions();
- fGLDomain.setData(pdman, dstdfp.fTextureDomain, proxy,
+ fGLDomain.setData(pdman, dstdfp.fTextureDomain, view,
dstdfp.textureSampler(0).samplerState());
float iw = 1.f / textureDims.width();
float ih = 1.f / textureDims.height();
@@ -570,7 +576,7 @@
iw, ih,
-dstdfp.fDeviceSpaceOffset.fX * iw, -dstdfp.fDeviceSpaceOffset.fY * ih
};
- if (proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
+ if (view.origin() == kBottomLeft_GrSurfaceOrigin) {
scaleAndTransData[1] = -scaleAndTransData[1];
scaleAndTransData[3] = 1 - scaleAndTransData[3];
}
@@ -588,8 +594,8 @@
bool GrDeviceSpaceTextureDecalFragmentProcessor::onIsEqual(const GrFragmentProcessor& fp) const {
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
- return dstdfp.fTextureSampler.proxy()->underlyingUniqueID() ==
- fTextureSampler.proxy()->underlyingUniqueID() &&
+ return dstdfp.fTextureSampler.view().proxy()->underlyingUniqueID() ==
+ fTextureSampler.view().proxy()->underlyingUniqueID() &&
dstdfp.fDeviceSpaceOffset == fDeviceSpaceOffset &&
dstdfp.fTextureDomain == fTextureDomain;
}
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 53f3fcb..88e6555 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -178,11 +178,11 @@
* account for the texture's origin. Filtering at the edge of the domain is inferred from
* the GrSamplerState's filter mode.
*/
- void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, const GrSurfaceProxy*,
- const GrSamplerState& state);
+ void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&,
+ const GrSurfaceProxyView&, const GrSamplerState& state);
/** Same as above but with direct control over decal filtering. */
void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, const GrSurfaceProxy*,
- bool filterIfDecal);
+ GrSurfaceOrigin, bool filterIfDecal);
enum {
kModeBits = 3, // See DomainKey().
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp
index 8af97f1..4d2d732 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -100,8 +100,8 @@
SkString str;
for (int i = 0; i < this->numTextureSamplers(); ++i) {
str.appendf("%d: %d %d ", i,
- this->textureSampler(i).proxy()->uniqueID().asUInt(),
- this->textureSampler(i).proxy()->underlyingUniqueID().asUInt());
+ this->textureSampler(i).view().proxy()->uniqueID().asUInt(),
+ this->textureSampler(i).view().proxy()->underlyingUniqueID().asUInt());
}
str.appendf("\n");
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index 3d5a925..863e88f 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -230,8 +230,6 @@
if (!blurProfile) {
return nullptr;
}
-
- SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
proxyProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
@@ -300,8 +298,8 @@
(void)textureRadius;
auto solidRadius = _outer.solidRadius;
(void)solidRadius;
- GrSurfaceProxy& blurProfileSamplerProxy = *_outer.textureSampler(0).proxy();
- GrTexture& blurProfileSampler = *blurProfileSamplerProxy.peekTexture();
+ const GrSurfaceProxyView& blurProfileSamplerView = _outer.textureSampler(0).view();
+ GrTexture& blurProfileSampler = *blurProfileSamplerView.proxy()->peekTexture();
(void)blurProfileSampler;
UniformHandle& circleData = circleDataVar;
(void)circleData;
diff --git a/src/gpu/effects/generated/GrMagnifierEffect.cpp b/src/gpu/effects/generated/GrMagnifierEffect.cpp
index 5a29834..a6522b5 100644
--- a/src/gpu/effects/generated/GrMagnifierEffect.cpp
+++ b/src/gpu/effects/generated/GrMagnifierEffect.cpp
@@ -85,8 +85,8 @@
pdman.set1f(xInvInsetVar, (_outer.xInvInset));
pdman.set1f(yInvInsetVar, (_outer.yInvInset));
}
- GrSurfaceProxy& srcProxy = *_outer.textureSampler(0).proxy();
- GrTexture& src = *srcProxy.peekTexture();
+ const GrSurfaceProxyView& srcView = _outer.textureSampler(0).view();
+ GrTexture& src = *srcView.proxy()->peekTexture();
(void)src;
auto bounds = _outer.bounds;
(void)bounds;
@@ -110,7 +110,7 @@
{
SkScalar y = srcRect.y() * invH;
- if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ if (srcView.origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - (srcRect.height() / bounds.height()) - y;
}
@@ -120,7 +120,7 @@
{
SkScalar y = bounds.y() * invH;
SkScalar hSign = 1.f;
- if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
+ if (srcView.origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - bounds.y() * invH;
hSign = -1.f;
}
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.cpp b/src/gpu/effects/generated/GrRRectBlurEffect.cpp
index 35cf1fec..71f50d7 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.cpp
@@ -111,8 +111,8 @@
(void)rect;
UniformHandle& cornerRadius = cornerRadiusVar;
(void)cornerRadius;
- GrSurfaceProxy& ninePatchSamplerProxy = *_outer.textureSampler(0).proxy();
- GrTexture& ninePatchSampler = *ninePatchSamplerProxy.peekTexture();
+ const GrSurfaceProxyView& ninePatchSamplerView = _outer.textureSampler(0).view();
+ GrTexture& ninePatchSampler = *ninePatchSamplerView.proxy()->peekTexture();
(void)ninePatchSampler;
UniformHandle& proxyRect = proxyRectVar;
(void)proxyRect;
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.cpp b/src/gpu/effects/generated/GrRectBlurEffect.cpp
index 7643406..8ba9506 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRectBlurEffect.cpp
@@ -132,8 +132,8 @@
(void)rectF;
UniformHandle& rectH = rectHVar;
(void)rectH;
- GrSurfaceProxy& integralProxy = *_outer.textureSampler(0).proxy();
- GrTexture& integral = *integralProxy.peekTexture();
+ const GrSurfaceProxyView& integralView = _outer.textureSampler(0).view();
+ GrTexture& integral = *integralView.proxy()->peekTexture();
(void)integral;
UniformHandle& invSixSigma = invSixSigmaVar;
(void)invSixSigma;
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 53760e6..23442c5 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -124,7 +124,8 @@
glslIter->setData(fProgramDataManager, *fpIter);
for (int i = 0; i < fpIter->numTextureSamplers(); ++i) {
const GrFragmentProcessor::TextureSampler& sampler = fpIter->textureSampler(i);
- fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(), sampler.swizzle(),
+ fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(),
+ sampler.view().swizzle(),
static_cast<GrGLTexture*>(sampler.peekTexture()));
}
}
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 77f7aee..ffe2ab0 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -190,9 +190,9 @@
SkString name;
name.printf("TextureSampler_%d", samplerIdx++);
const auto& sampler = subFP.textureSampler(i);
- texSamplers.emplace_back(this->emitSampler(sampler.proxy(),
+ texSamplers.emplace_back(this->emitSampler(sampler.view().proxy(),
sampler.samplerState(),
- sampler.swizzle(),
+ sampler.view().swizzle(),
name.c_str()));
}
}
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index f77af09..6de36bf 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -1018,10 +1018,10 @@
String nameString(decl.fVar->fName);
const char* name = nameString.c_str();
if (decl.fVar->fType.kind() == Type::kSampler_Kind) {
- this->writef(" GrSurfaceProxy& %sProxy = "
- "*_outer.textureSampler(%d).proxy();\n",
+ this->writef(" const GrSurfaceProxyView& %sView = "
+ "_outer.textureSampler(%d).view();\n",
name, samplerIndex);
- this->writef(" GrTexture& %s = *%sProxy.peekTexture();\n",
+ this->writef(" GrTexture& %s = *%sView.proxy()->peekTexture();\n",
name, name);
this->writef(" (void) %s;\n", name);
++samplerIndex;
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index fc9b0e0..25499d0d 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -131,9 +131,10 @@
, fProxyProvider(proxyProvider)
, fTest(test)
, fAtlas(atlas) {
+ static const GrColorType kColorType = GrColorType::kAlpha_F16;
+ static const GrSurfaceOrigin kOrigin = kBottomLeft_GrSurfaceOrigin;
const GrBackendFormat format =
- ctx->priv().caps()->getDefaultBackendFormat(GrColorType::kAlpha_F16,
- GrRenderable::kYes);
+ ctx->priv().caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
fLazyProxy = GrProxyProvider::MakeFullyLazyProxy(
[this](GrResourceProvider* rp) -> GrSurfaceProxy::LazyCallbackResult {
REPORTER_ASSERT(fTest->fReporter, !fTest->fHasClipTexture);
@@ -141,10 +142,12 @@
fAtlas->instantiate(rp);
return sk_ref_sp(fAtlas->peekTexture());
},
- format, GrRenderable::kYes, 1, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin,
+ format, GrRenderable::kYes, 1, GrProtected::kNo, kOrigin,
kAlpha_half_GrPixelConfig, *proxyProvider->caps(),
GrSurfaceProxy::UseAllocator::kYes);
- fAccess.reset(fLazyProxy, GrSamplerState::ClampNearest());
+ GrSwizzle swizzle = ctx->priv().caps()->getTextureSwizzle(format, kColorType);
+ fAccess.set(GrSurfaceProxyView(fLazyProxy, kOrigin, swizzle),
+ GrSamplerState::ClampNearest());
this->setTextureSamplerCnt(1);
}