diff options
author | Brian Salomon <bsalomon@google.com> | 2018-07-31 13:53:11 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-31 18:16:11 +0000 |
commit | e782f8472f61a5a553c57fef788ad4405844887b (patch) | |
tree | c987b012c7b7db78ce0764a46c9281c23409eb07 /src/gpu/GrFragmentProcessor.cpp | |
parent | 990ec990a66aab06bfa18aa16a5e3960a4b34118 (diff) |
Remove GrResourceIOProcessor.
Fold its functionality into GrPrimitiveProcessor and GrFragmentProcessor.
Make each have its own TextureSampler nested class. Currently the only
difference is that fragment processors lose the ability to inject their
samplers into the vertex shader. However, this facilitates refactoring
GrPrimitiveProcessor's TextureSampler class such that the textures are
specified separately from the TextureSampler.
Bug: skia:
Change-Id: I1e590187e7a6ae79ee3147155d397fcdcf5e4619
Reviewed-on: https://skia-review.googlesource.com/142814
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrFragmentProcessor.cpp')
-rw-r--r-- | src/gpu/GrFragmentProcessor.cpp | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp index 63dc39c36b..081aff31f8 100644 --- a/src/gpu/GrFragmentProcessor.cpp +++ b/src/gpu/GrFragmentProcessor.cpp @@ -19,10 +19,17 @@ #include "glsl/GrGLSLUniformHandler.h" bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that) const { - if (this->classID() != that.classID() || - !this->hasSameSamplers(that)) { + if (this->classID() != that.classID()) { return false; } + if (this->numTextureSamplers() != that.numTextureSamplers()) { + return false; + } + for (int i = 0; i < this->numTextureSamplers(); ++i) { + if (this->textureSampler(i) != that.textureSampler(i)) { + return false; + } + } if (!this->hasSameTransforms(that)) { return false; } @@ -40,6 +47,13 @@ bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that) const { return true; } +void GrFragmentProcessor::visitProxies(const std::function<void(GrSurfaceProxy*)>& func) { + GrFragmentProcessor::TextureAccessIter iter(this); + while (const TextureSampler* sampler = iter.next()) { + func(sampler->proxy()); + } +} + GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { GrGLSLFragmentProcessor* glFragProc = this->onCreateGLSLInstance(); glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); @@ -49,6 +63,11 @@ GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { return glFragProc; } +const GrFragmentProcessor::TextureSampler& GrFragmentProcessor::textureSampler(int i) const { + SkASSERT(i >= 0 && i < fTextureSamplerCnt); + return this->onTextureSampler(i); +} + void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { fCoordTransforms.push_back(transform); fFlags |= kUsesLocalCoords_Flag; @@ -56,8 +75,10 @@ void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { } bool GrFragmentProcessor::instantiate(GrResourceProvider* resourceProvider) const { - if (!INHERITED::instantiate(resourceProvider)) { - return false; + for (int i = 0; i < fTextureSamplerCnt; ++i) { + if (!this->textureSampler(i).instantiate(resourceProvider)) { + return false; + } } for (int i = 0; i < this->numChildProcessors(); ++i) { @@ -70,8 +91,11 @@ bool GrFragmentProcessor::instantiate(GrResourceProvider* resourceProvider) cons } void GrFragmentProcessor::markPendingExecution() const { - INHERITED::addPendingIOs(); - INHERITED::removeRefs(); + for (int i = 0; i < fTextureSamplerCnt; ++i) { + auto* proxy = this->textureSampler(i).programProxy(); + proxy->markPendingIO(); + proxy->removeRef(); + } for (int i = 0; i < this->numChildProcessors(); ++i) { this->childProcessor(i).markPendingExecution(); } @@ -499,3 +523,30 @@ const GrFragmentProcessor* GrFragmentProcessor::Iter::next() { return back; } +/////////////////////////////////////////////////////////////////////////////////////////////////// + +GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrTextureProxy> proxy, + const GrSamplerState& samplerState) { + 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) { + fProxyRef.setProxy(std::move(proxy), kRead_GrIOType); + fSamplerState = samplerState; + fSamplerState.setFilterMode(SkTMin(samplerState.filter(), this->proxy()->highestFilterMode())); +} + +void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy, + GrSamplerState::Filter filterMode, + GrSamplerState::WrapMode wrapXAndY) { + fProxyRef.setProxy(std::move(proxy), kRead_GrIOType); + filterMode = SkTMin(filterMode, this->proxy()->highestFilterMode()); + fSamplerState = GrSamplerState(wrapXAndY, filterMode); +} |