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

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

Issue 827973002: ViewMatrix uniform upload moved to GeometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@vm-on-gp
Patch Set: feedback inc Created 5 years, 11 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/builders/GrGLProgramBuilder.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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 fGpu->bindTexture(samplers[s].fTextureUnit, 125 fGpu->bindTexture(samplers[s].fTextureUnit,
126 textureAccess.getParams(), 126 textureAccess.getParams(),
127 static_cast<GrGLTexture*>(textureAccess.getTexture())) ; 127 static_cast<GrGLTexture*>(textureAccess.getTexture())) ;
128 } 128 }
129 } 129 }
130 130
131 131
132 /////////////////////////////////////////////////////////////////////////////// 132 ///////////////////////////////////////////////////////////////////////////////
133 133
134 void GrGLProgram::setData(const GrOptDrawState& optState) { 134 void GrGLProgram::setData(const GrOptDrawState& optState) {
135 this->setMatrixAndRenderTargetHeight(optState); 135 this->setRenderTargetState(optState);
136 136
137 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy(); 137 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
138 if (dstCopy) { 138 if (dstCopy) {
139 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) { 139 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) {
140 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni, 140 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni,
141 static_cast<GrGLfloat>(dstCopy->offset(). fX), 141 static_cast<GrGLfloat>(dstCopy->offset(). fX),
142 static_cast<GrGLfloat>(dstCopy->offset(). fY)); 142 static_cast<GrGLfloat>(dstCopy->offset(). fY));
143 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni, 143 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni,
144 1.f / dstCopy->texture()->width(), 144 1.f / dstCopy->texture()->width(),
145 1.f / dstCopy->texture()->height()); 145 1.f / dstCopy->texture()->height());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix); 198 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix);
199 transforms[t].fCurrentValue = matrix; 199 transforms[t].fCurrentValue = matrix;
200 } 200 }
201 } 201 }
202 } 202 }
203 203
204 void GrGLProgram::didSetData(GrGpu::DrawType drawType) { 204 void GrGLProgram::didSetData(GrGpu::DrawType drawType) {
205 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType)); 205 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
206 } 206 }
207 207
208 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { 208 void GrGLProgram::setRenderTargetState(const GrOptDrawState& optState) {
209 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. 209 // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
210 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && 210 if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
211 fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->he ight()) { 211 fRenderTargetState.fRenderTargetSize.fHeight != optState.getRenderTarget ()->height()) {
212 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, 212 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
213 SkIntToScalar(optState.getRenderTarget()->hei ght())); 213 SkIntToScalar(optState.getRenderTarget()->hei ght()));
214 } 214 }
215 215
216 // call subclasses to set the actual view matrix 216 // call subclasses to set the actual view matrix
217 this->onSetMatrixAndRenderTargetHeight(optState); 217 this->onSetRenderTargetState(optState);
218 } 218 }
219 219
220 void GrGLProgram::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optStat e) { 220 void GrGLProgram::onSetRenderTargetState(const GrOptDrawState& optState) {
221 const GrRenderTarget* rt = optState.getRenderTarget(); 221 const GrRenderTarget* rt = optState.getRenderTarget();
222 SkISize size; 222 SkISize size;
223 size.set(rt->width(), rt->height()); 223 size.set(rt->width(), rt->height());
224 if (fMatrixState.fRenderTargetOrigin != rt->origin() || 224 if (fRenderTargetState.fRenderTargetOrigin != rt->origin() ||
225 fMatrixState.fRenderTargetSize != size || 225 fRenderTargetState.fRenderTargetSize != size) {
226 !fMatrixState.fViewMatrix.cheapEqualTo(optState.getViewMatrix())) { 226 fRenderTargetState.fRenderTargetSize = size;
227 SkASSERT(fBuiltinUniformHandles.fViewMatrixUni.isValid()); 227 fRenderTargetState.fRenderTargetOrigin = rt->origin();
228
229 fMatrixState.fViewMatrix = optState.getViewMatrix();
230 fMatrixState.fRenderTargetSize = size;
231 fMatrixState.fRenderTargetOrigin = rt->origin();
232
233 GrGLfloat viewMatrix[3 * 3];
234 fMatrixState.getGLMatrix<3>(viewMatrix);
235 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v iewMatrix);
236 228
237 GrGLfloat rtAdjustmentVec[4]; 229 GrGLfloat rtAdjustmentVec[4];
238 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); 230 fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec);
239 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r tAdjustmentVec); 231 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r tAdjustmentVec);
240 } 232 }
241 } 233 }
242 234
243 //////////////////////////////////////////////////////////////////////////////// ///////// 235 //////////////////////////////////////////////////////////////////////////////// /////////
244 236
245 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGLGpu* gpu, 237 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGLGpu* gpu,
246 const GrProgramDesc& desc, 238 const GrProgramDesc& desc,
247 const BuiltinUniformHandles& builtinUni forms, 239 const BuiltinUniformHandles& builtinUni forms,
248 GrGLuint programID, 240 GrGLuint programID,
249 const UniformInfoArray& uniforms, 241 const UniformInfoArray& uniforms,
250 GrGLInstalledGeoProc* primProc, 242 GrGLInstalledGeoProc* primProc,
251 GrGLInstalledXferProc* xferProcessor, 243 GrGLInstalledXferProc* xferProcessor,
252 GrGLInstalledFragProcs* fragmentProcess ors) 244 GrGLInstalledFragProcs* fragmentProcess ors)
253 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc, 245 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc,
254 xferProcessor, fragmentProcessors) { 246 xferProcessor, fragmentProcessors) {
255 } 247 }
256 248
257 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { 249 void GrGLNvprProgramBase::onSetRenderTargetState(const GrOptDrawState& optState) {
258 SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType())); 250 SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType()));
259 const GrRenderTarget* rt = optState.getRenderTarget(); 251 const GrRenderTarget* rt = optState.getRenderTarget();
260 SkISize size; 252 SkISize size;
261 size.set(rt->width(), rt->height()); 253 size.set(rt->width(), rt->height());
262 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin()); 254 fGpu->glPathRendering()->setProjectionMatrix(optState.getPrimitiveProcessor( )->viewMatrix(),
255 size, rt->origin());
263 } 256 }
264 257
265 //////////////////////////////////////////////////////////////////////////////// ///////// 258 //////////////////////////////////////////////////////////////////////////////// /////////
266 259
267 GrGLNvprProgram::GrGLNvprProgram(GrGLGpu* gpu, 260 GrGLNvprProgram::GrGLNvprProgram(GrGLGpu* gpu,
268 const GrProgramDesc& desc, 261 const GrProgramDesc& desc,
269 const BuiltinUniformHandles& builtinUniforms, 262 const BuiltinUniformHandles& builtinUniforms,
270 GrGLuint programID, 263 GrGLuint programID,
271 const UniformInfoArray& uniforms, 264 const UniformInfoArray& uniforms,
272 GrGLInstalledGeoProc* primProc, 265 GrGLInstalledGeoProc* primProc,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 for (int t = 0; t < numTransforms; ++t) { 339 for (int t = 0; t < numTransforms; ++t) {
347 const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix); 340 const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
348 GrGLPathRendering::PathTexGenComponents components = 341 GrGLPathRendering::PathTexGenComponents components =
349 GrGLPathRendering::kST_PathTexGenComponents; 342 GrGLPathRendering::kST_PathTexGenComponents;
350 if (proc.isPerspectiveCoordTransform(t)) { 343 if (proc.isPerspectiveCoordTransform(t)) {
351 components = GrGLPathRendering::kSTR_PathTexGenComponents; 344 components = GrGLPathRendering::kSTR_PathTexGenComponents;
352 } 345 }
353 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform); 346 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
354 } 347 }
355 } 348 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698