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

Unified Diff: src/gpu/GrOvalRenderer.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/GrOptDrawState.cpp ('k') | src/gpu/GrProgramDesc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOvalRenderer.cpp
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 7f93bbe33916a0048ffbb4c9ba18463668c2ba16..b5f3f5a8feed0cbedc52f22f26840114f37bedcc 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -83,12 +83,15 @@ public:
const GrBatchTracker&)
: fColor(GrColor_ILLEGAL) {}
- void emitCode(const EmitArgs& args) SK_OVERRIDE {
+ void onEmitCode(EmitArgs& args) SK_OVERRIDE {
const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>();
GrGLGPBuilder* pb = args.fPB;
const BatchTracker& local = args.fBT.cast<BatchTracker>();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+ // emit attributes
+ vsBuilder->emitAttributes(ce);
+
GrGLVertToFrag v(kVec4f_GrSLType);
args.fPB->addVarying("CircleEdge", &v);
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), ce.inCircleEdge()->fName);
@@ -97,16 +100,16 @@ public:
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
&fColorUniform);
- // setup coord outputs
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), ce.inPosition()->fName);
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), ce.inPosition()->fName);
-
// setup uniform viewMatrix
this->addUniformViewMatrix(pb);
- // setup position varying
- vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(),
- this->uViewM(), ce.inPosition()->fName);
+ // Setup position
+ vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
+ ce.inPosition()->fName);
+
+ // emit transforms
+ this->emitTransforms(args.fPB, this->position(), ce.inPosition()->fName,
+ ce.localMatrix(), args.fTransformsIn, args.fTransformsOut);;
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn());
@@ -157,7 +160,8 @@ public:
GLProcessor::GenKey(*this, bt, caps, b);
}
- GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
+ virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
+ const GrGLCaps&) const SK_OVERRIDE {
return SkNEW_ARGS(GLProcessor, (*this, bt));
}
@@ -255,12 +259,15 @@ public:
const GrBatchTracker&)
: fColor(GrColor_ILLEGAL) {}
- void emitCode(const EmitArgs& args) SK_OVERRIDE {
+ void onEmitCode(EmitArgs& args) SK_OVERRIDE {
const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>();
GrGLGPBuilder* pb = args.fPB;
const BatchTracker& local = args.fBT.cast<BatchTracker>();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+ // emit attributes
+ vsBuilder->emitAttributes(ee);
+
GrGLVertToFrag ellipseOffsets(kVec2f_GrSLType);
args.fPB->addVarying("EllipseOffsets", &ellipseOffsets);
vsBuilder->codeAppendf("%s = %s;", ellipseOffsets.vsOut(),
@@ -275,16 +282,16 @@ public:
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
&fColorUniform);
- // setup coord outputs
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), ee.inPosition()->fName);
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), ee.inPosition()->fName);
-
// setup uniform viewMatrix
this->addUniformViewMatrix(pb);
- // setup position varying
- vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(),
- this->uViewM(), ee.inPosition()->fName);
+ // Setup position
+ vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
+ ee.inPosition()->fName);
+
+ // emit transforms
+ this->emitTransforms(args.fPB, this->position(), ee.inPosition()->fName,
+ ee.localMatrix(), args.fTransformsIn, args.fTransformsOut);
// for outer curve
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
@@ -351,7 +358,8 @@ public:
GLProcessor::GenKey(*this, bt, caps, b);
}
- GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
+ virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
+ const GrGLCaps&) const SK_OVERRIDE {
return SkNEW_ARGS(GLProcessor, (*this, bt));
}
@@ -455,12 +463,15 @@ public:
const GrBatchTracker&)
: fColor(GrColor_ILLEGAL) {}
- void emitCode(const EmitArgs& args) SK_OVERRIDE {
+ void onEmitCode(EmitArgs& args) SK_OVERRIDE {
const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>();
GrGLGPBuilder* pb = args.fPB;
const BatchTracker& local = args.fBT.cast<BatchTracker>();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+ // emit attributes
+ vsBuilder->emitAttributes(ee);
+
GrGLVertToFrag offsets0(kVec2f_GrSLType);
args.fPB->addVarying("EllipseOffsets0", &offsets0);
vsBuilder->codeAppendf("%s = %s;", offsets0.vsOut(),
@@ -475,16 +486,16 @@ public:
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
&fColorUniform);
- // setup coord outputs
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), ee.inPosition()->fName);
- vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), ee.inPosition()->fName);
-
// setup uniform viewMatrix
this->addUniformViewMatrix(pb);
- // setup position varying
- vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(),
- this->uViewM(), ee.inPosition()->fName);
+ // Setup position
+ vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uViewM(),
+ ee.inPosition()->fName);
+
+ // emit transforms
+ this->emitTransforms(args.fPB, this->position(), ee.inPosition()->fName,
+ ee.localMatrix(), args.fTransformsIn, args.fTransformsOut);
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
@@ -566,7 +577,8 @@ public:
GLProcessor::GenKey(*this, bt, caps, b);
}
- GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE {
+ virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
+ const GrGLCaps&) const SK_OVERRIDE {
return SkNEW_ARGS(GLProcessor, (*this, bt));
}
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698