Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: src/gpu/effects/GrBezierEffect.cpp

Issue 822423004: Move most of the transform logic into the primitive processors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrBezierEffect.h ('k') | src/gpu/effects/GrBitmapTextGeoProc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrBezierEffect.cpp
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index e16601dee111bd682716e691dbd90a52109bfd81..f6743457284786f970ec8e49eb733e2813e4f526 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -24,7 +24,7 @@ public:
GrGLConicEffect(const GrGeometryProcessor&,
const GrBatchTracker&);
- void emitCode(const EmitArgs&) SK_OVERRIDE;
+ void onEmitCode(EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrGeometryProcessor&,
const GrBatchTracker&,
@@ -66,12 +66,15 @@ GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor,
fEdgeType = ce.getEdgeType();
}
-void GrGLConicEffect::emitCode(const EmitArgs& args) {
+void GrGLConicEffect::onEmitCode(EmitArgs& args) {
GrGLGPBuilder* pb = args.fPB;
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
const ConicBatchTracker& local = args.fBT.cast<ConicBatchTracker>();
+ // emit attributes
+ vsBuilder->emitAttributes(gp);
+
GrGLVertToFrag v(kVec4f_GrSLType);
args.fPB->addVarying("ConicCoeffs", &v);
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
@@ -80,17 +83,17 @@ void GrGLConicEffect::emitCode(const EmitArgs& args) {
this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
&fColorUniform);
- // setup coord outputs
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPosition()->fName);
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()->fName);
-
// setup uniform viewMatrix
this->addUniformViewMatrix(pb);
- // setup position varying
- vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), this->uViewM(),
+ // Setup position
+ vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
gp.inPosition()->fName);
+ // emit transforms with position
+ this->emitTransforms(pb, this->position(), gp.inPosition()->fName, gp.localMatrix(),
+ args.fTransformsIn, args.fTransformsOut);
+
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppend("float edgeAlpha;");
@@ -184,7 +187,8 @@ void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt,
GrGLConicEffect::GenKey(*this, bt, caps, b);
}
-GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt) const {
+GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt,
+ const GrGLCaps&) const {
return SkNEW_ARGS(GrGLConicEffect, (*this, bt));
}
@@ -258,7 +262,7 @@ public:
GrGLQuadEffect(const GrGeometryProcessor&,
const GrBatchTracker&);
- void emitCode(const EmitArgs&) SK_OVERRIDE;
+ void onEmitCode(EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrGeometryProcessor&,
const GrBatchTracker&,
@@ -300,12 +304,15 @@ GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor,
fEdgeType = ce.getEdgeType();
}
-void GrGLQuadEffect::emitCode(const EmitArgs& args) {
+void GrGLQuadEffect::onEmitCode(EmitArgs& args) {
GrGLGPBuilder* pb = args.fPB;
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>();
+ // emit attributes
+ vsBuilder->emitAttributes(gp);
+
GrGLVertToFrag v(kVec4f_GrSLType);
args.fPB->addVarying("HairQuadEdge", &v);
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
@@ -314,17 +321,17 @@ void GrGLQuadEffect::emitCode(const EmitArgs& args) {
this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
&fColorUniform);
- // setup coord outputs
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPosition()->fName);
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()->fName);
-
// setup uniform viewMatrix
this->addUniformViewMatrix(pb);
- // setup position varying
- vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), this->uViewM(),
+ // Setup position
+ vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
gp.inPosition()->fName);
+ // emit transforms with position
+ this->emitTransforms(pb, this->position(), gp.inPosition()->fName, gp.localMatrix(),
+ args.fTransformsIn, args.fTransformsOut);
+
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("float edgeAlpha;");
@@ -404,7 +411,8 @@ void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt,
GrGLQuadEffect::GenKey(*this, bt, caps, b);
}
-GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt) const {
+GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt,
+ const GrGLCaps&) const {
return SkNEW_ARGS(GrGLQuadEffect, (*this, bt));
}
@@ -478,7 +486,7 @@ public:
GrGLCubicEffect(const GrGeometryProcessor&,
const GrBatchTracker&);
- void emitCode(const EmitArgs&) SK_OVERRIDE;
+ void onEmitCode(EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrGeometryProcessor&,
const GrBatchTracker&,
@@ -514,11 +522,14 @@ GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor,
fEdgeType = ce.getEdgeType();
}
-void GrGLCubicEffect::emitCode(const EmitArgs& args) {
+void GrGLCubicEffect::onEmitCode(EmitArgs& args) {
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>();
+ // emit attributes
+ vsBuilder->emitAttributes(gp);
+
GrGLVertToFrag v(kVec4f_GrSLType);
args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
@@ -527,17 +538,17 @@ void GrGLCubicEffect::emitCode(const EmitArgs& args) {
this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
&fColorUniform);
- // setup coord outputs
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPosition()->fName);
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()->fName);
-
// setup uniform viewMatrix
this->addUniformViewMatrix(args.fPB);
- // setup position varying
- vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), this->uViewM(),
+ // Setup position
+ vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
gp.inPosition()->fName);
+ // emit transforms with position
+ this->emitTransforms(args.fPB, this->position(), gp.inPosition()->fName, gp.localMatrix(),
+ args.fTransformsIn, args.fTransformsOut);
+
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
@@ -647,7 +658,8 @@ void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt,
GrGLCubicEffect::GenKey(*this, bt, caps, b);
}
-GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt) const {
+GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt,
+ const GrGLCaps&) const {
return SkNEW_ARGS(GrGLCubicEffect, (*this, bt));
}
« no previous file with comments | « src/gpu/effects/GrBezierEffect.h ('k') | src/gpu/effects/GrBitmapTextGeoProc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698