diff options
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); +} |