blob: 4a7daf2b793a76f3ef09638e82a98c04b36dc489 [file] [log] [blame]
joshualitt9c80b5f2015-08-13 10:05:51 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
joshualittbcf33d52015-08-26 08:10:35 -07008#include "GrNonAAFillRectBatch.h"
joshualitt9c80b5f2015-08-13 10:05:51 -07009
bsalomon75398562015-08-17 12:55:38 -070010#include "GrBatchFlushState.h"
joshualitt9c80b5f2015-08-13 10:05:51 -070011#include "GrColor.h"
12#include "GrDefaultGeoProcFactory.h"
13#include "GrPrimitiveProcessor.h"
joshualitt2244c272015-08-21 10:33:15 -070014#include "GrResourceProvider.h"
joshualittae5b2c62015-08-19 08:48:41 -070015#include "GrQuad.h"
bsalomon16b99132015-08-13 14:55:50 -070016#include "GrVertexBatch.h"
joshualitt9c80b5f2015-08-13 10:05:51 -070017
bsalomon08d14152016-06-30 12:45:18 -070018static const int kVertsPerInstance = 4;
19static const int kIndicesPerInstance = 6;
joshualitt2244c272015-08-21 10:33:15 -070020
21/** We always use per-vertex colors so that rects can be batched across color changes. Sometimes
22 we have explicit local coords and sometimes not. We *could* always provide explicit local
23 coords and just duplicate the positions when the caller hasn't provided a local coord rect,
24 but we haven't seen a use case which frequently switches between local rect and no local
25 rect draws.
26
27 The vertex attrib order is always pos, color, [local coords].
28 */
robertphillips6abd1d12016-07-01 09:06:56 -070029static sk_sp<GrGeometryProcessor> make_persp_gp(const SkMatrix& viewMatrix,
30 bool readsCoverage,
31 bool hasExplicitLocalCoords,
32 const SkMatrix* localMatrix) {
33 SkASSERT(viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective()));
34
joshualitt2244c272015-08-21 10:33:15 -070035 using namespace GrDefaultGeoProcFactory;
36 Color color(Color::kAttribute_Type);
37 Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type);
38
joshualitt8cce8f12015-08-26 06:23:39 -070039 // If we have perspective on the viewMatrix then we won't map on the CPU, nor will we map
40 // the local rect on the cpu (in case the localMatrix also has perspective).
41 // Otherwise, if we have a local rect, then we apply the localMatrix directly to the localRect
42 // to generate vertex local coords
43 if (viewMatrix.hasPerspective()) {
44 LocalCoords localCoords(hasExplicitLocalCoords ? LocalCoords::kHasExplicit_Type :
45 LocalCoords::kUsePosition_Type,
46 localMatrix);
bungeman06ca8ec2016-06-09 08:01:03 -070047 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, viewMatrix);
joshualitt8cce8f12015-08-26 06:23:39 -070048 } else if (hasExplicitLocalCoords) {
robertphillips6abd1d12016-07-01 09:06:56 -070049 LocalCoords localCoords(LocalCoords::kHasExplicit_Type, localMatrix);
bungeman06ca8ec2016-06-09 08:01:03 -070050 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
joshualitt2244c272015-08-21 10:33:15 -070051 } else {
52 LocalCoords localCoords(LocalCoords::kUsePosition_Type, localMatrix);
bungeman06ca8ec2016-06-09 08:01:03 -070053 return GrDefaultGeoProcFactory::MakeForDeviceSpace(color, coverage, localCoords,
54 viewMatrix);
joshualitt2244c272015-08-21 10:33:15 -070055 }
56}
57
robertphillips6abd1d12016-07-01 09:06:56 -070058static sk_sp<GrGeometryProcessor> make_gp(bool readsCoverage) {
59 using namespace GrDefaultGeoProcFactory;
60 Color color(Color::kAttribute_Type);
61 Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type);
62
63 LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
64 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
65}
66
joshualitt2244c272015-08-21 10:33:15 -070067static void tesselate(intptr_t vertices,
68 size_t vertexStride,
69 GrColor color,
robertphillips6abd1d12016-07-01 09:06:56 -070070 const SkMatrix* viewMatrix,
joshualitt2244c272015-08-21 10:33:15 -070071 const SkRect& rect,
joshualitt8cce8f12015-08-26 06:23:39 -070072 const GrQuad* localQuad) {
joshualitt2244c272015-08-21 10:33:15 -070073 SkPoint* positions = reinterpret_cast<SkPoint*>(vertices);
74
75 positions->setRectFan(rect.fLeft, rect.fTop,
76 rect.fRight, rect.fBottom, vertexStride);
joshualitt2244c272015-08-21 10:33:15 -070077
robertphillips6abd1d12016-07-01 09:06:56 -070078 if (viewMatrix) {
79 viewMatrix->mapPointsWithStride(positions, vertexStride, kVertsPerInstance);
joshualitt8cce8f12015-08-26 06:23:39 -070080 }
81
82 // Setup local coords
joshualitt2244c272015-08-21 10:33:15 -070083 // TODO we should only do this if local coords are being read
joshualitt8cce8f12015-08-26 06:23:39 -070084 if (localQuad) {
joshualitt2244c272015-08-21 10:33:15 -070085 static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
bsalomon08d14152016-06-30 12:45:18 -070086 for (int i = 0; i < kVertsPerInstance; i++) {
joshualitt8cce8f12015-08-26 06:23:39 -070087 SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset +
88 i * vertexStride);
89 *coords = localQuad->point(i);
joshualitt2244c272015-08-21 10:33:15 -070090 }
91 }
92
93 static const int kColorOffset = sizeof(SkPoint);
94 GrColor* vertColor = reinterpret_cast<GrColor*>(vertices + kColorOffset);
95 for (int j = 0; j < 4; ++j) {
96 *vertColor = color;
97 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
98 }
99}
100
bsalomon08d14152016-06-30 12:45:18 -0700101class NonAAFillRectBatch : public GrVertexBatch {
joshualitt2244c272015-08-21 10:33:15 -0700102public:
bsalomon08d14152016-06-30 12:45:18 -0700103 DEFINE_BATCH_CLASS_ID
104
bsalomon9d7f1842016-07-01 08:01:36 -0700105 NonAAFillRectBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
106 const SkRect* localRect, const SkMatrix* localMatrix)
107 : INHERITED(ClassID()) {
108 SkASSERT(!viewMatrix.hasPerspective() && (!localMatrix ||
109 !localMatrix->hasPerspective()));
110 RectInfo& info = fRects.push_back();
111 info.fColor = color;
112 info.fViewMatrix = viewMatrix;
113 info.fRect = rect;
114 if (localRect && localMatrix) {
115 info.fLocalQuad.setFromMappedRect(*localRect, *localMatrix);
116 } else if (localRect) {
117 info.fLocalQuad.set(*localRect);
118 } else if (localMatrix) {
119 info.fLocalQuad.setFromMappedRect(rect, *localMatrix);
120 } else {
121 info.fLocalQuad.set(rect);
122 }
123 viewMatrix.mapRect(&fBounds, fRects[0].fRect);
124 }
bsalomon08d14152016-06-30 12:45:18 -0700125
bsalomonbc9b6a42016-07-01 05:35:51 -0700126 const char* name() const override { return "NonAAFillRectBatch"; }
bsalomon08d14152016-06-30 12:45:18 -0700127
128 SkString dumpInfo() const override {
129 SkString str;
bsalomon9d7f1842016-07-01 08:01:36 -0700130 str.appendf("# batched: %d\n", fRects.count());
131 for (int i = 0; i < fRects.count(); ++i) {
132 const RectInfo& info = fRects[i];
bsalomonbc9b6a42016-07-01 05:35:51 -0700133 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
bsalomon9d7f1842016-07-01 08:01:36 -0700134 i, info.fColor,
135 info.fRect.fLeft, info.fRect.fTop, info.fRect.fRight, info.fRect.fBottom);
bsalomon08d14152016-06-30 12:45:18 -0700136 }
137 str.append(INHERITED::dumpInfo());
138 return str;
139 }
140
141 void computePipelineOptimizations(GrInitInvariantOutput* color,
142 GrInitInvariantOutput* coverage,
143 GrBatchToXPOverrides* overrides) const override {
144 // When this is called on a batch, there is only one geometry bundle
bsalomon9d7f1842016-07-01 08:01:36 -0700145 color->setKnownFourComponents(fRects[0].fColor);
bsalomonbc9b6a42016-07-01 05:35:51 -0700146 coverage->setKnownSingleComponent(0xff);
bsalomon08d14152016-06-30 12:45:18 -0700147 }
148
149 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
bsalomon9d7f1842016-07-01 08:01:36 -0700150 overrides.getOverrideColorIfSet(&fRects[0].fColor);
bsalomon08d14152016-06-30 12:45:18 -0700151 fOverrides = overrides;
152 }
153
bsalomon08d14152016-06-30 12:45:18 -0700154private:
bsalomon08d14152016-06-30 12:45:18 -0700155 NonAAFillRectBatch() : INHERITED(ClassID()) {}
156
157 void onPrepareDraws(Target* target) const override {
robertphillips6abd1d12016-07-01 09:06:56 -0700158 sk_sp<GrGeometryProcessor> gp = make_gp(fOverrides.readsCoverage());
bsalomon08d14152016-06-30 12:45:18 -0700159 if (!gp) {
160 SkDebugf("Couldn't create GrGeometryProcessor\n");
161 return;
162 }
bsalomonbc9b6a42016-07-01 05:35:51 -0700163 SkASSERT(gp->getVertexStride() ==
164 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr));
bsalomon08d14152016-06-30 12:45:18 -0700165
166 size_t vertexStride = gp->getVertexStride();
bsalomon9d7f1842016-07-01 08:01:36 -0700167 int instanceCount = fRects.count();
bsalomon08d14152016-06-30 12:45:18 -0700168
bsalomonbc9b6a42016-07-01 05:35:51 -0700169 SkAutoTUnref<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
bsalomon08d14152016-06-30 12:45:18 -0700170 InstancedHelper helper;
171 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
172 indexBuffer, kVertsPerInstance,
173 kIndicesPerInstance, instanceCount);
174 if (!vertices || !indexBuffer) {
175 SkDebugf("Could not allocate vertices\n");
176 return;
177 }
178
179 for (int i = 0; i < instanceCount; i++) {
180 intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
181 i * kVertsPerInstance * vertexStride;
robertphillips6abd1d12016-07-01 09:06:56 -0700182 tesselate(verts, vertexStride, fRects[i].fColor, &fRects[i].fViewMatrix,
bsalomon9d7f1842016-07-01 08:01:36 -0700183 fRects[i].fRect, &fRects[i].fLocalQuad);
bsalomon08d14152016-06-30 12:45:18 -0700184 }
185 helper.recordDraw(target, gp.get());
186 }
187
bsalomon08d14152016-06-30 12:45:18 -0700188 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
189 NonAAFillRectBatch* that = t->cast<NonAAFillRectBatch>();
190 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
191 that->bounds(), caps)) {
192 return false;
193 }
194
bsalomon08d14152016-06-30 12:45:18 -0700195 // In the event of two batches, one who can tweak, one who cannot, we just fall back to
196 // not tweaking
197 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakAlphaForCoverage()) {
198 fOverrides = that->fOverrides;
199 }
200
bsalomon9d7f1842016-07-01 08:01:36 -0700201 fRects.push_back_n(that->fRects.count(), that->fRects.begin());
bsalomon08d14152016-06-30 12:45:18 -0700202 this->joinBounds(that->bounds());
203 return true;
204 }
205
bsalomon9d7f1842016-07-01 08:01:36 -0700206 struct RectInfo {
207 GrColor fColor;
208 SkMatrix fViewMatrix;
209 SkRect fRect;
210 GrQuad fLocalQuad;
211 };
212
bsalomon08d14152016-06-30 12:45:18 -0700213 GrXPOverridesForBatch fOverrides;
bsalomon9d7f1842016-07-01 08:01:36 -0700214 SkSTArray<1, RectInfo, true> fRects;
bsalomon08d14152016-06-30 12:45:18 -0700215
216 typedef GrVertexBatch INHERITED;
joshualitt2244c272015-08-21 10:33:15 -0700217};
218
joshualitt8cce8f12015-08-26 06:23:39 -0700219// We handle perspective in the local matrix or viewmatrix with special batches
bsalomon08d14152016-06-30 12:45:18 -0700220class NonAAFillRectPerspectiveBatch : public GrVertexBatch {
joshualitt2244c272015-08-21 10:33:15 -0700221public:
bsalomon08d14152016-06-30 12:45:18 -0700222 DEFINE_BATCH_CLASS_ID
223
bsalomon9d7f1842016-07-01 08:01:36 -0700224 NonAAFillRectPerspectiveBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
225 const SkRect* localRect, const SkMatrix* localMatrix)
226 : INHERITED(ClassID())
227 , fViewMatrix(viewMatrix) {
228 SkASSERT(viewMatrix.hasPerspective() || (localMatrix &&
229 localMatrix->hasPerspective()));
230 RectInfo& info = fRects.push_back();
231 info.fColor = color;
232 info.fRect = rect;
233 fHasLocalRect = SkToBool(localRect);
234 fHasLocalMatrix = SkToBool(localMatrix);
235 if (fHasLocalMatrix) {
236 fLocalMatrix = *localMatrix;
237 }
238 if (fHasLocalRect) {
239 info.fLocalRect = *localRect;
240 }
241 viewMatrix.mapRect(&fBounds, rect);
242 }
bsalomon08d14152016-06-30 12:45:18 -0700243
bsalomonbc9b6a42016-07-01 05:35:51 -0700244 const char* name() const override { return "NonAAFillRectPerspectiveBatch"; }
bsalomon08d14152016-06-30 12:45:18 -0700245
246 SkString dumpInfo() const override {
247 SkString str;
bsalomon9d7f1842016-07-01 08:01:36 -0700248 str.appendf("# batched: %d\n", fRects.count());
249 for (int i = 0; i < fRects.count(); ++i) {
250 const RectInfo& geo = fRects[0];
bsalomonbc9b6a42016-07-01 05:35:51 -0700251 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
252 i, geo.fColor,
253 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect.fBottom);
bsalomon08d14152016-06-30 12:45:18 -0700254 }
255 str.append(INHERITED::dumpInfo());
256 return str;
257 }
258
259 void computePipelineOptimizations(GrInitInvariantOutput* color,
260 GrInitInvariantOutput* coverage,
261 GrBatchToXPOverrides* overrides) const override {
262 // When this is called on a batch, there is only one geometry bundle
bsalomon9d7f1842016-07-01 08:01:36 -0700263 color->setKnownFourComponents(fRects[0].fColor);
bsalomonbc9b6a42016-07-01 05:35:51 -0700264 coverage->setKnownSingleComponent(0xff);
bsalomon08d14152016-06-30 12:45:18 -0700265 }
266
267 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
bsalomon9d7f1842016-07-01 08:01:36 -0700268 overrides.getOverrideColorIfSet(&fRects[0].fColor);
bsalomon08d14152016-06-30 12:45:18 -0700269 fOverrides = overrides;
270 }
271
bsalomon08d14152016-06-30 12:45:18 -0700272private:
bsalomon08d14152016-06-30 12:45:18 -0700273 NonAAFillRectPerspectiveBatch() : INHERITED(ClassID()) {}
274
275 void onPrepareDraws(Target* target) const override {
robertphillips6abd1d12016-07-01 09:06:56 -0700276 sk_sp<GrGeometryProcessor> gp = make_persp_gp(fViewMatrix,
277 fOverrides.readsCoverage(),
278 fHasLocalRect,
279 fHasLocalMatrix ? &fLocalMatrix : nullptr);
bsalomon08d14152016-06-30 12:45:18 -0700280 if (!gp) {
281 SkDebugf("Couldn't create GrGeometryProcessor\n");
282 return;
283 }
bsalomon9d7f1842016-07-01 08:01:36 -0700284 SkASSERT(fHasLocalRect
bsalomonbc9b6a42016-07-01 05:35:51 -0700285 ? gp->getVertexStride() ==
286 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)
287 : gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
bsalomon08d14152016-06-30 12:45:18 -0700288
289 size_t vertexStride = gp->getVertexStride();
bsalomon9d7f1842016-07-01 08:01:36 -0700290 int instanceCount = fRects.count();
bsalomon08d14152016-06-30 12:45:18 -0700291
bsalomonbc9b6a42016-07-01 05:35:51 -0700292 SkAutoTUnref<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
bsalomon08d14152016-06-30 12:45:18 -0700293 InstancedHelper helper;
294 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
295 indexBuffer, kVertsPerInstance,
296 kIndicesPerInstance, instanceCount);
297 if (!vertices || !indexBuffer) {
298 SkDebugf("Could not allocate vertices\n");
299 return;
300 }
301
302 for (int i = 0; i < instanceCount; i++) {
bsalomon9d7f1842016-07-01 08:01:36 -0700303 const RectInfo& info = fRects[i];
bsalomon08d14152016-06-30 12:45:18 -0700304 intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
305 i * kVertsPerInstance * vertexStride;
bsalomon9d7f1842016-07-01 08:01:36 -0700306 if (fHasLocalRect) {
307 GrQuad quad(info.fLocalRect);
robertphillips6abd1d12016-07-01 09:06:56 -0700308 tesselate(verts, vertexStride, info.fColor, nullptr, info.fRect, &quad);
bsalomonbc9b6a42016-07-01 05:35:51 -0700309 } else {
robertphillips6abd1d12016-07-01 09:06:56 -0700310 tesselate(verts, vertexStride, info.fColor, nullptr, info.fRect, nullptr);
bsalomonbc9b6a42016-07-01 05:35:51 -0700311 }
bsalomon08d14152016-06-30 12:45:18 -0700312 }
313 helper.recordDraw(target, gp.get());
314 }
315
bsalomon08d14152016-06-30 12:45:18 -0700316 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
317 NonAAFillRectPerspectiveBatch* that = t->cast<NonAAFillRectPerspectiveBatch>();
318 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
319 that->bounds(), caps)) {
320 return false;
321 }
322
bsalomonbc9b6a42016-07-01 05:35:51 -0700323 // We could batch across perspective vm changes if we really wanted to
bsalomon9d7f1842016-07-01 08:01:36 -0700324 if (!fViewMatrix.cheapEqualTo(that->fViewMatrix)) {
bsalomonbc9b6a42016-07-01 05:35:51 -0700325 return false;
326 }
bsalomon9d7f1842016-07-01 08:01:36 -0700327 if (fHasLocalRect != that->fHasLocalRect) {
bsalomonbc9b6a42016-07-01 05:35:51 -0700328 return false;
329 }
bsalomon9d7f1842016-07-01 08:01:36 -0700330 if (fHasLocalMatrix && !fLocalMatrix.cheapEqualTo(that->fLocalMatrix)) {
bsalomon08d14152016-06-30 12:45:18 -0700331 return false;
332 }
333
334 // In the event of two batches, one who can tweak, one who cannot, we just fall back to
335 // not tweaking
336 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakAlphaForCoverage()) {
337 fOverrides = that->fOverrides;
338 }
339
bsalomon9d7f1842016-07-01 08:01:36 -0700340 fRects.push_back_n(that->fRects.count(), that->fRects.begin());
bsalomon08d14152016-06-30 12:45:18 -0700341 this->joinBounds(that->bounds());
342 return true;
343 }
344
bsalomon9d7f1842016-07-01 08:01:36 -0700345 struct RectInfo {
346 SkRect fRect;
347 GrColor fColor;
348 SkRect fLocalRect;
349 };
350
bsalomon08d14152016-06-30 12:45:18 -0700351 GrXPOverridesForBatch fOverrides;
bsalomon9d7f1842016-07-01 08:01:36 -0700352 SkSTArray<1, RectInfo, true> fRects;
353 bool fHasLocalMatrix;
354 bool fHasLocalRect;
355 SkMatrix fLocalMatrix;
356 SkMatrix fViewMatrix;
bsalomon08d14152016-06-30 12:45:18 -0700357
358 typedef GrVertexBatch INHERITED;
joshualittae41b382015-08-19 06:54:08 -0700359};
360
bsalomonb8cbd202016-06-30 13:09:48 -0700361namespace GrNonAAFillRectBatch {
362
363GrDrawBatch* Create(GrColor color,
364 const SkMatrix& viewMatrix,
365 const SkRect& rect,
366 const SkRect* localRect,
367 const SkMatrix* localMatrix) {
bsalomon9d7f1842016-07-01 08:01:36 -0700368 return new NonAAFillRectBatch(color, viewMatrix, rect, localRect, localMatrix);
joshualitt9c80b5f2015-08-13 10:05:51 -0700369}
joshualitt3566d442015-09-18 07:12:55 -0700370
bsalomonb8cbd202016-06-30 13:09:48 -0700371GrDrawBatch* CreateWithPerspective(GrColor color,
372 const SkMatrix& viewMatrix,
373 const SkRect& rect,
374 const SkRect* localRect,
375 const SkMatrix* localMatrix) {
bsalomon9d7f1842016-07-01 08:01:36 -0700376 return new NonAAFillRectPerspectiveBatch(color, viewMatrix, rect, localRect, localMatrix);
joshualitt3566d442015-09-18 07:12:55 -0700377}
378
joshualitt9c80b5f2015-08-13 10:05:51 -0700379};
380
381///////////////////////////////////////////////////////////////////////////////////////////////////
382
383#ifdef GR_TEST_UTILS
384
385#include "GrBatchTest.h"
386
bsalomonabd30f52015-08-13 13:34:48 -0700387DRAW_BATCH_TEST_DEFINE(RectBatch) {
joshualitt2244c272015-08-21 10:33:15 -0700388 GrColor color = GrRandomColor(random);
389 SkRect rect = GrTest::TestRect(random);
390 SkRect localRect = GrTest::TestRect(random);
391 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
392 SkMatrix localMatrix = GrTest::TestMatrix(random);
joshualitt9c80b5f2015-08-13 10:05:51 -0700393
joshualitt2244c272015-08-21 10:33:15 -0700394 bool hasLocalRect = random->nextBool();
395 bool hasLocalMatrix = random->nextBool();
joshualittbcf33d52015-08-26 08:10:35 -0700396 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect,
397 hasLocalRect ? &localRect : nullptr,
398 hasLocalMatrix ? &localMatrix : nullptr);
joshualitt9c80b5f2015-08-13 10:05:51 -0700399}
400
401#endif