Slim down GrFragmentProcessor::TextureSampler and GrPrimitiveProcessor::TextureSampler
I'm gearing up to add a GrBackendFormat to GrPrimitiveProcessor::TextureSampler so this CL just reduces the API surface area I'll need to alter.
The GrFragmentProcess::TextureSampler changes just keep it aligned with its "twin".
Change-Id: Ia9ece03ca76b4f6c8ebdaf0e0ba0061ecde6c5f4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248558
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 2e6b1a1..1e1f2e4 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -423,23 +423,9 @@
this->reset(std::move(proxy), samplerState);
}
-GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrTextureProxy> proxy,
- GrSamplerState::Filter filterMode,
- GrSamplerState::WrapMode wrapXAndY) {
- this->reset(std::move(proxy), filterMode, wrapXAndY);
-}
-
void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
const GrSamplerState& samplerState) {
fProxy = std::move(proxy);
fSamplerState = samplerState;
fSamplerState.setFilterMode(SkTMin(samplerState.filter(), this->proxy()->highestFilterMode()));
}
-
-void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
- GrSamplerState::Filter filterMode,
- GrSamplerState::WrapMode wrapXAndY) {
- fProxy = std::move(proxy);
- filterMode = SkTMin(filterMode, this->proxy()->highestFilterMode());
- fSamplerState = GrSamplerState(wrapXAndY, filterMode);
-}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index b9035ff..45d9a85 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -424,26 +424,17 @@
TextureSampler() = default;
/**
- * This copy constructor is used by GrFragmentProcessor::clone() implementations. The copy
- * always takes a new ref on the texture proxy as the new fragment processor will not yet be
- * in pending execution state.
+ * This copy constructor is used by GrFragmentProcessor::clone() implementations.
*/
explicit TextureSampler(const TextureSampler& that)
: fProxy(that.fProxy)
, fSamplerState(that.fSamplerState) {}
- TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState&);
-
- explicit TextureSampler(sk_sp<GrTextureProxy>,
- GrSamplerState::Filter = GrSamplerState::Filter::kNearest,
- GrSamplerState::WrapMode wrapXAndY = GrSamplerState::WrapMode::kClamp);
+ TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState& = GrSamplerState::ClampNearest());
TextureSampler& operator=(const TextureSampler&) = delete;
void reset(sk_sp<GrTextureProxy>, const GrSamplerState&);
- void reset(sk_sp<GrTextureProxy>,
- GrSamplerState::Filter = GrSamplerState::Filter::kNearest,
- GrSamplerState::WrapMode wrapXAndY = GrSamplerState::WrapMode::kClamp);
bool operator==(const TextureSampler& that) const {
return this->proxy()->underlyingUniqueID() == that.proxy()->underlyingUniqueID() &&
diff --git a/src/gpu/GrPrimitiveProcessor.cpp b/src/gpu/GrPrimitiveProcessor.cpp
index 70a812b..fea8e2d 100644
--- a/src/gpu/GrPrimitiveProcessor.cpp
+++ b/src/gpu/GrPrimitiveProcessor.cpp
@@ -60,13 +60,6 @@
this->reset(textureType, samplerState, swizzle, extraSamplerKey);
}
-GrPrimitiveProcessor::TextureSampler::TextureSampler(GrTextureType textureType,
- GrSamplerState::Filter filterMode,
- GrSamplerState::WrapMode wrapXAndY,
- const GrSwizzle& swizzle) {
- this->reset(textureType, filterMode, wrapXAndY, swizzle);
-}
-
void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
const GrSamplerState& samplerState,
const GrSwizzle& swizzle,
@@ -79,13 +72,3 @@
fIsInitialized = true;
}
-void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
- GrSamplerState::Filter filterMode,
- GrSamplerState::WrapMode wrapXAndY,
- const GrSwizzle& swizzle) {
- filterMode = clamp_filter(textureType, filterMode);
- fSamplerState = GrSamplerState(wrapXAndY, filterMode);
- fSwizzle = swizzle;
- fTextureType = textureType;
- fIsInitialized = true;
-}
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index 44e9fcf..41f37a3 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -246,29 +246,23 @@
//////////////////////////////////////////////////////////////////////////////
/**
- * Used to represent a texture that is required by a GrPrimitiveProcessor. It holds a GrTextureProxy
- * along with an associated GrSamplerState. TextureSamplers don't perform any coord manipulation to
- * account for texture origin.
+ * Used to capture the properties of the GrTextureProxies required/expected by a primitiveProcessor
+ * along with an associated GrSamplerState. The actual proxies used are stored in either the
+ * fixed or dynamic state arrays. TextureSamplers don't perform any coord manipulation to account
+ * for texture origin.
*/
class GrPrimitiveProcessor::TextureSampler {
public:
TextureSampler() = default;
TextureSampler(GrTextureType, const GrSamplerState&, const GrSwizzle&,
- uint32_t extraSamplerKey);
-
- explicit TextureSampler(GrTextureType, GrSamplerState::Filter,
- GrSamplerState::WrapMode wrapXAndY, const GrSwizzle&);
+ uint32_t extraSamplerKey = 0);
TextureSampler(const TextureSampler&) = delete;
TextureSampler& operator=(const TextureSampler&) = delete;
void reset(GrTextureType, const GrSamplerState&, const GrSwizzle&,
uint32_t extraSamplerKey = 0);
- void reset(GrTextureType,
- GrSamplerState::Filter,
- GrSamplerState::WrapMode wrapXAndY,
- const GrSwizzle& swizzle);
GrTextureType textureType() const { return fTextureType; }
diff --git a/src/gpu/ccpr/GrCCClipProcessor.cpp b/src/gpu/ccpr/GrCCClipProcessor.cpp
index 73537e6..75535dd 100644
--- a/src/gpu/ccpr/GrCCClipProcessor.cpp
+++ b/src/gpu/ccpr/GrCCClipProcessor.cpp
@@ -20,8 +20,7 @@
, fClipPath(clipPath)
, fIsCoverageCount(IsCoverageCount::kYes == isCoverageCount)
, fMustCheckBounds(MustCheckBounds::kYes == mustCheckBounds)
- , fAtlasAccess(sk_ref_sp(fClipPath->atlasLazyProxy()), GrSamplerState::Filter::kNearest,
- GrSamplerState::WrapMode::kClamp) {
+ , fAtlasAccess(sk_ref_sp(fClipPath->atlasLazyProxy()), GrSamplerState::ClampNearest()) {
SkASSERT(fAtlasAccess.proxy());
this->setTextureSamplerCnt(1);
}
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index dd6bcae..9fba60d 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -84,8 +84,8 @@
const SkMatrix& viewMatrixIfUsingLocalCoords)
: INHERITED(kGrCCPathProcessor_ClassID)
, fCoverageMode(coverageMode)
- , fAtlasAccess(atlasTexture->texturePriv().textureType(), GrSamplerState::Filter::kNearest,
- GrSamplerState::WrapMode::kClamp, swizzle)
+ , fAtlasAccess(atlasTexture->texturePriv().textureType(), GrSamplerState::ClampNearest(),
+ swizzle)
, fAtlasSize(SkISize::Make(atlasTexture->width(), atlasTexture->height()))
, fAtlasOrigin(atlasOrigin) {
// TODO: Can we just assert that atlas has GrCCAtlas::kTextureOrigin and remove fAtlasOrigin?
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 120f85e..fc9b0e0 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -144,8 +144,7 @@
format, GrRenderable::kYes, 1, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin,
kAlpha_half_GrPixelConfig, *proxyProvider->caps(),
GrSurfaceProxy::UseAllocator::kYes);
- fAccess.reset(fLazyProxy, GrSamplerState::Filter::kNearest,
- GrSamplerState::WrapMode::kClamp);
+ fAccess.reset(fLazyProxy, GrSamplerState::ClampNearest());
this->setTextureSamplerCnt(1);
}