OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 371 |
372 void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage, | 372 void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage, |
373 GrGLProcessor::TransformedCoordsArray* o
utCoords, | 373 GrGLProcessor::TransformedCoordsArray* o
utCoords, |
374 GrGLInstalledFragProc* ifp) { | 374 GrGLInstalledFragProc* ifp) { |
375 const GrFragmentProcessor* processor = stage.getProcessor(); | 375 const GrFragmentProcessor* processor = stage.getProcessor(); |
376 int numTransforms = processor->numTransforms(); | 376 int numTransforms = processor->numTransforms(); |
377 ifp->fTransforms.push_back_n(numTransforms); | 377 ifp->fTransforms.push_back_n(numTransforms); |
378 | 378 |
379 for (int t = 0; t < numTransforms; t++) { | 379 for (int t = 0; t < numTransforms; t++) { |
380 const char* uniName = "StageMatrix"; | 380 const char* uniName = "StageMatrix"; |
381 GrSLType varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrS
LType : | 381 GrSLType varyingType; |
382 kVec2f_GrS
LType; | 382 |
| 383 // TODO when we have deleted the coord change matrices we can get rid of
the below check |
| 384 GrCoordSet coordType = processor->coordTransform(t).sourceCoords(); |
| 385 const SkMatrix& localMatrix = fOptState.getPrimitiveProcessor()->localMa
trix(); |
| 386 if (localMatrix.isIdentity()) { |
| 387 varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrSLType
: |
| 388 kVec2f_GrSLType
; |
| 389 } else { |
| 390 uint32_t type = processor->coordTransform(t).getMatrix().getType(); |
| 391 if (kLocal_GrCoordSet == coordType) { |
| 392 type |= localMatrix.getType(); |
| 393 } |
| 394 varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_
GrSLType : |
| 395 kVec2f_
GrSLType; |
| 396 } |
383 GrSLPrecision precision = processor->coordTransform(t).precision(); | 397 GrSLPrecision precision = processor->coordTransform(t).precision(); |
384 | 398 |
385 SkString suffixedUniName; | 399 SkString suffixedUniName; |
386 if (0 != t) { | 400 if (0 != t) { |
387 suffixedUniName.append(uniName); | 401 suffixedUniName.append(uniName); |
388 suffixedUniName.appendf("_%i", t); | 402 suffixedUniName.appendf("_%i", t); |
389 uniName = suffixedUniName.c_str(); | 403 uniName = suffixedUniName.c_str(); |
390 } | 404 } |
391 ifp->fTransforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVert
ex_Visibility, | 405 ifp->fTransforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVert
ex_Visibility, |
392 kMat33f_GrSLType, precisi
on, | 406 kMat33f_GrSLType, precisi
on, |
393 uniName, | 407 uniName, |
394 &uniName).toShaderBuilder
Index(); | 408 &uniName).toShaderBuilder
Index(); |
395 | 409 |
396 const char* varyingName = "MatrixCoord"; | 410 const char* varyingName = "MatrixCoord"; |
397 SkString suffixedVaryingName; | 411 SkString suffixedVaryingName; |
398 if (0 != t) { | 412 if (0 != t) { |
399 suffixedVaryingName.append(varyingName); | 413 suffixedVaryingName.append(varyingName); |
400 suffixedVaryingName.appendf("_%i", t); | 414 suffixedVaryingName.appendf("_%i", t); |
401 varyingName = suffixedVaryingName.c_str(); | 415 varyingName = suffixedVaryingName.c_str(); |
402 } | 416 } |
403 | 417 |
404 GrCoordSet coordType = processor->coordTransform(t).sourceCoords(); | |
405 GrGLVertToFrag v(varyingType); | 418 GrGLVertToFrag v(varyingType); |
406 this->addVarying(varyingName, &v, precision); | 419 this->addVarying(varyingName, &v, precision); |
407 fCoordVaryings.push_back(TransformVarying(v, uniName, coordType)); | 420 fCoordVaryings.push_back(TransformVarying(v, uniName, coordType)); |
408 | 421 |
409 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingTyp
e); | 422 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingTyp
e); |
410 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, | 423 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, |
411 (SkString(v.fsIn()), varyingType)); | 424 (SkString(v.fsIn()), varyingType)); |
412 } | 425 } |
413 } | 426 } |
414 | 427 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } | 551 } |
539 | 552 |
540 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 553 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
541 | 554 |
542 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 555 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
543 int numProcs = fProcs.count(); | 556 int numProcs = fProcs.count(); |
544 for (int e = 0; e < numProcs; ++e) { | 557 for (int e = 0; e < numProcs; ++e) { |
545 SkDELETE(fProcs[e]); | 558 SkDELETE(fProcs[e]); |
546 } | 559 } |
547 } | 560 } |
OLD | NEW |