From e782f8472f61a5a553c57fef788ad4405844887b Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Tue, 31 Jul 2018 13:53:11 -0400 Subject: 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 Reviewed-by: Robert Phillips --- src/gpu/GrPrimitiveProcessor.cpp | 68 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'src/gpu/GrPrimitiveProcessor.cpp') diff --git a/src/gpu/GrPrimitiveProcessor.cpp b/src/gpu/GrPrimitiveProcessor.cpp index db79fb1052..10b13370f4 100644 --- a/src/gpu/GrPrimitiveProcessor.cpp +++ b/src/gpu/GrPrimitiveProcessor.cpp @@ -17,7 +17,12 @@ enum MatrixType { kGeneral_MatrixType = 1, }; -GrPrimitiveProcessor::GrPrimitiveProcessor(ClassID classID) : GrResourceIOProcessor(classID) {} +GrPrimitiveProcessor::GrPrimitiveProcessor(ClassID classID) : GrProcessor(classID) {} + +const GrPrimitiveProcessor::TextureSampler& GrPrimitiveProcessor::textureSampler(int i) const { + SkASSERT(i >= 0 && i < this->numTextureSamplers()); + return this->onTextureSampler(i); +} const GrPrimitiveProcessor::Attribute& GrPrimitiveProcessor::vertexAttribute(int i) const { SkASSERT(i >= 0 && i < this->numVertexAttributes()); @@ -69,6 +74,33 @@ size_t GrPrimitiveProcessor::debugOnly_instanceAttributeOffset(int i) const { } #endif +void GrPrimitiveProcessor::addPendingIOs() const { + for (int i = 0; i < fTextureSamplerCnt; ++i) { + this->textureSampler(i).programProxy()->markPendingIO(); + } +} + +void GrPrimitiveProcessor::removeRefs() const { + for (int i = 0; i < fTextureSamplerCnt; ++i) { + this->textureSampler(i).programProxy()->removeRef(); + } +} + +void GrPrimitiveProcessor::pendingIOComplete() const { + for (int i = 0; i < fTextureSamplerCnt; ++i) { + this->textureSampler(i).programProxy()->pendingIOComplete(); + } +} + +bool GrPrimitiveProcessor::instantiate(GrResourceProvider* resourceProvider) const { + for (int i = 0; i < fTextureSamplerCnt; ++i) { + if (!this->textureSampler(i).instantiate(resourceProvider)) { + return false; + } + } + return true; +} + uint32_t GrPrimitiveProcessor::getTransformKey(const SkTArray& coords, int numCoords) const { @@ -87,3 +119,37 @@ GrPrimitiveProcessor::getTransformKey(const SkTArray proxy, + const GrSamplerState& samplerState, + GrShaderFlags visibility) { + this->reset(std::move(proxy), samplerState, visibility); +} + +GrPrimitiveProcessor::TextureSampler::TextureSampler(sk_sp proxy, + GrSamplerState::Filter filterMode, + GrSamplerState::WrapMode wrapXAndY, + GrShaderFlags visibility) { + this->reset(std::move(proxy), filterMode, wrapXAndY, visibility); +} + +void GrPrimitiveProcessor::TextureSampler::reset(sk_sp proxy, + const GrSamplerState& samplerState, + GrShaderFlags visibility) { + fProxyRef.setProxy(std::move(proxy), kRead_GrIOType); + fSamplerState = samplerState; + fSamplerState.setFilterMode(SkTMin(samplerState.filter(), this->proxy()->highestFilterMode())); + fVisibility = visibility; +} + +void GrPrimitiveProcessor::TextureSampler::reset(sk_sp proxy, + GrSamplerState::Filter filterMode, + GrSamplerState::WrapMode wrapXAndY, + GrShaderFlags visibility) { + fProxyRef.setProxy(std::move(proxy), kRead_GrIOType); + filterMode = SkTMin(filterMode, this->proxy()->highestFilterMode()); + fSamplerState = GrSamplerState(wrapXAndY, filterMode); + fVisibility = visibility; +} -- cgit v1.2.3