joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 8 | #include "GrNonAAFillRectBatch.h" |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 9 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 10 | #include "GrBatchFlushState.h" |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 11 | #include "GrColor.h" |
| 12 | #include "GrDefaultGeoProcFactory.h" |
| 13 | #include "GrPrimitiveProcessor.h" |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 14 | #include "GrResourceProvider.h" |
| 15 | #include "GrTInstanceBatch.h" |
joshualitt | ae5b2c6 | 2015-08-19 08:48:41 -0700 | [diff] [blame] | 16 | #include "GrQuad.h" |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 17 | #include "GrVertexBatch.h" |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 18 | |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 19 | // Common functions |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 20 | class NonAAFillRectBatchBase { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 21 | public: |
| 22 | static const int kVertsPerInstance = 4; |
| 23 | static const int kIndicesPerInstance = 6; |
joshualitt | 87e4752 | 2015-08-20 07:22:42 -0700 | [diff] [blame] | 24 | |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 25 | static void InitInvariantOutputCoverage(GrInitInvariantOutput* out) { |
| 26 | out->setKnownSingleComponent(0xff); |
| 27 | } |
| 28 | |
| 29 | static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* rp) { |
| 30 | return rp->refQuadIndexBuffer(); |
| 31 | } |
| 32 | |
| 33 | template <typename Geometry> |
| 34 | static void SetBounds(const Geometry& geo, SkRect* outBounds) { |
| 35 | geo.fViewMatrix.mapRect(outBounds, geo.fRect); |
| 36 | } |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 37 | |
| 38 | template <typename Geometry> |
| 39 | static void UpdateBoundsAfterAppend(const Geometry& geo, SkRect* outBounds) { |
| 40 | SkRect bounds = geo.fRect; |
| 41 | geo.fViewMatrix.mapRect(&bounds); |
| 42 | outBounds->join(bounds); |
| 43 | } |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | /** We always use per-vertex colors so that rects can be batched across color changes. Sometimes |
| 47 | we have explicit local coords and sometimes not. We *could* always provide explicit local |
| 48 | coords and just duplicate the positions when the caller hasn't provided a local coord rect, |
| 49 | but we haven't seen a use case which frequently switches between local rect and no local |
| 50 | rect draws. |
| 51 | |
| 52 | The vertex attrib order is always pos, color, [local coords]. |
| 53 | */ |
| 54 | static const GrGeometryProcessor* create_gp(const SkMatrix& viewMatrix, |
| 55 | bool readsCoverage, |
| 56 | bool hasExplicitLocalCoords, |
| 57 | const SkMatrix* localMatrix) { |
| 58 | using namespace GrDefaultGeoProcFactory; |
| 59 | Color color(Color::kAttribute_Type); |
| 60 | Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type); |
| 61 | |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 62 | // If we have perspective on the viewMatrix then we won't map on the CPU, nor will we map |
| 63 | // the local rect on the cpu (in case the localMatrix also has perspective). |
| 64 | // Otherwise, if we have a local rect, then we apply the localMatrix directly to the localRect |
| 65 | // to generate vertex local coords |
| 66 | if (viewMatrix.hasPerspective()) { |
| 67 | LocalCoords localCoords(hasExplicitLocalCoords ? LocalCoords::kHasExplicit_Type : |
| 68 | LocalCoords::kUsePosition_Type, |
| 69 | localMatrix); |
| 70 | return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, viewMatrix); |
| 71 | } else if (hasExplicitLocalCoords) { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 72 | LocalCoords localCoords(LocalCoords::kHasExplicit_Type); |
| 73 | return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()); |
| 74 | } else { |
| 75 | LocalCoords localCoords(LocalCoords::kUsePosition_Type, localMatrix); |
| 76 | return GrDefaultGeoProcFactory::CreateForDeviceSpace(color, coverage, localCoords, |
| 77 | viewMatrix); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | static void tesselate(intptr_t vertices, |
| 82 | size_t vertexStride, |
| 83 | GrColor color, |
| 84 | const SkMatrix& viewMatrix, |
| 85 | const SkRect& rect, |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 86 | const GrQuad* localQuad) { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 87 | SkPoint* positions = reinterpret_cast<SkPoint*>(vertices); |
| 88 | |
| 89 | positions->setRectFan(rect.fLeft, rect.fTop, |
| 90 | rect.fRight, rect.fBottom, vertexStride); |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 91 | |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 92 | if (!viewMatrix.hasPerspective()) { |
| 93 | viewMatrix.mapPointsWithStride(positions, vertexStride, |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 94 | NonAAFillRectBatchBase::kVertsPerInstance); |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | // Setup local coords |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 98 | // TODO we should only do this if local coords are being read |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 99 | if (localQuad) { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 100 | static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor); |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 101 | for (int i = 0; i < NonAAFillRectBatchBase::kVertsPerInstance; i++) { |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 102 | SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset + |
| 103 | i * vertexStride); |
| 104 | *coords = localQuad->point(i); |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 105 | } |
| 106 | } |
| 107 | |
| 108 | static const int kColorOffset = sizeof(SkPoint); |
| 109 | GrColor* vertColor = reinterpret_cast<GrColor*>(vertices + kColorOffset); |
| 110 | for (int j = 0; j < 4; ++j) { |
| 111 | *vertColor = color; |
| 112 | vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride); |
| 113 | } |
| 114 | } |
| 115 | |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 116 | class NonAAFillRectBatchImp : public NonAAFillRectBatchBase { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 117 | public: |
| 118 | struct Geometry { |
| 119 | SkMatrix fViewMatrix; |
| 120 | SkRect fRect; |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 121 | GrQuad fLocalQuad; |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 122 | GrColor fColor; |
| 123 | }; |
| 124 | |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 125 | static const char* Name() { return "NonAAFillRectBatch"; } |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 126 | |
| 127 | static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
| 128 | const GrPipelineOptimizations& opts) { |
joshualitt | 87e4752 | 2015-08-20 07:22:42 -0700 | [diff] [blame] | 129 | return true; |
| 130 | } |
| 131 | |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 132 | static const GrGeometryProcessor* CreateGP(const Geometry& geo, |
| 133 | const GrPipelineOptimizations& opts) { |
| 134 | const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, opts.readsCoverage(), true, |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 135 | nullptr); |
joshualitt | 87e4752 | 2015-08-20 07:22:42 -0700 | [diff] [blame] | 136 | |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 137 | SkASSERT(gp->getVertexStride() == |
| 138 | sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)); |
| 139 | return gp; |
joshualitt | ae41b38 | 2015-08-19 06:54:08 -0700 | [diff] [blame] | 140 | } |
| 141 | |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 142 | static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, |
| 143 | const GrPipelineOptimizations& opts) { |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 144 | tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.fRect, &geo.fLocalQuad); |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 145 | } |
| 146 | }; |
| 147 | |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 148 | // We handle perspective in the local matrix or viewmatrix with special batches |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 149 | class NonAAFillRectBatchPerspectiveImp : public NonAAFillRectBatchBase { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 150 | public: |
| 151 | struct Geometry { |
| 152 | SkMatrix fViewMatrix; |
| 153 | SkMatrix fLocalMatrix; |
| 154 | SkRect fRect; |
| 155 | SkRect fLocalRect; |
joshualitt | ae41b38 | 2015-08-19 06:54:08 -0700 | [diff] [blame] | 156 | GrColor fColor; |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 157 | bool fHasLocalMatrix; |
| 158 | bool fHasLocalRect; |
joshualitt | ae41b38 | 2015-08-19 06:54:08 -0700 | [diff] [blame] | 159 | }; |
| 160 | |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 161 | static const char* Name() { return "NonAAFillRectBatchPerspective"; } |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 162 | |
| 163 | static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
| 164 | const GrPipelineOptimizations& opts) { |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 165 | // We could batch across perspective vm changes if we really wanted to |
| 166 | return mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix) && |
joshualitt | 2120b6f | 2015-09-18 12:56:41 -0700 | [diff] [blame] | 167 | mine.fHasLocalRect == theirs.fHasLocalRect && |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 168 | (!mine.fHasLocalMatrix || mine.fLocalMatrix.cheapEqualTo(theirs.fLocalMatrix)); |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static const GrGeometryProcessor* CreateGP(const Geometry& geo, |
| 172 | const GrPipelineOptimizations& opts) { |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 173 | const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, opts.readsCoverage(), |
| 174 | geo.fHasLocalRect, |
| 175 | geo.fHasLocalMatrix ? &geo.fLocalMatrix : |
| 176 | nullptr); |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 177 | |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 178 | SkASSERT(geo.fHasLocalRect ? |
| 179 | gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) : |
| 180 | gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr)); |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 181 | return gp; |
| 182 | } |
| 183 | |
| 184 | static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, |
| 185 | const GrPipelineOptimizations& opts) { |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 186 | if (geo.fHasLocalRect) { |
| 187 | GrQuad quad(geo.fLocalRect); |
| 188 | tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.fRect, &quad); |
| 189 | } else { |
| 190 | tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.fRect, nullptr); |
| 191 | } |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 192 | } |
joshualitt | ae41b38 | 2015-08-19 06:54:08 -0700 | [diff] [blame] | 193 | }; |
| 194 | |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 195 | typedef GrTInstanceBatch<NonAAFillRectBatchImp> NonAAFillRectBatchSimple; |
| 196 | typedef GrTInstanceBatch<NonAAFillRectBatchPerspectiveImp> NonAAFillRectBatchPerspective; |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 197 | |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 198 | inline static void append_to_batch(NonAAFillRectBatchSimple* batch, GrColor color, |
| 199 | const SkMatrix& viewMatrix, const SkRect& rect, |
| 200 | const SkRect* localRect, const SkMatrix* localMatrix) { |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 201 | SkASSERT(!viewMatrix.hasPerspective() && (!localMatrix || !localMatrix->hasPerspective())); |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 202 | NonAAFillRectBatchSimple::Geometry& geo = batch->geoData()->push_back(); |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 203 | |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 204 | geo.fColor = color; |
| 205 | geo.fViewMatrix = viewMatrix; |
| 206 | geo.fRect = rect; |
joshualitt | 8cce8f1 | 2015-08-26 06:23:39 -0700 | [diff] [blame] | 207 | |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 208 | if (localRect && localMatrix) { |
| 209 | geo.fLocalQuad.setFromMappedRect(*localRect, *localMatrix); |
| 210 | } else if (localRect) { |
| 211 | geo.fLocalQuad.set(*localRect); |
| 212 | } else if (localMatrix) { |
| 213 | geo.fLocalQuad.setFromMappedRect(rect, *localMatrix); |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 214 | } else { |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 215 | geo.fLocalQuad.set(rect); |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 216 | } |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 217 | } |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 218 | |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 219 | inline static void append_to_batch(NonAAFillRectBatchPerspective* batch, GrColor color, |
| 220 | const SkMatrix& viewMatrix, const SkRect& rect, |
| 221 | const SkRect* localRect, const SkMatrix* localMatrix) { |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 222 | SkASSERT(viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective())); |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 223 | NonAAFillRectBatchPerspective::Geometry& geo = batch->geoData()->push_back(); |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 224 | |
| 225 | geo.fColor = color; |
| 226 | geo.fViewMatrix = viewMatrix; |
| 227 | geo.fRect = rect; |
| 228 | geo.fHasLocalRect = SkToBool(localRect); |
| 229 | geo.fHasLocalMatrix = SkToBool(localMatrix); |
| 230 | if (localMatrix) { |
| 231 | geo.fLocalMatrix = *localMatrix; |
| 232 | } |
| 233 | if (localRect) { |
| 234 | geo.fLocalRect = *localRect; |
| 235 | } |
| 236 | |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 237 | } |
| 238 | |
| 239 | namespace GrNonAAFillRectBatch { |
| 240 | |
| 241 | GrDrawBatch* Create(GrColor color, |
| 242 | const SkMatrix& viewMatrix, |
| 243 | const SkRect& rect, |
| 244 | const SkRect* localRect, |
| 245 | const SkMatrix* localMatrix) { |
| 246 | NonAAFillRectBatchSimple* batch = NonAAFillRectBatchSimple::Create(); |
| 247 | append_to_batch(batch, color, viewMatrix, rect, localRect, localMatrix); |
joshualitt | 3566d44 | 2015-09-18 07:12:55 -0700 | [diff] [blame] | 248 | batch->init(); |
| 249 | return batch; |
| 250 | } |
| 251 | |
joshualitt | aa37a96 | 2015-09-18 13:03:25 -0700 | [diff] [blame^] | 252 | GrDrawBatch* CreateWithPerspective(GrColor color, |
| 253 | const SkMatrix& viewMatrix, |
| 254 | const SkRect& rect, |
| 255 | const SkRect* localRect, |
| 256 | const SkMatrix* localMatrix) { |
| 257 | NonAAFillRectBatchPerspective* batch = NonAAFillRectBatchPerspective::Create(); |
| 258 | append_to_batch(batch, color, viewMatrix, rect, localRect, localMatrix); |
| 259 | batch->init(); |
| 260 | return batch; |
| 261 | } |
| 262 | |
| 263 | bool Append(GrBatch* origBatch, |
| 264 | GrColor color, |
| 265 | const SkMatrix& viewMatrix, |
| 266 | const SkRect& rect, |
| 267 | const SkRect* localRect, |
| 268 | const SkMatrix* localMatrix) { |
| 269 | bool usePerspective = viewMatrix.hasPerspective() || |
| 270 | (localMatrix && localMatrix->hasPerspective()); |
| 271 | |
| 272 | if (usePerspective && origBatch->classID() != NonAAFillRectBatchPerspective::ClassID()) { |
| 273 | return false; |
| 274 | } |
| 275 | |
| 276 | if (!usePerspective) { |
| 277 | NonAAFillRectBatchSimple* batch = origBatch->cast<NonAAFillRectBatchSimple>(); |
| 278 | append_to_batch(batch, color, viewMatrix, rect, localRect, localMatrix); |
| 279 | batch->updateBoundsAfterAppend(); |
| 280 | } else { |
| 281 | NonAAFillRectBatchPerspective* batch = origBatch->cast<NonAAFillRectBatchPerspective>(); |
| 282 | const NonAAFillRectBatchPerspective::Geometry& geo = batch->geoData()->back(); |
| 283 | |
| 284 | if (!geo.fViewMatrix.cheapEqualTo(viewMatrix) || |
| 285 | geo.fHasLocalRect != SkToBool(localRect) || |
| 286 | geo.fHasLocalMatrix != SkToBool(localMatrix) || |
| 287 | (geo.fHasLocalMatrix && !geo.fLocalMatrix.cheapEqualTo(*localMatrix))) { |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | append_to_batch(batch, color, viewMatrix, rect, localRect, localMatrix); |
| 292 | batch->updateBoundsAfterAppend(); |
| 293 | } |
| 294 | |
| 295 | return true; |
| 296 | } |
| 297 | |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 298 | }; |
| 299 | |
| 300 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 301 | |
| 302 | #ifdef GR_TEST_UTILS |
| 303 | |
| 304 | #include "GrBatchTest.h" |
| 305 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 306 | DRAW_BATCH_TEST_DEFINE(RectBatch) { |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 307 | GrColor color = GrRandomColor(random); |
| 308 | SkRect rect = GrTest::TestRect(random); |
| 309 | SkRect localRect = GrTest::TestRect(random); |
| 310 | SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 311 | SkMatrix localMatrix = GrTest::TestMatrix(random); |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 312 | |
joshualitt | 2244c27 | 2015-08-21 10:33:15 -0700 | [diff] [blame] | 313 | bool hasLocalRect = random->nextBool(); |
| 314 | bool hasLocalMatrix = random->nextBool(); |
joshualitt | bcf33d5 | 2015-08-26 08:10:35 -0700 | [diff] [blame] | 315 | return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, |
| 316 | hasLocalRect ? &localRect : nullptr, |
| 317 | hasLocalMatrix ? &localMatrix : nullptr); |
joshualitt | 9c80b5f | 2015-08-13 10:05:51 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | #endif |