aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/batches
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/batches')
-rw-r--r--src/gpu/batches/GrAAFillRectBatch.cpp30
-rw-r--r--src/gpu/batches/GrAAFillRectBatch.h20
-rw-r--r--src/gpu/batches/GrAAStrokeRectBatch.cpp10
-rw-r--r--src/gpu/batches/GrAAStrokeRectBatch.h4
-rw-r--r--src/gpu/batches/GrBWFillRectBatch.cpp23
-rw-r--r--src/gpu/batches/GrBWFillRectBatch.h4
-rw-r--r--src/gpu/batches/GrBatch.cpp41
-rw-r--r--src/gpu/batches/GrBatch.h144
-rw-r--r--src/gpu/batches/GrDrawAtlasBatch.cpp12
-rw-r--r--src/gpu/batches/GrDrawAtlasBatch.h7
-rw-r--r--src/gpu/batches/GrDrawVerticesBatch.cpp10
-rw-r--r--src/gpu/batches/GrDrawVerticesBatch.h14
-rw-r--r--src/gpu/batches/GrRectBatchFactory.cpp39
-rw-r--r--src/gpu/batches/GrRectBatchFactory.h36
-rw-r--r--src/gpu/batches/GrStrokeRectBatch.cpp2
-rw-r--r--src/gpu/batches/GrStrokeRectBatch.h4
-rw-r--r--src/gpu/batches/GrTestBatch.h2
17 files changed, 217 insertions, 185 deletions
diff --git a/src/gpu/batches/GrAAFillRectBatch.cpp b/src/gpu/batches/GrAAFillRectBatch.cpp
index 4cea65ac56..9b190283ff 100644
--- a/src/gpu/batches/GrAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrAAFillRectBatch.cpp
@@ -62,7 +62,7 @@ const GrIndexBuffer* get_index_buffer(GrResourceProvider* resourceProvider) {
* SkPoint* fan0Position, const Geometry&)
*/
template <typename Base>
-class AAFillRectBatch : public GrBatch {
+class AAFillRectBatch : public GrVertexBatch {
public:
typedef typename Base::Geometry Geometry;
@@ -165,12 +165,12 @@ private:
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
- if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
- caps)) {
+ AAFillRectBatch* that = t->cast<AAFillRectBatch>();
+ if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
+ that->bounds(), caps)) {
return false;
}
- AAFillRectBatch* that = t->cast<AAFillRectBatch>();
if (!Base::CanCombineLocalCoords(this->viewMatrix(), that->viewMatrix(),
this->usesLocalCoords())) {
return false;
@@ -399,10 +399,10 @@ typedef AAFillRectBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatri
namespace GrAAFillRectBatch {
-GrBatch* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
+GrDrawBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create();
AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry();
geo.fColor = color;
@@ -412,11 +412,11 @@ GrBatch* Create(GrColor color,
return batch;
}
-GrBatch* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
+GrDrawBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry();
geo.fColor = color;
@@ -435,7 +435,7 @@ GrBatch* Create(GrColor color,
#include "GrBatchTest.h"
-BATCH_TEST_DEFINE(AAFillRectBatch) {
+DRAW_BATCH_TEST_DEFINE(AAFillRectBatch) {
AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create();
AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry();
geo.fColor = GrRandomColor(random);
@@ -445,7 +445,7 @@ BATCH_TEST_DEFINE(AAFillRectBatch) {
return batch;
}
-BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
+DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry();
geo.fColor = GrRandomColor(random);
diff --git a/src/gpu/batches/GrAAFillRectBatch.h b/src/gpu/batches/GrAAFillRectBatch.h
index 3fc1e3480c..5a657a3fa8 100644
--- a/src/gpu/batches/GrAAFillRectBatch.h
+++ b/src/gpu/batches/GrAAFillRectBatch.h
@@ -10,21 +10,21 @@
#include "GrColor.h"
-class GrBatch;
+class GrDrawBatch;
class SkMatrix;
struct SkRect;
namespace GrAAFillRectBatch {
-GrBatch* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect);
+GrDrawBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect);
-GrBatch* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const SkRect& devRect);
+GrDrawBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect,
+ const SkRect& devRect);
};
#endif
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectBatch.cpp
index 0083aaad6c..91ff230f0d 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp
@@ -204,13 +204,13 @@ const GrIndexBuffer* GrAAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* res
}
bool GrAAStrokeRectBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
- if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
- caps)) {
+ GrAAStrokeRectBatch* that = t->cast<GrAAStrokeRectBatch>();
+
+ if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
+ that->bounds(), caps)) {
return false;
}
- GrAAStrokeRectBatch* that = t->cast<GrAAStrokeRectBatch>();
-
// TODO batch across miterstroke changes
if (this->miterStroke() != that->miterStroke()) {
return false;
@@ -356,7 +356,7 @@ void GrAAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
#include "GrBatchTest.h"
-BATCH_TEST_DEFINE(AAStrokeRectBatch) {
+DRAW_BATCH_TEST_DEFINE(AAStrokeRectBatch) {
bool miterStroke = random->nextBool();
// Create mock stroke rect
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.h b/src/gpu/batches/GrAAStrokeRectBatch.h
index 7fa15f5326..b6fb89f502 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.h
+++ b/src/gpu/batches/GrAAStrokeRectBatch.h
@@ -14,7 +14,7 @@
#include "SkMatrix.h"
#include "SkRect.h"
-class GrAAStrokeRectBatch : public GrBatch {
+class GrAAStrokeRectBatch : public GrVertexBatch {
public:
// TODO support AA rotated stroke rects by copying around view matrices
struct Geometry {
@@ -25,7 +25,7 @@ public:
bool fMiterStroke;
};
- static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix) {
+ static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix) {
return SkNEW_ARGS(GrAAStrokeRectBatch, (geometry, viewMatrix));
}
diff --git a/src/gpu/batches/GrBWFillRectBatch.cpp b/src/gpu/batches/GrBWFillRectBatch.cpp
index c3ddc2b6cb..0009789986 100644
--- a/src/gpu/batches/GrBWFillRectBatch.cpp
+++ b/src/gpu/batches/GrBWFillRectBatch.cpp
@@ -17,7 +17,7 @@ class GrBatchTarget;
class SkMatrix;
struct SkRect;
-class BWFillRectBatch : public GrBatch {
+class BWFillRectBatch : public GrVertexBatch {
public:
struct Geometry {
SkMatrix fViewMatrix;
@@ -29,7 +29,7 @@ public:
bool fHasLocalMatrix;
};
- static GrBatch* Create(const Geometry& geometry) {
+ static GrDrawBatch* Create(const Geometry& geometry) {
return SkNEW_ARGS(BWFillRectBatch, (geometry));
}
@@ -134,13 +134,12 @@ private:
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
- if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
- caps)) {
+ BWFillRectBatch* that = t->cast<BWFillRectBatch>();
+ if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
+ that->bounds(), caps)) {
return false;
}
- BWFillRectBatch* that = t->cast<BWFillRectBatch>();
-
if (this->hasLocalRect() != that->hasLocalRect()) {
return false;
}
@@ -210,11 +209,11 @@ private:
};
namespace GrBWFillRectBatch {
-GrBatch* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
+GrDrawBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
BWFillRectBatch::Geometry geometry;
geometry.fColor = color;
geometry.fViewMatrix = viewMatrix;
@@ -244,7 +243,7 @@ GrBatch* Create(GrColor color,
#include "GrBatchTest.h"
-BATCH_TEST_DEFINE(RectBatch) {
+DRAW_BATCH_TEST_DEFINE(RectBatch) {
BWFillRectBatch::Geometry geometry;
geometry.fColor = GrRandomColor(random);
diff --git a/src/gpu/batches/GrBWFillRectBatch.h b/src/gpu/batches/GrBWFillRectBatch.h
index ff1533caa2..c95fd7037b 100644
--- a/src/gpu/batches/GrBWFillRectBatch.h
+++ b/src/gpu/batches/GrBWFillRectBatch.h
@@ -10,12 +10,12 @@
#include "GrColor.h"
-class GrBatch;
+class GrDrawBatch;
class SkMatrix;
struct SkRect;
namespace GrBWFillRectBatch {
-GrBatch* Create(GrColor color,
+GrDrawBatch* Create(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
diff --git a/src/gpu/batches/GrBatch.cpp b/src/gpu/batches/GrBatch.cpp
index 3840b4c83b..b696d6b95b 100644
--- a/src/gpu/batches/GrBatch.cpp
+++ b/src/gpu/batches/GrBatch.cpp
@@ -50,8 +50,6 @@ void GrBatch::operator delete(void* target) {
GrBatch::GrBatch()
: fClassID(kIllegalBatchID)
- , fNumberOfDraws(0)
- , fPipelineInstalled(false)
#if GR_BATCH_SPEW
, fUniqueID(GenID(&gCurrBatchUniqueID))
#endif
@@ -59,13 +57,34 @@ GrBatch::GrBatch()
SkDEBUGCODE(fUsed = false;)
}
-GrBatch::~GrBatch() {
+GrBatch::~GrBatch() {}
+
+//////////////////////////////////////////////////////////////////////////////
+
+GrDrawBatch::GrDrawBatch() : fPipelineInstalled(false) { }
+
+GrDrawBatch::~GrDrawBatch() {
if (fPipelineInstalled) {
this->pipeline()->~GrPipeline();
}
}
-void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType,
+bool GrDrawBatch::installPipeline(const GrPipeline::CreateArgs& args) {
+ GrPipelineOptimizations opts;
+ void* location = fPipelineStorage.get();
+ if (!GrPipeline::CreateAt(location, args, &opts)) {
+ return false;
+ }
+ this->initBatchTracker(opts);
+ fPipelineInstalled = true;
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+GrVertexBatch::GrVertexBatch() : fNumberOfDraws(0) {}
+
+void* GrVertexBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType,
size_t vertexStride, const GrIndexBuffer* indexBuffer,
int verticesPerInstance, int indicesPerInstance,
int instancesToDraw) {
@@ -92,7 +111,8 @@ void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType
return vertices;
}
-void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToDraw) {
+void* GrVertexBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride,
+ int quadsToDraw) {
SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer(
batchTarget->resourceProvider()->refQuadIndexBuffer());
if (!quadIndexBuffer) {
@@ -102,14 +122,3 @@ void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride,
return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertexStride,
quadIndexBuffer, kVerticesPerQuad, kIndicesPerQuad, quadsToDraw);
}
-
-bool GrBatch::installPipeline(const GrPipeline::CreateArgs& args) {
- GrPipelineOptimizations opts;
- void* location = fPipelineStorage.get();
- if (!GrPipeline::CreateAt(location, args, &opts)) {
- return false;
- }
- this->initBatchTracker(opts);
- fPipelineInstalled = true;
- return true;
-}
diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h
index 35844cd99a..ef8f56c4b9 100644
--- a/src/gpu/batches/GrBatch.h
+++ b/src/gpu/batches/GrBatch.h
@@ -21,7 +21,7 @@ class GrPipeline;
struct GrInitInvariantOutput;
-/*
+/**
* GrBatch is the base class for all Ganesh deferred geometry generators. To facilitate
* reorderable batching, Ganesh does not generate geometry inline with draw calls. Instead, it
* captures the arguments to the draw and then generates the geometry on demand. This gives GrBatch
@@ -51,8 +51,6 @@ public:
~GrBatch() override;
virtual const char* name() const = 0;
- virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
- virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
bool combineIfPossible(GrBatch* that, const GrCaps& caps) {
if (this->classID() != that->classID()) {
@@ -62,14 +60,8 @@ public:
return this->onCombineIfPossible(that, caps);
}
- virtual void generateGeometry(GrBatchTarget*) = 0;
-
const SkRect& bounds() const { return fBounds; }
- // TODO this goes away when batches are everywhere
- void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; }
- int numberOfDraws() const { return fNumberOfDraws; }
-
void* operator new(size_t size);
void operator delete(void* target);
@@ -81,28 +73,17 @@ public:
}
/**
- * Helper for down-casting to a GrBatch subclass
- */
+ * Helper for down-casting to a GrBatch subclass
+ */
template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
template <typename T> T* cast() { return static_cast<T*>(this); }
uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fClassID; }
- // TODO no GrPrimitiveProcessors yet read fragment position
- bool willReadFragmentPosition() const { return false; }
-
- SkDEBUGCODE(bool isUsed() const { return fUsed; })
-
- const GrPipeline* pipeline() const {
- SkASSERT(fPipelineInstalled);
- return reinterpret_cast<const GrPipeline*>(fPipelineStorage.get());
- }
-
- bool installPipeline(const GrPipeline::CreateArgs&);
-
#if GR_BATCH_SPEW
uint32_t uniqueID() const { return fUniqueID; }
#endif
+ SkDEBUGCODE(bool isUsed() const { return fUsed; })
protected:
template <typename PROC_SUBCLASS> void initClassID() {
@@ -118,8 +99,86 @@ protected:
return fBounds.joinPossiblyEmptyRect(otherBounds);
}
+ SkRect fBounds;
+
+private:
+ virtual bool onCombineIfPossible(GrBatch*, const GrCaps& caps) = 0;
+
+ static uint32_t GenID(int32_t* idCounter) {
+ // fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
+ // atomic inc returns the old value not the incremented value. So we add
+ // 1 to the returned value.
+ uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1;
+ if (!id) {
+ SkFAIL("This should never wrap as it should only be called once for each GrBatch "
+ "subclass.");
+ }
+ return id;
+ }
+
+ enum {
+ kIllegalBatchID = 0,
+ };
+
+ uint32_t fClassID;
+ SkDEBUGCODE(bool fUsed;)
+#if GR_BATCH_SPEW
+ uint32_t fUniqueID;
+ static int32_t gCurrBatchUniqueID;
+#endif
+ static int32_t gCurrBatchClassID;
+ typedef GrNonAtomicRef INHERITED;
+};
+
+/**
+ * Base class for GrBatches that draw. These batches have a GrPipeline installed by GrDrawTarget.
+ */
+class GrDrawBatch : public GrBatch {
+public:
+ GrDrawBatch();
+ ~GrDrawBatch() override;
+
+ virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
+ virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
+
+ const GrPipeline* pipeline() const {
+ SkASSERT(fPipelineInstalled);
+ return reinterpret_cast<const GrPipeline*>(fPipelineStorage.get());
+ }
+
+ bool installPipeline(const GrPipeline::CreateArgs&);
+
+ // TODO no GrPrimitiveProcessors yet read fragment position
+ bool willReadFragmentPosition() const { return false; }
+
+private:
+ /**
+ * initBatchTracker is a hook for the some additional overrides / optimization possibilities
+ * from the GrXferProcessor.
+ */
+ virtual void initBatchTracker(const GrPipelineOptimizations&) = 0;
+
+ SkAlignedSTStorage<1, GrPipeline> fPipelineStorage;
+ bool fPipelineInstalled;
+ typedef GrBatch INHERITED;
+};
+
+/**
+ * Base class for vertex-based GrBatches.
+ */
+class GrVertexBatch : public GrDrawBatch {
+public:
+ GrVertexBatch();
+
+ virtual void generateGeometry(GrBatchTarget*) = 0;
+
+ // TODO this goes away when batches are everywhere
+ void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; }
+ int numberOfDraws() const { return fNumberOfDraws; }
+
+protected:
/** Helper for rendering instances using an instanced index index buffer. This class creates the
- space for the vertices and flushes the draws to the batch target.*/
+ space for the vertices and flushes the draws to the batch target. */
class InstancedHelper {
public:
InstancedHelper() {}
@@ -156,44 +215,9 @@ protected:
typedef InstancedHelper INHERITED;
};
- uint32_t fClassID;
- SkRect fBounds;
-
private:
- virtual bool onCombineIfPossible(GrBatch*, const GrCaps& caps) = 0;
-
- /*
- * initBatchTracker is a hook for the some additional overrides / optimization possibilities
- * from the GrXferProcessor.
- */
- virtual void initBatchTracker(const GrPipelineOptimizations&) = 0;
-
-
- static uint32_t GenID(int32_t* idCounter) {
- // fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
- // atomic inc returns the old value not the incremented value. So we add
- // 1 to the returned value.
- uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1;
- if (!id) {
- SkFAIL("This should never wrap as it should only be called once for each GrBatch "
- "subclass.");
- }
- return id;
- }
-
- enum {
- kIllegalBatchID = 0,
- };
- SkAlignedSTStorage<1, GrPipeline> fPipelineStorage;
int fNumberOfDraws;
- SkDEBUGCODE(bool fUsed;)
- bool fPipelineInstalled;
-#if GR_BATCH_SPEW
- uint32_t fUniqueID;
- static int32_t gCurrBatchUniqueID;
-#endif
- static int32_t gCurrBatchClassID;
- typedef SkRefCnt INHERITED;
+ typedef GrDrawBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrDrawAtlasBatch.cpp b/src/gpu/batches/GrDrawAtlasBatch.cpp
index f79412be54..28c6922d99 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.cpp
+++ b/src/gpu/batches/GrDrawAtlasBatch.cpp
@@ -157,13 +157,13 @@ GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& vie
}
bool GrDrawAtlasBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
- if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
- caps)) {
+ GrDrawAtlasBatch* that = t->cast<GrDrawAtlasBatch>();
+
+ if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
+ that->bounds(), caps)) {
return false;
}
-
- GrDrawAtlasBatch* that = t->cast<GrDrawAtlasBatch>();
-
+
// We currently use a uniform viewmatrix for this batch
if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
return false;
@@ -231,7 +231,7 @@ static void randomize_params(uint32_t count, SkRandom* random,
}
}
-BATCH_TEST_DEFINE(GrDrawAtlasBatch) {
+DRAW_BATCH_TEST_DEFINE(GrDrawAtlasBatch) {
uint32_t spriteCount = random->nextRangeU(1, 100);
SkTArray<SkRSXform> xforms(spriteCount);
diff --git a/src/gpu/batches/GrDrawAtlasBatch.h b/src/gpu/batches/GrDrawAtlasBatch.h
index e6ce7a03df..6b46cfb0a3 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.h
+++ b/src/gpu/batches/GrDrawAtlasBatch.h
@@ -12,15 +12,16 @@
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
-class GrDrawAtlasBatch : public GrBatch {
+class GrDrawAtlasBatch : public GrVertexBatch {
public:
struct Geometry {
GrColor fColor;
SkTArray<uint8_t, true> fVerts;
};
- static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, int spriteCount,
- const SkRSXform* xforms, const SkRect* rects, const SkColor* colors) {
+ static GrDrawBatch* 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));
}
diff --git a/src/gpu/batches/GrDrawVerticesBatch.cpp b/src/gpu/batches/GrDrawVerticesBatch.cpp
index f36c54b067..ebfda36296 100644
--- a/src/gpu/batches/GrDrawVerticesBatch.cpp
+++ b/src/gpu/batches/GrDrawVerticesBatch.cpp
@@ -184,13 +184,13 @@ void GrDrawVerticesBatch::generateGeometry(GrBatchTarget* batchTarget) {
}
bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
- if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
- caps)) {
+ GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>();
+
+ if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
+ that->bounds(), caps)) {
return false;
}
- GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>();
-
if (!this->batchablePrimitiveType() || this->primitiveType() != that->primitiveType()) {
return false;
}
@@ -295,7 +295,7 @@ static void randomize_params(size_t count, size_t maxVertex, SkScalar min, SkSca
}
}
-BATCH_TEST_DEFINE(VerticesBatch) {
+DRAW_BATCH_TEST_DEFINE(VerticesBatch) {
GrPrimitiveType type = GrPrimitiveType(random->nextULessThan(kLast_GrPrimitiveType + 1));
uint32_t primitiveCount = random->nextRangeU(1, 100);
diff --git a/src/gpu/batches/GrDrawVerticesBatch.h b/src/gpu/batches/GrDrawVerticesBatch.h
index 9446d88bde..11decbe01d 100644
--- a/src/gpu/batches/GrDrawVerticesBatch.h
+++ b/src/gpu/batches/GrDrawVerticesBatch.h
@@ -18,7 +18,7 @@
class GrBatchTarget;
struct GrInitInvariantOutput;
-class GrDrawVerticesBatch : public GrBatch {
+class GrDrawVerticesBatch : public GrVertexBatch {
public:
struct Geometry {
GrColor fColor;
@@ -28,12 +28,12 @@ public:
SkTDArray<SkPoint> fLocalCoords;
};
- static GrBatch* Create(const Geometry& geometry, GrPrimitiveType primitiveType,
- const SkMatrix& viewMatrix,
- const SkPoint* positions, int vertexCount,
- const uint16_t* indices, int indexCount,
- const GrColor* colors, const SkPoint* localCoords,
- const SkRect& bounds) {
+ static GrDrawBatch* Create(const Geometry& geometry, GrPrimitiveType primitiveType,
+ const SkMatrix& viewMatrix,
+ const SkPoint* positions, int vertexCount,
+ const uint16_t* indices, int indexCount,
+ const GrColor* colors, const SkPoint* localCoords,
+ const SkRect& bounds) {
return SkNEW_ARGS(GrDrawVerticesBatch, (geometry, primitiveType, viewMatrix, positions,
vertexCount, indices, indexCount, colors,
localCoords, bounds));
diff --git a/src/gpu/batches/GrRectBatchFactory.cpp b/src/gpu/batches/GrRectBatchFactory.cpp
index e874acbb49..86980d2944 100644
--- a/src/gpu/batches/GrRectBatchFactory.cpp
+++ b/src/gpu/batches/GrRectBatchFactory.cpp
@@ -12,12 +12,12 @@
#include "SkStrokeRec.h"
-static GrBatch* create_stroke_aa_batch(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& devOutside,
- const SkRect& devOutsideAssist,
- const SkRect& devInside,
- bool miterStroke) {
+static GrDrawBatch* create_stroke_aa_batch(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& devOutside,
+ const SkRect& devOutsideAssist,
+ const SkRect& devInside,
+ bool miterStroke) {
GrAAStrokeRectBatch::Geometry geometry;
geometry.fColor = color;
geometry.fDevOutside = devOutside;
@@ -30,12 +30,11 @@ static GrBatch* create_stroke_aa_batch(GrColor color,
namespace GrRectBatchFactory {
-
-GrBatch* CreateStrokeBW(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- SkScalar strokeWidth,
- bool snapToPixelCenters) {
+GrDrawBatch* CreateStrokeBW(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ SkScalar strokeWidth,
+ bool snapToPixelCenters) {
GrStrokeRectBatch::Geometry geometry;
geometry.fColor = color;
geometry.fViewMatrix = viewMatrix;
@@ -44,11 +43,11 @@ GrBatch* CreateStrokeBW(GrColor color,
return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
}
-GrBatch* CreateStrokeAA(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect,
- const SkStrokeRec& stroke) {
+GrDrawBatch* CreateStrokeAA(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect,
+ const SkStrokeRec& stroke) {
SkVector devStrokeSize;
SkScalar width = stroke.getWidth();
if (width > 0) {
@@ -103,9 +102,9 @@ GrBatch* CreateStrokeAA(GrColor color,
miterStroke);
}
-GrBatch* CreateFillNestedRectsAA(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect rects[2]) {
+GrDrawBatch* CreateFillNestedRectsAA(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect rects[2]) {
SkASSERT(viewMatrix.rectStaysRect());
SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
diff --git a/src/gpu/batches/GrRectBatchFactory.h b/src/gpu/batches/GrRectBatchFactory.h
index 6ded22db7b..7eaec795e8 100644
--- a/src/gpu/batches/GrRectBatchFactory.h
+++ b/src/gpu/batches/GrRectBatchFactory.h
@@ -22,7 +22,7 @@ class SkStrokeRec;
*/
namespace GrRectBatchFactory {
-inline GrBatch* CreateFillBW(GrColor color,
+inline GrDrawBatch* CreateFillBW(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
@@ -30,29 +30,29 @@ inline GrBatch* CreateFillBW(GrColor color,
return GrBWFillRectBatch::Create(color, viewMatrix, rect, localRect, localMatrix);
}
-inline GrBatch* CreateFillAA(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
+inline GrDrawBatch* CreateFillAA(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
return GrAAFillRectBatch::Create(color, viewMatrix, rect, devRect);
}
-GrBatch* CreateStrokeBW(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- SkScalar strokeWidth,
- bool snapToPixelCenters);
+GrDrawBatch* CreateStrokeBW(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ SkScalar strokeWidth,
+ bool snapToPixelCenters);
-GrBatch* CreateStrokeAA(GrColor,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect,
- const SkStrokeRec& stroke);
+GrDrawBatch* CreateStrokeAA(GrColor,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect,
+ const SkStrokeRec& stroke);
// First rect is outer; second rect is inner
-GrBatch* CreateFillNestedRectsAA(GrColor,
- const SkMatrix& viewMatrix,
- const SkRect rects[2]);
+GrDrawBatch* CreateFillNestedRectsAA(GrColor,
+ const SkMatrix& viewMatrix,
+ const SkRect rects[2]);
};
diff --git a/src/gpu/batches/GrStrokeRectBatch.cpp b/src/gpu/batches/GrStrokeRectBatch.cpp
index 9c31149a5b..649ba01ddd 100644
--- a/src/gpu/batches/GrStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrStrokeRectBatch.cpp
@@ -128,7 +128,7 @@ void GrStrokeRectBatch::generateGeometry(GrBatchTarget* batchTarget) {
#ifdef GR_TEST_UTILS
-BATCH_TEST_DEFINE(GrStrokeRectBatch) {
+DRAW_BATCH_TEST_DEFINE(GrStrokeRectBatch) {
GrStrokeRectBatch::Geometry geometry;
geometry.fViewMatrix = GrTest::TestMatrix(random);
geometry.fColor = GrRandomColor(random);
diff --git a/src/gpu/batches/GrStrokeRectBatch.h b/src/gpu/batches/GrStrokeRectBatch.h
index 7979a6492d..2c891a467d 100644
--- a/src/gpu/batches/GrStrokeRectBatch.h
+++ b/src/gpu/batches/GrStrokeRectBatch.h
@@ -12,7 +12,7 @@
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
-class GrStrokeRectBatch : public GrBatch {
+class GrStrokeRectBatch : public GrVertexBatch {
public:
struct Geometry {
GrColor fColor;
@@ -21,7 +21,7 @@ public:
SkScalar fStrokeWidth;
};
- static GrBatch* Create(const Geometry& geometry, bool snapToPixelCenters) {
+ static GrDrawBatch* Create(const Geometry& geometry, bool snapToPixelCenters) {
return SkNEW_ARGS(GrStrokeRectBatch, (geometry, snapToPixelCenters));
}
diff --git a/src/gpu/batches/GrTestBatch.h b/src/gpu/batches/GrTestBatch.h
index 68ea676d25..d8986b6816 100644
--- a/src/gpu/batches/GrTestBatch.h
+++ b/src/gpu/batches/GrTestBatch.h
@@ -16,7 +16,7 @@
* 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
*/
-class GrTestBatch : public GrBatch {
+class GrTestBatch : public GrVertexBatch {
public:
struct Geometry {
GrColor fColor;