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

Unified Diff: src/gpu/GrAARectRenderer.cpp

Issue 1261083003: Use new API everywhere for GrDefaultGeoProcFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@lccleanup2
Patch Set: feedback inc Created 5 years, 5 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
Index: src/gpu/GrAARectRenderer.cpp
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 93b276ad43ca36e5048ddac9d711a4a81d989fcb..dd8ddd09e18b8c9a7e13e47d9dae7aea4a7d3cf9 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -30,24 +30,6 @@ static void set_inset_fan(SkPoint* pts, size_t stride,
pts->setRectFan(r.fLeft + dx, r.fTop + dy,
r.fRight - dx, r.fBottom - dy, stride);
}
-
-static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage,
- const SkMatrix& localMatrix,
- bool usesLocalCoords,
- bool coverageIgnored) {
- uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
- const GrGeometryProcessor* gp;
- if (tweakAlphaForCoverage) {
- gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
- SkMatrix::I(), localMatrix);
- } else {
- flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
- gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
- SkMatrix::I(), localMatrix);
- }
- return gp;
-}
-
GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
class AAFillRectBatch : public GrBatch {
@@ -92,17 +74,15 @@ public:
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
- SkMatrix localMatrix;
- if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
- SkDebugf("Cannot invert\n");
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ GrDefaultGeoProcFactory::CreateForDeviceSpaceAlphaTweakIfPossible(
+ this->viewMatrix(), this->usesLocalCoords(), this->coverageIgnored(),
+ canTweakAlphaForCoverage));
+ if (!gp) {
+ SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
}
- SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
- localMatrix,
- this->usesLocalCoords(),
- this->coverageIgnored()));
-
batchTarget->initDraw(gp, pipeline);
size_t vertexStride = gp->getVertexStride();
@@ -443,20 +423,15 @@ public:
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
-
- // Local matrix is ignored if we don't have local coords. If we have localcoords we only
- // batch with identical view matrices
- SkMatrix localMatrix;
- if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
- SkDebugf("Cannot invert\n");
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ GrDefaultGeoProcFactory::CreateForDeviceSpaceAlphaTweakIfPossible(
+ this->viewMatrix(), this->usesLocalCoords(), this->coverageIgnored(),
+ canTweakAlphaForCoverage));
+ if (!gp) {
+ SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
}
- SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
- localMatrix,
- this->usesLocalCoords(),
- this->coverageIgnored()));
-
batchTarget->initDraw(gp, pipeline);
size_t vertexStride = gp->getVertexStride();

Powered by Google App Engine
This is Rietveld 408576698