| 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 "GrGeometryProcessor.h" | 8 #include "GrGeometryProcessor.h" |
| 9 | 9 |
| 10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } else { | 234 } else { |
| 235 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName
, localCoords); | 235 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName
, localCoords); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 void | 243 void |
| 244 GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor* primProc, | 244 GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor& primProc, |
| 245 const GrGLProgramDataManager& pdman, | 245 const GrGLProgramDataManager& pdman, |
| 246 int index, | 246 int index, |
| 247 const SkTArray<const GrCoordTransform*,
true>& transforms) { | 247 const SkTArray<const GrCoordTransform*,
true>& transforms) { |
| 248 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index]; | 248 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index]; |
| 249 int numTransforms = transforms.count(); | 249 int numTransforms = transforms.count(); |
| 250 for (int t = 0; t < numTransforms; ++t) { | 250 for (int t = 0; t < numTransforms; ++t) { |
| 251 SkASSERT(procTransforms[t].fHandle.isValid()); | 251 SkASSERT(procTransforms[t].fHandle.isValid()); |
| 252 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix(),
*transforms[t]); | 252 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), *
transforms[t]); |
| 253 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { | 253 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { |
| 254 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle()
, transform); | 254 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle()
, transform); |
| 255 procTransforms[t].fCurrentValue = transform; | 255 procTransforms[t].fCurrentValue = transform; |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 void GrGLGeometryProcessor::SetupPosition(GrGLVertexBuilder* vsBuilder, | 260 void GrGLGeometryProcessor::SetupPosition(GrGLVertexBuilder* vsBuilder, |
| 261 GrGPArgs* gpArgs, | 261 GrGPArgs* gpArgs, |
| 262 const char* posName, | 262 const char* posName, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 for (int t = 0; t < coordTransforms.count(); ++t) { | 370 for (int t = 0; t < coordTransforms.count(); ++t) { |
| 371 GrSLType type = coordTransforms[t]->getMatrix().hasPerspective()
? kVec3f_GrSLType : | 371 GrSLType type = coordTransforms[t]->getMatrix().hasPerspective()
? kVec3f_GrSLType : |
| 372
kVec2f_GrSLType; | 372
kVec2f_GrSLType; |
| 373 | 373 |
| 374 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCo
ordIndex++); | 374 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCo
ordIndex++); |
| 375 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCo
ords, (name, type)); | 375 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCo
ords, (name, type)); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 void setTransformData(const GrPrimitiveProcessor* primProc, | 380 void setTransformData(const GrPrimitiveProcessor& primProc, |
| 381 int index, | 381 int index, |
| 382 const SkTArray<const GrCoordTransform*, true>& transfo
rms, | 382 const SkTArray<const GrCoordTransform*, true>& transfo
rms, |
| 383 GrGLPathRendering* glpr, | 383 GrGLPathRendering* glpr, |
| 384 GrGLuint) SK_OVERRIDE { | 384 GrGLuint) SK_OVERRIDE { |
| 385 // We've hidden the texcoord index in the first entry of the transforms
array for each | 385 // We've hidden the texcoord index in the first entry of the transforms
array for each |
| 386 // effect | 386 // effect |
| 387 int texCoordIndex = fInstalledTransforms[index][0].fHandle.handle(); | 387 int texCoordIndex = fInstalledTransforms[index][0].fHandle.handle(); |
| 388 for (int t = 0; t < transforms.count(); ++t) { | 388 for (int t = 0; t < transforms.count(); ++t) { |
| 389 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix
(), *transforms[t]); | 389 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(
), *transforms[t]); |
| 390 GrGLPathRendering::PathTexGenComponents components = | 390 GrGLPathRendering::PathTexGenComponents components = |
| 391 GrGLPathRendering::kST_PathTexGenComponents; | 391 GrGLPathRendering::kST_PathTexGenComponents; |
| 392 if (transform.hasPerspective()) { | 392 if (transform.hasPerspective()) { |
| 393 components = GrGLPathRendering::kSTR_PathTexGenComponents; | 393 components = GrGLPathRendering::kSTR_PathTexGenComponents; |
| 394 } | 394 } |
| 395 glpr->enablePathTexGen(texCoordIndex++, components, transform); | 395 glpr->enablePathTexGen(texCoordIndex++, components, transform); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 void didSetData(GrGLPathRendering* glpr) SK_OVERRIDE { | 399 void didSetData(GrGLPathRendering* glpr) SK_OVERRIDE { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 GrGLint location; | 448 GrGLint location; |
| 449 GR_GL_CALL_RET(gpu->glInterface(), | 449 GR_GL_CALL_RET(gpu->glInterface(), |
| 450 location, | 450 location, |
| 451 GetProgramResourceLocation(programId, | 451 GetProgramResourceLocation(programId, |
| 452 GR_GL_FRAGMENT_INPUT, | 452 GR_GL_FRAGMENT_INPUT, |
| 453 fSeparableVaryingInfos[i].
fVariable.c_str())); | 453 fSeparableVaryingInfos[i].
fVariable.c_str())); |
| 454 fSeparableVaryingInfos[i].fLocation = location; | 454 fSeparableVaryingInfos[i].fLocation = location; |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 void setTransformData(const GrPrimitiveProcessor* primProc, | 458 void setTransformData(const GrPrimitiveProcessor& primProc, |
| 459 int index, | 459 int index, |
| 460 const SkTArray<const GrCoordTransform*, true>& coordTr
ansforms, | 460 const SkTArray<const GrCoordTransform*, true>& coordTr
ansforms, |
| 461 GrGLPathRendering* glpr, | 461 GrGLPathRendering* glpr, |
| 462 GrGLuint programID) SK_OVERRIDE { | 462 GrGLuint programID) SK_OVERRIDE { |
| 463 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; | 463 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; |
| 464 int numTransforms = transforms.count(); | 464 int numTransforms = transforms.count(); |
| 465 for (int t = 0; t < numTransforms; ++t) { | 465 for (int t = 0; t < numTransforms; ++t) { |
| 466 SkASSERT(transforms[t].fHandle.isValid()); | 466 SkASSERT(transforms[t].fHandle.isValid()); |
| 467 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix
(), | 467 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(
), |
| 468 *coordTransforms[t]); | 468 *coordTransforms[t]); |
| 469 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { | 469 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { |
| 470 continue; | 470 continue; |
| 471 } | 471 } |
| 472 transforms[t].fCurrentValue = transform; | 472 transforms[t].fCurrentValue = transform; |
| 473 const SeparableVaryingInfo& fragmentInput = | 473 const SeparableVaryingInfo& fragmentInput = |
| 474 fSeparableVaryingInfos[transforms[t].fHandle.handle()]; | 474 fSeparableVaryingInfos[transforms[t].fHandle.handle()]; |
| 475 SkASSERT(transforms[t].fType == kVec2f_GrSLType || | 475 SkASSERT(transforms[t].fType == kVec2f_GrSLType || |
| 476 transforms[t].fType == kVec3f_GrSLType); | 476 transforms[t].fType == kVec3f_GrSLType); |
| 477 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3
; | 477 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3
; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 const GrGLCaps& caps)
const { | 560 const GrGLCaps& caps)
const { |
| 561 SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport); | 561 SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport); |
| 562 if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) { | 562 if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) { |
| 563 return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt, | 563 return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt, |
| 564 caps.maxFixedFunctionTexture
Coords())); | 564 caps.maxFixedFunctionTexture
Coords())); |
| 565 } else { | 565 } else { |
| 566 return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt)); | 566 return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt)); |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 | 569 |
| OLD | NEW |