| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrGLProgramEffects.h" | 8 #include "GrGLProgramEffects.h" |
| 9 #include "GrDrawEffect.h" | 9 #include "GrDrawEffect.h" |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| 11 #include "gl/GrGLShaderBuilder.h" | 11 #include "gl/GrGLShaderBuilder.h" |
| 12 #include "gl/GrGLVertexEffect.h" | 12 #include "gl/GrGLVertexEffect.h" |
| 13 #include "gl/GrGpuGL.h" | 13 #include "gl/GrGpuGL.h" |
| 14 | 14 |
| 15 typedef GrGLProgramEffects::EffectKey EffectKey; | 15 typedef GrGLProgramEffects::EffectKey EffectKey; |
| 16 typedef GrGLProgramEffects::TransformedCoords TransformedCoords; | 16 typedef GrGLProgramEffects::TransformedCoords TransformedCoords; |
| 17 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; | 17 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; |
| 18 typedef GrGLProgramEffects::TextureSampler TextureSampler; | 18 typedef GrGLProgramEffects::TextureSampler TextureSampler; |
| 19 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; | 19 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * We specialize the vertex code for each of these matrix types. | 22 * We specialize the vertex code for each of these matrix types. |
| 23 */ | 23 */ |
| 24 enum MatrixType { | 24 enum MatrixType { |
| 25 kIdentity_MatrixType = 0, | 25 kNoPersp_MatrixType = 0, |
| 26 kTrans_MatrixType = 1, | 26 kGeneral_MatrixType = 1, |
| 27 kNoPersp_MatrixType = 2, | |
| 28 kGeneral_MatrixType = 3, | |
| 29 }; | 27 }; |
| 30 | 28 |
| 31 /** | 29 /** |
| 32 * The key for an individual coord transform is made up of a matrix type and a b
it that | 30 * The key for an individual coord transform is made up of a matrix type and a b
it that |
| 33 * indicates the source of the input coords. | 31 * indicates the source of the input coords. |
| 34 */ | 32 */ |
| 35 enum { | 33 enum { |
| 36 kMatrixTypeKeyBits = 2, | 34 kMatrixTypeKeyBits = 1, |
| 37 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, | 35 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, |
| 38 kPositionCoords_Flag = (1 << kMatrixTypeKeyBits), | 36 kPositionCoords_Flag = (1 << kMatrixTypeKeyBits), |
| 39 kTransformKeyBits = kMatrixTypeKeyBits + 1, | 37 kTransformKeyBits = kMatrixTypeKeyBits + 1, |
| 40 }; | 38 }; |
| 41 | 39 |
| 42 namespace { | 40 namespace { |
| 43 | 41 |
| 44 /** | 42 /** |
| 45 * Do we need to either map r,g,b->a or a->r. configComponentMask indicates whic
h channels are | 43 * Do we need to either map r,g,b->a or a->r. configComponentMask indicates whic
h channels are |
| 46 * present in the texture's config. swizzleComponentMask indicates the channels
present in the | 44 * present in the texture's config. swizzleComponentMask indicates the channels
present in the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 * the same coordinate set as the original GrCoordTransform if the position and
local coords are | 79 * the same coordinate set as the original GrCoordTransform if the position and
local coords are |
| 82 * identical for this program. | 80 * identical for this program. |
| 83 */ | 81 */ |
| 84 GrCoordSet get_source_coords(EffectKey transformKey, int transformIdx) { | 82 GrCoordSet get_source_coords(EffectKey transformKey, int transformIdx) { |
| 85 return (transformKey >> (kTransformKeyBits * transformIdx)) & kPositionCoord
s_Flag ? | 83 return (transformKey >> (kTransformKeyBits * transformIdx)) & kPositionCoord
s_Flag ? |
| 86 kPosition_GrCoordSet : | 84 kPosition_GrCoordSet : |
| 87 kLocal_GrCoordSet; | 85 kLocal_GrCoordSet; |
| 88 } | 86 } |
| 89 | 87 |
| 90 /** | 88 /** |
| 91 * Retrieves the final translation that a transform needs to apply to its source
coords (and | |
| 92 * verifies that a translation is all it needs). | |
| 93 */ | |
| 94 void get_transform_translation(const GrDrawEffect& drawEffect, | |
| 95 int transformIdx, | |
| 96 GrGLfloat* tx, | |
| 97 GrGLfloat* ty) { | |
| 98 const GrCoordTransform& coordTransform = (*drawEffect.effect())->coordTransf
orm(transformIdx); | |
| 99 SkASSERT(!coordTransform.reverseY()); | |
| 100 const SkMatrix& matrix = coordTransform.getMatrix(); | |
| 101 if (kLocal_GrCoordSet == coordTransform.sourceCoords() && | |
| 102 !drawEffect.programHasExplicitLocalCoords()) { | |
| 103 const SkMatrix& coordChangeMatrix = drawEffect.getCoordChangeMatrix(); | |
| 104 SkASSERT(SkMatrix::kTranslate_Mask == (matrix.getType() | coordChangeMat
rix.getType())); | |
| 105 *tx = SkScalarToFloat(matrix[SkMatrix::kMTransX] + coordChangeMatrix[SkM
atrix::kMTransX]); | |
| 106 *ty = SkScalarToFloat(matrix[SkMatrix::kMTransY] + coordChangeMatrix[SkM
atrix::kMTransY]); | |
| 107 } else { | |
| 108 SkASSERT(SkMatrix::kTranslate_Mask == matrix.getType()); | |
| 109 *tx = SkScalarToFloat(matrix[SkMatrix::kMTransX]); | |
| 110 *ty = SkScalarToFloat(matrix[SkMatrix::kMTransY]); | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 /** | |
| 115 * Retrieves the final matrix that a transform needs to apply to its source coor
ds. | 89 * Retrieves the final matrix that a transform needs to apply to its source coor
ds. |
| 116 */ | 90 */ |
| 117 SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx)
{ | 91 SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx)
{ |
| 118 const GrCoordTransform& coordTransform = (*drawEffect.effect())->coordTransf
orm(transformIdx); | 92 const GrCoordTransform& coordTransform = (*drawEffect.effect())->coordTransf
orm(transformIdx); |
| 119 SkMatrix combined; | 93 SkMatrix combined; |
| 120 if (kLocal_GrCoordSet == coordTransform.sourceCoords() && | 94 if (kLocal_GrCoordSet == coordTransform.sourceCoords() && |
| 121 !drawEffect.programHasExplicitLocalCoords()) { | 95 !drawEffect.programHasExplicitLocalCoords()) { |
| 122 combined.setConcat(coordTransform.getMatrix(), drawEffect.getCoordChange
Matrix()); | 96 combined.setConcat(coordTransform.getMatrix(), drawEffect.getCoordChange
Matrix()); |
| 123 } else { | 97 } else { |
| 124 combined = coordTransform.getMatrix(); | 98 combined = coordTransform.getMatrix(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // We only make the key indicate that device coords are referenc
ed when the local coords | 142 // We only make the key indicate that device coords are referenc
ed when the local coords |
| 169 // are not actually determined by positions. Otherwise the local
coords var and position | 143 // are not actually determined by positions. Otherwise the local
coords var and position |
| 170 // var are identical. | 144 // var are identical. |
| 171 key |= kPositionCoords_Flag; | 145 key |= kPositionCoords_Flag; |
| 172 } | 146 } |
| 173 type1 = SkMatrix::kIdentity_Mask; | 147 type1 = SkMatrix::kIdentity_Mask; |
| 174 } | 148 } |
| 175 | 149 |
| 176 int combinedTypes = type0 | type1; | 150 int combinedTypes = type0 | type1; |
| 177 | 151 |
| 178 bool reverseY = coordTransform.reverseY(); | |
| 179 | |
| 180 if (SkMatrix::kPerspective_Mask & combinedTypes) { | 152 if (SkMatrix::kPerspective_Mask & combinedTypes) { |
| 181 key |= kGeneral_MatrixType; | 153 key |= kGeneral_MatrixType; |
| 182 } else if (((SkMatrix::kAffine_Mask | SkMatrix::kScale_Mask) & combinedT
ypes) || reverseY) { | 154 } else { |
| 183 key |= kNoPersp_MatrixType; | 155 key |= kNoPersp_MatrixType; |
| 184 } else if (SkMatrix::kTranslate_Mask & combinedTypes) { | |
| 185 key |= kTrans_MatrixType; | |
| 186 } else { | |
| 187 key |= kIdentity_MatrixType; | |
| 188 } | 156 } |
| 189 key <<= kTransformKeyBits * t; | 157 key <<= kTransformKeyBits * t; |
| 190 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to
overlap | 158 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to
overlap |
| 191 totalKey |= key; | 159 totalKey |= key; |
| 192 } | 160 } |
| 193 return totalKey; | 161 return totalKey; |
| 194 } | 162 } |
| 195 | 163 |
| 196 EffectKey GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, cons
t GrGLCaps& caps) { | 164 EffectKey GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, cons
t GrGLCaps& caps) { |
| 197 EffectKey key = 0; | 165 EffectKey key = 0; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 EffectKey effectKey, | 281 EffectKey effectKey, |
| 314 TransformedCoordsArray* outCoords)
{ | 282 TransformedCoordsArray* outCoords)
{ |
| 315 SkTArray<Transform, true>& transforms = fTransforms.push_back(); | 283 SkTArray<Transform, true>& transforms = fTransforms.push_back(); |
| 316 EffectKey totalKey = GrBackendEffectFactory::GetTransformKey(effectKey); | 284 EffectKey totalKey = GrBackendEffectFactory::GetTransformKey(effectKey); |
| 317 int numTransforms = effect->numTransforms(); | 285 int numTransforms = effect->numTransforms(); |
| 318 transforms.push_back_n(numTransforms); | 286 transforms.push_back_n(numTransforms); |
| 319 for (int t = 0; t < numTransforms; t++) { | 287 for (int t = 0; t < numTransforms; t++) { |
| 320 GrSLType varyingType = kVoid_GrSLType; | 288 GrSLType varyingType = kVoid_GrSLType; |
| 321 const char* uniName; | 289 const char* uniName; |
| 322 switch (get_matrix_type(totalKey, t)) { | 290 switch (get_matrix_type(totalKey, t)) { |
| 323 case kIdentity_MatrixType: | |
| 324 transforms[t].fType = kVoid_GrSLType; | |
| 325 uniName = NULL; | |
| 326 varyingType = kVec2f_GrSLType; | |
| 327 break; | |
| 328 case kTrans_MatrixType: | |
| 329 transforms[t].fType = kVec2f_GrSLType; | |
| 330 uniName = "StageTranslate"; | |
| 331 varyingType = kVec2f_GrSLType; | |
| 332 break; | |
| 333 case kNoPersp_MatrixType: | 291 case kNoPersp_MatrixType: |
| 334 transforms[t].fType = kMat33f_GrSLType; | |
| 335 uniName = "StageMatrix"; | 292 uniName = "StageMatrix"; |
| 336 varyingType = kVec2f_GrSLType; | 293 varyingType = kVec2f_GrSLType; |
| 337 break; | 294 break; |
| 338 case kGeneral_MatrixType: | 295 case kGeneral_MatrixType: |
| 339 transforms[t].fType = kMat33f_GrSLType; | |
| 340 uniName = "StageMatrix"; | 296 uniName = "StageMatrix"; |
| 341 varyingType = kVec3f_GrSLType; | 297 varyingType = kVec3f_GrSLType; |
| 342 break; | 298 break; |
| 343 default: | 299 default: |
| 344 SkFAIL("Unexpected key."); | 300 SkFAIL("Unexpected key."); |
| 345 } | 301 } |
| 346 SkString suffixedUniName; | 302 SkString suffixedUniName; |
| 347 if (kVoid_GrSLType != transforms[t].fType) { | 303 if (0 != t) { |
| 348 if (0 != t) { | 304 suffixedUniName.append(uniName); |
| 349 suffixedUniName.append(uniName); | 305 suffixedUniName.appendf("_%i", t); |
| 350 suffixedUniName.appendf("_%i", t); | 306 uniName = suffixedUniName.c_str(); |
| 351 uniName = suffixedUniName.c_str(); | |
| 352 } | |
| 353 transforms[t].fHandle = builder->addUniform(GrGLShaderBuilder::kVert
ex_Visibility, | |
| 354 transforms[t].fType, | |
| 355 uniName, | |
| 356 &uniName); | |
| 357 } | 307 } |
| 308 transforms[t].fHandle = builder->addUniform(GrGLShaderBuilder::kVertex_V
isibility, |
| 309 kMat33f_GrSLType, |
| 310 uniName, |
| 311 &uniName); |
| 358 | 312 |
| 359 const char* varyingName = "MatrixCoord"; | 313 const char* varyingName = "MatrixCoord"; |
| 360 SkString suffixedVaryingName; | 314 SkString suffixedVaryingName; |
| 361 if (0 != t) { | 315 if (0 != t) { |
| 362 suffixedVaryingName.append(varyingName); | 316 suffixedVaryingName.append(varyingName); |
| 363 suffixedVaryingName.appendf("_%i", t); | 317 suffixedVaryingName.appendf("_%i", t); |
| 364 varyingName = suffixedVaryingName.c_str(); | 318 varyingName = suffixedVaryingName.c_str(); |
| 365 } | 319 } |
| 366 const char* vsVaryingName; | 320 const char* vsVaryingName; |
| 367 const char* fsVaryingName; | 321 const char* fsVaryingName; |
| 368 builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVarying
Name); | 322 builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVarying
Name); |
| 369 | 323 |
| 370 const GrGLShaderVar& coords = kPosition_GrCoordSet == get_source_coords(
totalKey, t) ? | 324 const GrGLShaderVar& coords = kPosition_GrCoordSet == get_source_coords(
totalKey, t) ? |
| 371 builder->positionAttribute() : | 325 builder->positionAttribute() : |
| 372 builder->localCoordsAttribute(); | 326 builder->localCoordsAttribute(); |
| 373 // varying = matrix * coords (logically) | 327 // varying = matrix * coords (logically) |
| 374 switch (transforms[t].fType) { | 328 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingTyp
e); |
| 375 case kVoid_GrSLType: | 329 if (kVec2f_GrSLType == varyingType) { |
| 376 SkASSERT(kVec2f_GrSLType == varyingType); | 330 builder->vsCodeAppendf("\t%s = (%s * vec3(%s, 1)).xy;\n", |
| 377 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, coords.c_s
tr()); | 331 vsVaryingName, uniName, coords.c_str()); |
| 378 break; | 332 } else { |
| 379 case kVec2f_GrSLType: | 333 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n", |
| 380 SkASSERT(kVec2f_GrSLType == varyingType); | 334 vsVaryingName, uniName, coords.c_str()); |
| 381 builder->vsCodeAppendf("\t%s = %s + %s;\n", | |
| 382 vsVaryingName, uniName, coords.c_str()); | |
| 383 break; | |
| 384 case kMat33f_GrSLType: { | |
| 385 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == va
ryingType); | |
| 386 if (kVec2f_GrSLType == varyingType) { | |
| 387 builder->vsCodeAppendf("\t%s = (%s * vec3(%s, 1)).xy;\n", | |
| 388 vsVaryingName, uniName, coords.c_str(
)); | |
| 389 } else { | |
| 390 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n", | |
| 391 vsVaryingName, uniName, coords.c_str(
)); | |
| 392 } | |
| 393 break; | |
| 394 } | |
| 395 default: | |
| 396 SkFAIL("Unexpected uniform type."); | |
| 397 } | 335 } |
| 398 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, | 336 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, |
| 399 (SkString(fsVaryingName), varyingType)); | 337 (SkString(fsVaryingName), varyingType)); |
| 400 } | 338 } |
| 401 } | 339 } |
| 402 | 340 |
| 403 void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, | 341 void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, |
| 404 const GrGLUniformManager& uniformManager, | 342 const GrGLUniformManager& uniformManager, |
| 405 const GrEffectStage* effectStages[]) { | 343 const GrEffectStage* effectStages[]) { |
| 406 int numEffects = fGLEffects.count(); | 344 int numEffects = fGLEffects.count(); |
| 407 SkASSERT(numEffects == fTransforms.count()); | 345 SkASSERT(numEffects == fTransforms.count()); |
| 408 SkASSERT(numEffects == fSamplers.count()); | 346 SkASSERT(numEffects == fSamplers.count()); |
| 409 for (int e = 0; e < numEffects; ++e) { | 347 for (int e = 0; e < numEffects; ++e) { |
| 410 GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords); | 348 GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords); |
| 411 fGLEffects[e]->setData(uniformManager, drawEffect); | 349 fGLEffects[e]->setData(uniformManager, drawEffect); |
| 412 this->setTransformData(uniformManager, drawEffect, e); | 350 this->setTransformData(uniformManager, drawEffect, e); |
| 413 this->bindTextures(gpu, *drawEffect.effect(), e); | 351 this->bindTextures(gpu, *drawEffect.effect(), e); |
| 414 } | 352 } |
| 415 } | 353 } |
| 416 | 354 |
| 417 void GrGLVertexProgramEffects::setTransformData(const GrGLUniformManager& unifor
mManager, | 355 void GrGLVertexProgramEffects::setTransformData(const GrGLUniformManager& unifor
mManager, |
| 418 const GrDrawEffect& drawEffect, | 356 const GrDrawEffect& drawEffect, |
| 419 int effectIdx) { | 357 int effectIdx) { |
| 420 SkTArray<Transform, true>& transforms = fTransforms[effectIdx]; | 358 SkTArray<Transform, true>& transforms = fTransforms[effectIdx]; |
| 421 int numTransforms = transforms.count(); | 359 int numTransforms = transforms.count(); |
| 422 SkASSERT(numTransforms == (*drawEffect.effect())->numTransforms()); | 360 SkASSERT(numTransforms == (*drawEffect.effect())->numTransforms()); |
| 423 for (int t = 0; t < numTransforms; ++t) { | 361 for (int t = 0; t < numTransforms; ++t) { |
| 424 SkASSERT(transforms[t].fHandle.isValid() != (kVoid_GrSLType == transform
s[t].fType)); | 362 SkASSERT(transforms[t].fHandle.isValid()); |
| 425 switch (transforms[t].fType) { | 363 const SkMatrix& matrix = get_transform_matrix(drawEffect, t); |
| 426 case kVoid_GrSLType: | 364 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { |
| 427 SkASSERT(get_transform_matrix(drawEffect, t).isIdentity()); | 365 uniformManager.setSkMatrix(transforms[t].fHandle, matrix); |
| 428 break; | 366 transforms[t].fCurrentValue = matrix; |
| 429 case kVec2f_GrSLType: { | |
| 430 GrGLfloat tx, ty; | |
| 431 get_transform_translation(drawEffect, t, &tx, &ty); | |
| 432 if (transforms[t].fCurrentValue.get(SkMatrix::kMTransX) != tx || | |
| 433 transforms[t].fCurrentValue.get(SkMatrix::kMTransY) != ty) { | |
| 434 uniformManager.set2f(transforms[t].fHandle, tx, ty); | |
| 435 transforms[t].fCurrentValue.set(SkMatrix::kMTransX, tx); | |
| 436 transforms[t].fCurrentValue.set(SkMatrix::kMTransY, ty); | |
| 437 } | |
| 438 break; | |
| 439 } | |
| 440 case kMat33f_GrSLType: { | |
| 441 const SkMatrix& matrix = get_transform_matrix(drawEffect, t); | |
| 442 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { | |
| 443 uniformManager.setSkMatrix(transforms[t].fHandle, matrix); | |
| 444 transforms[t].fCurrentValue = matrix; | |
| 445 } | |
| 446 break; | |
| 447 } | |
| 448 default: | |
| 449 SkFAIL("Unexpected uniform type."); | |
| 450 } | 367 } |
| 451 } | 368 } |
| 452 } | 369 } |
| 453 | 370 |
| 454 GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB
uilder* builder, | 371 GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB
uilder* builder, |
| 455 int reserveCoun
t) | 372 int reserveCoun
t) |
| 456 : fBuilder(builder) | 373 : fBuilder(builder) |
| 457 , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects, | 374 , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects, |
| 458 (reserveCount, fBuilder->hasExplicitLocalCoords
()))) { | 375 (reserveCount, fBuilder->hasExplicitLocalCoords
()))) { |
| 459 } | 376 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 448 } |
| 532 | 449 |
| 533 void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu, | 450 void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu, |
| 534 const GrDrawEffect& drawEffect, | 451 const GrDrawEffect& drawEffect, |
| 535 int effectIdx) { | 452 int effectIdx) { |
| 536 EffectKey totalKey = fTransforms[effectIdx].fTransformKey; | 453 EffectKey totalKey = fTransforms[effectIdx].fTransformKey; |
| 537 int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex; | 454 int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex; |
| 538 int numTransforms = (*drawEffect.effect())->numTransforms(); | 455 int numTransforms = (*drawEffect.effect())->numTransforms(); |
| 539 for (int t = 0; t < numTransforms; ++t) { | 456 for (int t = 0; t < numTransforms; ++t) { |
| 540 switch (get_matrix_type(totalKey, t)) { | 457 switch (get_matrix_type(totalKey, t)) { |
| 541 case kIdentity_MatrixType: { | |
| 542 SkASSERT(get_transform_matrix(drawEffect, t).isIdentity()); | |
| 543 GrGLfloat identity[] = {1, 0, 0, | |
| 544 0, 1, 0}; | |
| 545 gpu->enablePathTexGen(texCoordIndex++, | |
| 546 GrGpuGL::kST_PathTexGenComponents, | |
| 547 identity); | |
| 548 break; | |
| 549 } | |
| 550 case kTrans_MatrixType: { | |
| 551 GrGLfloat tx, ty; | |
| 552 get_transform_translation(drawEffect, t, &tx, &ty); | |
| 553 GrGLfloat translate[] = {1, 0, tx, | |
| 554 0, 1, ty}; | |
| 555 gpu->enablePathTexGen(texCoordIndex++, | |
| 556 GrGpuGL::kST_PathTexGenComponents, | |
| 557 translate); | |
| 558 break; | |
| 559 } | |
| 560 case kNoPersp_MatrixType: { | 458 case kNoPersp_MatrixType: { |
| 561 const SkMatrix& transform = get_transform_matrix(drawEffect, t); | 459 const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
| 562 gpu->enablePathTexGen(texCoordIndex++, | 460 gpu->enablePathTexGen(texCoordIndex++, |
| 563 GrGpuGL::kST_PathTexGenComponents, | 461 GrGpuGL::kST_PathTexGenComponents, |
| 564 transform); | 462 transform); |
| 565 break; | 463 break; |
| 566 } | 464 } |
| 567 case kGeneral_MatrixType: { | 465 case kGeneral_MatrixType: { |
| 568 const SkMatrix& transform = get_transform_matrix(drawEffect, t); | 466 const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
| 569 gpu->enablePathTexGen(texCoordIndex++, | 467 gpu->enablePathTexGen(texCoordIndex++, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 585 } | 483 } |
| 586 | 484 |
| 587 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, | 485 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, |
| 588 GrGLProgramEffects::EffectK
ey key, | 486 GrGLProgramEffects::EffectK
ey key, |
| 589 const char* outColor, | 487 const char* outColor, |
| 590 const char* inColor, | 488 const char* inColor, |
| 591 int stageIndex) { | 489 int stageIndex) { |
| 592 SkASSERT(NULL != fProgramEffects.get()); | 490 SkASSERT(NULL != fProgramEffects.get()); |
| 593 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn
dex); | 491 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn
dex); |
| 594 } | 492 } |
| OLD | NEW |