Minor geometry processor clarification.
Some renames, comments, and override->final Change-Id: Iebc7aeee9a64021e958f76bf4278ffff56884a56 Reviewed-on: https://skia-review.googlesource.com/35165 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
c902ff8fc8
commit
7f23543d1d
@ -132,12 +132,12 @@ public:
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
if (gp.hasExplicitLocalCoords()) {
|
||||
// emit transforms with explicit local coords
|
||||
|
@ -24,9 +24,9 @@ public:
|
||||
, fLocalCoordsType(kUnused_LocalCoordsType)
|
||||
, fSampleShading(0.0) {}
|
||||
|
||||
bool willUseGeoShader() const override { return fWillUseGeoShader; }
|
||||
bool willUseGeoShader() const final { return fWillUseGeoShader; }
|
||||
|
||||
bool hasExplicitLocalCoords() const override {
|
||||
bool hasExplicitLocalCoords() const final {
|
||||
return kHasExplicit_LocalCoordsType == fLocalCoordsType;
|
||||
}
|
||||
|
||||
@ -35,9 +35,7 @@ public:
|
||||
* instance, if sampleShading is 0.5 in MSAA16 mode, the fragment shader will run a minimum of
|
||||
* 8 times per pixel. The default value is zero.
|
||||
*/
|
||||
float getSampleShading() const override {
|
||||
return fSampleShading;
|
||||
}
|
||||
float getSampleShading() const final { return fSampleShading; }
|
||||
|
||||
protected:
|
||||
void setWillUseGeoShader() { fWillUseGeoShader = true; }
|
||||
|
@ -86,12 +86,12 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -347,12 +347,12 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -552,12 +552,12 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// Setup KLM
|
||||
const char* devkLMMatrixName;
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, cte.inPosition()->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, cte.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
|
@ -54,12 +54,12 @@ public:
|
||||
varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -331,12 +331,12 @@ public:
|
||||
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -568,12 +568,12 @@ public:
|
||||
varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
varyingHandler->addPassThroughAttribute(rsgp.inColor(), args.fOutputColor);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, rsgp.inPosition()->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, rsgp.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
|
@ -85,19 +85,19 @@ void GrGLSLGeometryProcessor::setTransformDataHelper(const SkMatrix& localMatrix
|
||||
SkASSERT(i == fInstalledTransforms.count());
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName) {
|
||||
void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName) {
|
||||
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
UniformHandle* viewMatrixUniform) {
|
||||
void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
UniformHandle* viewMatrixUniform) {
|
||||
if (mat.isIdentity()) {
|
||||
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
|
@ -20,10 +20,10 @@ class GrGLSLGPBuilder;
|
||||
class GrGLSLGeometryProcessor : public GrGLSLPrimitiveProcessor {
|
||||
public:
|
||||
/* Any general emit code goes in the base class emitCode. Subclasses override onEmitCode */
|
||||
void emitCode(EmitArgs&) override;
|
||||
void emitCode(EmitArgs&) final;
|
||||
|
||||
protected:
|
||||
// A helper which subclasses can use if needed and used above in the default setTransformData().
|
||||
// A helper which subclasses can use to upload coord transform matrices in setData().
|
||||
void setTransformDataHelper(const SkMatrix& localMatrix,
|
||||
const GrGLSLProgramDataManager& pdman,
|
||||
FPCoordTransformIter*);
|
||||
@ -39,7 +39,7 @@ protected:
|
||||
posVar, localCoords, SkMatrix::I(), handler);
|
||||
}
|
||||
|
||||
// Emit pre-transformed coords as a vertex attribute per coord-transform.
|
||||
// Emit pre-transformed coords as a varying per coord-transform.
|
||||
void emitTransforms(GrGLSLVertexBuilder*,
|
||||
GrGLSLVaryingHandler*,
|
||||
GrGLSLUniformHandler*,
|
||||
@ -49,19 +49,25 @@ protected:
|
||||
FPCoordTransformHandler*);
|
||||
|
||||
struct GrGPArgs {
|
||||
// The variable used by a GP to store its position. It can be
|
||||
// either a float2 or a float3 depending on the presence of perspective.
|
||||
// Used to specify the output variable used by the GP to store its device position. It can
|
||||
// either be a float2 or a float3 (in order to handle perspective). The subclass sets this
|
||||
// in its onEmitCode().
|
||||
GrShaderVar fPositionVar;
|
||||
};
|
||||
|
||||
// Create the correct type of position variable given the CTM
|
||||
void setupPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
|
||||
void setupPosition(GrGLSLVertexBuilder*,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
GrGPArgs*,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
UniformHandle* viewMatrixUniform);
|
||||
// Helpers for adding code to write the transformed vertex position. The first simple version
|
||||
// just writes a variable named by 'posName' into the position output variable with the
|
||||
// assumption that the position is 2D. The second version transforms the input position by a
|
||||
// view matrix and the output variable is 2D or 3D depending on whether the view matrix is
|
||||
// perspective. Both versions declare the output position variable and will set
|
||||
// GrGPArgs::fPositionVar.
|
||||
void writeOutputPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
|
||||
void writeOutputPosition(GrGLSLVertexBuilder*,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
GrGPArgs*,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
UniformHandle* viewMatrixUniform);
|
||||
|
||||
static uint32_t ComputePosKey(const SkMatrix& mat) {
|
||||
if (mat.isIdentity()) {
|
||||
|
@ -574,7 +574,7 @@ public:
|
||||
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, qe.fInPosition->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, qe.fInPosition->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
|
@ -896,7 +896,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, dce.inPosition()->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, dce.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -1100,7 +1100,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, de.inPosition()->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, de.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
|
@ -145,8 +145,8 @@ public:
|
||||
vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName,
|
||||
qp.viewMatrix(), &fViewMatrixUniform);
|
||||
this->writeOutputPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName,
|
||||
qp.viewMatrix(), &fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
|
||||
|
@ -141,7 +141,7 @@ private:
|
||||
varyingHandler->addPassThroughAttribute(cgp.fInColor, args.fOutputColor);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, cgp.fInPosition->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, cgp.fInPosition->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -289,7 +289,7 @@ private:
|
||||
varyingHandler->addPassThroughAttribute(egp.fInColor, args.fOutputColor);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder, gpArgs, egp.fInPosition->fName);
|
||||
this->writeOutputPosition(vertBuilder, gpArgs, egp.fInPosition->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
@ -429,12 +429,12 @@ private:
|
||||
varyingHandler->addPassThroughAttribute(diegp.fInColor, args.fOutputColor);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
diegp.fInPosition->fName,
|
||||
diegp.fViewMatrix,
|
||||
&fViewMatrixUniform);
|
||||
this->writeOutputPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
diegp.fInPosition->fName,
|
||||
diegp.fViewMatrix,
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(vertBuilder,
|
||||
|
@ -70,7 +70,7 @@ private:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
||||
const GP& gp = args.fGP.cast<GP>();
|
||||
args.fVaryingHandler->emitAttributes(gp);
|
||||
this->setupPosition(args.fVertBuilder, gpArgs, gp.getAttrib(0).fName);
|
||||
this->writeOutputPosition(args.fVertBuilder, gpArgs, gp.getAttrib(0).fName);
|
||||
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
fragBuilder->codeAppendf("%s = float4(1);", args.fOutputColor);
|
||||
fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
|
||||
|
Loading…
Reference in New Issue
Block a user