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

Unified Diff: src/gpu/batches/GrAAFillRectBatch.cpp

Issue 1355353002: Create GrDraw and start fast pathing src over rects (Closed) Base URL: https://skia.googlesource.com/skia.git@strokerect2
Patch Set: tweaks Created 5 years, 3 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/batches/GrAAFillRectBatch.h ('k') | src/gpu/batches/GrBatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAAFillRectBatch.cpp
diff --git a/src/gpu/batches/GrAAFillRectBatch.cpp b/src/gpu/batches/GrAAFillRectBatch.cpp
index 5b22422e1098b6ff2ebb31c8780c93f4d3f9822d..2c754beedcf3e6537451ed9a6c5762fc1ceaf07d 100644
--- a/src/gpu/batches/GrAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrAAFillRectBatch.cpp
@@ -288,25 +288,23 @@ public:
typedef GrTInstanceBatch<AAFillRectBatchNoLocalMatrixImp> AAFillRectBatchNoLocalMatrix;
typedef GrTInstanceBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatrix;
-inline static void append_to_batch(AAFillRectBatchNoLocalMatrix* batch, GrColor color,
- const SkMatrix& viewMatrix, const SkRect& rect,
- const SkRect& devRect) {
- AAFillRectBatchNoLocalMatrix::Geometry& geo = batch->geoData()->push_back();
- geo.fColor = color;
- geo.fViewMatrix = viewMatrix;
- geo.fRect = rect;
- geo.fDevRect = devRect;
+inline static void setup_geo(AAFillRectBatchNoLocalMatrix::Geometry* geo, GrColor color,
+ const SkMatrix& viewMatrix, const SkRect& rect,
+ const SkRect& devRect) {
+ geo->fColor = color;
+ geo->fViewMatrix = viewMatrix;
+ geo->fRect = rect;
+ geo->fDevRect = devRect;
}
-inline static void append_to_batch(AAFillRectBatchLocalMatrix* batch, GrColor color,
- const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
- const SkRect& rect, const SkRect& devRect) {
- AAFillRectBatchLocalMatrix::Geometry& geo = batch->geoData()->push_back();
- geo.fColor = color;
- geo.fViewMatrix = viewMatrix;
- geo.fLocalMatrix = localMatrix;
- geo.fRect = rect;
- geo.fDevRect = devRect;
+inline static void setup_geo(AAFillRectBatchLocalMatrix::Geometry* geo, GrColor color,
+ const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
+ const SkRect& rect, const SkRect& devRect) {
+ geo->fColor = color;
+ geo->fViewMatrix = viewMatrix;
+ geo->fLocalMatrix = localMatrix;
+ geo->fRect = rect;
+ geo->fDevRect = devRect;
}
namespace GrAAFillRectBatch {
@@ -316,7 +314,7 @@ GrDrawBatch* Create(GrColor color,
const SkRect& rect,
const SkRect& devRect) {
AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create();
- append_to_batch(batch, color, viewMatrix, rect, devRect);
+ setup_geo(&batch->geoData()->push_back(), color, viewMatrix, rect, devRect);
batch->init();
return batch;
}
@@ -324,33 +322,41 @@ GrDrawBatch* Create(GrColor color,
GrDrawBatch* Create(GrColor color,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
+ const SkRect& rect) {
+ //map rect
+ SkRect devRect;
+ viewMatrix.mapRect(&devRect, rect);
+
AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
- append_to_batch(batch, color, viewMatrix, localMatrix, rect, devRect);
+ setup_geo(&batch->geoData()->push_back(), color, viewMatrix, localMatrix, rect, devRect);
batch->init();
return batch;
}
-void Append(GrBatch* origBatch,
+bool Append(GrBatch* origBatch,
GrColor color,
const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
+ const SkRect& rect) {
+ // map rect
+ SkRect devRect;
+ viewMatrix.mapRect(&devRect, rect);
+
AAFillRectBatchNoLocalMatrix* batch = origBatch->cast<AAFillRectBatchNoLocalMatrix>();
- append_to_batch(batch, color, viewMatrix, rect, devRect);
- batch->updateBoundsAfterAppend();
+ AAFillRectBatchNoLocalMatrix::Geometry geo;
+ setup_geo(&geo, color, viewMatrix, rect, devRect);
+ return batch->appendIfPossible(geo);
}
-void Append(GrBatch* origBatch,
+bool Append(GrBatch* origBatch,
GrColor color,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix,
const SkRect& rect,
const SkRect& devRect) {
AAFillRectBatchLocalMatrix* batch = origBatch->cast<AAFillRectBatchLocalMatrix>();
- append_to_batch(batch, color, viewMatrix, localMatrix, rect, devRect);
- batch->updateBoundsAfterAppend();
+ AAFillRectBatchLocalMatrix::Geometry geo;
+ setup_geo(&geo, color, viewMatrix, localMatrix, rect, devRect);
+ return batch->appendIfPossible(geo);
}
};
@@ -374,8 +380,7 @@ DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
SkMatrix localMatrix = GrTest::TestMatrix(random);
SkRect rect = GrTest::TestRect(random);
- SkRect devRect = GrTest::TestRect(random);
- return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRect);
+ return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect);
}
#endif
« no previous file with comments | « src/gpu/batches/GrAAFillRectBatch.h ('k') | src/gpu/batches/GrBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698