diff options
author | Brian Salomon <bsalomon@google.com> | 2018-07-30 14:48:15 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-30 19:40:03 +0000 |
commit | f7dcd76c552a4e93a75a3808289de69a997da169 (patch) | |
tree | 29fe08e9681f29e3d3d2af8e721ecfba6dd09beb /src/gpu/GrProcessor.h | |
parent | 7226c232d73356a37ec8cfef0ed55147e68dd2fd (diff) |
Remove array of TextureSampler pointers from GrIOResourceProcessor.
Instead store sampler count on base class and subclasses implement a
virtual to get the ith sampler.
Change-Id: I13e2447a6467a09761d8615acb4aa360b87b1476
Reviewed-on: https://skia-review.googlesource.com/141563
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrProcessor.h')
-rw-r--r-- | src/gpu/GrProcessor.h | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h index 5d83ce3ddb..586f6d25b9 100644 --- a/src/gpu/GrProcessor.h +++ b/src/gpu/GrProcessor.h @@ -23,8 +23,6 @@ #include "SkString.h" class GrContext; -class GrCoordTransform; -class GrInvariantOutput; class GrResourceProvider; /** @@ -203,24 +201,31 @@ class GrResourceIOProcessor : public GrProcessor { public: class TextureSampler; - int numTextureSamplers() const { return fTextureSamplers.count(); } + int numTextureSamplers() const { return fNumTextureSamplers; } - /** Returns the access pattern for the texture at index. index must be valid according to - numTextureSamplers(). */ - const TextureSampler& textureSampler(int index) const { return *fTextureSamplers[index]; } + /** Gets a TextureSampler which is a combination of a GrTextureProxy and how it is sampled. + * index must be valid according to numTextureSamplers(). */ + const TextureSampler& textureSampler(int index) const { + SkASSERT(index >= 0 && index < fNumTextureSamplers); + return this->onTextureSampler(index); + } bool instantiate(GrResourceProvider* resourceProvider) const; protected: + template <typename... Args> + static const TextureSampler& IthTextureSampler(int i, const TextureSampler& samp0, + const Args&... samps) { + return (0 == i) ? samp0 : IthTextureSampler(i - 1, samps...); + } + inline static const TextureSampler& IthTextureSampler(int i); + GrResourceIOProcessor(ClassID classID) : INHERITED(classID) {} - /** - * Subclasses call these from their constructor to register sampler sources. The processor - * subclass manages the lifetime of the objects (these functions only store pointers). The - * TextureSampler instances are typically member fields of the GrProcessor subclass. These must - * only be called from the constructor because GrProcessors are immutable. - */ - void addTextureSampler(const TextureSampler*); + void setTextureSamplerCnt(int numTextureSamplers) { + SkASSERT(numTextureSamplers >= 0); + fNumTextureSamplers = numTextureSamplers; + } bool hasSameSamplers(const GrResourceIOProcessor&) const; @@ -230,8 +235,9 @@ protected: void pendingIOComplete() const; private: - SkSTArray<4, const TextureSampler*, true> fTextureSamplers; + virtual const TextureSampler& onTextureSampler(int index) const { return IthTextureSampler(0); } + int fNumTextureSamplers = 0; typedef GrProcessor INHERITED; }; @@ -306,4 +312,10 @@ private: GrShaderFlags fVisibility; }; +const GrResourceIOProcessor::TextureSampler& GrResourceIOProcessor::IthTextureSampler(int i) { + SK_ABORT("Illegal texture sampler index"); + static const TextureSampler kBogus; + return kBogus; +} + #endif |