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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 /////////////////////////////////////////////////////////////////////////////// | 104 /////////////////////////////////////////////////////////////////////////////// |
105 | 105 |
106 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
& pipeline, | 106 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
& pipeline, |
107 const GrBatchTracker& batchTracker) { | 107 const GrBatchTracker& batchTracker) { |
108 this->setRenderTargetState(primProc, pipeline); | 108 this->setRenderTargetState(primProc, pipeline); |
109 | 109 |
110 const GrDeviceCoordTexture* dstCopy = pipeline.getDstCopy(); | |
111 if (dstCopy) { | |
112 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) { | |
113 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni, | |
114 static_cast<GrGLfloat>(dstCopy->offset().
fX), | |
115 static_cast<GrGLfloat>(dstCopy->offset().
fY)); | |
116 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni, | |
117 1.f / dstCopy->texture()->width(), | |
118 1.f / dstCopy->texture()->height()); | |
119 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture())
; | |
120 static GrTextureParams kParams; // the default is clamp, nearest fil
tering. | |
121 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture); | |
122 } else { | |
123 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); | |
124 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); | |
125 } | |
126 } else { | |
127 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); | |
128 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); | |
129 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); | |
130 } | |
131 | |
132 // we set the textures, and uniforms for installed processors in a generic w
ay, but subclasses | 110 // we set the textures, and uniforms for installed processors in a generic w
ay, but subclasses |
133 // of GLProgram determine how to set coord transforms | 111 // of GLProgram determine how to set coord transforms |
134 fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, batchTra
cker); | 112 fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, batchTra
cker); |
135 this->bindTextures(fGeometryProcessor.get(), primProc); | 113 this->bindTextures(fGeometryProcessor.get(), primProc); |
136 | 114 |
137 if (fXferProcessor.get()) { | 115 const GrXferProcessor& xp = *pipeline.getXferProcessor(); |
138 const GrXferProcessor& xp = *pipeline.getXferProcessor(); | 116 fXferProcessor->fGLProc->setData(fProgramDataManager, xp); |
139 fXferProcessor->fGLProc->setData(fProgramDataManager, xp); | 117 this->bindTextures(fXferProcessor.get(), xp); |
140 this->bindTextures(fXferProcessor.get(), xp); | 118 |
141 } | |
142 this->setFragmentData(primProc, pipeline); | 119 this->setFragmentData(primProc, pipeline); |
143 | 120 |
144 // Some of GrGLProgram subclasses need to update state here | 121 // Some of GrGLProgram subclasses need to update state here |
145 this->didSetData(); | 122 this->didSetData(); |
146 } | 123 } |
147 | 124 |
148 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, | 125 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, |
149 const GrPipeline& pipeline) { | 126 const GrPipeline& pipeline) { |
150 int numProcessors = fFragmentProcessors->fProcs.count(); | 127 int numProcessors = fFragmentProcessors->fProcs.count(); |
151 for (int e = 0; e < numProcessors; ++e) { | 128 for (int e = 0; e < numProcessors; ++e) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 206 |
230 void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primPro
c, | 207 void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primPro
c, |
231 const GrPipeline& pipeline) { | 208 const GrPipeline& pipeline) { |
232 SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0); | 209 SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0); |
233 const GrRenderTarget* rt = pipeline.getRenderTarget(); | 210 const GrRenderTarget* rt = pipeline.getRenderTarget(); |
234 SkISize size; | 211 SkISize size; |
235 size.set(rt->width(), rt->height()); | 212 size.set(rt->width(), rt->height()); |
236 fGpu->glPathRendering()->setProjectionMatrix(primProc.viewMatrix(), | 213 fGpu->glPathRendering()->setProjectionMatrix(primProc.viewMatrix(), |
237 size, rt->origin()); | 214 size, rt->origin()); |
238 } | 215 } |
OLD | NEW |