Index: src/gpu/effects/GrDashingEffect.cpp |
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp |
index f4298eb4a0c6c7934488af89d99e05d7a838e472..af6c4769a16f9a089c41d7b29dcc6048f0f3a859 100644 |
--- a/src/gpu/effects/GrDashingEffect.cpp |
+++ b/src/gpu/effects/GrDashingEffect.cpp |
@@ -10,9 +10,9 @@ |
#include "../GrAARectRenderer.h" |
-#include "effects/GrVertexEffect.h" |
+#include "effects/GrGeometryProcessor.h" |
#include "gl/GrGLEffect.h" |
-#include "gl/GrGLVertexEffect.h" |
+#include "gl/GrGLGeometryProcessor.h" |
#include "gl/GrGLSL.h" |
#include "GrContext.h" |
#include "GrCoordTransform.h" |
@@ -69,6 +69,10 @@ struct DashLineVertex { |
SkPoint fDashPos; |
}; |
+extern const GrVertexAttrib gDashLineNoAAVertexAttribs[] = { |
+ { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding } |
+}; |
+ |
extern const GrVertexAttrib gDashLineVertexAttribs[] = { |
{ kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, |
{ kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding }, |
@@ -346,12 +350,16 @@ bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const GrPaint& paint, |
GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_DashCap : |
GrDashingEffect::kNonRound_DashCap; |
drawState->setGeometryProcessor( |
- GrDashingEffect::Create(edgeType, devInfo, strokeWidth, capType), 1)->unref(); |
- } |
+ GrDashingEffect::Create(edgeType, devInfo, strokeWidth, capType))->unref(); |
- // Set up the vertex data for the line and start/end dashes |
- drawState->setVertexAttribs<gDashLineVertexAttribs>(SK_ARRAY_COUNT(gDashLineVertexAttribs), |
- sizeof(DashLineVertex)); |
+ // Set up the vertex data for the line and start/end dashes |
+ drawState->setVertexAttribs<gDashLineVertexAttribs>(SK_ARRAY_COUNT(gDashLineVertexAttribs), |
+ sizeof(DashLineVertex)); |
+ } else { |
+ // Set up the vertex data for the line and start/end dashes |
+ drawState->setVertexAttribs<gDashLineNoAAVertexAttribs>( |
+ SK_ARRAY_COUNT(gDashLineNoAAVertexAttribs), sizeof(DashLineVertex)); |
+ } |
int totalRectCnt = 0; |
@@ -414,6 +422,10 @@ bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const GrPaint& paint, |
////////////////////////////////////////////////////////////////////////////// |
+const GrShaderVar kAttrCoord("aCoord", |
+ kVec2f_GrSLType, |
+ GrShaderVar::kAttribute_TypeModifier); |
+ |
class GLDashingCircleEffect; |
/* |
* This effect will draw a dotted line (defined as a dashed lined with round caps and no on |
@@ -424,7 +436,7 @@ class GLDashingCircleEffect; |
* transform the line to be horizontal, with the start of line at the origin then shifted to the |
* right by half the off interval. The line then goes in the positive x direction. |
*/ |
-class DashingCircleEffect : public GrVertexEffect { |
+class DashingCircleEffect : public GrGeometryProcessor { |
public: |
typedef SkPathEffect::DashInfo DashInfo; |
@@ -460,12 +472,12 @@ private: |
GR_DECLARE_EFFECT_TEST; |
- typedef GrVertexEffect INHERITED; |
+ typedef GrGeometryProcessor INHERITED; |
}; |
////////////////////////////////////////////////////////////////////////////// |
-class GLDashingCircleEffect : public GrGLVertexEffect { |
+class GLDashingCircleEffect : public GrGLGeometryProcessor { |
public: |
GLDashingCircleEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
@@ -486,7 +498,7 @@ private: |
SkScalar fPrevRadius; |
SkScalar fPrevCenterX; |
SkScalar fPrevIntervalLength; |
- typedef GrGLVertexEffect INHERITED; |
+ typedef GrGLGeometryProcessor INHERITED; |
}; |
GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendEffectFactory& factory, |
@@ -517,9 +529,7 @@ void GLDashingCircleEffect::emitCode(GrGLFullProgramBuilder* builder, |
builder->addVarying(kVec2f_GrSLType, "Coord", &vsCoordName, &fsCoordName); |
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
- const SkString* attr0Name = |
- vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); |
- vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, attr0Name->c_str()); |
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, kAttrCoord.c_str()); |
// transforms all points so that we can compare them to our test circle |
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
@@ -589,7 +599,7 @@ DashingCircleEffect::DashingCircleEffect(GrEffectEdgeType edgeType, const DashIn |
fRadius = radius; |
fCenterX = SkScalarHalf(offLen); |
- this->addVertexAttrib(kVec2f_GrSLType); |
+ this->addVertexAttrib(kAttrCoord); |
} |
bool DashingCircleEffect::onIsEqual(const GrEffect& other) const { |
@@ -635,7 +645,7 @@ class GLDashingLineEffect; |
* line at the origin then shifted to the right by half the off interval. The line then goes in the |
* positive x direction. |
*/ |
-class DashingLineEffect : public GrVertexEffect { |
+class DashingLineEffect : public GrGeometryProcessor { |
public: |
typedef SkPathEffect::DashInfo DashInfo; |
@@ -668,12 +678,12 @@ private: |
GR_DECLARE_EFFECT_TEST; |
- typedef GrVertexEffect INHERITED; |
+ typedef GrGeometryProcessor INHERITED; |
}; |
////////////////////////////////////////////////////////////////////////////// |
-class GLDashingLineEffect : public GrGLVertexEffect { |
+class GLDashingLineEffect : public GrGLGeometryProcessor { |
public: |
GLDashingLineEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
@@ -694,7 +704,7 @@ private: |
GrGLProgramDataManager::UniformHandle fIntervalUniform; |
SkRect fPrevRect; |
SkScalar fPrevIntervalLength; |
- typedef GrGLVertexEffect INHERITED; |
+ typedef GrGLGeometryProcessor INHERITED; |
}; |
GLDashingLineEffect::GLDashingLineEffect(const GrBackendEffectFactory& factory, |
@@ -729,9 +739,7 @@ void GLDashingLineEffect::emitCode(GrGLFullProgramBuilder* builder, |
const char *vsCoordName, *fsCoordName; |
builder->addVarying(kVec2f_GrSLType, "Coord", &vsCoordName, &fsCoordName); |
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
- const SkString* attr0Name = |
- vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); |
- vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, attr0Name->c_str()); |
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, kAttrCoord.c_str()); |
// transforms all points so that we can compare them to our test rect |
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
@@ -809,7 +817,7 @@ DashingLineEffect::DashingLineEffect(GrEffectEdgeType edgeType, const DashInfo& |
fIntervalLength = onLen + offLen; |
fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); |
- this->addVertexAttrib(kVec2f_GrSLType); |
+ this->addVertexAttrib(kAttrCoord); |
} |
bool DashingLineEffect::onIsEqual(const GrEffect& other) const { |