blob: abf5393d8422b5d592fe33415cce872af4b8d36d [file] [log] [blame]
commit-bot@chromium.org78a10782013-08-21 19:27:48 +00001/*
2 * Copyright 2013 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
Greg Daniel7ef28f32017-04-20 16:41:55 +00008#include "GrBackendSurface.h"
bsalomon682c2692015-05-22 14:01:46 -07009#include "GrContextOptions.h"
Chris Daltonfe199b72017-05-05 11:26:15 -040010#include "GrContextPriv.h"
Brian Salomon2ee084e2016-12-16 18:59:19 -050011#include "GrDrawOpAtlas.h"
robertphillips77a2e522015-10-17 07:43:27 -070012#include "GrDrawingManager.h"
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040013#include "GrGpu.h"
bsalomon3582d3e2015-02-13 14:20:05 -080014#include "GrGpuResourceCacheAccess.h"
Robert Phillipsc994a932018-06-19 13:09:54 -040015#include "GrMemoryPool.h"
Brian Salomon17726632017-05-12 14:09:46 -040016#include "GrRenderTargetContext.h"
Brian Salomon2ee084e2016-12-16 18:59:19 -050017#include "GrRenderTargetContextPriv.h"
csmartdaltonf9635992016-08-10 11:09:07 -070018#include "GrRenderTargetProxy.h"
bsalomon0ea80f42015-02-11 10:49:59 -080019#include "GrResourceCache.h"
Greg Daniel6be35232017-03-01 17:01:09 -050020#include "GrSemaphore.h"
Brian Salomon17726632017-05-12 14:09:46 -040021#include "GrSurfaceContextPriv.h"
Robert Phillips646e4292017-06-13 12:44:56 -040022#include "GrTexture.h"
Brian Osman3b655982017-03-07 16:58:08 -050023#include "SkGr.h"
Robert Phillips22f4a1f2016-12-20 08:57:26 -050024#include "SkImage_Gpu.h"
halcanary4dbbd042016-06-07 17:21:10 -070025#include "SkMathPriv.h"
mtkleinb9eb4ac2015-02-02 18:26:03 -080026#include "SkString.h"
Hal Canaryc640d0d2018-06-13 09:59:02 -040027#include "SkTo.h"
Chris Dalton4da70192018-06-18 09:51:36 -060028#include "ccpr/GrCoverageCountingPathRenderer.h"
Brian Salomon17726632017-05-12 14:09:46 -040029#include "ops/GrMeshDrawOp.h"
Robert Phillipsc4039ea2018-03-01 11:36:45 -050030#include "text/GrGlyphCache.h"
joshualitte8042922015-12-11 06:11:21 -080031#include "text/GrTextBlobCache.h"
Hal Canary8a001442018-09-19 11:31:27 -040032
Hal Canaryc640d0d2018-06-13 09:59:02 -040033#include <algorithm>
joshualitte8042922015-12-11 06:11:21 -080034
Robert Phillipseaa86252016-11-08 13:49:39 +000035bool GrSurfaceProxy::isWrapped_ForTesting() const {
36 return SkToBool(fTarget);
37}
38
39bool GrRenderTargetContext::isWrapped_ForTesting() const {
40 return fRenderTargetProxy->isWrapped_ForTesting();
41}
42
Robert Phillips0c4b7b12018-03-06 08:20:37 -050043void GrContextPriv::setTextBlobCacheLimit_ForTesting(size_t bytes) {
44 fContext->fTextBlobCache->setBudget(bytes);
joshualitt17d833b2015-08-03 10:17:44 -070045}
46
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000047///////////////////////////////////////////////////////////////////////////////
48
Robert Phillips0c4b7b12018-03-06 08:20:37 -050049void GrContextPriv::purgeAllUnlockedResources_ForTesting() {
50 fContext->fResourceCache->purgeAllUnlocked();
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000051}
bsalomon33435572014-11-05 14:47:41 -080052
Robert Phillips0c4b7b12018-03-06 08:20:37 -050053void GrContextPriv::resetGpuStats() const {
joshualitte45c81c2015-12-02 09:05:37 -080054#if GR_GPU_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050055 fContext->fGpu->stats()->reset();
joshualitte45c81c2015-12-02 09:05:37 -080056#endif
57}
58
Robert Phillips0c4b7b12018-03-06 08:20:37 -050059void GrContextPriv::dumpCacheStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -080060#if GR_CACHE_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050061 fContext->fResourceCache->dumpStats(out);
mtkleinb9eb4ac2015-02-02 18:26:03 -080062#endif
63}
64
Robert Phillips0c4b7b12018-03-06 08:20:37 -050065void GrContextPriv::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
66 SkTArray<double>* values) const {
joshualittdc5685a2015-12-02 14:08:25 -080067#if GR_CACHE_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050068 fContext->fResourceCache->dumpStatsKeyValuePairs(keys, values);
joshualittdc5685a2015-12-02 14:08:25 -080069#endif
70}
71
Robert Phillips0c4b7b12018-03-06 08:20:37 -050072void GrContextPriv::printCacheStats() const {
mtkleinb9eb4ac2015-02-02 18:26:03 -080073 SkString out;
74 this->dumpCacheStats(&out);
kkinnunen297aaf92015-02-19 06:32:12 -080075 SkDebugf("%s", out.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -080076}
77
Robert Phillips0c4b7b12018-03-06 08:20:37 -050078void GrContextPriv::dumpGpuStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -080079#if GR_GPU_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050080 return fContext->fGpu->stats()->dump(out);
mtkleinb9eb4ac2015-02-02 18:26:03 -080081#endif
82}
83
Robert Phillips0c4b7b12018-03-06 08:20:37 -050084void GrContextPriv::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
85 SkTArray<double>* values) const {
joshualitte45c81c2015-12-02 09:05:37 -080086#if GR_GPU_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050087 return fContext->fGpu->stats()->dumpKeyValuePairs(keys, values);
joshualitte45c81c2015-12-02 09:05:37 -080088#endif
89}
90
Robert Phillips0c4b7b12018-03-06 08:20:37 -050091void GrContextPriv::printGpuStats() const {
mtkleinb9eb4ac2015-02-02 18:26:03 -080092 SkString out;
93 this->dumpGpuStats(&out);
kkinnunen297aaf92015-02-19 06:32:12 -080094 SkDebugf("%s", out.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -080095}
96
Robert Phillips0c4b7b12018-03-06 08:20:37 -050097sk_sp<SkImage> GrContextPriv::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
Robert Phillips5a66efb2018-03-07 15:13:18 -050098 auto atlasManager = this->getAtlasManager();
99 if (!atlasManager) {
100 return nullptr;
101 }
jvanverth629162d2015-11-08 08:07:24 -0800102
Jim Van Verthcbeae032018-05-16 14:54:41 -0400103 unsigned int numActiveProxies;
104 const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(format, &numActiveProxies);
105 if (index >= numActiveProxies || !proxies || !proxies[index]) {
Robert Phillips32f28182017-02-28 16:20:03 -0500106 return nullptr;
107 }
108
Jim Van Verth87d18ce2018-01-22 12:45:47 -0500109 SkASSERT(proxies[index]->priv().isExact());
Brian Salomon8a8dd332018-05-24 14:08:31 -0400110 sk_sp<SkImage> image(new SkImage_Gpu(sk_ref_sp(fContext), kNeedNewImageUniqueID,
111 kPremul_SkAlphaType, proxies[index], nullptr,
112 SkBudgeted::kNo));
Robert Phillips22f4a1f2016-12-20 08:57:26 -0500113 return image;
jvanverth0671b962015-12-08 18:53:44 -0800114}
jvanverth629162d2015-11-08 08:07:24 -0800115
mtkleinb9eb4ac2015-02-02 18:26:03 -0800116#if GR_GPU_STATS
117void GrGpu::Stats::dump(SkString* out) {
118 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
119 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
bsalomonb12ea412015-02-02 21:19:50 -0800120 out->appendf("Textures Created: %d\n", fTextureCreates);
121 out->appendf("Texture Uploads: %d\n", fTextureUploads);
jvanverth17aa0472016-01-05 10:41:27 -0800122 out->appendf("Transfers to Texture: %d\n", fTransfersToTexture);
egdaniel8dc7c3a2015-04-16 11:22:42 -0700123 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
joshualitt87a5c9f2015-09-08 13:42:05 -0700124 out->appendf("Number of draws: %d\n", fNumDraws);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800125}
joshualitte45c81c2015-12-02 09:05:37 -0800126
127void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) {
128 keys->push_back(SkString("render_target_binds")); values->push_back(fRenderTargetBinds);
129 keys->push_back(SkString("shader_compilations")); values->push_back(fShaderCompilations);
joshualitte45c81c2015-12-02 09:05:37 -0800130 keys->push_back(SkString("texture_uploads")); values->push_back(fTextureUploads);
joshualitte45c81c2015-12-02 09:05:37 -0800131 keys->push_back(SkString("number_of_draws")); values->push_back(fNumDraws);
bsalomon1d417a82016-03-23 11:50:26 -0700132 keys->push_back(SkString("number_of_failed_draws")); values->push_back(fNumFailedDraws);
joshualitte45c81c2015-12-02 09:05:37 -0800133}
134
mtkleinb9eb4ac2015-02-02 18:26:03 -0800135#endif
136
Brian Salomon52e943a2018-03-13 09:32:39 -0400137GrBackendTexture GrGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
Brian Osman2b23c4b2018-06-01 12:25:08 -0400138 SkColorType colorType, bool isRenderTarget,
Brian Salomonbdecacf2018-02-02 20:32:49 -0500139 GrMipMapped mipMapped) {
Brian Osman2b23c4b2018-06-01 12:25:08 -0400140 GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
Greg Daniel0a7aa142018-02-21 13:02:32 -0500141 if (kUnknown_GrPixelConfig == config) {
142 return GrBackendTexture();
143 }
Brian Salomonbdecacf2018-02-02 20:32:49 -0500144 return this->createTestingOnlyBackendTexture(pixels, w, h, config, isRenderTarget, mipMapped);
145}
146
mtkleinb9eb4ac2015-02-02 18:26:03 -0800147#if GR_CACHE_STATS
robertphillips60029a52015-11-09 13:51:06 -0800148void GrResourceCache::getStats(Stats* stats) const {
149 stats->reset();
150
151 stats->fTotal = this->getResourceCount();
152 stats->fNumNonPurgeable = fNonpurgeableResources.count();
153 stats->fNumPurgeable = fPurgeableQueue.count();
154
155 for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
156 stats->update(fNonpurgeableResources[i]);
157 }
158 for (int i = 0; i < fPurgeableQueue.count(); ++i) {
159 stats->update(fPurgeableQueue.at(i));
160 }
161}
162
bsalomon0ea80f42015-02-11 10:49:59 -0800163void GrResourceCache::dumpStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -0800164 this->validate();
165
bsalomonf320e042015-02-17 15:09:34 -0800166 Stats stats;
167
robertphillips60029a52015-11-09 13:51:06 -0800168 this->getStats(&stats);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800169
170 float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
171 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
172
173 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
174 out->appendf("\t\tEntry Count: current %d"
kkinnunen2e6055b2016-04-22 01:48:29 -0700175 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
176 stats.fTotal, fBudgetedCount, stats.fWrapped, stats.fNumNonPurgeable,
177 stats.fScratch, countUtilization, fHighWaterCount);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800178 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n",
bsalomonf320e042015-02-17 15:09:34 -0800179 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
180 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
mtkleinb9eb4ac2015-02-02 18:26:03 -0800181}
182
joshualittdc5685a2015-12-02 14:08:25 -0800183void GrResourceCache::dumpStatsKeyValuePairs(SkTArray<SkString>* keys,
184 SkTArray<double>* values) const {
185 this->validate();
186
187 Stats stats;
188 this->getStats(&stats);
189
joshualittdc5685a2015-12-02 14:08:25 -0800190 keys->push_back(SkString("gpu_cache_purgable_entries")); values->push_back(stats.fNumPurgeable);
joshualittdc5685a2015-12-02 14:08:25 -0800191}
192
mtkleinb9eb4ac2015-02-02 18:26:03 -0800193#endif
194
bsalomonddf30e62015-02-19 11:38:44 -0800195///////////////////////////////////////////////////////////////////////////////
196
197void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newTimestamp; }
mtkleinb9eb4ac2015-02-02 18:26:03 -0800198
Brian Salomon1090da62017-01-06 12:04:19 -0500199#ifdef SK_DEBUG
200int GrResourceCache::countUniqueKeysWithTag(const char* tag) const {
201 int count = 0;
202 UniqueHash::ConstIter iter(&fUniqueHash);
203 while (!iter.done()) {
204 if (0 == strcmp(tag, (*iter).getUniqueKey().tag())) {
205 ++count;
206 }
207 ++iter;
208 }
209 return count;
210}
211#endif
212
bsalomon33435572014-11-05 14:47:41 -0800213///////////////////////////////////////////////////////////////////////////////
joshualittf5883a62016-01-13 07:47:38 -0800214
215#define ASSERT_SINGLE_OWNER \
Robert Phillipsa90aa2b2017-04-10 08:19:26 -0400216 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());)
joshualittf5883a62016-01-13 07:47:38 -0800217
Chris Dalton706a6ff2017-11-29 22:01:06 -0700218
Chris Daltona32a3c32017-12-05 10:05:21 -0700219uint32_t GrRenderTargetContextPriv::testingOnly_getOpListID() {
220 return fRenderTargetContext->getOpList()->uniqueID();
221}
222
Brian Salomonac70f842017-05-08 10:43:33 -0400223uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(std::unique_ptr<GrDrawOp> op) {
Chris Dalton706a6ff2017-11-29 22:01:06 -0700224 return this->testingOnly_addDrawOp(GrNoClip(), std::move(op));
225}
226
227uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(const GrClip& clip,
228 std::unique_ptr<GrDrawOp> op) {
Brian Salomonac70f842017-05-08 10:43:33 -0400229 ASSERT_SINGLE_OWNER
230 if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
Robert Phillipsc994a932018-06-19 13:09:54 -0400231 fRenderTargetContext->fContext->contextPriv().opMemoryPool()->release(std::move(op));
Brian Salomonac70f842017-05-08 10:43:33 -0400232 return SK_InvalidUniqueID;
233 }
234 SkDEBUGCODE(fRenderTargetContext->validate());
235 GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
236 "GrRenderTargetContext::testingOnly_addDrawOp");
Chris Dalton706a6ff2017-11-29 22:01:06 -0700237 return fRenderTargetContext->addDrawOp(clip, std::move(op));
Brian Salomonac70f842017-05-08 10:43:33 -0400238}
239
joshualittf5883a62016-01-13 07:47:38 -0800240#undef ASSERT_SINGLE_OWNER
joshualittf5883a62016-01-13 07:47:38 -0800241
242///////////////////////////////////////////////////////////////////////////////
csmartdaltonf9635992016-08-10 11:09:07 -0700243
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400244GrInternalSurfaceFlags GrSurfaceProxy::testingOnly_getFlags() const {
245 return fSurfaceFlags;
csmartdaltonf9635992016-08-10 11:09:07 -0700246}
247
Brian Salomon17726632017-05-12 14:09:46 -0400248//////////////////////////////////////////////////////////////////////////////
249
Chris Daltonfe199b72017-05-05 11:26:15 -0400250void GrContextPriv::testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
251 fContext->flush();
252 fContext->fDrawingManager->testingOnly_removeOnFlushCallbackObject(cb);
253}
254
255void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
256 int n = std::find(fOnFlushCBObjects.begin(), fOnFlushCBObjects.end(), cb) -
257 fOnFlushCBObjects.begin();
258 SkASSERT(n < fOnFlushCBObjects.count());
259 fOnFlushCBObjects.removeShuffle(n);
260}
Brian Salomon17726632017-05-12 14:09:46 -0400261
262//////////////////////////////////////////////////////////////////////////////
263
Chris Daltona2b5b642018-06-24 13:08:57 -0600264void GrCoverageCountingPathRenderer::testingOnly_drawPathDirectly(const DrawPathArgs& args) {
265 // Call onDrawPath() directly: We want to test paths that might fail onCanDrawPath() simply for
266 // performance reasons, and GrPathRenderer::drawPath() assert that this call returns true.
267 // The test is responsible to not draw any paths that CCPR is not actually capable of.
268 this->onDrawPath(args);
269}
270
Chris Dalton4da70192018-06-18 09:51:36 -0600271const GrUniqueKey& GrCoverageCountingPathRenderer::testingOnly_getStashedAtlasKey() const {
272 return fStashedAtlasKey;
273}
274
275//////////////////////////////////////////////////////////////////////////////
276
Brian Salomon17726632017-05-12 14:09:46 -0400277#define DRAW_OP_TEST_EXTERN(Op) \
Brian Salomon815486c2017-07-11 08:52:13 -0400278 extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, GrContext*, GrFSAAType)
Brian Salomon17726632017-05-12 14:09:46 -0400279#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
280
Brian Salomon10978a62017-06-15 16:21:49 -0400281DRAW_OP_TEST_EXTERN(AAConvexPathOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400282DRAW_OP_TEST_EXTERN(AAFillRectOp);
Brian Salomonb2955732017-07-13 16:42:55 -0400283DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp);
Brian Salomona531f252017-07-07 13:29:28 -0400284DRAW_OP_TEST_EXTERN(AAHairlineOp);
Brian Salomonbaaf4392017-06-15 09:59:23 -0400285DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400286DRAW_OP_TEST_EXTERN(CircleOp);
Brian Salomon98222ac2017-07-12 15:27:54 -0400287DRAW_OP_TEST_EXTERN(DashOp);
Brian Salomonee3e0ba2017-07-13 16:40:46 -0400288DRAW_OP_TEST_EXTERN(DefaultPathOp);
Brian Salomon05441c42017-05-15 16:45:49 -0400289DRAW_OP_TEST_EXTERN(DIEllipseOp);
290DRAW_OP_TEST_EXTERN(EllipseOp);
Brian Salomon44acb5b2017-07-18 19:59:24 -0400291DRAW_OP_TEST_EXTERN(GrAtlasTextOp);
Brian Salomon0088f942017-07-12 11:51:27 -0400292DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
Brian Salomonc2f42542017-07-12 14:11:22 -0400293DRAW_OP_TEST_EXTERN(GrDrawVerticesOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400294DRAW_OP_TEST_EXTERN(NonAAFillRectOp);
295DRAW_OP_TEST_EXTERN(NonAALatticeOp);
Brian Salomonbaaf4392017-06-15 09:59:23 -0400296DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
Brian Salomon05969092017-07-13 11:20:51 -0400297DRAW_OP_TEST_EXTERN(ShadowRRectOp);
Brian Salomonfebbd232017-07-11 15:52:02 -0400298DRAW_OP_TEST_EXTERN(SmallPathOp);
Brian Salomonf0366322017-07-11 15:53:05 -0400299DRAW_OP_TEST_EXTERN(RegionOp);
Brian Salomon05441c42017-05-15 16:45:49 -0400300DRAW_OP_TEST_EXTERN(RRectOp);
Brian Salomon9530f7e2017-07-11 09:03:10 -0400301DRAW_OP_TEST_EXTERN(TesselatingPathOp);
Brian Salomon34169692017-08-28 15:32:01 -0400302DRAW_OP_TEST_EXTERN(TextureOp);
Brian Salomon17726632017-05-12 14:09:46 -0400303
304void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext, GrPaint&& paint) {
305 GrContext* context = renderTargetContext->surfPriv().getContext();
Brian Salomon17726632017-05-12 14:09:46 -0400306 using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*, GrContext*, GrFSAAType);
307 static constexpr MakeDrawOpFn* gFactories[] = {
Brian Salomon34169692017-08-28 15:32:01 -0400308 DRAW_OP_TEST_ENTRY(AAConvexPathOp),
309 DRAW_OP_TEST_ENTRY(AAFillRectOp),
310 DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
311 DRAW_OP_TEST_ENTRY(AAHairlineOp),
312 DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
313 DRAW_OP_TEST_ENTRY(CircleOp),
314 DRAW_OP_TEST_ENTRY(DashOp),
315 DRAW_OP_TEST_ENTRY(DefaultPathOp),
316 DRAW_OP_TEST_ENTRY(DIEllipseOp),
317 DRAW_OP_TEST_ENTRY(EllipseOp),
318 DRAW_OP_TEST_ENTRY(GrAtlasTextOp),
319 DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
320 DRAW_OP_TEST_ENTRY(GrDrawVerticesOp),
321 DRAW_OP_TEST_ENTRY(NonAAFillRectOp),
322 DRAW_OP_TEST_ENTRY(NonAALatticeOp),
323 DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
324 DRAW_OP_TEST_ENTRY(ShadowRRectOp),
325 DRAW_OP_TEST_ENTRY(SmallPathOp),
326 DRAW_OP_TEST_ENTRY(RegionOp),
327 DRAW_OP_TEST_ENTRY(RRectOp),
328 DRAW_OP_TEST_ENTRY(TesselatingPathOp),
329 DRAW_OP_TEST_ENTRY(TextureOp),
Brian Salomon17726632017-05-12 14:09:46 -0400330 };
331
Brian Salomonfc26f3c2017-07-14 15:27:56 -0400332 static constexpr size_t kTotal = SK_ARRAY_COUNT(gFactories);
Brian Salomon17726632017-05-12 14:09:46 -0400333 uint32_t index = random->nextULessThan(static_cast<uint32_t>(kTotal));
Brian Salomonfc26f3c2017-07-14 15:27:56 -0400334 auto op = gFactories[index](
335 std::move(paint), random, context, renderTargetContext->fsaaType());
336 SkASSERT(op);
337 renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
Brian Salomon17726632017-05-12 14:09:46 -0400338}