Revise DrawAtlasBatch to get rid of one copy when generating the batch.
This doesn't appear to have much affect on perf in SampleApp, but
it should avoid some copies and replaces a couple of STArrays
with one that just does a memcpy in the copy constructor.
Review URL: https://codereview.chromium.org/1279343004
diff --git a/src/gpu/batches/GrDrawAtlasBatch.h b/src/gpu/batches/GrDrawAtlasBatch.h
index 6db0c94..bc882b2 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.h
+++ b/src/gpu/batches/GrDrawAtlasBatch.h
@@ -15,18 +15,14 @@
class GrDrawAtlasBatch : public GrBatch {
public:
struct Geometry {
- GrColor fColor;
- SkTDArray<SkPoint> fPositions;
- SkTDArray<GrColor> fColors;
- SkTDArray<SkPoint> fLocalCoords;
+ GrColor fColor;
+ SkTArray<uint8_t, true> fVerts;
};
- static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
- const SkPoint* positions, int vertexCount,
- const GrColor* colors, const SkPoint* localCoords,
- const SkRect& bounds) {
- return SkNEW_ARGS(GrDrawAtlasBatch, (geometry, viewMatrix, positions,
- vertexCount, colors, localCoords, bounds));
+ static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, int spriteCount,
+ const SkRSXform* xforms, const SkRect* rects, const SkColor* colors) {
+ return SkNEW_ARGS(GrDrawAtlasBatch, (geometry, viewMatrix, spriteCount,
+ xforms, rects, colors));
}
const char* name() const override { return "DrawAtlasBatch"; }
@@ -50,15 +46,14 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
private:
- GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix,
- const SkPoint* positions, int vertexCount,
- const GrColor* colors, const SkPoint* localCoords, const SkRect& bounds);
+ GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, int spriteCount,
+ const SkRSXform* xforms, const SkRect* rects, const SkColor* colors);
GrColor color() const { return fColor; }
bool colorIgnored() const { return fColorIgnored; }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
bool hasColors() const { return fHasColors; }
- int vertexCount() const { return fVertexCount; }
+ int quadCount() const { return fQuadCount; }
bool coverageIgnored() const { return fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t) override;
@@ -66,7 +61,7 @@
SkMatrix fViewMatrix;
GrColor fColor;
- int fVertexCount;
+ int fQuadCount;
bool fColorIgnored;
bool fCoverageIgnored;
bool fHasColors;