aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDefaultGeoProcFactory.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-19 14:33:47 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 20:01:29 +0000
commit92be2f74db81f0ed480b55c58cbde39270f9b772 (patch)
treed2b7135f511a318f10c5c86f2537c07051c922bd /src/gpu/GrDefaultGeoProcFactory.cpp
parentf5ac906476cd26f2967a48340940e6af580fa71f (diff)
Revert "Revert "Change how vertex/instance attributes are handled in geometry processors.""
This reverts commit 5045e501d2aec23e5f1e4b46346033ac3202c6b0. TBR=csmartdalton@google.com Change-Id: Ifbf5f1d8f8ef340fdc69653e931b6d68d4bf0854 Reviewed-on: https://skia-review.googlesource.com/135862 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrDefaultGeoProcFactory.cpp')
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index defb214eb0..e2bf87b277 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -45,17 +45,13 @@ public:
const char* name() const override { return "DefaultGeometryProcessor"; }
- const Attribute* inPosition() const { return fInPosition; }
- const Attribute* inColor() const { return fInColor; }
- const Attribute* inLocalCoords() const { return fInLocalCoords; }
- const Attribute* inCoverage() const { return fInCoverage; }
GrColor color() const { return fColor; }
- bool hasVertexColor() const { return SkToBool(fInColor); }
+ bool hasVertexColor() const { return fInColor.isInitialized(); }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
bool localCoordsWillBeRead() const { return fLocalCoordsWillBeRead; }
uint8_t coverage() const { return fCoverage; }
- bool hasVertexCoverage() const { return SkToBool(fInCoverage); }
+ bool hasVertexCoverage() const { return fInCoverage.isInitialized(); }
class GLSLProcessor : public GrGLSLGeometryProcessor {
public:
@@ -78,7 +74,7 @@ public:
varyingHandler->addVarying("color", &varying);
// There are several optional steps to process the color. Start with the attribute:
- vertBuilder->codeAppendf("half4 color = %s;", gp.inColor()->name());
+ vertBuilder->codeAppendf("half4 color = %s;", gp.fInColor.name());
// For SkColor, do a red/blue swap, possible color space conversion, and premul
if (gp.fFlags & kColorAttributeIsSkColor_GPFlag) {
@@ -107,16 +103,16 @@ public:
this->writeOutputPosition(vertBuilder,
uniformHandler,
gpArgs,
- gp.inPosition()->name(),
+ gp.fInPosition.name(),
gp.viewMatrix(),
&fViewMatrixUniform);
- if (gp.inLocalCoords()) {
+ if (gp.fInLocalCoords.isInitialized()) {
// emit transforms with explicit local coords
this->emitTransforms(vertBuilder,
varyingHandler,
uniformHandler,
- gp.inLocalCoords()->asShaderVar(),
+ gp.fInLocalCoords.asShaderVar(),
gp.localMatrix(),
args.fFPCoordTransformHandler);
} else {
@@ -124,7 +120,7 @@ public:
this->emitTransforms(vertBuilder,
varyingHandler,
uniformHandler,
- gp.inPosition()->asShaderVar(),
+ gp.fInPosition.asShaderVar(),
gp.localMatrix(),
args.fFPCoordTransformHandler);
}
@@ -132,7 +128,7 @@ public:
// Setup coverage as pass through
if (gp.hasVertexCoverage()) {
fragBuilder->codeAppendf("half alpha = 1.0;");
- varyingHandler->addPassThroughAttribute(gp.inCoverage(), "alpha");
+ varyingHandler->addPassThroughAttribute(gp.fInCoverage, "alpha");
fragBuilder->codeAppendf("%s = half4(alpha);", args.fOutputCoverage);
} else if (gp.coverage() == 0xff) {
fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
@@ -222,22 +218,31 @@ private:
, fFlags(gpTypeFlags)
, fLocalCoordsWillBeRead(localCoordsWillBeRead)
, fColorSpaceXform(std::move(colorSpaceXform)) {
- fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType);
+ fInPosition = {"inPosition", kFloat2_GrVertexAttribType};
+ int cnt = 1;
if (fFlags & kColorAttribute_GPFlag) {
- fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType);
+ fInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
+ ++cnt;
}
if (fFlags & kLocalCoordAttribute_GPFlag) {
- fInLocalCoords = &this->addVertexAttrib("inLocalCoord", kFloat2_GrVertexAttribType);
+ fInLocalCoords = {"inLocalCoord", kFloat2_GrVertexAttribType};
+ ++cnt;
}
if (fFlags & kCoverageAttribute_GPFlag) {
- fInCoverage = &this->addVertexAttrib("inCoverage", kHalf_GrVertexAttribType);
+ fInCoverage = {"inCoverage", kHalf_GrVertexAttribType};
+ ++cnt;
}
+ this->setVertexAttributeCnt(cnt);
}
- const Attribute* fInPosition = nullptr;
- const Attribute* fInColor = nullptr;
- const Attribute* fInLocalCoords = nullptr;
- const Attribute* fInCoverage = nullptr;
+ const Attribute& onVertexAttribute(int i) const override {
+ return IthInitializedAttribute(i, fInPosition, fInColor, fInLocalCoords, fInCoverage);
+ }
+
+ Attribute fInPosition;
+ Attribute fInColor;
+ Attribute fInLocalCoords;
+ Attribute fInCoverage;
GrColor fColor;
SkMatrix fViewMatrix;
SkMatrix fLocalMatrix;