aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-08-13 10:05:51 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-13 10:05:51 -0700
commit9c80b5ff592caf1c18b43e98c85bc8340b3ac531 (patch)
tree19af39b4cc96d2aca98a75098248b6941b3482c4
parentd5b75638f77974165a59b44a59a442728bb39fa5 (diff)
Move GrRectBatch to GrBWFillRectBatch and make internal
-rw-r--r--gyp/gpu.gypi4
-rw-r--r--src/gpu/batches/GrBWFillRectBatch.cpp269
-rw-r--r--src/gpu/batches/GrBWFillRectBatch.h25
-rw-r--r--src/gpu/batches/GrRectBatch.cpp175
-rw-r--r--src/gpu/batches/GrRectBatch.h84
-rw-r--r--src/gpu/batches/GrRectBatchFactory.cpp28
-rw-r--r--src/gpu/batches/GrRectBatchFactory.h21
7 files changed, 308 insertions, 298 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 88ecb59ad3..a9871c400a 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -223,14 +223,14 @@
'<(skia_src_path)/gpu/batches/GrAAFillRectBatch.h',
'<(skia_src_path)/gpu/batches/GrAAStrokeRectBatch.cpp',
'<(skia_src_path)/gpu/batches/GrAAStrokeRectBatch.h',
+ '<(skia_src_path)/gpu/batches/GrBWFillRectBatch.h',
+ '<(skia_src_path)/gpu/batches/GrBWFillRectBatch.cpp',
'<(skia_src_path)/gpu/batches/GrBatch.cpp',
'<(skia_src_path)/gpu/batches/GrBatch.h',
'<(skia_src_path)/gpu/batches/GrDrawAtlasBatch.cpp',
'<(skia_src_path)/gpu/batches/GrDrawAtlasBatch.h',
'<(skia_src_path)/gpu/batches/GrDrawVerticesBatch.cpp',
'<(skia_src_path)/gpu/batches/GrDrawVerticesBatch.h',
- '<(skia_src_path)/gpu/batches/GrRectBatch.h',
- '<(skia_src_path)/gpu/batches/GrRectBatch.cpp',
'<(skia_src_path)/gpu/batches/GrRectBatchFactory.h',
'<(skia_src_path)/gpu/batches/GrRectBatchFactory.cpp',
'<(skia_src_path)/gpu/batches/GrStrokeRectBatch.cpp',
diff --git a/src/gpu/batches/GrBWFillRectBatch.cpp b/src/gpu/batches/GrBWFillRectBatch.cpp
new file mode 100644
index 0000000000..c3ddc2b6cb
--- /dev/null
+++ b/src/gpu/batches/GrBWFillRectBatch.cpp
@@ -0,0 +1,269 @@
+/*
+ * 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 "GrBWFillRectBatch.h"
+
+#include "GrBatch.h"
+#include "GrBatchTarget.h"
+#include "GrColor.h"
+#include "GrDefaultGeoProcFactory.h"
+#include "GrPrimitiveProcessor.h"
+
+class GrBatchTarget;
+class SkMatrix;
+struct SkRect;
+
+class BWFillRectBatch : 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(BWFillRectBatch, (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 GrPipelineOptimizations& init) override {
+ // Handle any color overrides
+ if (!init.readsColor()) {
+ fGeoData[0].fColor = GrColor_ILLEGAL;
+ }
+ init.getOverrideColorIfSet(&fGeoData[0].fColor);
+
+ // setup batch properties
+ fBatch.fColorIgnored = !init.readsColor();
+ fBatch.fColor = fGeoData[0].fColor;
+ fBatch.fUsesLocalCoords = init.readsLocalCoords();
+ fBatch.fCoverageIgnored = !init.readsCoverage();
+ }
+
+ void generateGeometry(GrBatchTarget* batchTarget) override {
+ SkAutoTUnref<const GrGeometryProcessor> gp(this->createRectGP());
+ if (!gp) {
+ SkDebugf("Could not create GrGeometryProcessor\n");
+ return;
+ }
+
+ batchTarget->initDraw(gp, this->pipeline());
+
+ int instanceCount = fGeoData.count();
+ size_t vertexStride = gp->getVertexStride();
+ SkASSERT(this->hasLocalRect() ?
+ 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 = reinterpret_cast<intptr_t>(vertices) +
+ kVerticesPerQuad * i * vertexStride;
+ SkPoint* positions = reinterpret_cast<SkPoint*>(offset);
+
+ positions->setRectFan(geom.fRect.fLeft, geom.fRect.fTop,
+ geom.fRect.fRight, geom.fRect.fBottom, vertexStride);
+ geom.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVerticesPerQuad);
+
+ // TODO we should only do this if local coords are being read
+ if (geom.fHasLocalRect) {
+ static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
+ SkPoint* coords = reinterpret_cast<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 = reinterpret_cast<GrColor*>(offset + kColorOffset);
+ for (int j = 0; j < 4; ++j) {
+ *vertColor = geom.fColor;
+ vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
+ }
+ }
+
+ helper.issueDraw(batchTarget);
+ }
+
+ SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
+
+private:
+ BWFillRectBatch(const Geometry& geometry) {
+ this->initClassID<BWFillRectBatch>();
+ 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, const GrCaps& caps) override {
+ if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
+ caps)) {
+ return false;
+ }
+
+ BWFillRectBatch* that = t->cast<BWFillRectBatch>();
+
+ 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;
+ }
+
+
+ /** 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].
+ */
+ const GrGeometryProcessor* createRectGP() const {
+ using namespace GrDefaultGeoProcFactory;
+ Color color(Color::kAttribute_Type);
+ Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type : Coverage::kSolid_Type);
+
+ // if we have a local rect, then we apply the localMatrix directly to the localRect to
+ // generate vertex local coords
+ if (this->hasLocalRect()) {
+ LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
+ return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ } else {
+ LocalCoords localCoords(LocalCoords::kUsePosition_Type,
+ this->hasLocalMatrix() ? &this->localMatrix() : NULL);
+ return GrDefaultGeoProcFactory::CreateForDeviceSpace(color, coverage, localCoords,
+ this->viewMatrix());
+ }
+ }
+
+ struct BatchTracker {
+ GrColor fColor;
+ bool fUsesLocalCoords;
+ bool fColorIgnored;
+ bool fCoverageIgnored;
+ };
+
+ BatchTracker fBatch;
+ SkSTArray<1, Geometry, true> fGeoData;
+};
+
+namespace GrBWFillRectBatch {
+GrBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ BWFillRectBatch::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 BWFillRectBatch::Create(geometry);
+}
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef GR_TEST_UTILS
+
+#include "GrBatchTest.h"
+
+BATCH_TEST_DEFINE(RectBatch) {
+ BWFillRectBatch::Geometry geometry;
+ geometry.fColor = GrRandomColor(random);
+
+ geometry.fRect = GrTest::TestRect(random);
+ geometry.fHasLocalRect = random->nextBool();
+
+ if (geometry.fHasLocalRect) {
+ geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
+ geometry.fLocalRect = GrTest::TestRect(random);
+ } else {
+ geometry.fViewMatrix = GrTest::TestMatrix(random);
+ }
+
+ geometry.fHasLocalMatrix = random->nextBool();
+ if (geometry.fHasLocalMatrix) {
+ geometry.fLocalMatrix = GrTest::TestMatrix(random);
+ }
+
+ return BWFillRectBatch::Create(geometry);
+}
+
+#endif
diff --git a/src/gpu/batches/GrBWFillRectBatch.h b/src/gpu/batches/GrBWFillRectBatch.h
new file mode 100644
index 0000000000..ff1533caa2
--- /dev/null
+++ b/src/gpu/batches/GrBWFillRectBatch.h
@@ -0,0 +1,25 @@
+/*
+ * 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 GrBWFillRectBatch_DEFINED
+#define GrBWFillRectBatch_DEFINED
+
+#include "GrColor.h"
+
+class GrBatch;
+class SkMatrix;
+struct SkRect;
+
+namespace GrBWFillRectBatch {
+GrBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix);
+};
+
+#endif
diff --git a/src/gpu/batches/GrRectBatch.cpp b/src/gpu/batches/GrRectBatch.cpp
deleted file mode 100644
index 1d5b9f305b..0000000000
--- a/src/gpu/batches/GrRectBatch.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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 "GrBatchTarget.h"
-#include "GrDefaultGeoProcFactory.h"
-#include "GrPrimitiveProcessor.h"
-
-void GrRectBatch::initBatchTracker(const GrPipelineOptimizations& init) {
- // Handle any color overrides
- if (!init.readsColor()) {
- fGeoData[0].fColor = GrColor_ILLEGAL;
- }
- init.getOverrideColorIfSet(&fGeoData[0].fColor);
-
- // setup batch properties
- fBatch.fColorIgnored = !init.readsColor();
- fBatch.fColor = fGeoData[0].fColor;
- fBatch.fUsesLocalCoords = init.readsLocalCoords();
- fBatch.fCoverageIgnored = !init.readsCoverage();
-}
-
-void GrRectBatch::generateGeometry(GrBatchTarget* batchTarget) {
- SkAutoTUnref<const GrGeometryProcessor> gp(this->createRectGP());
- if (!gp) {
- SkDebugf("Could not create GrGeometryProcessor\n");
- return;
- }
-
- batchTarget->initDraw(gp, this->pipeline());
-
- int instanceCount = fGeoData.count();
- size_t vertexStride = gp->getVertexStride();
- SkASSERT(this->hasLocalRect() ?
- 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 = reinterpret_cast<intptr_t>(vertices) +
- kVerticesPerQuad * i * vertexStride;
- SkPoint* positions = reinterpret_cast<SkPoint*>(offset);
-
- positions->setRectFan(geom.fRect.fLeft, geom.fRect.fTop,
- geom.fRect.fRight, geom.fRect.fBottom, vertexStride);
- geom.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVerticesPerQuad);
-
- // TODO we should only do this if local coords are being read
- if (geom.fHasLocalRect) {
- static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
- SkPoint* coords = reinterpret_cast<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 = reinterpret_cast<GrColor*>(offset + kColorOffset);
- for (int j = 0; j < 4; ++j) {
- *vertColor = geom.fColor;
- vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
- }
- }
-
- helper.issueDraw(batchTarget);
-}
-
-bool GrRectBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
- if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(), t->bounds(),
- caps)) {
- return false;
- }
-
- GrRectBatch* that = t->cast<GrRectBatch>();
-
- 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;
-}
-
-/** 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].
- */
-const GrGeometryProcessor* GrRectBatch::createRectGP() {
- using namespace GrDefaultGeoProcFactory;
- Color color(Color::kAttribute_Type);
- Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type : Coverage::kSolid_Type);
-
- // if we have a local rect, then we apply the localMatrix directly to the localRect to
- // generate vertex local coords
- if (this->hasLocalRect()) {
- LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
- } else {
- LocalCoords localCoords(LocalCoords::kUsePosition_Type,
- this->hasLocalMatrix() ? &this->localMatrix() : NULL);
- return GrDefaultGeoProcFactory::CreateForDeviceSpace(color, coverage, localCoords,
- this->viewMatrix());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef GR_TEST_UTILS
-
-#include "GrBatchTest.h"
-
-BATCH_TEST_DEFINE(RectBatch) {
- GrRectBatch::Geometry geometry;
- geometry.fColor = GrRandomColor(random);
-
- geometry.fRect = GrTest::TestRect(random);
- geometry.fHasLocalRect = random->nextBool();
-
- if (geometry.fHasLocalRect) {
- geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
- geometry.fLocalRect = GrTest::TestRect(random);
- } else {
- geometry.fViewMatrix = GrTest::TestMatrix(random);
- }
-
- geometry.fHasLocalMatrix = random->nextBool();
- if (geometry.fHasLocalMatrix) {
- geometry.fLocalMatrix = GrTest::TestMatrix(random);
- }
-
- return GrRectBatch::Create(geometry);
-}
-
-#endif
diff --git a/src/gpu/batches/GrRectBatch.h b/src/gpu/batches/GrRectBatch.h
deleted file mode 100644
index 3f13ef5bb5..0000000000
--- a/src/gpu/batches/GrRectBatch.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 "GrBatch.h"
-#include "GrColor.h"
-
-class GrBatchTarget;
-class SkMatrix;
-struct SkRect;
-
-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 GrPipelineOptimizations&) 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, const GrCaps&) override;
-
- const GrGeometryProcessor* createRectGP();
-
- struct BatchTracker {
- GrColor fColor;
- bool fUsesLocalCoords;
- bool fColorIgnored;
- bool fCoverageIgnored;
- };
-
- BatchTracker fBatch;
- SkSTArray<1, Geometry, true> fGeoData;
-};
-
-#endif
diff --git a/src/gpu/batches/GrRectBatchFactory.cpp b/src/gpu/batches/GrRectBatchFactory.cpp
index a66d0904a2..e874acbb49 100644
--- a/src/gpu/batches/GrRectBatchFactory.cpp
+++ b/src/gpu/batches/GrRectBatchFactory.cpp
@@ -7,9 +7,7 @@
#include "GrRectBatchFactory.h"
-#include "GrAAFillRectBatch.h"
#include "GrAAStrokeRectBatch.h"
-#include "GrRectBatch.h"
#include "GrStrokeRectBatch.h"
#include "SkStrokeRec.h"
@@ -32,32 +30,6 @@ static GrBatch* create_stroke_aa_batch(GrColor color,
namespace GrRectBatchFactory {
-GrBatch* CreateFillBW(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
- GrRectBatch::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 GrRectBatch::Create(geometry);
-}
GrBatch* CreateStrokeBW(GrColor color,
const SkMatrix& viewMatrix,
diff --git a/src/gpu/batches/GrRectBatchFactory.h b/src/gpu/batches/GrRectBatchFactory.h
index 8a08883438..6ded22db7b 100644
--- a/src/gpu/batches/GrRectBatchFactory.h
+++ b/src/gpu/batches/GrRectBatchFactory.h
@@ -9,6 +9,7 @@
#define GrRectBatchFactory_DEFINED
#include "GrAAFillRectBatch.h"
+#include "GrBWFillRectBatch.h"
#include "GrColor.h"
class GrBatch;
@@ -21,16 +22,18 @@ class SkStrokeRec;
*/
namespace GrRectBatchFactory {
-GrBatch* CreateFillBW(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix);
+inline GrBatch* CreateFillBW(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ return GrBWFillRectBatch::Create(color, viewMatrix, rect, localRect, localMatrix);
+}
-static GrBatch* CreateFillAA(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
+inline GrBatch* CreateFillAA(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
return GrAAFillRectBatch::Create(color, viewMatrix, rect, devRect);
}