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

Unified Diff: src/gpu/GrDefaultGeoProcFactory.cpp

Issue 1243583002: Add support for transformedLocalCoords to GrDefaultGeoProc (Closed) Base URL: https://skia.googlesource.com/skia.git@pipelinetobatch2
Patch Set: tweaks Created 5 years, 4 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/GrDefaultGeoProcFactory.h ('k') | src/gpu/GrGeometryProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDefaultGeoProcFactory.cpp
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 639a593220c68fbf56b099517084e373434597bc..f8d30f8395e2ed3f218f26315f92eb4dd7ea040f 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -16,6 +16,14 @@
* matrix. It also leaves coverage untouched. Behind the scenes, we may add per vertex color or
* local coords.
*/
+
+enum GPFlag {
+ kColor_GPFlag = 0x1,
+ kLocalCoord_GPFlag = 0x2,
+ kCoverage_GPFlag= 0x4,
+ kTransformedLocalCoord_GPFlag = 0x8,
+};
+
class DefaultGeoProc : public GrGeometryProcessor {
public:
static GrGeometryProcessor* Create(uint32_t gpTypeFlags,
@@ -77,10 +85,14 @@ public:
this->setupPosition(pb, gpArgs, gp.inPosition()->fName, gp.viewMatrix(),
&fViewMatrixUniform);
- if (gp.inLocalCoords()) {
+ if (gp.hasExplicitLocalCoords()) {
// emit transforms with explicit local coords
this->emitTransforms(pb, gpArgs->fPositionVar, gp.inLocalCoords()->fName,
gp.localMatrix(), args.fTransformsIn, args.fTransformsOut);
+ } else if(gp.hasTransformedLocalCoords()) {
+ // transforms have already been applied to vertex attributes on the cpu
+ this->emitTransforms(pb, gp.inLocalCoords()->fName,
+ args.fTransformsIn, args.fTransformsOut);
} else {
// emit transforms with position
this->emitTransforms(pb, gpArgs->fPositionVar, gp.inPosition()->fName,
@@ -199,9 +211,11 @@ private:
, fLocalCoordsWillBeRead(localCoordsWillBeRead)
, fCoverageWillBeIgnored(coverageWillBeIgnored) {
this->initClassID<DefaultGeoProc>();
- bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType);
- bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType);
- bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCoverage_GPType);
+ bool hasColor = SkToBool(gpTypeFlags & kColor_GPFlag);
+ bool hasExplicitLocalCoords = SkToBool(gpTypeFlags & kLocalCoord_GPFlag);
+ bool hasTransformedLocalCoords = SkToBool(gpTypeFlags & kTransformedLocalCoord_GPFlag);
+ bool hasLocalCoord = hasExplicitLocalCoords || hasTransformedLocalCoords;
+ bool hasCoverage = SkToBool(gpTypeFlags & kCoverage_GPFlag);
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
if (hasColor) {
@@ -210,7 +224,12 @@ private:
if (hasLocalCoord) {
fInLocalCoords = &this->addVertexAttrib(Attribute("inLocalCoord",
kVec2f_GrVertexAttribType));
- this->setHasLocalCoords();
+ if (hasExplicitLocalCoords) {
+ this->setHasExplicitLocalCoords();
+ } else {
+ SkASSERT(hasTransformedLocalCoords);
+ this->setHasTransformedLocalCoords();
+ }
}
if (hasCoverage) {
fInCoverage = &this->addVertexAttrib(Attribute("inCoverage",
@@ -240,13 +259,16 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc);
GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
uint32_t flags = 0;
if (d->fRandom->nextBool()) {
- flags |= GrDefaultGeoProcFactory::kColor_GPType;
+ flags |= kColor_GPFlag;
+ }
+ if (d->fRandom->nextBool()) {
+ flags |= kCoverage_GPFlag;
}
if (d->fRandom->nextBool()) {
- flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
+ flags |= kLocalCoord_GPFlag;
}
if (d->fRandom->nextBool()) {
- flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType;
+ flags |= kTransformedLocalCoord_GPFlag;
}
return DefaultGeoProc::Create(flags,
@@ -263,9 +285,11 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
const LocalCoords& localCoords,
const SkMatrix& viewMatrix) {
uint32_t flags = 0;
- flags |= color.fType == Color::kAttribute_Type ? kColor_GPType : 0;
- flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverage_GPType : 0;
- flags |= localCoords.fType == LocalCoords::kHasExplicit_Type ? kLocalCoord_GPType : 0;
+ flags |= color.fType == Color::kAttribute_Type ? kColor_GPFlag : 0;
+ flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverage_GPFlag : 0;
+ flags |= localCoords.fType == LocalCoords::kHasExplicit_Type ? kLocalCoord_GPFlag : 0;
+ flags |= localCoords.fType == LocalCoords::kHasTransformed_Type ?
+ kTransformedLocalCoord_GPFlag : 0;
uint8_t inCoverage = coverage.fCoverage;
bool coverageWillBeIgnored = coverage.fType == Coverage::kNone_Type;
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.h ('k') | src/gpu/GrGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698