aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-05-05 10:45:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-05 10:45:57 -0700
commitad17cfc8c72515176a1b191767caac48e316b43a (patch)
tree4e04919905c0ac901833be86fb3c950a373e0e8a /src
parente4b19c4593da5179b346b66b291e8f4f45af617f (diff)
Move RectBatch to GrRect
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawTarget.cpp12
-rw-r--r--src/gpu/GrDrawTarget.h13
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp240
-rw-r--r--src/gpu/GrInOrderDrawBuffer.h6
-rw-r--r--src/gpu/GrRectBatch.cpp251
-rw-r--r--src/gpu/GrRectBatch.h31
6 files changed, 295 insertions, 258 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index a45aca8a72..1be4598c52 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -15,6 +15,7 @@
#include "GrPath.h"
#include "GrPipeline.h"
#include "GrMemoryPool.h"
+#include "GrRectBatch.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetPriv.h"
#include "GrSurfacePriv.h"
@@ -302,6 +303,17 @@ void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder,
transformType, count, stencilSettings, pipelineInfo);
}
+void GrDrawTarget::drawRect(GrPipelineBuilder* pipelineBuilder,
+ GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ SkAutoTUnref<GrBatch> batch(GrRectBatch::Create(color, viewMatrix, rect, localRect,
+ localMatrix));
+ this->drawBatch(pipelineBuilder, batch);
+}
+
void GrDrawTarget::clear(const SkIRect* rect,
GrColor color,
bool canIgnoreRect,
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 5871abfe7e..b80991efd1 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -28,7 +28,6 @@
#include "SkTypes.h"
#include "SkXfermode.h"
-class GrBatch;
class GrClip;
class GrDrawTargetCaps;
class GrIndexBufferAllocPool;
@@ -125,9 +124,7 @@ public:
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
- const SkMatrix* localMatrix) {
- this->onDrawRect(pipelineBuilder, color, viewMatrix, rect, localRect, localMatrix);
- }
+ const SkMatrix* localMatrix);
/**
* Helper for drawRect when the caller doesn't need separate local rects or matrices.
@@ -288,14 +285,6 @@ private:
virtual void onFlush() = 0;
virtual void onDrawBatch(GrBatch*, const PipelineInfo&) = 0;
- // TODO copy in order drawbuffer onDrawRect to here
- virtual void onDrawRect(GrPipelineBuilder*,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) = 0;
-
virtual void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 1e8f3ae659..4aaff8e68e 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -7,9 +7,6 @@
#include "GrInOrderDrawBuffer.h"
-#include "GrDefaultGeoProcFactory.h"
-#include "GrTemplates.h"
-
GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context,
GrVertexBufferAllocPool* vertexPool,
GrIndexBufferAllocPool* indexPool)
@@ -28,243 +25,6 @@ GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
this->reset();
}
-////////////////////////////////////////////////////////////////////////////////
-
-/** We always use per-vertex colors so that rects can be batched across color changes. Sometimes we
- have explicit local coords and sometimes not. We *could* always provide explicit local coords
- and just duplicate the positions when the caller hasn't provided a local coord rect, but we
- haven't seen a use case which frequently switches between local rect and no local rect draws.
-
- The color param is used to determine whether the opaque hint can be set on the draw state.
- The caller must populate the vertex colors itself.
-
- The vertex attrib order is always pos, color, [local coords].
- */
-static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords,
- GrColor color,
- const SkMatrix* localMatrix) {
- uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
- GrDefaultGeoProcFactory::kColor_GPType;
- flags |= hasExplicitLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
- if (localMatrix) {
- return GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), *localMatrix,
- GrColorIsOpaque(color));
- } else {
- return GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), SkMatrix::I(),
- GrColorIsOpaque(color));
- }
-}
-
-class RectBatch : public GrBatch {
-public:
- struct Geometry {
- GrColor fColor;
- SkMatrix fViewMatrix;
- SkRect fRect;
- bool fHasLocalRect;
- bool fHasLocalMatrix;
- SkRect fLocalRect;
- SkMatrix fLocalMatrix;
- };
-
- static GrBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(RectBatch, (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 {
- // Handle any color overrides
- if (init.fColorIgnored) {
- fGeoData[0].fColor = GrColor_ILLEGAL;
- } else if (GrColor_ILLEGAL != init.fOverrideColor) {
- fGeoData[0].fColor = init.fOverrideColor;
- }
-
- // setup batch properties
- fBatch.fColorIgnored = init.fColorIgnored;
- fBatch.fColor = fGeoData[0].fColor;
- fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
- fBatch.fCoverageIgnored = init.fCoverageIgnored;
- }
-
- void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
- // Go to device coords to allow batching across matrix changes
- SkMatrix invert = SkMatrix::I();
-
- // if we have a local rect, then we apply the localMatrix directly to the localRect to
- // generate vertex local coords
- bool hasExplicitLocalCoords = this->hasLocalRect();
- if (!hasExplicitLocalCoords) {
- if (!this->viewMatrix().isIdentity() && !this->viewMatrix().invert(&invert)) {
- SkDebugf("Could not invert\n");
- return;
- }
-
- if (this->hasLocalMatrix()) {
- invert.preConcat(this->localMatrix());
- }
- }
-
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCoords,
- this->color(),
- &invert));
-
- batchTarget->initDraw(gp, pipeline);
-
- // TODO this is hacky, but the only way we have to initialize the GP is to use the
- // GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
- // everywhere we can remove this nastiness
- GrPipelineInfo init;
- init.fColorIgnored = fBatch.fColorIgnored;
- init.fOverrideColor = GrColor_ILLEGAL;
- init.fCoverageIgnored = fBatch.fCoverageIgnored;
- init.fUsesLocalCoords = this->usesLocalCoords();
- gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
-
- int instanceCount = fGeoData.count();
- size_t vertexStride = gp->getVertexStride();
- SkASSERT(hasExplicitLocalCoords ?
- vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) :
- vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
- QuadHelper helper;
- void* vertices = helper.init(batchTarget, vertexStride, instanceCount);
-
- if (!vertices) {
- return;
- }
-
-
- for (int i = 0; i < instanceCount; i++) {
- const Geometry& geom = fGeoData[i];
-
- intptr_t offset = GrTCast<intptr_t>(vertices) + kVerticesPerQuad * i * vertexStride;
- SkPoint* positions = GrTCast<SkPoint*>(offset);
-
- positions->setRectFan(geom.fRect.fLeft, geom.fRect.fTop,
- geom.fRect.fRight, geom.fRect.fBottom, vertexStride);
- geom.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVerticesPerQuad);
-
- if (geom.fHasLocalRect) {
- static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
- SkPoint* coords = GrTCast<SkPoint*>(offset + kLocalOffset);
- coords->setRectFan(geom.fLocalRect.fLeft, geom.fLocalRect.fTop,
- geom.fLocalRect.fRight, geom.fLocalRect.fBottom,
- vertexStride);
- if (geom.fHasLocalMatrix) {
- geom.fLocalMatrix.mapPointsWithStride(coords, vertexStride, kVerticesPerQuad);
- }
- }
-
- static const int kColorOffset = sizeof(SkPoint);
- GrColor* vertColor = GrTCast<GrColor*>(offset + kColorOffset);
- for (int j = 0; j < 4; ++j) {
- *vertColor = geom.fColor;
- vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
- }
- }
-
- helper.issueDraws(batchTarget);
- }
-
- SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
-
-private:
- RectBatch(const Geometry& geometry) {
- this->initClassID<RectBatch>();
- 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 onCombineIfPossible(GrBatch* t) override {
- RectBatch* that = t->cast<RectBatch>();
-
- if (this->hasLocalRect() != that->hasLocalRect()) {
- return false;
- }
-
- SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
- if (!this->hasLocalRect() && this->usesLocalCoords()) {
- if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
- return false;
- }
-
- if (this->hasLocalMatrix() != that->hasLocalMatrix()) {
- return false;
- }
-
- if (this->hasLocalMatrix() && !this->localMatrix().cheapEqualTo(that->localMatrix())) {
- return false;
- }
- }
-
- if (this->color() != that->color()) {
- fBatch.fColor = GrColor_ILLEGAL;
- }
- fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
- this->joinBounds(that->bounds());
- return true;
- }
-
- struct BatchTracker {
- GrColor fColor;
- bool fUsesLocalCoords;
- bool fColorIgnored;
- bool fCoverageIgnored;
- };
-
- BatchTracker fBatch;
- SkSTArray<1, Geometry, true> fGeoData;
-};
-
-void GrInOrderDrawBuffer::onDrawRect(GrPipelineBuilder* pipelineBuilder,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
- RectBatch::Geometry geometry;
- geometry.fColor = color;
- geometry.fViewMatrix = viewMatrix;
- geometry.fRect = rect;
-
- if (localRect) {
- geometry.fHasLocalRect = true;
- geometry.fLocalRect = *localRect;
- } else {
- geometry.fHasLocalRect = false;
- }
-
- if (localMatrix) {
- geometry.fHasLocalMatrix = true;
- geometry.fLocalMatrix = *localMatrix;
- } else {
- geometry.fHasLocalMatrix = false;
- }
-
- SkAutoTUnref<GrBatch> batch(RectBatch::Create(geometry));
- this->drawBatch(pipelineBuilder, batch);
-}
-
void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,
const PipelineInfo& pipelineInfo) {
State* state = this->setupPipelineAndShouldDraw(batch, pipelineInfo);
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index 264d2a7297..3e266b23ed 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -90,12 +90,6 @@ private:
// overrides from GrDrawTarget
void onDrawBatch(GrBatch*, const PipelineInfo&) override;
- void onDrawRect(GrPipelineBuilder*,
- GrColor,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) override;
void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp
new file mode 100644
index 0000000000..ba63db1e0f
--- /dev/null
+++ b/src/gpu/GrRectBatch.cpp
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrRectBatch.h"
+
+#include "GrBatch.h"
+#include "GrBatchTarget.h"
+#include "GrDefaultGeoProcFactory.h"
+#include "GrPrimitiveProcessor.h"
+#include "GrTemplates.h"
+
+/** We always use per-vertex colors so that rects can be batched across color changes. Sometimes we
+ have explicit local coords and sometimes not. We *could* always provide explicit local coords
+ and just duplicate the positions when the caller hasn't provided a local coord rect, but we
+ haven't seen a use case which frequently switches between local rect and no local rect draws.
+
+ The color param is used to determine whether the opaque hint can be set on the draw state.
+ The caller must populate the vertex colors itself.
+
+ The vertex attrib order is always pos, color, [local coords].
+ */
+static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords,
+ GrColor color,
+ const SkMatrix* localMatrix) {
+ uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
+ GrDefaultGeoProcFactory::kColor_GPType;
+ flags |= hasExplicitLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
+ if (localMatrix) {
+ return GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), *localMatrix,
+ GrColorIsOpaque(color));
+ } else {
+ return GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), SkMatrix::I(),
+ GrColorIsOpaque(color));
+ }
+}
+
+class RectBatch : public GrBatch {
+public:
+ struct Geometry {
+ GrColor fColor;
+ SkMatrix fViewMatrix;
+ SkRect fRect;
+ bool fHasLocalRect;
+ bool fHasLocalMatrix;
+ SkRect fLocalRect;
+ SkMatrix fLocalMatrix;
+ };
+
+ static GrBatch* Create(const Geometry& geometry) {
+ return SkNEW_ARGS(RectBatch, (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 {
+ // Handle any color overrides
+ if (init.fColorIgnored) {
+ fGeoData[0].fColor = GrColor_ILLEGAL;
+ } else if (GrColor_ILLEGAL != init.fOverrideColor) {
+ fGeoData[0].fColor = init.fOverrideColor;
+ }
+
+ // setup batch properties
+ fBatch.fColorIgnored = init.fColorIgnored;
+ fBatch.fColor = fGeoData[0].fColor;
+ fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
+ fBatch.fCoverageIgnored = init.fCoverageIgnored;
+ }
+
+ void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
+ // Go to device coords to allow batching across matrix changes
+ SkMatrix invert = SkMatrix::I();
+
+ // if we have a local rect, then we apply the localMatrix directly to the localRect to
+ // generate vertex local coords
+ bool hasExplicitLocalCoords = this->hasLocalRect();
+ if (!hasExplicitLocalCoords) {
+ if (!this->viewMatrix().isIdentity() && !this->viewMatrix().invert(&invert)) {
+ SkDebugf("Could not invert\n");
+ return;
+ }
+
+ if (this->hasLocalMatrix()) {
+ invert.preConcat(this->localMatrix());
+ }
+ }
+
+ SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCoords,
+ this->color(),
+ &invert));
+
+ batchTarget->initDraw(gp, pipeline);
+
+ // TODO this is hacky, but the only way we have to initialize the GP is to use the
+ // GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
+ // everywhere we can remove this nastiness
+ GrPipelineInfo init;
+ init.fColorIgnored = fBatch.fColorIgnored;
+ init.fOverrideColor = GrColor_ILLEGAL;
+ init.fCoverageIgnored = fBatch.fCoverageIgnored;
+ init.fUsesLocalCoords = this->usesLocalCoords();
+ gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
+
+ int instanceCount = fGeoData.count();
+ size_t vertexStride = gp->getVertexStride();
+ SkASSERT(hasExplicitLocalCoords ?
+ vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) :
+ vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
+ QuadHelper helper;
+ void* vertices = helper.init(batchTarget, vertexStride, instanceCount);
+
+ if (!vertices) {
+ return;
+ }
+
+
+ for (int i = 0; i < instanceCount; i++) {
+ const Geometry& geom = fGeoData[i];
+
+ intptr_t offset = GrTCast<intptr_t>(vertices) + kVerticesPerQuad * i * vertexStride;
+ SkPoint* positions = GrTCast<SkPoint*>(offset);
+
+ positions->setRectFan(geom.fRect.fLeft, geom.fRect.fTop,
+ geom.fRect.fRight, geom.fRect.fBottom, vertexStride);
+ geom.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVerticesPerQuad);
+
+ if (geom.fHasLocalRect) {
+ static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
+ SkPoint* coords = GrTCast<SkPoint*>(offset + kLocalOffset);
+ coords->setRectFan(geom.fLocalRect.fLeft, geom.fLocalRect.fTop,
+ geom.fLocalRect.fRight, geom.fLocalRect.fBottom,
+ vertexStride);
+ if (geom.fHasLocalMatrix) {
+ geom.fLocalMatrix.mapPointsWithStride(coords, vertexStride, kVerticesPerQuad);
+ }
+ }
+
+ static const int kColorOffset = sizeof(SkPoint);
+ GrColor* vertColor = GrTCast<GrColor*>(offset + kColorOffset);
+ for (int j = 0; j < 4; ++j) {
+ *vertColor = geom.fColor;
+ vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
+ }
+ }
+
+ helper.issueDraws(batchTarget);
+ }
+
+ SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
+
+private:
+ RectBatch(const Geometry& geometry) {
+ this->initClassID<RectBatch>();
+ 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 onCombineIfPossible(GrBatch* t) override {
+ RectBatch* that = t->cast<RectBatch>();
+
+ if (this->hasLocalRect() != that->hasLocalRect()) {
+ return false;
+ }
+
+ SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
+ if (!this->hasLocalRect() && this->usesLocalCoords()) {
+ if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
+ return false;
+ }
+
+ if (this->hasLocalMatrix() != that->hasLocalMatrix()) {
+ return false;
+ }
+
+ if (this->hasLocalMatrix() && !this->localMatrix().cheapEqualTo(that->localMatrix())) {
+ return false;
+ }
+ }
+
+ if (this->color() != that->color()) {
+ fBatch.fColor = GrColor_ILLEGAL;
+ }
+ fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
+ this->joinBounds(that->bounds());
+ return true;
+ }
+
+ struct BatchTracker {
+ GrColor fColor;
+ bool fUsesLocalCoords;
+ bool fColorIgnored;
+ bool fCoverageIgnored;
+ };
+
+ BatchTracker fBatch;
+ SkSTArray<1, Geometry, true> fGeoData;
+};
+
+namespace GrRectBatch {
+
+GrBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ RectBatch::Geometry geometry;
+ geometry.fColor = color;
+ geometry.fViewMatrix = viewMatrix;
+ geometry.fRect = rect;
+
+ if (localRect) {
+ geometry.fHasLocalRect = true;
+ geometry.fLocalRect = *localRect;
+ } else {
+ geometry.fHasLocalRect = false;
+ }
+
+ if (localMatrix) {
+ geometry.fHasLocalMatrix = true;
+ geometry.fLocalMatrix = *localMatrix;
+ } else {
+ geometry.fHasLocalMatrix = false;
+ }
+
+ return RectBatch::Create(geometry);
+}
+
+};
diff --git a/src/gpu/GrRectBatch.h b/src/gpu/GrRectBatch.h
new file mode 100644
index 0000000000..5844cc3b01
--- /dev/null
+++ b/src/gpu/GrRectBatch.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrRectBatch_DEFINED
+#define GrRectBatch_DEFINED
+
+#include "GrColor.h"
+
+class GrBatch;
+class SkMatrix;
+struct SkRect;
+
+/*
+ * A factory for returning batches which can draw rectangles. Right now this only handles non-AA
+ * rects
+ */
+namespace GrRectBatch {
+
+GrBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix);
+
+};
+
+#endif