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

Unified Diff: src/gpu/batches/GrRectBatch.h

Issue 1287433003: Create GrRectBatchFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@batchfactory1
Patch Set: 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/GrDrawTarget.cpp ('k') | src/gpu/batches/GrRectBatch.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrRectBatch.h
diff --git a/src/gpu/batches/GrRectBatch.h b/src/gpu/batches/GrRectBatch.h
index 5844cc3b011601eb48b1264d0965eb53f4cd21b2..b8c57424c7151d72d6ce0ddc59ba7ecc7ff8d044 100644
--- a/src/gpu/batches/GrRectBatch.h
+++ b/src/gpu/batches/GrRectBatch.h
@@ -8,24 +8,77 @@
#ifndef GrRectBatch_DEFINED
#define GrRectBatch_DEFINED
+#include "GrBatch.h"
#include "GrColor.h"
-class GrBatch;
+class GrBatchTarget;
class SkMatrix;
struct SkRect;
-/*
- * A factory for returning batches which can draw rectangles. Right now this only handles non-AA
- * rects
- */
-namespace GrRectBatch {
+class GrRectBatch : public GrBatch {
+public:
+ struct Geometry {
+ SkMatrix fViewMatrix;
+ SkRect fRect;
+ SkRect fLocalRect;
+ SkMatrix fLocalMatrix;
+ GrColor fColor;
+ bool fHasLocalRect;
+ bool fHasLocalMatrix;
+ };
+
+ static GrBatch* Create(const Geometry& geometry) {
+ return SkNEW_ARGS(GrRectBatch, (geometry));
+ }
+
+ const char* name() const override { return "RectBatch"; }
+
+ void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
+ // When this is called on a batch, there is only one geometry bundle
+ out->setKnownFourComponents(fGeoData[0].fColor);
+ }
+
+ void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
+ out->setKnownSingleComponent(0xff);
+ }
+
+ void initBatchTracker(const GrPipelineInfo& init) override;
+
+ void generateGeometry(GrBatchTarget* batchTarget) override;
+
+ SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
+
+private:
+ GrRectBatch(const Geometry& geometry) {
+ this->initClassID<GrRectBatch>();
+ fGeoData.push_back(geometry);
+
+ fBounds = geometry.fRect;
+ geometry.fViewMatrix.mapRect(&fBounds);
+ }
+
+ GrColor color() const { return fBatch.fColor; }
+ bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
+ bool colorIgnored() const { return fBatch.fColorIgnored; }
+ const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
+ const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; }
+ bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; }
+ bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; }
+ bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
+
+ bool onCombineIfPossible(GrBatch* t) override;
+
+ const GrGeometryProcessor* createRectGP();
-GrBatch* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix);
+ struct BatchTracker {
+ GrColor fColor;
+ bool fUsesLocalCoords;
+ bool fColorIgnored;
+ bool fCoverageIgnored;
+ };
+ BatchTracker fBatch;
+ SkSTArray<1, Geometry, true> fGeoData;
};
#endif
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/batches/GrRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698