Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 1336763003: remove path specific program building classes (Closed) Base URL: https://skia.googlesource.com/skia.git@pathgp
Patch Set: a few more tidys Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) 24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
26 26
27 //////////////////////////////////////////////////////////////////////////////// /////////////////// 27 //////////////////////////////////////////////////////////////////////////////// ///////////////////
28 28
29 GrGLProgram::GrGLProgram(GrGLGpu* gpu, 29 GrGLProgram::GrGLProgram(GrGLGpu* gpu,
30 const GrProgramDesc& desc, 30 const GrProgramDesc& desc,
31 const BuiltinUniformHandles& builtinUniforms, 31 const BuiltinUniformHandles& builtinUniforms,
32 GrGLuint programID, 32 GrGLuint programID,
33 const UniformInfoArray& uniforms, 33 const UniformInfoArray& uniforms,
34 const SeparableVaryingInfoArray& separableVaryings,
34 GrGLInstalledGeoProc* geometryProcessor, 35 GrGLInstalledGeoProc* geometryProcessor,
35 GrGLInstalledXferProc* xferProcessor, 36 GrGLInstalledXferProc* xferProcessor,
36 GrGLInstalledFragProcs* fragmentProcessors, 37 GrGLInstalledFragProcs* fragmentProcessors,
37 SkTArray<UniformHandle>* passSamplerUniforms) 38 SkTArray<UniformHandle>* passSamplerUniforms)
38 : fColor(GrColor_ILLEGAL) 39 : fColor(GrColor_ILLEGAL)
39 , fCoverage(0) 40 , fCoverage(0)
40 , fDstTextureUnit(-1) 41 , fDstTextureUnit(-1)
41 , fBuiltinUniformHandles(builtinUniforms) 42 , fBuiltinUniformHandles(builtinUniforms)
42 , fProgramID(programID) 43 , fProgramID(programID)
43 , fGeometryProcessor(geometryProcessor) 44 , fGeometryProcessor(geometryProcessor)
44 , fXferProcessor(xferProcessor) 45 , fXferProcessor(xferProcessor)
45 , fFragmentProcessors(SkRef(fragmentProcessors)) 46 , fFragmentProcessors(SkRef(fragmentProcessors))
46 , fDesc(desc) 47 , fDesc(desc)
47 , fGpu(gpu) 48 , fGpu(gpu)
48 , fProgramDataManager(gpu, uniforms) { 49 , fProgramDataManager(gpu, programID, uniforms, separableVaryings) {
49 fSamplerUniforms.swap(passSamplerUniforms); 50 fSamplerUniforms.swap(passSamplerUniforms);
50 // Assign texture units to sampler uniforms one time up front. 51 // Assign texture units to sampler uniforms one time up front.
51 GL_CALL(UseProgram(fProgramID)); 52 GL_CALL(UseProgram(fProgramID));
52 for (int i = 0; i < fSamplerUniforms.count(); i++) { 53 for (int i = 0; i < fSamplerUniforms.count(); i++) {
53 fProgramDataManager.setSampler(fSamplerUniforms[i], i); 54 fProgramDataManager.setSampler(fSamplerUniforms[i], i);
54 } 55 }
55 } 56 }
56 57
57 GrGLProgram::~GrGLProgram() { 58 GrGLProgram::~GrGLProgram() {
58 if (fProgramID) { 59 if (fProgramID) {
(...skipping 29 matching lines...) Expand all
88 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses 89 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses
89 // of GLProgram determine how to set coord transforms 90 // of GLProgram determine how to set coord transforms
90 fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc); 91 fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc);
91 append_texture_bindings(fGeometryProcessor.get(), primProc, textureBindings) ; 92 append_texture_bindings(fGeometryProcessor.get(), primProc, textureBindings) ;
92 93
93 this->setFragmentData(primProc, pipeline, textureBindings); 94 this->setFragmentData(primProc, pipeline, textureBindings);
94 95
95 const GrXferProcessor& xp = *pipeline.getXferProcessor(); 96 const GrXferProcessor& xp = *pipeline.getXferProcessor();
96 fXferProcessor->fGLProc->setData(fProgramDataManager, xp); 97 fXferProcessor->fGLProc->setData(fProgramDataManager, xp);
97 append_texture_bindings(fXferProcessor.get(), xp, textureBindings); 98 append_texture_bindings(fXferProcessor.get(), xp, textureBindings);
98
99 // Some of GrGLProgram subclasses need to update state here
100 this->didSetData();
101 } 99 }
102 100
103 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, 101 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
104 const GrPipeline& pipeline, 102 const GrPipeline& pipeline,
105 SkTArray<const GrTextureAccess*>* textureBindi ngs) { 103 SkTArray<const GrTextureAccess*>* textureBindi ngs) {
106 int numProcessors = fFragmentProcessors->fProcs.count(); 104 int numProcessors = fFragmentProcessors->fProcs.count();
107 for (int i = 0; i < numProcessors; ++i) { 105 for (int i = 0; i < numProcessors; ++i) {
108 const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); 106 const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
109 fFragmentProcessors->fProcs[i]->fGLProc->setData(fProgramDataManager, pr ocessor); 107 fFragmentProcessors->fProcs[i]->fGLProc->setData(fProgramDataManager, pr ocessor);
110 this->setTransformData(primProc, 108 this->setTransformData(primProc,
111 processor, 109 processor,
112 i, 110 i,
113 fFragmentProcessors->fProcs[i]); 111 fFragmentProcessors->fProcs[i]);
114 append_texture_bindings(fFragmentProcessors->fProcs[i], processor, textu reBindings); 112 append_texture_bindings(fFragmentProcessors->fProcs[i], processor, textu reBindings);
115 } 113 }
116 } 114 }
117 void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc, 115 void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
118 const GrFragmentProcessor& processor, 116 const GrFragmentProcessor& processor,
119 int index, 117 int index,
120 GrGLInstalledFragProc* ip) { 118 GrGLInstalledFragProc* ip) {
121 GrGLGeometryProcessor* gp = 119 GrGLPrimitiveProcessor* gp = fGeometryProcessor.get()->fGLProc.get();
122 static_cast<GrGLGeometryProcessor*>(fGeometryProcessor.get()->fGLPro c.get());
123 gp->setTransformData(primProc, fProgramDataManager, index, 120 gp->setTransformData(primProc, fProgramDataManager, index,
124 processor.coordTransforms()); 121 processor.coordTransforms());
125 } 122 }
126 123
127 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, 124 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
128 const GrPipeline& pipeline) { 125 const GrPipeline& pipeline) {
129 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. 126 // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
130 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && 127 if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
131 fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget ()->height()) { 128 fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget ()->height()) {
132 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, 129 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
133 SkIntToScalar(pipeline.getRenderTarget()->hei ght())); 130 SkIntToScalar(pipeline.getRenderTarget()->hei ght()));
134 } 131 }
135 132
136 // call subclasses to set the actual view matrix 133 // set RT adjustment
137 this->onSetRenderTargetState(primProc, pipeline);
138 }
139
140 void GrGLProgram::onSetRenderTargetState(const GrPrimitiveProcessor&,
141 const GrPipeline& pipeline) {
142 const GrRenderTarget* rt = pipeline.getRenderTarget(); 134 const GrRenderTarget* rt = pipeline.getRenderTarget();
143 SkISize size; 135 SkISize size;
144 size.set(rt->width(), rt->height()); 136 size.set(rt->width(), rt->height());
145 if (fRenderTargetState.fRenderTargetOrigin != rt->origin() || 137 if (!primProc.isPathRendering()) {
146 fRenderTargetState.fRenderTargetSize != size) { 138 if (fRenderTargetState.fRenderTargetOrigin != rt->origin() ||
147 fRenderTargetState.fRenderTargetSize = size; 139 fRenderTargetState.fRenderTargetSize != size) {
148 fRenderTargetState.fRenderTargetOrigin = rt->origin(); 140 fRenderTargetState.fRenderTargetSize = size;
141 fRenderTargetState.fRenderTargetOrigin = rt->origin();
149 142
150 GrGLfloat rtAdjustmentVec[4]; 143 GrGLfloat rtAdjustmentVec[4];
151 fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); 144 fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec);
152 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r tAdjustmentVec); 145 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
146 }
147 } else {
148 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
149 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
150 fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(),
151 size, rt->origin());
153 } 152 }
154 } 153 }
155
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698