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/gl/GrGLProgram.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/gl/GrGLProgram.cpp')
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 52d53bde95..a392bc26f0 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -84,9 +84,13 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline int nextTexSamplerIdx = 0; fPrimitiveProcessor->setData(fProgramDataManager, primProc, GrFragmentProcessor::CoordTransformIter(pipeline)); - this->bindTextures(primProc, &nextTexSamplerIdx); + for (int i = 0; i < primProc.numTextureSamplers(); ++i) { + const GrPrimitiveProcessor::TextureSampler& sampler = primProc.textureSampler(i); + fGpu->bindTexture(nextTexSamplerIdx++, sampler.samplerState(), + static_cast<GrGLTexture*>(sampler.peekTexture())); + } - this->setFragmentData(primProc, pipeline, &nextTexSamplerIdx); + this->setFragmentData(pipeline, &nextTexSamplerIdx); const GrXferProcessor& xp = pipeline.getXferProcessor(); SkIPoint offset; @@ -102,31 +106,47 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline void GrGLProgram::generateMipmaps(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { - this->generateMipmaps(primProc); + auto genLevelsIfNeeded = [this](GrTexture* tex, const GrSamplerState& sampler) { + if (sampler.filter() == GrSamplerState::Filter::kMipMap && + tex->texturePriv().mipMapped() == GrMipMapped::kYes && + tex->texturePriv().mipMapsAreDirty()) { + SkASSERT(fGpu->caps()->mipMapSupport()); + fGpu->regenerateMipMapLevels(static_cast<GrGLTexture*>(tex)); + } + }; + + for (int i = 0; i < primProc.numTextureSamplers(); ++i) { + const auto& textureSampler = primProc.textureSampler(i); + genLevelsIfNeeded(textureSampler.peekTexture(), textureSampler.samplerState()); + } GrFragmentProcessor::Iter iter(pipeline); while (const GrFragmentProcessor* fp = iter.next()) { - this->generateMipmaps(*fp); + for (int i = 0; i < fp->numTextureSamplers(); ++i) { + const auto& textureSampler = fp->textureSampler(i); + genLevelsIfNeeded(textureSampler.peekTexture(), textureSampler.samplerState()); + } } } -void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, - const GrPipeline& pipeline, - int* nextTexSamplerIdx) { +void GrGLProgram::setFragmentData(const GrPipeline& pipeline, int* nextTexSamplerIdx) { GrFragmentProcessor::Iter iter(pipeline); GrGLSLFragmentProcessor::Iter glslIter(fFragmentProcessors.get(), fFragmentProcessorCnt); const GrFragmentProcessor* fp = iter.next(); GrGLSLFragmentProcessor* glslFP = glslIter.next(); while (fp && glslFP) { glslFP->setData(fProgramDataManager, *fp); - this->bindTextures(*fp, nextTexSamplerIdx); + for (int i = 0; i < fp->numTextureSamplers(); ++i) { + const GrFragmentProcessor::TextureSampler& sampler = fp->textureSampler(i); + fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(), + static_cast<GrGLTexture*>(sampler.peekTexture())); + } fp = iter.next(); glslFP = glslIter.next(); } SkASSERT(!fp && !glslFP); } - void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, const GrRenderTargetProxy* proxy) { GrRenderTarget* rt = proxy->priv().peekRenderTarget(); @@ -156,25 +176,3 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, size, proxy->origin()); } } - -void GrGLProgram::bindTextures(const GrResourceIOProcessor& processor, - int* nextTexSamplerIdx) { - for (int i = 0; i < processor.numTextureSamplers(); ++i) { - const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i); - fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(), - static_cast<GrGLTexture*>(sampler.peekTexture())); - } -} - -void GrGLProgram::generateMipmaps(const GrResourceIOProcessor& processor) { - for (int i = 0; i < processor.numTextureSamplers(); ++i) { - const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i); - auto* tex = sampler.peekTexture(); - if (sampler.samplerState().filter() == GrSamplerState::Filter::kMipMap && - tex->texturePriv().mipMapped() == GrMipMapped::kYes && - tex->texturePriv().mipMapsAreDirty()) { - SkASSERT(fGpu->caps()->mipMapSupport()); - fGpu->regenerateMipMapLevels(static_cast<GrGLTexture*>(sampler.peekTexture())); - } - } -} |