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

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

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 9 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/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrVertexBatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrTestBatch.h
diff --git a/src/gpu/batches/GrTestBatch.h b/src/gpu/batches/GrTestBatch.h
index 5da65f81ea112fac3f4a0637c3eeb17c3d2b65e1..273baaebfd4691735c08a14e146d2ae518022ead 100644
--- a/src/gpu/batches/GrTestBatch.h
+++ b/src/gpu/batches/GrTestBatch.h
@@ -14,73 +14,52 @@
#include "batches/GrVertexBatch.h"
/*
- * A simple batch only for testing purposes which actually doesn't batch at all, but can fit into
- * the batch pipeline and generate arbitrary geometry
+ * A simple solid color batch only for testing purposes which actually doesn't batch at all. It
+ * saves having to fill out some boiler plate methods.
*/
class GrTestBatch : public GrVertexBatch {
public:
- struct Geometry {
- GrColor fColor;
- };
-
virtual const char* name() const override = 0;
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
- color->setKnownFourComponents(this->geoData(0)->fColor);
+ color->setKnownFourComponents(fColor);
coverage->setUnknownSingleComponent();
}
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
- // Handle any color overrides
- if (!overrides.readsColor()) {
- this->geoData(0)->fColor = GrColor_ILLEGAL;
- }
- overrides.getOverrideColorIfSet(&this->geoData(0)->fColor);
+ overrides.getOverrideColorIfSet(&fColor);
- // setup batch properties
- fBatch.fColorIgnored = !overrides.readsColor();
- fBatch.fColor = this->geoData(0)->fColor;
- fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
- fBatch.fCoverageIgnored = !overrides.readsCoverage();
+ fOptimizations.fColorIgnored = !overrides.readsColor();
+ fOptimizations.fUsesLocalCoords = overrides.readsLocalCoords();
+ fOptimizations.fCoverageIgnored = !overrides.readsCoverage();
}
protected:
- GrTestBatch(uint32_t classID, const GrGeometryProcessor* gp, const SkRect& bounds)
- : INHERITED(classID) {
- fGeometryProcessor.reset(SkRef(gp));
-
+ GrTestBatch(uint32_t classID, const SkRect& bounds, GrColor color)
+ : INHERITED(classID)
+ , fColor(color) {
this->setBounds(bounds);
}
- const GrGeometryProcessor* geometryProcessor() const { return fGeometryProcessor; }
-
-private:
- void onPrepareDraws(Target* target) const override {
- target->initDraw(fGeometryProcessor);
- this->generateGeometry(target);
- }
+ struct Optimizations {
+ bool fColorIgnored = false;
+ bool fUsesLocalCoords = false;
+ bool fCoverageIgnored = false;
+ };
- virtual Geometry* geoData(int index) = 0;
- virtual const Geometry* geoData(int index) const = 0;
+ GrColor color() const { return fColor; }
+ const Optimizations optimizations() const { return fOptimizations; }
+private:
bool onCombineIfPossible(GrBatch* t, const GrCaps&) override {
return false;
}
- virtual void generateGeometry(Target*) const = 0;
-
- struct BatchTracker {
- GrColor fColor;
- bool fUsesLocalCoords;
- bool fColorIgnored;
- bool fCoverageIgnored;
- };
-
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
- BatchTracker fBatch;
+ GrColor fColor;
+ Optimizations fOptimizations;
typedef GrVertexBatch INHERITED;
};
« no previous file with comments | « src/gpu/batches/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrVertexBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698