blob: 2c90b8bcf2e06558dbb8d68ecc3d721363a1cc00 [file] [log] [blame]
joshualitt9ff64252015-08-10 09:03: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
8#include "GrAAFillRectBatch.h"
9
joshualitt37eb1842015-08-12 06:36:57 -070010#include "GrColor.h"
joshualitt9ff64252015-08-10 09:03:51 -070011#include "GrDefaultGeoProcFactory.h"
12#include "GrResourceKey.h"
13#include "GrResourceProvider.h"
joshualitt2ad37be2015-08-18 10:16:01 -070014#include "GrTInstanceBatch.h"
joshualitt37eb1842015-08-12 06:36:57 -070015#include "GrTypes.h"
16#include "SkMatrix.h"
17#include "SkRect.h"
joshualitt9ff64252015-08-10 09:03:51 -070018
19GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
20
21static void set_inset_fan(SkPoint* pts, size_t stride,
22 const SkRect& r, SkScalar dx, SkScalar dy) {
23 pts->setRectFan(r.fLeft + dx, r.fTop + dy,
24 r.fRight - dx, r.fBottom - dy, stride);
25}
26
joshualitt27801bf2015-08-12 12:52:47 -070027static const int kNumAAFillRectsInIndexBuffer = 256;
28static const int kVertsPerAAFillRect = 8;
29static const int kIndicesPerAAFillRect = 30;
30
cdalton397536c2016-03-25 12:15:03 -070031const GrBuffer* get_index_buffer(GrResourceProvider* resourceProvider) {
joshualitt27801bf2015-08-12 12:52:47 -070032 GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
33
34 static const uint16_t gFillAARectIdx[] = {
35 0, 1, 5, 5, 4, 0,
36 1, 2, 6, 6, 5, 1,
37 2, 3, 7, 7, 6, 2,
38 3, 0, 4, 4, 7, 3,
39 4, 5, 6, 6, 7, 4,
40 };
41 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect);
42 return resourceProvider->findOrCreateInstancedIndexBuffer(gFillAARectIdx,
43 kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer, kVertsPerAAFillRect,
44 gAAFillRectIndexBufferKey);
45}
46
joshualittcd47b712015-08-18 07:25:38 -070047static const GrGeometryProcessor* create_fill_rect_gp(
48 const SkMatrix& viewMatrix,
ethannicholasff210322015-11-24 12:10:10 -080049 const GrXPOverridesForBatch& overrides,
joshualittcd47b712015-08-18 07:25:38 -070050 GrDefaultGeoProcFactory::LocalCoords::Type localCoordsType) {
51 using namespace GrDefaultGeoProcFactory;
52
53 Color color(Color::kAttribute_Type);
54 Coverage::Type coverageType;
55 // TODO remove coverage if coverage is ignored
56 /*if (coverageIgnored) {
57 coverageType = Coverage::kNone_Type;
ethannicholasff210322015-11-24 12:10:10 -080058 } else*/ if (overrides.canTweakAlphaForCoverage()) {
joshualittcd47b712015-08-18 07:25:38 -070059 coverageType = Coverage::kSolid_Type;
60 } else {
61 coverageType = Coverage::kAttribute_Type;
62 }
63 Coverage coverage(coverageType);
64
65 // We assume the caller has inverted the viewmatrix
66 if (LocalCoords::kHasExplicit_Type == localCoordsType) {
67 LocalCoords localCoords(localCoordsType);
68 return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
69 } else {
ethannicholasff210322015-11-24 12:10:10 -080070 LocalCoords localCoords(overrides.readsLocalCoords() ? localCoordsType :
71 LocalCoords::kUnused_Type);
joshualittcd47b712015-08-18 07:25:38 -070072 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
73 }
74}
75
76static void generate_aa_fill_rect_geometry(intptr_t verts,
77 size_t vertexStride,
78 GrColor color,
79 const SkMatrix& viewMatrix,
80 const SkRect& rect,
81 const SkRect& devRect,
ethannicholasff210322015-11-24 12:10:10 -080082 const GrXPOverridesForBatch& overrides,
joshualittcd47b712015-08-18 07:25:38 -070083 const SkMatrix* localMatrix) {
84 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
85 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
86
robertphillips0851d2d2016-06-02 05:21:34 -070087 SkScalar inset;
joshualittcd47b712015-08-18 07:25:38 -070088
89 if (viewMatrix.rectStaysRect()) {
robertphillips0851d2d2016-06-02 05:21:34 -070090 inset = SkMinScalar(devRect.width(), SK_Scalar1);
91 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
92
joshualittcd47b712015-08-18 07:25:38 -070093 set_inset_fan(fan0Pos, vertexStride, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
94 set_inset_fan(fan1Pos, vertexStride, devRect, inset, inset);
95 } else {
96 // compute transformed (1, 0) and (0, 1) vectors
97 SkVector vec[2] = {
98 { viewMatrix[SkMatrix::kMScaleX], viewMatrix[SkMatrix::kMSkewY] },
99 { viewMatrix[SkMatrix::kMSkewX], viewMatrix[SkMatrix::kMScaleY] }
100 };
101
robertphillips0851d2d2016-06-02 05:21:34 -0700102 SkScalar len1 = SkPoint::Normalize(&vec[0]);
joshualittcd47b712015-08-18 07:25:38 -0700103 vec[0].scale(SK_ScalarHalf);
robertphillips0851d2d2016-06-02 05:21:34 -0700104 SkScalar len2 = SkPoint::Normalize(&vec[1]);
joshualittcd47b712015-08-18 07:25:38 -0700105 vec[1].scale(SK_ScalarHalf);
106
robertphillips0851d2d2016-06-02 05:21:34 -0700107 inset = SkMinScalar(len1 * rect.width(), SK_Scalar1);
108 inset = SK_ScalarHalf * SkMinScalar(inset, len2 * rect.height());
109
joshualittcd47b712015-08-18 07:25:38 -0700110 // create the rotated rect
111 fan0Pos->setRectFan(rect.fLeft, rect.fTop,
112 rect.fRight, rect.fBottom, vertexStride);
113 viewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4);
114
115 // Now create the inset points and then outset the original
116 // rotated points
117
118 // TL
119 *((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) =
120 *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) + vec[0] + vec[1];
121 *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) -= vec[0] + vec[1];
122 // BL
123 *((SkPoint*)((intptr_t)fan1Pos + 1 * vertexStride)) =
124 *((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) + vec[0] - vec[1];
125 *((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) -= vec[0] - vec[1];
126 // BR
127 *((SkPoint*)((intptr_t)fan1Pos + 2 * vertexStride)) =
128 *((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) - vec[0] - vec[1];
129 *((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) += vec[0] + vec[1];
130 // TR
131 *((SkPoint*)((intptr_t)fan1Pos + 3 * vertexStride)) =
132 *((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) - vec[0] + vec[1];
133 *((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) += vec[0] - vec[1];
134 }
135
136 if (localMatrix) {
137 SkMatrix invViewMatrix;
138 if (!viewMatrix.invert(&invViewMatrix)) {
139 SkASSERT(false);
140 invViewMatrix = SkMatrix::I();
141 }
142 SkMatrix localCoordMatrix;
143 localCoordMatrix.setConcat(*localMatrix, invViewMatrix);
144 SkPoint* fan0Loc = reinterpret_cast<SkPoint*>(verts + sizeof(SkPoint) + sizeof(GrColor));
145 localCoordMatrix.mapPointsWithStride(fan0Loc, fan0Pos, vertexStride, 8);
146 }
147
ethannicholasff210322015-11-24 12:10:10 -0800148 bool tweakAlphaForCoverage = overrides.canTweakAlphaForCoverage();
joshualittcd47b712015-08-18 07:25:38 -0700149
150 // Make verts point to vertex color and then set all the color and coverage vertex attrs
151 // values.
152 verts += sizeof(SkPoint);
153
154 // The coverage offset is always the last vertex attribute
155 intptr_t coverageOffset = vertexStride - sizeof(GrColor) - sizeof(SkPoint);
156 for (int i = 0; i < 4; ++i) {
157 if (tweakAlphaForCoverage) {
158 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = 0;
159 } else {
160 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
161 *reinterpret_cast<float*>(verts + i * vertexStride + coverageOffset) = 0;
162 }
163 }
164
165 int scale;
166 if (inset < SK_ScalarHalf) {
167 scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
168 SkASSERT(scale >= 0 && scale <= 255);
169 } else {
170 scale = 0xff;
171 }
172
173 verts += 4 * vertexStride;
174
175 float innerCoverage = GrNormalizeByteToFloat(scale);
176 GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
177
178 for (int i = 0; i < 4; ++i) {
179 if (tweakAlphaForCoverage) {
180 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
181 } else {
182 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
183 *reinterpret_cast<float*>(verts + i * vertexStride +
184 coverageOffset) = innerCoverage;
185 }
186 }
187}
188
joshualitt2ad37be2015-08-18 10:16:01 -0700189// Common functions
190class AAFillRectBatchBase {
191public:
192 static const int kVertsPerInstance = kVertsPerAAFillRect;
193 static const int kIndicesPerInstance = kIndicesPerAAFillRect;
194
joshualitt2244c272015-08-21 10:33:15 -0700195 static void InitInvariantOutputCoverage(GrInitInvariantOutput* out) {
196 out->setUnknownSingleComponent();
197 }
198
cdalton397536c2016-03-25 12:15:03 -0700199 static const GrBuffer* GetIndexBuffer(GrResourceProvider* rp) {
joshualitt2ad37be2015-08-18 10:16:01 -0700200 return get_index_buffer(rp);
201 }
joshualitt2244c272015-08-21 10:33:15 -0700202
203 template <class Geometry>
204 static void SetBounds(const Geometry& geo, SkRect* outBounds) {
205 *outBounds = geo.fDevRect;
206 }
joshualittaa37a962015-09-18 13:03:25 -0700207
208 template <class Geometry>
209 static void UpdateBoundsAfterAppend(const Geometry& geo, SkRect* outBounds) {
210 outBounds->join(geo.fDevRect);
211 }
joshualitt2ad37be2015-08-18 10:16:01 -0700212};
213
214class AAFillRectBatchNoLocalMatrixImp : public AAFillRectBatchBase {
joshualitt147dc062015-08-12 11:51:46 -0700215public:
216 struct Geometry {
217 SkMatrix fViewMatrix;
joshualitt40ac15a2015-08-14 08:45:39 -0700218 SkRect fRect;
joshualitt147dc062015-08-12 11:51:46 -0700219 SkRect fDevRect;
220 GrColor fColor;
221 };
222
joshualitt2244c272015-08-21 10:33:15 -0700223 static const char* Name() { return "AAFillRectBatchNoLocalMatrix"; }
joshualitt2ad37be2015-08-18 10:16:01 -0700224
robertphillips783a4da2015-11-19 14:00:02 -0800225 static SkString DumpInfo(const Geometry& geo, int index) {
robertphillipse004bfc2015-11-16 09:06:59 -0800226 SkString str;
robertphillips783a4da2015-11-19 14:00:02 -0800227 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
228 index,
robertphillipse004bfc2015-11-16 09:06:59 -0800229 geo.fColor,
230 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect.fBottom);
231 return str;
232 }
233
joshualitt2244c272015-08-21 10:33:15 -0700234 static bool CanCombine(const Geometry& mine, const Geometry& theirs,
ethannicholasff210322015-11-24 12:10:10 -0800235 const GrXPOverridesForBatch& overrides) {
joshualitt147dc062015-08-12 11:51:46 -0700236 // We apply the viewmatrix to the rect points on the cpu. However, if the pipeline uses
237 // local coords then we won't be able to batch. We could actually upload the viewmatrix
238 // using vertex attributes in these cases, but haven't investigated that
ethannicholasff210322015-11-24 12:10:10 -0800239 return !overrides.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix);
joshualitt147dc062015-08-12 11:51:46 -0700240 }
241
joshualitt2244c272015-08-21 10:33:15 -0700242 static const GrGeometryProcessor* CreateGP(const Geometry& geo,
ethannicholasff210322015-11-24 12:10:10 -0800243 const GrXPOverridesForBatch& overrides) {
joshualittcd47b712015-08-18 07:25:38 -0700244 const GrGeometryProcessor* gp =
ethannicholasff210322015-11-24 12:10:10 -0800245 create_fill_rect_gp(geo.fViewMatrix, overrides,
joshualittcd47b712015-08-18 07:25:38 -0700246 GrDefaultGeoProcFactory::LocalCoords::kUsePosition_Type);
247
ethannicholasff210322015-11-24 12:10:10 -0800248 SkASSERT(overrides.canTweakAlphaForCoverage() ?
joshualittcd47b712015-08-18 07:25:38 -0700249 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
250 gp->getVertexStride() ==
251 sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
252 return gp;
joshualitt147dc062015-08-12 11:51:46 -0700253 }
254
joshualitt2244c272015-08-21 10:33:15 -0700255 static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo,
ethannicholasff210322015-11-24 12:10:10 -0800256 const GrXPOverridesForBatch& overrides) {
joshualittcd47b712015-08-18 07:25:38 -0700257 generate_aa_fill_rect_geometry(vertices, vertexStride,
halcanary9d524f22016-03-29 09:03:52 -0700258 geo.fColor, geo.fViewMatrix, geo.fRect, geo.fDevRect,
ethannicholasff210322015-11-24 12:10:10 -0800259 overrides, nullptr);
joshualitt147dc062015-08-12 11:51:46 -0700260 }
joshualitt147dc062015-08-12 11:51:46 -0700261};
262
joshualitt2ad37be2015-08-18 10:16:01 -0700263class AAFillRectBatchLocalMatrixImp : public AAFillRectBatchBase {
joshualitt147dc062015-08-12 11:51:46 -0700264public:
265 struct Geometry {
266 SkMatrix fViewMatrix;
267 SkMatrix fLocalMatrix;
joshualitt40ac15a2015-08-14 08:45:39 -0700268 SkRect fRect;
joshualitt147dc062015-08-12 11:51:46 -0700269 SkRect fDevRect;
270 GrColor fColor;
271 };
272
joshualitt2244c272015-08-21 10:33:15 -0700273 static const char* Name() { return "AAFillRectBatchLocalMatrix"; }
joshualitt2ad37be2015-08-18 10:16:01 -0700274
robertphillips783a4da2015-11-19 14:00:02 -0800275 static SkString DumpInfo(const Geometry& geo, int index) {
robertphillipse004bfc2015-11-16 09:06:59 -0800276 SkString str;
robertphillips783a4da2015-11-19 14:00:02 -0800277 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
278 index,
robertphillipse004bfc2015-11-16 09:06:59 -0800279 geo.fColor,
280 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect.fBottom);
281 return str;
282 }
283
joshualitt2244c272015-08-21 10:33:15 -0700284 static bool CanCombine(const Geometry& mine, const Geometry& theirs,
ethannicholasff210322015-11-24 12:10:10 -0800285 const GrXPOverridesForBatch& overrides) {
joshualitt147dc062015-08-12 11:51:46 -0700286 return true;
287 }
288
joshualitt2244c272015-08-21 10:33:15 -0700289 static const GrGeometryProcessor* CreateGP(const Geometry& geo,
ethannicholasff210322015-11-24 12:10:10 -0800290 const GrXPOverridesForBatch& overrides) {
joshualittcd47b712015-08-18 07:25:38 -0700291 const GrGeometryProcessor* gp =
ethannicholasff210322015-11-24 12:10:10 -0800292 create_fill_rect_gp(geo.fViewMatrix, overrides,
joshualittcd47b712015-08-18 07:25:38 -0700293 GrDefaultGeoProcFactory::LocalCoords::kHasExplicit_Type);
294
ethannicholasff210322015-11-24 12:10:10 -0800295 SkASSERT(overrides.canTweakAlphaForCoverage() ?
joshualittcd47b712015-08-18 07:25:38 -0700296 gp->getVertexStride() ==
297 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) :
298 gp->getVertexStride() ==
299 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordCoverage));
300 return gp;
joshualitt147dc062015-08-12 11:51:46 -0700301 }
302
joshualitt2244c272015-08-21 10:33:15 -0700303 static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo,
ethannicholasff210322015-11-24 12:10:10 -0800304 const GrXPOverridesForBatch& overrides) {
joshualittcd47b712015-08-18 07:25:38 -0700305 generate_aa_fill_rect_geometry(vertices, vertexStride,
halcanary9d524f22016-03-29 09:03:52 -0700306 geo.fColor, geo.fViewMatrix, geo.fRect, geo.fDevRect,
ethannicholasff210322015-11-24 12:10:10 -0800307 overrides, &geo.fLocalMatrix);
joshualitt147dc062015-08-12 11:51:46 -0700308 }
309};
310
joshualitt2ad37be2015-08-18 10:16:01 -0700311typedef GrTInstanceBatch<AAFillRectBatchNoLocalMatrixImp> AAFillRectBatchNoLocalMatrix;
312typedef GrTInstanceBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatrix;
joshualitt147dc062015-08-12 11:51:46 -0700313
joshualittaa37a962015-09-18 13:03:25 -0700314inline static void append_to_batch(AAFillRectBatchNoLocalMatrix* batch, GrColor color,
315 const SkMatrix& viewMatrix, const SkRect& rect,
316 const SkRect& devRect) {
317 AAFillRectBatchNoLocalMatrix::Geometry& geo = batch->geoData()->push_back();
318 geo.fColor = color;
319 geo.fViewMatrix = viewMatrix;
320 geo.fRect = rect;
321 geo.fDevRect = devRect;
322}
323
324inline static void append_to_batch(AAFillRectBatchLocalMatrix* batch, GrColor color,
325 const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
326 const SkRect& rect, const SkRect& devRect) {
327 AAFillRectBatchLocalMatrix::Geometry& geo = batch->geoData()->push_back();
328 geo.fColor = color;
329 geo.fViewMatrix = viewMatrix;
330 geo.fLocalMatrix = localMatrix;
331 geo.fRect = rect;
332 geo.fDevRect = devRect;
333}
334
joshualitt37eb1842015-08-12 06:36:57 -0700335namespace GrAAFillRectBatch {
joshualitt9ff64252015-08-10 09:03:51 -0700336
bsalomonabd30f52015-08-13 13:34:48 -0700337GrDrawBatch* Create(GrColor color,
338 const SkMatrix& viewMatrix,
339 const SkRect& rect,
340 const SkRect& devRect) {
joshualitt147dc062015-08-12 11:51:46 -0700341 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create();
joshualittaa37a962015-09-18 13:03:25 -0700342 append_to_batch(batch, color, viewMatrix, rect, devRect);
joshualitt147dc062015-08-12 11:51:46 -0700343 batch->init();
344 return batch;
345}
346
bsalomonabd30f52015-08-13 13:34:48 -0700347GrDrawBatch* Create(GrColor color,
348 const SkMatrix& viewMatrix,
349 const SkMatrix& localMatrix,
350 const SkRect& rect,
351 const SkRect& devRect) {
joshualitt147dc062015-08-12 11:51:46 -0700352 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
joshualittaa37a962015-09-18 13:03:25 -0700353 append_to_batch(batch, color, viewMatrix, localMatrix, rect, devRect);
joshualitt147dc062015-08-12 11:51:46 -0700354 batch->init();
355 return batch;
joshualitt9ff64252015-08-10 09:03:51 -0700356}
357
bsalomonc55271f2015-11-09 11:55:57 -0800358GrDrawBatch* Create(GrColor color,
359 const SkMatrix& viewMatrix,
360 const SkMatrix& localMatrix,
361 const SkRect& rect) {
362 SkRect devRect;
363 viewMatrix.mapRect(&devRect, rect);
364 return Create(color, viewMatrix, localMatrix, rect, devRect);
365}
366
367GrDrawBatch* CreateWithLocalRect(GrColor color,
368 const SkMatrix& viewMatrix,
369 const SkRect& rect,
370 const SkRect& localRect) {
371 SkRect devRect;
372 viewMatrix.mapRect(&devRect, rect);
373 SkMatrix localMatrix;
374 if (!localMatrix.setRectToRect(rect, localRect, SkMatrix::kFill_ScaleToFit)) {
375 return nullptr;
376 }
377 return Create(color, viewMatrix, localMatrix, rect, devRect);
378}
379
joshualittaa37a962015-09-18 13:03:25 -0700380void Append(GrBatch* origBatch,
381 GrColor color,
382 const SkMatrix& viewMatrix,
383 const SkRect& rect,
384 const SkRect& devRect) {
385 AAFillRectBatchNoLocalMatrix* batch = origBatch->cast<AAFillRectBatchNoLocalMatrix>();
386 append_to_batch(batch, color, viewMatrix, rect, devRect);
387 batch->updateBoundsAfterAppend();
388}
389
390void Append(GrBatch* origBatch,
391 GrColor color,
392 const SkMatrix& viewMatrix,
393 const SkMatrix& localMatrix,
394 const SkRect& rect,
395 const SkRect& devRect) {
396 AAFillRectBatchLocalMatrix* batch = origBatch->cast<AAFillRectBatchLocalMatrix>();
397 append_to_batch(batch, color, viewMatrix, localMatrix, rect, devRect);
398 batch->updateBoundsAfterAppend();
399}
400
joshualitt37eb1842015-08-12 06:36:57 -0700401};
402
joshualitt9ff64252015-08-10 09:03:51 -0700403///////////////////////////////////////////////////////////////////////////////////////////////////
404
405#ifdef GR_TEST_UTILS
406
407#include "GrBatchTest.h"
408
bsalomonabd30f52015-08-13 13:34:48 -0700409DRAW_BATCH_TEST_DEFINE(AAFillRectBatch) {
joshualitt090ae8e2015-08-14 09:01:21 -0700410 GrColor color = GrRandomColor(random);
411 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
412 SkRect rect = GrTest::TestRect(random);
413 SkRect devRect = GrTest::TestRect(random);
414 return GrAAFillRectBatch::Create(color, viewMatrix, rect, devRect);
joshualitt147dc062015-08-12 11:51:46 -0700415}
416
bsalomonabd30f52015-08-13 13:34:48 -0700417DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
joshualitt090ae8e2015-08-14 09:01:21 -0700418 GrColor color = GrRandomColor(random);
419 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
420 SkMatrix localMatrix = GrTest::TestMatrix(random);
421 SkRect rect = GrTest::TestRect(random);
422 SkRect devRect = GrTest::TestRect(random);
423 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRect);
joshualitt9ff64252015-08-10 09:03:51 -0700424}
425
426#endif