Skip to content

Commit 7d7aaf4

Browse files
rphilliSkia Commit-Bot
authored andcommitted
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>
1 parent 4cb778e commit 7d7aaf4

File tree

7 files changed

+11
-59
lines changed

7 files changed

+11
-59
lines changed

src/gpu/GrFragmentProcessor.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -423,23 +423,9 @@ GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrTextureProxy> proxy,
423423
this->reset(std::move(proxy), samplerState);
424424
}
425425

426-
GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrTextureProxy> proxy,
427-
GrSamplerState::Filter filterMode,
428-
GrSamplerState::WrapMode wrapXAndY) {
429-
this->reset(std::move(proxy), filterMode, wrapXAndY);
430-
}
431-
432426
void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
433427
const GrSamplerState& samplerState) {
434428
fProxy = std::move(proxy);
435429
fSamplerState = samplerState;
436430
fSamplerState.setFilterMode(SkTMin(samplerState.filter(), this->proxy()->highestFilterMode()));
437431
}
438-
439-
void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
440-
GrSamplerState::Filter filterMode,
441-
GrSamplerState::WrapMode wrapXAndY) {
442-
fProxy = std::move(proxy);
443-
filterMode = SkTMin(filterMode, this->proxy()->highestFilterMode());
444-
fSamplerState = GrSamplerState(wrapXAndY, filterMode);
445-
}

src/gpu/GrFragmentProcessor.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,26 +424,17 @@ class GrFragmentProcessor::TextureSampler {
424424
TextureSampler() = default;
425425

426426
/**
427-
* This copy constructor is used by GrFragmentProcessor::clone() implementations. The copy
428-
* always takes a new ref on the texture proxy as the new fragment processor will not yet be
429-
* in pending execution state.
427+
* This copy constructor is used by GrFragmentProcessor::clone() implementations.
430428
*/
431429
explicit TextureSampler(const TextureSampler& that)
432430
: fProxy(that.fProxy)
433431
, fSamplerState(that.fSamplerState) {}
434432

435-
TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState&);
436-
437-
explicit TextureSampler(sk_sp<GrTextureProxy>,
438-
GrSamplerState::Filter = GrSamplerState::Filter::kNearest,
439-
GrSamplerState::WrapMode wrapXAndY = GrSamplerState::WrapMode::kClamp);
433+
TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState& = GrSamplerState::ClampNearest());
440434

441435
TextureSampler& operator=(const TextureSampler&) = delete;
442436

443437
void reset(sk_sp<GrTextureProxy>, const GrSamplerState&);
444-
void reset(sk_sp<GrTextureProxy>,
445-
GrSamplerState::Filter = GrSamplerState::Filter::kNearest,
446-
GrSamplerState::WrapMode wrapXAndY = GrSamplerState::WrapMode::kClamp);
447438

448439
bool operator==(const TextureSampler& that) const {
449440
return this->proxy()->underlyingUniqueID() == that.proxy()->underlyingUniqueID() &&

src/gpu/GrPrimitiveProcessor.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ GrPrimitiveProcessor::TextureSampler::TextureSampler(GrTextureType textureType,
6060
this->reset(textureType, samplerState, swizzle, extraSamplerKey);
6161
}
6262

63-
GrPrimitiveProcessor::TextureSampler::TextureSampler(GrTextureType textureType,
64-
GrSamplerState::Filter filterMode,
65-
GrSamplerState::WrapMode wrapXAndY,
66-
const GrSwizzle& swizzle) {
67-
this->reset(textureType, filterMode, wrapXAndY, swizzle);
68-
}
69-
7063
void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
7164
const GrSamplerState& samplerState,
7265
const GrSwizzle& swizzle,
@@ -79,13 +72,3 @@ void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
7972
fIsInitialized = true;
8073
}
8174

82-
void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
83-
GrSamplerState::Filter filterMode,
84-
GrSamplerState::WrapMode wrapXAndY,
85-
const GrSwizzle& swizzle) {
86-
filterMode = clamp_filter(textureType, filterMode);
87-
fSamplerState = GrSamplerState(wrapXAndY, filterMode);
88-
fSwizzle = swizzle;
89-
fTextureType = textureType;
90-
fIsInitialized = true;
91-
}

src/gpu/GrPrimitiveProcessor.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,29 +246,23 @@ class GrPrimitiveProcessor : public GrProcessor, public GrNonAtomicRef<GrPrimiti
246246
//////////////////////////////////////////////////////////////////////////////
247247

248248
/**
249-
* Used to represent a texture that is required by a GrPrimitiveProcessor. It holds a GrTextureProxy
250-
* along with an associated GrSamplerState. TextureSamplers don't perform any coord manipulation to
251-
* account for texture origin.
249+
* Used to capture the properties of the GrTextureProxies required/expected by a primitiveProcessor
250+
* along with an associated GrSamplerState. The actual proxies used are stored in either the
251+
* fixed or dynamic state arrays. TextureSamplers don't perform any coord manipulation to account
252+
* for texture origin.
252253
*/
253254
class GrPrimitiveProcessor::TextureSampler {
254255
public:
255256
TextureSampler() = default;
256257

257258
TextureSampler(GrTextureType, const GrSamplerState&, const GrSwizzle&,
258-
uint32_t extraSamplerKey);
259-
260-
explicit TextureSampler(GrTextureType, GrSamplerState::Filter,
261-
GrSamplerState::WrapMode wrapXAndY, const GrSwizzle&);
259+
uint32_t extraSamplerKey = 0);
262260

263261
TextureSampler(const TextureSampler&) = delete;
264262
TextureSampler& operator=(const TextureSampler&) = delete;
265263

266264
void reset(GrTextureType, const GrSamplerState&, const GrSwizzle&,
267265
uint32_t extraSamplerKey = 0);
268-
void reset(GrTextureType,
269-
GrSamplerState::Filter,
270-
GrSamplerState::WrapMode wrapXAndY,
271-
const GrSwizzle& swizzle);
272266

273267
GrTextureType textureType() const { return fTextureType; }
274268

src/gpu/ccpr/GrCCClipProcessor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ GrCCClipProcessor::GrCCClipProcessor(const GrCCClipPath* clipPath, IsCoverageCou
2020
, fClipPath(clipPath)
2121
, fIsCoverageCount(IsCoverageCount::kYes == isCoverageCount)
2222
, fMustCheckBounds(MustCheckBounds::kYes == mustCheckBounds)
23-
, fAtlasAccess(sk_ref_sp(fClipPath->atlasLazyProxy()), GrSamplerState::Filter::kNearest,
24-
GrSamplerState::WrapMode::kClamp) {
23+
, fAtlasAccess(sk_ref_sp(fClipPath->atlasLazyProxy()), GrSamplerState::ClampNearest()) {
2524
SkASSERT(fAtlasAccess.proxy());
2625
this->setTextureSamplerCnt(1);
2726
}

src/gpu/ccpr/GrCCPathProcessor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ GrCCPathProcessor::GrCCPathProcessor(CoverageMode coverageMode, const GrTexture*
8484
const SkMatrix& viewMatrixIfUsingLocalCoords)
8585
: INHERITED(kGrCCPathProcessor_ClassID)
8686
, fCoverageMode(coverageMode)
87-
, fAtlasAccess(atlasTexture->texturePriv().textureType(), GrSamplerState::Filter::kNearest,
88-
GrSamplerState::WrapMode::kClamp, swizzle)
87+
, fAtlasAccess(atlasTexture->texturePriv().textureType(), GrSamplerState::ClampNearest(),
88+
swizzle)
8989
, fAtlasSize(SkISize::Make(atlasTexture->width(), atlasTexture->height()))
9090
, fAtlasOrigin(atlasOrigin) {
9191
// TODO: Can we just assert that atlas has GrCCAtlas::kTextureOrigin and remove fAtlasOrigin?

tests/LazyProxyTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ class LazyProxyTest final : public GrOnFlushCallbackObject {
144144
format, GrRenderable::kYes, 1, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin,
145145
kAlpha_half_GrPixelConfig, *proxyProvider->caps(),
146146
GrSurfaceProxy::UseAllocator::kYes);
147-
fAccess.reset(fLazyProxy, GrSamplerState::Filter::kNearest,
148-
GrSamplerState::WrapMode::kClamp);
147+
fAccess.reset(fLazyProxy, GrSamplerState::ClampNearest());
149148
this->setTextureSamplerCnt(1);
150149
}
151150

0 commit comments

Comments
 (0)