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

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

Issue 821243003: removing coord change matrices (Closed) Base URL: https://skia.googlesource.com/skia.git@no-coordchange-on-drawstate
Patch Set: rebase 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/GrProcOptInfo.cpp ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('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 12 matching lines...) Expand all
23 23
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 * Retrieves the final matrix that a transform needs to apply to its source coor ds. 28 * Retrieves the final matrix that a transform needs to apply to its source coor ds.
29 */ 29 */
30 static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, 30 static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage,
31 int transformIdx, 31 int transformIdx,
32 const SkMatrix& localMatrix) { 32 const SkMatrix& localMatrix) {
33 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransfor m(transformIdx); 33 const GrCoordTransform& coordTransform = stage.processor()->coordTransform(t ransformIdx);
34 SkMatrix combined; 34 SkMatrix combined;
35 35
36 // We only apply the localmatrix to localcoords
36 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { 37 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
37 // If we have explicit local coords or are in device coords then we shou ldn't need a coord 38 combined.setConcat(coordTransform.getMatrix(), localMatrix);
38 // change.
39 // TODO shortly we will get rid of coord change matrices entirely, and t he PrimProc will
40 // always have a local matrix, often Identity, which can be used to tran sform coord
41 // transforms. Until we actually do this, we need some way for a PrimPr oc to say 'use my
42 // matrix' instead of the coord change mechanism. Temporarily, we have overloaded
43 // The identity matrix to be this value, ie if a primproc has an identit y matrix for a
44 // local matrix then use the coord change matrix, otherwise use the matr ix on the primproc
45 if (localMatrix.isIdentity()) {
46 const SkMatrix& ccm = stage.getCoordChangeMatrix();
47 combined.setConcat(coordTransform.getMatrix(), ccm);
48 } else {
49 combined.setConcat(coordTransform.getMatrix(), localMatrix);
50 }
51 } else { 39 } else {
52 combined = coordTransform.getMatrix(); 40 combined = coordTransform.getMatrix();
53 } 41 }
54 if (coordTransform.reverseY()) { 42 if (coordTransform.reverseY()) {
55 // combined.postScale(1,-1); 43 // combined.postScale(1,-1);
56 // combined.postTranslate(0,1); 44 // combined.postTranslate(0,1);
57 combined.set(SkMatrix::kMSkewY, 45 combined.set(SkMatrix::kMSkewY,
58 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); 46 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
59 combined.set(SkMatrix::kMScaleY, 47 combined.set(SkMatrix::kMScaleY,
60 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); 48 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 this->setFragmentData(optState); 171 this->setFragmentData(optState);
184 172
185 // Some of GrGLProgram subclasses need to update state here 173 // Some of GrGLProgram subclasses need to update state here
186 this->didSetData(optState.drawType()); 174 this->didSetData(optState.drawType());
187 } 175 }
188 176
189 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) { 177 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
190 int numProcessors = fFragmentProcessors->fProcs.count(); 178 int numProcessors = fFragmentProcessors->fProcs.count();
191 for (int e = 0; e < numProcessors; ++e) { 179 for (int e = 0; e < numProcessors; ++e) {
192 const GrPendingFragmentStage& stage = optState.getFragmentStage(e); 180 const GrPendingFragmentStage& stage = optState.getFragmentStage(e);
193 const GrProcessor& processor = *stage.getProcessor(); 181 const GrProcessor& processor = *stage.processor();
194 fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr ocessor); 182 fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr ocessor);
195 const SkMatrix& localMatrix = optState.getPrimitiveProcessor()->localMat rix(); 183 const SkMatrix& localMatrix = optState.getPrimitiveProcessor()->localMat rix();
196 this->setTransformData(stage, localMatrix, fFragmentProcessors->fProcs[e ]); 184 this->setTransformData(stage, localMatrix, fFragmentProcessors->fProcs[e ]);
197 this->bindTextures(fFragmentProcessors->fProcs[e], processor); 185 this->bindTextures(fFragmentProcessors->fProcs[e], processor);
198 } 186 }
199 } 187 }
200 void GrGLProgram::setTransformData(const GrPendingFragmentStage& processor, 188 void GrGLProgram::setTransformData(const GrPendingFragmentStage& processor,
201 const SkMatrix& localMatrix, 189 const SkMatrix& localMatrix,
202 GrGLInstalledFragProc* ip) { 190 GrGLInstalledFragProc* ip) {
203 SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor ms; 191 SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor ms;
204 int numTransforms = transforms.count(); 192 int numTransforms = transforms.count();
205 SkASSERT(numTransforms == processor.getProcessor()->numTransforms()); 193 SkASSERT(numTransforms == processor.processor()->numTransforms());
206 for (int t = 0; t < numTransforms; ++t) { 194 for (int t = 0; t < numTransforms; ++t) {
207 SkASSERT(transforms[t].fHandle.isValid()); 195 SkASSERT(transforms[t].fHandle.isValid());
208 const SkMatrix& matrix = get_transform_matrix(processor, t, localMatrix) ; 196 const SkMatrix& matrix = get_transform_matrix(processor, t, localMatrix) ;
209 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { 197 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
210 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix); 198 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix);
211 transforms[t].fCurrentValue = matrix; 199 transforms[t].fCurrentValue = matrix;
212 } 200 }
213 } 201 }
214 } 202 }
215 203
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 290
303 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) { 291 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) {
304 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); 292 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
305 } 293 }
306 294
307 void GrGLNvprProgram::setTransformData(const GrPendingFragmentStage& proc, 295 void GrGLNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
308 const SkMatrix& localMatrix, 296 const SkMatrix& localMatrix,
309 GrGLInstalledFragProc* ip) { 297 GrGLInstalledFragProc* ip) {
310 SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor ms; 298 SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor ms;
311 int numTransforms = transforms.count(); 299 int numTransforms = transforms.count();
312 SkASSERT(numTransforms == proc.getProcessor()->numTransforms()); 300 SkASSERT(numTransforms == proc.processor()->numTransforms());
313 for (int t = 0; t < numTransforms; ++t) { 301 for (int t = 0; t < numTransforms; ++t) {
314 SkASSERT(transforms[t].fHandle.isValid()); 302 SkASSERT(transforms[t].fHandle.isValid());
315 const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix); 303 const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
316 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { 304 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
317 continue; 305 continue;
318 } 306 }
319 transforms[t].fCurrentValue = transform; 307 transforms[t].fCurrentValue = transform;
320 const Varying& fragmentInput = fVaryings[transforms[t].fHandle.handle()] ; 308 const Varying& fragmentInput = fVaryings[transforms[t].fHandle.handle()] ;
321 SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType = = kVec3f_GrSLType); 309 SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType = = kVec3f_GrSLType);
322 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; 310 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
(...skipping 24 matching lines...) Expand all
347 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); 335 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
348 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); 336 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt);
349 } 337 }
350 338
351 void 339 void
352 GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc, 340 GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
353 const SkMatrix& localMatrix, 341 const SkMatrix& localMatrix,
354 GrGLInstalledFragProc* ip) { 342 GrGLInstalledFragProc* ip) {
355 // We've hidden the texcoord index in the first entry of the transforms arra y for each effect 343 // We've hidden the texcoord index in the first entry of the transforms arra y for each effect
356 int texCoordIndex = ip->fTransforms[0].fHandle.handle(); 344 int texCoordIndex = ip->fTransforms[0].fHandle.handle();
357 int numTransforms = proc.getProcessor()->numTransforms(); 345 int numTransforms = proc.processor()->numTransforms();
358 for (int t = 0; t < numTransforms; ++t) { 346 for (int t = 0; t < numTransforms; ++t) {
359 const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix); 347 const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
360 GrGLPathRendering::PathTexGenComponents components = 348 GrGLPathRendering::PathTexGenComponents components =
361 GrGLPathRendering::kST_PathTexGenComponents; 349 GrGLPathRendering::kST_PathTexGenComponents;
362 if (proc.isPerspectiveCoordTransform(t)) { 350 if (proc.isPerspectiveCoordTransform(t)) {
363 components = GrGLPathRendering::kSTR_PathTexGenComponents; 351 components = GrGLPathRendering::kSTR_PathTexGenComponents;
364 } 352 }
365 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform); 353 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
366 } 354 }
367 } 355 }
OLDNEW
« no previous file with comments | « src/gpu/GrProcOptInfo.cpp ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698