Index: src/gpu/gl/GrGLProgramEffects.cpp |
diff --git a/src/gpu/gl/GrGLProgramEffects.cpp b/src/gpu/gl/GrGLProgramEffects.cpp |
index 8ea77d05eb6480ac51fe9c38e85df50ded2524a7..7cf530a91041f5f91297b2d920fd1a51d23a1fa6 100644 |
--- a/src/gpu/gl/GrGLProgramEffects.cpp |
+++ b/src/gpu/gl/GrGLProgramEffects.cpp |
@@ -8,6 +8,7 @@ |
#include "GrGLProgramEffects.h" |
#include "GrDrawEffect.h" |
#include "gl/GrGLEffect.h" |
+#include "gl/GrGLPathRendering.h" |
#include "gl/GrGLShaderBuilder.h" |
#include "gl/GrGLVertexEffect.h" |
#include "gl/GrGpuGL.h" |
@@ -306,6 +307,16 @@ void GrGLVertexProgramEffects::emitTransforms(GrGLFullShaderBuilder* builder, |
uint32_t totalKey = GenTransformKey(drawEffect); |
int numTransforms = drawEffect.effect()->numTransforms(); |
transforms.push_back_n(numTransforms); |
+ |
+ SkTArray<PathTransform, true>* pathTransforms = NULL; |
+ const GrGLCaps* glCaps = builder->ctxInfo().caps(); |
+ if (glCaps->pathRenderingSupport() && |
+ builder->gpu()->glPathRendering()->texturingMode() == |
+ GrGLPathRendering::SeparableShaders_TexturingMode) { |
+ pathTransforms = &fPathTransforms.push_back(); |
+ pathTransforms->push_back_n(numTransforms); |
+ } |
+ |
for (int t = 0; t < numTransforms; t++) { |
GrSLType varyingType = kVoid_GrSLType; |
const char* uniName; |
@@ -341,7 +352,15 @@ void GrGLVertexProgramEffects::emitTransforms(GrGLFullShaderBuilder* builder, |
} |
const char* vsVaryingName; |
const char* fsVaryingName; |
- builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName); |
+ |
+ if (pathTransforms) { |
+ (*pathTransforms)[t].fHandle = |
+ builder->addSeparableVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName); |
+ (*pathTransforms)[t].fType = varyingType; |
+ } else { |
+ builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName); |
+ } |
+ |
const GrGLShaderVar& coords = kPosition_GrCoordSet == get_source_coords(totalKey, t) ? |
builder->positionAttribute() : |
@@ -361,20 +380,27 @@ void GrGLVertexProgramEffects::emitTransforms(GrGLFullShaderBuilder* builder, |
} |
void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, |
- const GrGLProgramDataManager& programResourceManager, |
+ GrGpu::DrawType drawType, |
+ const GrGLProgramDataManager& programDataManager, |
const GrEffectStage* effectStages[]) { |
int numEffects = fGLEffects.count(); |
SkASSERT(numEffects == fTransforms.count()); |
SkASSERT(numEffects == fSamplers.count()); |
for (int e = 0; e < numEffects; ++e) { |
GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords); |
- fGLEffects[e]->setData(programResourceManager, drawEffect); |
- this->setTransformData(programResourceManager, drawEffect, e); |
+ fGLEffects[e]->setData(programDataManager, drawEffect); |
+ if (GrGpu::IsPathRenderingDrawType(drawType)) { |
+ this->setPathTransformData(gpu, programDataManager, drawEffect, e); |
+ } else { |
+ this->setTransformData(gpu, programDataManager, drawEffect, e); |
+ } |
+ |
this->bindTextures(gpu, drawEffect.effect(), e); |
} |
} |
-void GrGLVertexProgramEffects::setTransformData(const GrGLProgramDataManager& programResourceManager, |
+void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu, |
+ const GrGLProgramDataManager& pdman, |
const GrDrawEffect& drawEffect, |
int effectIdx) { |
SkTArray<Transform, true>& transforms = fTransforms[effectIdx]; |
@@ -384,12 +410,40 @@ void GrGLVertexProgramEffects::setTransformData(const GrGLProgramDataManager& pr |
SkASSERT(transforms[t].fHandle.isValid()); |
const SkMatrix& matrix = get_transform_matrix(drawEffect, t); |
if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { |
- programResourceManager.setSkMatrix(transforms[t].fHandle, matrix); |
+ pdman.setSkMatrix(transforms[t].fHandle, matrix); |
transforms[t].fCurrentValue = matrix; |
} |
} |
} |
+void GrGLVertexProgramEffects::setPathTransformData(GrGpuGL* gpu, |
+ const GrGLProgramDataManager& pdman, |
+ const GrDrawEffect& drawEffect, |
+ int effectIdx) { |
+ SkTArray<PathTransform, true>& transforms = fPathTransforms[effectIdx]; |
+ int numTransforms = transforms.count(); |
+ SkASSERT(numTransforms == drawEffect.effect()->numTransforms()); |
+ for (int t = 0; t < numTransforms; ++t) { |
+ SkASSERT(transforms[t].fHandle.isValid()); |
+ const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
+ if (transforms[t].fCurrentValue.cheapEqualTo(transform)) |
bsalomon
2014/08/22 13:31:13
minor nit: we always use {} for if
Kimmo Kinnunen
2014/08/25 12:43:28
Done.
|
+ continue; |
+ transforms[t].fCurrentValue = transform; |
+ switch (transforms[t].fType) { |
+ case kVec2f_GrSLType: { |
bsalomon
2014/08/22 13:31:12
optional: {} only required if a var is declared in
Kimmo Kinnunen
2014/08/25 12:43:28
Done.
|
+ pdman.setProgramPathFragmentInputTransform(transforms[t].fHandle, 2, transform); |
+ break; |
+ } |
+ case kVec3f_GrSLType: { |
+ pdman.setProgramPathFragmentInputTransform(transforms[t].fHandle, 3, transform); |
+ break; |
+ } |
+ default: |
+ SkFAIL("Unexpected matrixs type."); |
bsalomon
2014/08/22 13:31:12
typo, s on matrix
Kimmo Kinnunen
2014/08/25 12:43:28
Done.
|
+ } |
+ } |
+} |
+ |
GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderBuilder* builder, |
int reserveCount) |
: fBuilder(builder) |
@@ -455,14 +509,15 @@ void GrGLPathTexGenProgramEffects::setupPathTexGen(GrGLFragmentOnlyShaderBuilder |
} |
void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu, |
- const GrGLProgramDataManager& programResourceManager, |
- const GrEffectStage* effectStages[]) { |
+ GrGpu::DrawType, |
+ const GrGLProgramDataManager& pdman, |
+ const GrEffectStage* effectStages[]) { |
int numEffects = fGLEffects.count(); |
SkASSERT(numEffects == fTransforms.count()); |
SkASSERT(numEffects == fSamplers.count()); |
for (int e = 0; e < numEffects; ++e) { |
GrDrawEffect drawEffect(*effectStages[e], false); |
- fGLEffects[e]->setData(programResourceManager, drawEffect); |
+ fGLEffects[e]->setData(pdman, drawEffect); |
this->setPathTexGenState(gpu, drawEffect, e); |
this->bindTextures(gpu, drawEffect.effect(), e); |
} |