| Index: src/gpu/gl/GrGLProgram.cpp
|
| diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
|
| index aa828a24c429ff2831df1fdf51510dd8f1aac910..22c045069a3b43eb6d7b7bd0e2387ef6c9af4d3e 100644
|
| --- a/src/gpu/gl/GrGLProgram.cpp
|
| +++ b/src/gpu/gl/GrGLProgram.cpp
|
| @@ -11,6 +11,7 @@
|
| #include "GrProcessor.h"
|
| #include "GrCoordTransform.h"
|
| #include "GrGLGpu.h"
|
| +#include "GrGLBuffer.h"
|
| #include "GrGLPathRendering.h"
|
| #include "GrPathProcessor.h"
|
| #include "GrPipeline.h"
|
| @@ -66,46 +67,37 @@ void GrGLProgram::abandon() {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -static void append_texture_bindings(const GrProcessor& processor,
|
| - SkTArray<const GrTextureAccess*>* textureBindings) {
|
| - if (int numTextures = processor.numTextures()) {
|
| - const GrTextureAccess** bindings = textureBindings->push_back_n(numTextures);
|
| - int i = 0;
|
| - do {
|
| - bindings[i] = &processor.textureAccess(i);
|
| - } while (++i < numTextures);
|
| - }
|
| -}
|
| -
|
| void GrGLProgram::setData(const GrPrimitiveProcessor& primProc,
|
| const GrPipeline& pipeline,
|
| - SkTArray<const GrTextureAccess*>* textureBindings) {
|
| + bool allowSRGBInputs) {
|
| this->setRenderTargetState(primProc, pipeline);
|
|
|
| // we set the textures, and uniforms for installed processors in a generic way, but subclasses
|
| // of GLProgram determine how to set coord transforms
|
| + int nextSamplerIdx = 0;
|
| fGeometryProcessor->setData(fProgramDataManager, primProc);
|
| - append_texture_bindings(primProc, textureBindings);
|
| + this->bindTextures(primProc, allowSRGBInputs, &nextSamplerIdx);
|
|
|
| - this->setFragmentData(primProc, pipeline, textureBindings);
|
| + this->setFragmentData(primProc, pipeline, allowSRGBInputs, &nextSamplerIdx);
|
|
|
| if (primProc.getPixelLocalStorageState() !=
|
| GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
|
| const GrXferProcessor& xp = pipeline.getXferProcessor();
|
| fXferProcessor->setData(fProgramDataManager, xp);
|
| - append_texture_bindings(xp, textureBindings);
|
| + this->bindTextures(xp, allowSRGBInputs, &nextSamplerIdx);
|
| }
|
| }
|
|
|
| void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
|
| const GrPipeline& pipeline,
|
| - SkTArray<const GrTextureAccess*>* textureBindings) {
|
| + bool allowSRGBInputs,
|
| + int* nextSamplerIdx) {
|
| int numProcessors = fFragmentProcessors.count();
|
| for (int i = 0; i < numProcessors; ++i) {
|
| const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
|
| fFragmentProcessors[i]->setData(fProgramDataManager, processor);
|
| this->setTransformData(primProc, processor, i);
|
| - append_texture_bindings(processor, textureBindings);
|
| + this->bindTextures(processor, allowSRGBInputs, nextSamplerIdx);
|
| }
|
| }
|
| void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
|
| @@ -145,3 +137,17 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
|
| size, rt->origin());
|
| }
|
| }
|
| +
|
| +void GrGLProgram::bindTextures(const GrProcessor& processor, bool allowSRGBInputs,
|
| + int* nextSamplerIdx) {
|
| + for (int i = 0; i < processor.numTextures(); ++i) {
|
| + const GrTextureAccess& access = processor.textureAccess(i);
|
| + fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(),
|
| + allowSRGBInputs, static_cast<GrGLTexture*>(access.getTexture()));
|
| + }
|
| + for (int i = 0; i < processor.numBuffers(); ++i) {
|
| + const GrBufferAccess& access = processor.bufferAccess(i);
|
| + fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), access.texelConfig(),
|
| + static_cast<GrGLBuffer*>(access.buffer()));
|
| + }
|
| +}
|
|
|