aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-09-16 06:46:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-16 06:46:30 -0700
commit8ddbe8b9366c8c59c4fb55f01f253de8a0b37d6e (patch)
tree737dce511f4f0314e313c825a7db8a38b3544a94 /src/gpu/gl
parentee6206572b42fec11f83ad0c1e6d435903640518 (diff)
removing GrDrawEffect
BUG=skia: R=bsalomon@google.com Author: joshualitt@chromium.org Review URL: https://codereview.chromium.org/571163002
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLEffect.h17
-rw-r--r--src/gpu/gl/GrGLGeometryProcessor.h4
-rw-r--r--src/gpu/gl/GrGLProgram.cpp1
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp16
-rw-r--r--src/gpu/gl/GrGLProgramEffects.cpp166
-rw-r--r--src/gpu/gl/GrGLProgramEffects.h26
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp1
7 files changed, 116 insertions, 115 deletions
diff --git a/src/gpu/gl/GrGLEffect.h b/src/gpu/gl/GrGLEffect.h
index e7d847d0a2..24c20c6d57 100644
--- a/src/gpu/gl/GrGLEffect.h
+++ b/src/gpu/gl/GrGLEffect.h
@@ -20,19 +20,16 @@ class GrGLShaderBuilder;
include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitting the
GLSL code that implements a GrEffect and for uploading uniforms at draw time. If they don't
always emit the same GLSL code, they must have a function:
- static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*)
+ static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*)
that is used to implement a program cache. When two GrEffects produce the same key this means
that their GrGLEffects would emit the same GLSL code.
The GrGLEffect subclass must also have a constructor of the form:
- EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDrawEffect&)
- The effect held by the GrDrawEffect is guaranteed to be of the type that generated the
- GrGLEffect subclass instance.
+ EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEffect&)
These objects are created by the factory object returned by the GrEffect::getFactory().
*/
-class GrDrawEffect;
class GrGLTexture;
class GrGLGeometryProcessor;
@@ -55,7 +52,7 @@ public:
stages.
@param builder Interface used to emit code in the shaders.
- @param drawEffect A wrapper on the effect that generated this program stage.
+ @param effect The effect that generated this program stage.
@param key The key that was computed by GenKey() from the generating GrEffect.
@param outputColor A predefined vec4 in the FS in which the stage should place its output
color (or coverage).
@@ -69,7 +66,7 @@ public:
reads in the generated code.
*/
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrDrawEffect& drawEffect,
+ const GrEffect& effect,
const GrEffectKey& key,
const char* outputColor,
const char* inputColor,
@@ -78,16 +75,16 @@ public:
/** A GrGLEffect instance can be reused with any GrEffect that produces the same stage
key; this function reads data from a GrEffect and uploads any uniform variables required
- by the shaders created in emitCode(). The GrEffect installed in the GrDrawEffect is
+ by the shaders created in emitCode(). The GrEffect is
guaranteed to be of the same type that created this GrGLEffect and to have an identical
effect key as the one that created this GrGLEffect. Effects that use local coords have
to consider whether the GrEffectStage's coord change matrix should be used. When explicit
local coordinates are used it can be ignored. */
- virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) {}
+ virtual void setData(const GrGLProgramDataManager&, const GrEffect&) {}
const char* name() const { return fFactory.name(); }
- static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
+ static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
/** Used by the system when generating shader code, to see if this effect can be downcasted to
the internal GrGLGeometryProcessor type */
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h
index 4b9bd449fb..d057154c6b 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -25,7 +25,7 @@ public:
* This allows the effect subclass to emit vertex code.
*/
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrDrawEffect& drawEffect,
+ const GrEffect& effect,
const GrEffectKey& key,
const char* outputColor,
const char* inputColor,
@@ -35,7 +35,7 @@ public:
* Provide a default override for base class's emitCode() function.
*/
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrDrawEffect& drawEffect,
+ const GrEffect& effect,
const GrEffectKey& key,
const char* outputColor,
const char* inputColor,
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 96c5367c6a..112cecd995 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -9,7 +9,6 @@
#include "GrAllocator.h"
#include "GrEffect.h"
#include "GrCoordTransform.h"
-#include "GrDrawEffect.h"
#include "GrGLEffect.h"
#include "GrGpuGL.h"
#include "GrGLPathRendering.h"
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index bde4072cc3..b49cff97af 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -8,7 +8,6 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrGLProgramDesc.h"
#include "GrBackendEffectFactory.h"
-#include "GrDrawEffect.h"
#include "GrEffect.h"
#include "GrGpuGL.h"
#include "GrOptDrawState.h"
@@ -24,24 +23,27 @@ bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage,
bool* setTrueIfReadsPos,
bool* setTrueIfRequiresVertexShader) {
const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
- GrDrawEffect drawEffect(stage, useExplicitLocalCoords);
- if (stage.getEffect()->willReadDstColor()) {
+ const GrEffect& effect = *stage.getEffect();
+ if (effect.willReadDstColor()) {
*setTrueIfReadsDst = true;
}
- if (stage.getEffect()->willReadFragmentPosition()) {
+ if (effect.willReadFragmentPosition()) {
*setTrueIfReadsPos = true;
}
- if (stage.getEffect()->requiresVertexShader()) {
+ if (effect.requiresVertexShader()) {
*setTrueIfRequiresVertexShader = true;
}
- factory.getGLEffectKey(drawEffect, caps, b);
+ factory.getGLEffectKey(effect, caps, b);
size_t size = b->size();
if (size > SK_MaxU16) {
*effectKeySize = 0; // suppresses a warning.
return false;
}
*effectKeySize = SkToU16(size);
- if (!GrGLProgramEffects::GenEffectMetaKey(drawEffect, caps, b)) {
+ if (!GrGLProgramEffects::GenEffectMetaKey(stage,
+ useExplicitLocalCoords,
+ caps,
+ b)) {
return false;
}
return true;
diff --git a/src/gpu/gl/GrGLProgramEffects.cpp b/src/gpu/gl/GrGLProgramEffects.cpp
index 369ec10760..d69cbbb452 100644
--- a/src/gpu/gl/GrGLProgramEffects.cpp
+++ b/src/gpu/gl/GrGLProgramEffects.cpp
@@ -7,7 +7,6 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrGLProgramEffects.h"
-#include "GrDrawEffect.h"
#include "gl/GrGLEffect.h"
#include "gl/GrGLPathRendering.h"
#include "gl/builders/GrGLProgramBuilder.h"
@@ -89,15 +88,17 @@ GrCoordSet get_source_coords(uint32_t transformKey, int transformIdx) {
/**
* Retrieves the final matrix that a transform needs to apply to its source coords.
*/
-SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx) {
- const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(transformIdx);
+SkMatrix get_transform_matrix(const GrEffectStage& effectStage,
+ bool useExplicitLocalCoords,
+ int transformIdx) {
+ const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(transformIdx);
SkMatrix combined;
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
// If we have explicit local coords then we shouldn't need a coord change.
- SkASSERT(!drawEffect.programHasExplicitLocalCoords() ||
- drawEffect.getCoordChangeMatrix().isIdentity());
- combined.setConcat(coordTransform.getMatrix(), drawEffect.getCoordChangeMatrix());
+ const SkMatrix& ccm =
+ useExplicitLocalCoords ? SkMatrix::I() : effectStage.getCoordChangeMatrix();
+ combined.setConcat(coordTransform.getMatrix(), ccm);
} else {
combined = coordTransform.getMatrix();
}
@@ -113,18 +114,19 @@ SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx)
}
return combined;
}
-
}
////////////////////////////////////////////////////////////////////////////////
-bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps,
+bool GrGLProgramEffects::GenEffectMetaKey(const GrEffectStage& effectStage,
+ bool useExplicitLocalCoords,
+ const GrGLCaps& caps,
GrEffectKeyBuilder* b) {
- uint32_t textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps);
- uint32_t transformKey = GrGLProgramEffects::GenTransformKey(drawEffect);
- uint32_t attribKey = GrGLProgramEffects::GenAttribKey(drawEffect.castEffect<GrEffect>());
- uint32_t classID = drawEffect.effect()->getFactory().effectClassID();
+ uint32_t textureKey = GrGLProgramEffects::GenTextureKey(effectStage.getEffect(), caps);
+ uint32_t transformKey = GrGLProgramEffects::GenTransformKey(effectStage,useExplicitLocalCoords);
+ uint32_t attribKey = GrGLProgramEffects::GenAttribKey(effectStage.getEffect());
+ uint32_t classID = effectStage.getEffect()->getFactory().effectClassID();
// Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
// don't fit.
@@ -139,10 +141,10 @@ bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const
return true;
}
-uint32_t GrGLProgramEffects::GenAttribKey(const GrEffect& effect) {
+uint32_t GrGLProgramEffects::GenAttribKey(const GrEffect* effect) {
uint32_t key = 0;
- const GrEffect::VertexAttribArray& vars = effect.getVertexAttribs();
+ const GrEffect::VertexAttribArray& vars = effect->getVertexAttribs();
int numAttributes = vars.count();
SkASSERT(numAttributes <= 2);
for (int a = 0; a < numAttributes; ++a) {
@@ -152,24 +154,22 @@ uint32_t GrGLProgramEffects::GenAttribKey(const GrEffect& effect) {
return key;
}
-uint32_t GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
+uint32_t GrGLProgramEffects::GenTransformKey(const GrEffectStage& effectStage,
+ bool useExplicitLocalCoords) {
uint32_t totalKey = 0;
- int numTransforms = drawEffect.effect()->numTransforms();
+ int numTransforms = effectStage.getEffect()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
uint32_t key = 0;
- const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(t);
+ const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(t);
SkMatrix::TypeMask type0 = coordTransform.getMatrix().getType();
- SkMatrix::TypeMask type1;
- if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
- type1 = drawEffect.getCoordChangeMatrix().getType();
- } else {
- if (drawEffect.programHasExplicitLocalCoords()) {
- // We only make the key indicate that device coords are referenced when the local coords
- // are not actually determined by positions. Otherwise the local coords var and position
- // var are identical.
- key |= kPositionCoords_Flag;
- }
- type1 = SkMatrix::kIdentity_Mask;
+ SkMatrix::TypeMask type1 = SkMatrix::kIdentity_Mask;
+ if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLocalCoords) {
+ type1 = effectStage.getCoordChangeMatrix().getType();
+ } else if (kPosition_GrCoordSet == coordTransform.sourceCoords() && useExplicitLocalCoords) {
+ // We only make the key indicate that device coords are referenced when the local coords
+ // are not actually determined by positions. Otherwise the local coords var and position
+ // var are identical.
+ key |= kPositionCoords_Flag;
}
int combinedTypes = type0 | type1;
@@ -186,11 +186,11 @@ uint32_t GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
return totalKey;
}
-uint32_t GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps) {
+uint32_t GrGLProgramEffects::GenTextureKey(const GrEffect* effect, const GrGLCaps& caps) {
uint32_t key = 0;
- int numTextures = drawEffect.effect()->numTextures();
+ int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
- const GrTextureAccess& access = drawEffect.effect()->textureAccess(t);
+ const GrTextureAccess& access = effect->textureAccess(t);
uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config());
if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) {
key |= 1 << t;
@@ -207,10 +207,10 @@ GrGLProgramEffects::~GrGLProgramEffects() {
}
void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder,
- const GrEffect* effect,
+ const GrEffect& effect,
TextureSamplerArray* outSamplers) {
SkTArray<Sampler, true>& samplers = fSamplers.push_back();
- int numTextures = effect->numTextures();
+ int numTextures = effect.numTextures();
samplers.push_back_n(numTextures);
SkString name;
for (int t = 0; t < numTextures; ++t) {
@@ -219,7 +219,7 @@ void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder,
kSampler2D_GrSLType,
name.c_str());
SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler,
- (samplers[t].fUniform, effect->textureAccess(t)));
+ (samplers[t].fUniform, effect.textureAccess(t)));
}
}
@@ -237,13 +237,13 @@ void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResou
}
}
-void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect* effect, int effectIdx) {
+void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect& effect, int effectIdx) {
const SkTArray<Sampler, true>& samplers = fSamplers[effectIdx];
int numSamplers = samplers.count();
- SkASSERT(numSamplers == effect->numTextures());
+ SkASSERT(numSamplers == effect.numTextures());
for (int s = 0; s < numSamplers; ++s) {
SkASSERT(samplers[s].fTextureUnit >= 0);
- const GrTextureAccess& textureAccess = effect->textureAccess(s);
+ const GrTextureAccess& textureAccess = effect.textureAccess(s);
gpu->bindTexture(samplers[s].fTextureUnit,
textureAccess.getParams(),
static_cast<GrGLTexture*>(textureAccess.getTexture()));
@@ -258,18 +258,17 @@ void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder,
const char* outColor,
const char* inColor,
int stageIndex) {
- GrDrawEffect drawEffect(stage, fHasExplicitLocalCoords);
- const GrEffect* effect = stage.getEffect();
- SkSTArray<2, TransformedCoords> coords(effect->numTransforms());
- SkSTArray<4, TextureSampler> samplers(effect->numTextures());
+ const GrEffect& effect = *stage.getEffect();
+ SkSTArray<2, TransformedCoords> coords(effect.numTransforms());
+ SkSTArray<4, TextureSampler> samplers(effect.numTextures());
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
vsBuilder->emitAttributes(stage);
- this->emitTransforms(builder, drawEffect, &coords);
+ this->emitTransforms(builder, stage, &coords);
this->emitSamplers(builder, effect, &samplers);
- GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect);
+ GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
fGLEffects.push_back(glEffect);
// Enclose custom code in a block to avoid namespace conflicts
@@ -280,9 +279,9 @@ void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder,
if (glEffect->isVertexEffect()) {
GrGLGeometryProcessor* vertexEffect = static_cast<GrGLGeometryProcessor*>(glEffect);
- vertexEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers);
+ vertexEffect->emitCode(builder, effect, key, outColor, inColor, coords, samplers);
} else {
- glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers);
+ glEffect->emitCode(builder, effect, key, outColor, inColor, coords, samplers);
}
vsBuilder->codeAppend("\t}\n");
@@ -290,11 +289,11 @@ void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder,
}
void GrGLVertexProgramEffects::emitTransforms(GrGLFullProgramBuilder* builder,
- const GrDrawEffect& drawEffect,
+ const GrEffectStage& effectStage,
TransformedCoordsArray* outCoords) {
SkTArray<Transform, true>& transforms = fTransforms.push_back();
- uint32_t totalKey = GenTransformKey(drawEffect);
- int numTransforms = drawEffect.effect()->numTransforms();
+ uint32_t totalKey = GenTransformKey(effectStage, fHasExplicitLocalCoords);
+ int numTransforms = effectStage.getEffect()->numTransforms();
transforms.push_back_n(numTransforms);
SkTArray<PathTransform, true>* pathTransforms = NULL;
@@ -375,15 +374,16 @@ void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
SkASSERT(numEffects == fTransforms.count());
SkASSERT(numEffects == fSamplers.count());
for (int e = 0; e < numEffects; ++e) {
- GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords);
- fGLEffects[e]->setData(programDataManager, drawEffect);
+ const GrEffectStage& effectStage = *effectStages[e];
+ const GrEffect& effect = *effectStage.getEffect();
+ fGLEffects[e]->setData(programDataManager, effect);
if (GrGpu::IsPathRenderingDrawType(drawType)) {
- this->setPathTransformData(gpu, programDataManager, drawEffect, e);
+ this->setPathTransformData(gpu, programDataManager, effectStage, e);
} else {
- this->setTransformData(gpu, programDataManager, drawEffect, e);
+ this->setTransformData(gpu, programDataManager, effectStage, e);
}
- this->bindTextures(gpu, drawEffect.effect(), e);
+ this->bindTextures(gpu, effect, e);
}
}
@@ -394,27 +394,27 @@ void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
SkASSERT(1 == fTransforms.count());
SkASSERT(1 == fSamplers.count());
SkASSERT(1 == fGLEffects.count());
- GrDrawEffect drawEffect(*effectStage, fHasExplicitLocalCoords);
- fGLEffects[0]->setData(programDataManager, drawEffect);
+ const GrEffect& effect = *effectStage->getEffect();
+ fGLEffects[0]->setData(programDataManager, effect);
if (GrGpu::IsPathRenderingDrawType(drawType)) {
- this->setPathTransformData(gpu, programDataManager, drawEffect, 0);
+ this->setPathTransformData(gpu, programDataManager, *effectStage, 0);
} else {
- this->setTransformData(gpu, programDataManager, drawEffect, 0);
+ this->setTransformData(gpu, programDataManager, *effectStage, 0);
}
- this->bindTextures(gpu, drawEffect.effect(), 0);
+ this->bindTextures(gpu, effect, 0);
}
void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu,
const GrGLProgramDataManager& pdman,
- const GrDrawEffect& drawEffect,
+ const GrEffectStage& effectStage,
int effectIdx) {
SkTArray<Transform, true>& transforms = fTransforms[effectIdx];
int numTransforms = transforms.count();
- SkASSERT(numTransforms == drawEffect.effect()->numTransforms());
+ SkASSERT(numTransforms == effectStage.getEffect()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
- const SkMatrix& matrix = get_transform_matrix(drawEffect, t);
+ const SkMatrix& matrix = get_transform_matrix(effectStage, fHasExplicitLocalCoords, t);
if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
pdman.setSkMatrix(transforms[t].fHandle, matrix);
transforms[t].fCurrentValue = matrix;
@@ -424,14 +424,14 @@ void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu,
void GrGLVertexProgramEffects::setPathTransformData(GrGpuGL* gpu,
const GrGLProgramDataManager& pdman,
- const GrDrawEffect& drawEffect,
+ const GrEffectStage& effectStage,
int effectIdx) {
SkTArray<PathTransform, true>& transforms = fPathTransforms[effectIdx];
int numTransforms = transforms.count();
- SkASSERT(numTransforms == drawEffect.effect()->numTransforms());
+ SkASSERT(numTransforms == effectStage.getEffect()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
- const SkMatrix& transform = get_transform_matrix(drawEffect, t);
+ const SkMatrix& transform = get_transform_matrix(effectStage, fHasExplicitLocalCoords, t);
if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
continue;
}
@@ -473,16 +473,15 @@ void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyProgramBuilder* bu
const char* outColor,
const char* inColor,
int stageIndex) {
- GrDrawEffect drawEffect(stage, false);
- const GrEffect* effect = stage.getEffect();
- SkSTArray<2, TransformedCoords> coords(effect->numTransforms());
- SkSTArray<4, TextureSampler> samplers(effect->numTextures());
+ const GrEffect& effect = *stage.getEffect();
+ SkSTArray<2, TransformedCoords> coords(effect.numTransforms());
+ SkSTArray<4, TextureSampler> samplers(effect.numTextures());
- SkASSERT(0 == effect->getVertexAttribs().count());
- this->setupPathTexGen(builder, drawEffect, &coords);
+ SkASSERT(0 == effect.getVertexAttribs().count());
+ this->setupPathTexGen(builder, stage, &coords);
this->emitSamplers(builder, effect, &samplers);
- GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect);
+ GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
fGLEffects.push_back(glEffect);
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
@@ -492,16 +491,16 @@ void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyProgramBuilder* bu
fsBuilder->codeAppend(openBrace.c_str());
SkASSERT(!glEffect->isVertexEffect());
- glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers);
+ glEffect->emitCode(builder, effect, key, outColor, inColor, coords, samplers);
fsBuilder->codeAppend("\t}\n");
}
void GrGLPathTexGenProgramEffects::setupPathTexGen(GrGLFragmentOnlyProgramBuilder* builder,
- const GrDrawEffect& drawEffect,
+ const GrEffectStage& effectStage,
TransformedCoordsArray* outCoords) {
- int numTransforms = drawEffect.effect()->numTransforms();
- uint32_t totalKey = GenTransformKey(drawEffect);
+ int numTransforms = effectStage.getEffect()->numTransforms();
+ uint32_t totalKey = GenTransformKey(effectStage, false);
int texCoordIndex = builder->addTexCoordSets(numTransforms);
SkNEW_APPEND_TO_TARRAY(&fTransforms, Transforms, (totalKey, texCoordIndex));
SkString name;
@@ -522,23 +521,24 @@ void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu,
SkASSERT(numEffects == fTransforms.count());
SkASSERT(numEffects == fSamplers.count());
for (int e = 0; e < numEffects; ++e) {
- GrDrawEffect drawEffect(*effectStages[e], false);
- fGLEffects[e]->setData(pdman, drawEffect);
- this->setPathTexGenState(gpu, drawEffect, e);
- this->bindTextures(gpu, drawEffect.effect(), e);
+ const GrEffectStage& effectStage = *effectStages[e];
+ const GrEffect& effect = *effectStage.getEffect();
+ fGLEffects[e]->setData(pdman, effect);
+ this->setPathTexGenState(gpu, effectStage, e);
+ this->bindTextures(gpu, effect, e);
}
}
void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
- const GrDrawEffect& drawEffect,
+ const GrEffectStage& effectStage,
int effectIdx) {
uint32_t totalKey = fTransforms[effectIdx].fTransformKey;
int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
- int numTransforms = drawEffect.effect()->numTransforms();
+ int numTransforms = effectStage.getEffect()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
switch (get_matrix_type(totalKey, t)) {
case kNoPersp_MatrixType: {
- const SkMatrix& transform = get_transform_matrix(drawEffect, t);
+ const SkMatrix& transform = get_transform_matrix(effectStage, false, t);
gpu->glPathRendering()->enablePathTexGen(
texCoordIndex++,
GrGLPathRendering::kST_PathTexGenComponents,
@@ -546,7 +546,7 @@ void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
break;
}
case kGeneral_MatrixType: {
- const SkMatrix& transform = get_transform_matrix(drawEffect, t);
+ const SkMatrix& transform = get_transform_matrix(effectStage, false, t);
gpu->glPathRendering()->enablePathTexGen(
texCoordIndex++,
GrGLPathRendering::kSTR_PathTexGenComponents,
diff --git a/src/gpu/gl/GrGLProgramEffects.h b/src/gpu/gl/GrGLProgramEffects.h
index 79afa0a168..dd3feab843 100644
--- a/src/gpu/gl/GrGLProgramEffects.h
+++ b/src/gpu/gl/GrGLProgramEffects.h
@@ -39,7 +39,10 @@ public:
* which must be different for every GrEffect subclass. It can fail if an effect uses too many
* textures, attributes, etc for the space allotted in the meta-key.
*/
- static bool GenEffectMetaKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static bool GenEffectMetaKey(const GrEffectStage&,
+ bool,
+ const GrGLCaps&,
+ GrEffectKeyBuilder*);
virtual ~GrGLProgramEffects();
@@ -114,9 +117,9 @@ protected:
/**
* Helpers for GenEffectMetaKey.
*/
- static uint32_t GenAttribKey(const GrEffect&);
- static uint32_t GenTransformKey(const GrDrawEffect&);
- static uint32_t GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
+ static uint32_t GenAttribKey(const GrEffect*);
+ static uint32_t GenTransformKey(const GrEffectStage&, bool useExplicitLocalCoords);
+ static uint32_t GenTextureKey(const GrEffect*, const GrGLCaps&);
GrGLProgramEffects(int reserveCount)
: fGLEffects(reserveCount)
@@ -128,12 +131,12 @@ protected:
* appends the necessary data to the TextureSamplerArray* object so effects can add texture
* lookups to their code. This method is only meant to be called during the construction phase.
*/
- void emitSamplers(GrGLProgramBuilder*, const GrEffect*, TextureSamplerArray*);
+ void emitSamplers(GrGLProgramBuilder*, const GrEffect&, TextureSamplerArray*);
/**
* Helper for setData(). Binds all the textures for an effect.
*/
- void bindTextures(GrGpuGL*, const GrEffect*, int effectIdx);
+ void bindTextures(GrGpuGL*, const GrEffect&, int effectIdx);
struct Sampler {
SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
@@ -212,14 +215,15 @@ private:
* TransformedCoordsArray* object, which is in turn passed to the effect's emitCode() function.
*/
void emitTransforms(GrGLFullProgramBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
TransformedCoordsArray*);
/**
* Helper for setData(). Sets all the transform matrices for an effect.
*/
- void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrDrawEffect&, int effectIdx);
- void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrDrawEffect&,
+ void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&,
+ int effectIdx);
+ void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&,
int effectIdx);
struct Transform {
@@ -307,13 +311,13 @@ private:
* effect's emitCode() function.
*/
void setupPathTexGen(GrGLFragmentOnlyProgramBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
TransformedCoordsArray*);
/**
* Helper for setData(). Sets the PathTexGen state for each transform in an effect.
*/
- void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx);
+ void setPathTexGenState(GrGpuGL*, const GrEffectStage&, int effectIdx);
struct Transforms {
Transforms(uint32_t transformKey, int texCoordIndex)
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 3844a30f92..279f3a2d53 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -9,7 +9,6 @@
#include "gl/GrGLSLPrettyPrint.h"
#include "gl/GrGLUniformHandle.h"
#include "GrCoordTransform.h"
-#include "GrDrawEffect.h"
#include "../GrGpuGL.h"
#include "GrGLFragmentShaderBuilder.h"
#include "GrGLProgramBuilder.h"