jvanverth | 14b8803 | 2015-08-07 12:18:54 -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 | |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 8 | #include "GrDrawAtlasOp.h" |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 9 | #include "GrDrawOpTest.h" |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 10 | #include "GrOpFlushState.h" |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 11 | #include "SkGr.h" |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 12 | #include "SkRSXform.h" |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 13 | #include "SkRandom.h" |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 14 | #include "SkRectPriv.h" |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 15 | |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame^] | 16 | static sk_sp<GrGeometryProcessor> make_gp(const GrShaderCaps* shaderCaps, |
| 17 | bool hasColors, |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 18 | GrColor color, |
| 19 | const SkMatrix& viewMatrix) { |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 20 | using namespace GrDefaultGeoProcFactory; |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 21 | Color gpColor(color); |
| 22 | if (hasColors) { |
Brian Salomon | 3de0aee | 2017-01-29 09:34:17 -0500 | [diff] [blame] | 23 | gpColor.fType = Color::kPremulGrColorAttribute_Type; |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 24 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 25 | |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame^] | 26 | return GrDefaultGeoProcFactory::Make(shaderCaps, gpColor, Coverage::kSolid_Type, |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 27 | LocalCoords::kHasExplicit_Type, viewMatrix); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 30 | GrDrawAtlasOp::GrDrawAtlasOp(const Helper::MakeArgs& helperArgs, GrColor color, |
| 31 | const SkMatrix& viewMatrix, GrAAType aaType, int spriteCount, |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 32 | const SkRSXform* xforms, const SkRect* rects, const SkColor* colors) |
Brian Salomon | f99a173 | 2017-07-14 09:24:30 -0400 | [diff] [blame] | 33 | : INHERITED(ClassID()), fHelper(helperArgs, aaType), fColor(color) { |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 34 | SkASSERT(xforms); |
| 35 | SkASSERT(rects); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 36 | |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 37 | fViewMatrix = viewMatrix; |
bsalomon | 0432dd6 | 2016-06-30 07:19:27 -0700 | [diff] [blame] | 38 | Geometry& installedGeo = fGeoData.push_back(); |
| 39 | installedGeo.fColor = color; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 40 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 41 | // Figure out stride and offsets |
| 42 | // Order within the vertex is: position [color] texCoord |
| 43 | size_t texOffset = sizeof(SkPoint); |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 44 | size_t vertexStride = 2 * sizeof(SkPoint); |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 45 | fHasColors = SkToBool(colors); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 46 | if (colors) { |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 47 | texOffset += sizeof(GrColor); |
| 48 | vertexStride += sizeof(GrColor); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 49 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 50 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 51 | // Compute buffer size and alloc buffer |
| 52 | fQuadCount = spriteCount; |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 53 | int allocSize = static_cast<int>(4 * vertexStride * spriteCount); |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 54 | installedGeo.fVerts.reset(allocSize); |
| 55 | uint8_t* currVertex = installedGeo.fVerts.begin(); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 56 | |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 57 | SkRect bounds = SkRectPriv::MakeLargestInverted(); |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 58 | int paintAlpha = GrColorUnpackA(installedGeo.fColor); |
| 59 | for (int spriteIndex = 0; spriteIndex < spriteCount; ++spriteIndex) { |
| 60 | // Transform rect |
Brian Salomon | 57caa66 | 2017-10-18 12:21:05 +0000 | [diff] [blame] | 61 | SkPoint strip[4]; |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 62 | const SkRect& currRect = rects[spriteIndex]; |
Brian Salomon | 57caa66 | 2017-10-18 12:21:05 +0000 | [diff] [blame] | 63 | xforms[spriteIndex].toTriStrip(currRect.width(), currRect.height(), strip); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 64 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 65 | // Copy colors if necessary |
| 66 | if (colors) { |
| 67 | // convert to GrColor |
| 68 | SkColor color = colors[spriteIndex]; |
| 69 | if (paintAlpha != 255) { |
| 70 | color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paintAlpha)); |
| 71 | } |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 72 | GrColor grColor = SkColorToPremulGrColor(color); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 73 | |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 74 | *(reinterpret_cast<GrColor*>(currVertex + sizeof(SkPoint))) = grColor; |
| 75 | *(reinterpret_cast<GrColor*>(currVertex + vertexStride + sizeof(SkPoint))) = grColor; |
| 76 | *(reinterpret_cast<GrColor*>(currVertex + 2 * vertexStride + sizeof(SkPoint))) = |
| 77 | grColor; |
| 78 | *(reinterpret_cast<GrColor*>(currVertex + 3 * vertexStride + sizeof(SkPoint))) = |
| 79 | grColor; |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 80 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 81 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 82 | // Copy position and uv to verts |
Brian Salomon | 57caa66 | 2017-10-18 12:21:05 +0000 | [diff] [blame] | 83 | *(reinterpret_cast<SkPoint*>(currVertex)) = strip[0]; |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 84 | *(reinterpret_cast<SkPoint*>(currVertex + texOffset)) = |
| 85 | SkPoint::Make(currRect.fLeft, currRect.fTop); |
Mike Reed | 185ffe9 | 2018-01-08 17:09:54 -0500 | [diff] [blame] | 86 | SkRectPriv::GrowToInclude(&bounds, strip[0]); |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 87 | currVertex += vertexStride; |
| 88 | |
Brian Salomon | 57caa66 | 2017-10-18 12:21:05 +0000 | [diff] [blame] | 89 | *(reinterpret_cast<SkPoint*>(currVertex)) = strip[1]; |
Brian Salomon | 62563de | 2017-10-17 19:14:05 +0000 | [diff] [blame] | 90 | *(reinterpret_cast<SkPoint*>(currVertex + texOffset)) = |
| 91 | SkPoint::Make(currRect.fLeft, currRect.fBottom); |
Mike Reed | 185ffe9 | 2018-01-08 17:09:54 -0500 | [diff] [blame] | 92 | SkRectPriv::GrowToInclude(&bounds, strip[1]); |
Brian Salomon | 57caa66 | 2017-10-18 12:21:05 +0000 | [diff] [blame] | 93 | currVertex += vertexStride; |
| 94 | |
| 95 | *(reinterpret_cast<SkPoint*>(currVertex)) = strip[2]; |
| 96 | *(reinterpret_cast<SkPoint*>(currVertex + texOffset)) = |
| 97 | SkPoint::Make(currRect.fRight, currRect.fTop); |
Mike Reed | 185ffe9 | 2018-01-08 17:09:54 -0500 | [diff] [blame] | 98 | SkRectPriv::GrowToInclude(&bounds, strip[2]); |
Brian Salomon | 57caa66 | 2017-10-18 12:21:05 +0000 | [diff] [blame] | 99 | currVertex += vertexStride; |
| 100 | |
| 101 | *(reinterpret_cast<SkPoint*>(currVertex)) = strip[3]; |
| 102 | *(reinterpret_cast<SkPoint*>(currVertex + texOffset)) = |
| 103 | SkPoint::Make(currRect.fRight, currRect.fBottom); |
Mike Reed | 185ffe9 | 2018-01-08 17:09:54 -0500 | [diff] [blame] | 104 | SkRectPriv::GrowToInclude(&bounds, strip[3]); |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 105 | currVertex += vertexStride; |
| 106 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 107 | |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 108 | this->setTransformedBounds(bounds, viewMatrix, HasAABloat::kNo, IsZeroArea::kNo); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 109 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 110 | |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 111 | SkString GrDrawAtlasOp::dumpInfo() const { |
| 112 | SkString string; |
| 113 | for (const auto& geo : fGeoData) { |
| 114 | string.appendf("Color: 0x%08x, Quads: %d\n", geo.fColor, geo.fVerts.count() / 4); |
| 115 | } |
| 116 | string += fHelper.dumpInfo(); |
| 117 | string += INHERITED::dumpInfo(); |
| 118 | return string; |
| 119 | } |
| 120 | |
Brian Salomon | 91326c3 | 2017-08-09 16:02:19 -0400 | [diff] [blame] | 121 | void GrDrawAtlasOp::onPrepareDraws(Target* target) { |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 122 | // Setup geometry processor |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame^] | 123 | sk_sp<GrGeometryProcessor> gp(make_gp(target->caps().shaderCaps(), |
| 124 | this->hasColors(), |
| 125 | this->color(), |
| 126 | this->viewMatrix())); |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 127 | |
| 128 | int instanceCount = fGeoData.count(); |
Brian Salomon | 92be2f7 | 2018-06-19 14:33:47 -0400 | [diff] [blame] | 129 | size_t vertexStride = |
| 130 | sizeof(SkPoint) + sizeof(SkPoint) + (this->hasColors() ? sizeof(GrColor) : 0); |
| 131 | SkASSERT(vertexStride == gp->debugOnly_vertexStride()); |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 132 | |
| 133 | QuadHelper helper; |
| 134 | int numQuads = this->quadCount(); |
| 135 | void* verts = helper.init(target, vertexStride, numQuads); |
| 136 | if (!verts) { |
| 137 | SkDebugf("Could not allocate vertices\n"); |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | uint8_t* vertPtr = reinterpret_cast<uint8_t*>(verts); |
| 142 | for (int i = 0; i < instanceCount; i++) { |
| 143 | const Geometry& args = fGeoData[i]; |
| 144 | |
| 145 | size_t allocSize = args.fVerts.count(); |
| 146 | memcpy(vertPtr, args.fVerts.begin(), allocSize); |
| 147 | vertPtr += allocSize; |
| 148 | } |
Brian Salomon | 4934890 | 2018-06-26 09:12:38 -0400 | [diff] [blame] | 149 | auto pipe = fHelper.makePipeline(target); |
| 150 | helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState); |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 151 | } |
| 152 | |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 153 | bool GrDrawAtlasOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { |
| 154 | GrDrawAtlasOp* that = t->cast<GrDrawAtlasOp>(); |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 155 | |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 156 | if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 157 | return false; |
| 158 | } |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 159 | |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 160 | // We currently use a uniform viewmatrix for this op. |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 161 | if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
| 162 | return false; |
| 163 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 164 | |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 165 | if (this->hasColors() != that->hasColors()) { |
| 166 | return false; |
| 167 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 168 | |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 169 | if (!this->hasColors() && this->color() != that->color()) { |
| 170 | return false; |
| 171 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 172 | |
bsalomon | 0432dd6 | 2016-06-30 07:19:27 -0700 | [diff] [blame] | 173 | fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin()); |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 174 | fQuadCount += that->quadCount(); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 175 | |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 176 | this->joinBounds(*that); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 177 | return true; |
| 178 | } |
| 179 | |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 180 | GrDrawOp::FixedFunctionFlags GrDrawAtlasOp::fixedFunctionFlags() const { |
| 181 | return fHelper.fixedFunctionFlags(); |
| 182 | } |
| 183 | |
| 184 | GrDrawOp::RequiresDstTexture GrDrawAtlasOp::finalize(const GrCaps& caps, |
Brian Osman | 532b3f9 | 2018-07-11 10:02:07 -0400 | [diff] [blame] | 185 | const GrAppliedClip* clip) { |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 186 | GrProcessorAnalysisColor gpColor; |
| 187 | if (this->hasColors()) { |
| 188 | gpColor.setToUnknown(); |
| 189 | } else { |
| 190 | gpColor.setToConstant(fColor); |
| 191 | } |
Brian Osman | 532b3f9 | 2018-07-11 10:02:07 -0400 | [diff] [blame] | 192 | auto result = fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kNone, |
| 193 | &gpColor); |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 194 | if (gpColor.isConstant(&fColor)) { |
| 195 | fHasColors = false; |
| 196 | } |
| 197 | return result; |
| 198 | } |
| 199 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 200 | #if GR_TEST_UTILS |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 201 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 202 | static SkRSXform random_xform(SkRandom* random) { |
| 203 | static const SkScalar kMinExtent = -100.f; |
| 204 | static const SkScalar kMaxExtent = 100.f; |
| 205 | static const SkScalar kMinScale = 0.1f; |
| 206 | static const SkScalar kMaxScale = 100.f; |
| 207 | static const SkScalar kMinRotate = -SK_ScalarPI; |
| 208 | static const SkScalar kMaxRotate = SK_ScalarPI; |
| 209 | |
| 210 | SkRSXform xform = SkRSXform::MakeFromRadians(random->nextRangeScalar(kMinScale, kMaxScale), |
| 211 | random->nextRangeScalar(kMinRotate, kMaxRotate), |
| 212 | random->nextRangeScalar(kMinExtent, kMaxExtent), |
| 213 | random->nextRangeScalar(kMinExtent, kMaxExtent), |
| 214 | random->nextRangeScalar(kMinExtent, kMaxExtent), |
| 215 | random->nextRangeScalar(kMinExtent, kMaxExtent)); |
| 216 | return xform; |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 217 | } |
| 218 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 219 | static SkRect random_texRect(SkRandom* random) { |
| 220 | static const SkScalar kMinCoord = 0.0f; |
| 221 | static const SkScalar kMaxCoord = 1024.f; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 222 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 223 | SkRect texRect = SkRect::MakeLTRB(random->nextRangeScalar(kMinCoord, kMaxCoord), |
| 224 | random->nextRangeScalar(kMinCoord, kMaxCoord), |
| 225 | random->nextRangeScalar(kMinCoord, kMaxCoord), |
| 226 | random->nextRangeScalar(kMinCoord, kMaxCoord)); |
| 227 | texRect.sort(); |
| 228 | return texRect; |
| 229 | } |
| 230 | |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 231 | static void randomize_params(uint32_t count, SkRandom* random, SkTArray<SkRSXform>* xforms, |
| 232 | SkTArray<SkRect>* texRects, SkTArray<GrColor>* colors, |
| 233 | bool hasColors) { |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 234 | for (uint32_t v = 0; v < count; v++) { |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 235 | xforms->push_back(random_xform(random)); |
| 236 | texRects->push_back(random_texRect(random)); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 237 | if (hasColors) { |
| 238 | colors->push_back(GrRandomColor(random)); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 243 | GR_DRAW_OP_TEST_DEFINE(GrDrawAtlasOp) { |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 244 | uint32_t spriteCount = random->nextRangeU(1, 100); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 245 | |
jvanverth | 5a4d235 | 2015-08-12 08:15:31 -0700 | [diff] [blame] | 246 | SkTArray<SkRSXform> xforms(spriteCount); |
| 247 | SkTArray<SkRect> texRects(spriteCount); |
jvanverth | 1acf250 | 2015-08-13 11:53:39 -0700 | [diff] [blame] | 248 | SkTArray<GrColor> colors; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 249 | |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 250 | bool hasColors = random->nextBool(); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 251 | |
Brian Salomon | fc527d2 | 2016-12-14 21:07:01 -0500 | [diff] [blame] | 252 | randomize_params(spriteCount, random, &xforms, &texRects, &colors, hasColors); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 253 | |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 254 | SkMatrix viewMatrix = GrTest::TestMatrix(random); |
Brian Salomon | 0088f94 | 2017-07-12 11:51:27 -0400 | [diff] [blame] | 255 | GrAAType aaType = GrAAType::kNone; |
| 256 | if (GrFSAAType::kUnifiedMSAA == fsaaType && random->nextBool()) { |
| 257 | aaType = GrAAType::kMSAA; |
| 258 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 259 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 260 | return GrDrawAtlasOp::Make(context, std::move(paint), viewMatrix, aaType, spriteCount, |
| 261 | xforms.begin(), texRects.begin(), |
| 262 | hasColors ? colors.begin() : nullptr); |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | #endif |