OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrGLProgram.h" | 8 #include "GrGLProgram.h" |
9 | 9 |
10 #include "GrAllocator.h" | 10 #include "GrAllocator.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 /////////////////////////////////////////////////////////////////////////////// | 65 /////////////////////////////////////////////////////////////////////////////// |
66 | 66 |
67 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
& pipeline) { | 67 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
& pipeline) { |
68 this->setRenderTargetState(primProc, pipeline); | 68 this->setRenderTargetState(primProc, pipeline); |
69 | 69 |
70 // we set the textures, and uniforms for installed processors in a generic w
ay, but subclasses | 70 // we set the textures, and uniforms for installed processors in a generic w
ay, but subclasses |
71 // of GLProgram determine how to set coord transforms | 71 // of GLProgram determine how to set coord transforms |
72 int nextSamplerIdx = 0; | 72 int nextSamplerIdx = 0; |
73 fGeometryProcessor->setData(fProgramDataManager, primProc, | 73 fGeometryProcessor->setData(fProgramDataManager, primProc); |
74 GrFragmentProcessor::CoordTransformIter(pipeline
)); | |
75 this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextSamplerIdx)
; | 74 this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextSamplerIdx)
; |
76 | 75 |
77 this->setFragmentData(primProc, pipeline, &nextSamplerIdx); | 76 this->setFragmentData(primProc, pipeline, &nextSamplerIdx); |
78 | 77 |
79 if (primProc.getPixelLocalStorageState() != | 78 if (primProc.getPixelLocalStorageState() != |
80 GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) { | 79 GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) { |
81 const GrXferProcessor& xp = pipeline.getXferProcessor(); | 80 const GrXferProcessor& xp = pipeline.getXferProcessor(); |
82 fXferProcessor->setData(fProgramDataManager, xp); | 81 fXferProcessor->setData(fProgramDataManager, xp); |
83 this->bindTextures(xp, pipeline.getAllowSRGBInputs(), &nextSamplerIdx); | 82 this->bindTextures(xp, pipeline.getAllowSRGBInputs(), &nextSamplerIdx); |
84 } | 83 } |
(...skipping 16 matching lines...) Expand all Loading... |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, | 103 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, |
105 const GrPipeline& pipeline, | 104 const GrPipeline& pipeline, |
106 int* nextSamplerIdx) { | 105 int* nextSamplerIdx) { |
107 int numProcessors = fFragmentProcessors.count(); | 106 int numProcessors = fFragmentProcessors.count(); |
108 for (int i = 0; i < numProcessors; ++i) { | 107 for (int i = 0; i < numProcessors; ++i) { |
109 const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); | 108 const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); |
110 fFragmentProcessors[i]->setData(fProgramDataManager, processor); | 109 fFragmentProcessors[i]->setData(fProgramDataManager, processor); |
| 110 this->setTransformData(primProc, processor, i); |
111 this->bindTextures(processor, pipeline.getAllowSRGBInputs(), nextSampler
Idx); | 111 this->bindTextures(processor, pipeline.getAllowSRGBInputs(), nextSampler
Idx); |
112 } | 112 } |
113 } | 113 } |
114 | 114 void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc, |
| 115 const GrFragmentProcessor& processor, |
| 116 int index) { |
| 117 fGeometryProcessor->setTransformData(primProc, fProgramDataManager, index, |
| 118 processor.coordTransforms()); |
| 119 } |
115 | 120 |
116 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, | 121 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, |
117 const GrPipeline& pipeline) { | 122 const GrPipeline& pipeline) { |
118 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. | 123 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. |
119 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && | 124 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && |
120 fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget
()->height()) { | 125 fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget
()->height()) { |
121 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, | 126 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, |
122 SkIntToScalar(pipeline.getRenderTarget()->hei
ght())); | 127 SkIntToScalar(pipeline.getRenderTarget()->hei
ght())); |
123 } | 128 } |
124 | 129 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 165 } |
161 | 166 |
162 void GrGLProgram::generateMipmaps(const GrProcessor& processor, | 167 void GrGLProgram::generateMipmaps(const GrProcessor& processor, |
163 bool allowSRGBInputs) { | 168 bool allowSRGBInputs) { |
164 for (int i = 0; i < processor.numTextures(); ++i) { | 169 for (int i = 0; i < processor.numTextures(); ++i) { |
165 const GrTextureAccess& access = processor.textureAccess(i); | 170 const GrTextureAccess& access = processor.textureAccess(i); |
166 fGpu->generateMipmaps(access.getParams(), allowSRGBInputs, | 171 fGpu->generateMipmaps(access.getParams(), allowSRGBInputs, |
167 static_cast<GrGLTexture*>(access.getTexture())); | 172 static_cast<GrGLTexture*>(access.getTexture())); |
168 } | 173 } |
169 } | 174 } |
OLD | NEW |