blob: 57ff77e5e7a3857103cb0f59d730bef1c32c3161 [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
8#include "GrTest.h"
Brian Salomon17726632017-05-12 14:09:46 -04009#include <algorithm>
Greg Daniel7ef28f32017-04-20 16:41:55 +000010#include "GrBackendSurface.h"
bsalomon682c2692015-05-22 14:01:46 -070011#include "GrContextOptions.h"
Chris Daltonfe199b72017-05-05 11:26:15 -040012#include "GrContextPriv.h"
Brian Salomon2ee084e2016-12-16 18:59:19 -050013#include "GrDrawOpAtlas.h"
robertphillips77a2e522015-10-17 07:43:27 -070014#include "GrDrawingManager.h"
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040015#include "GrGpu.h"
bsalomon3582d3e2015-02-13 14:20:05 -080016#include "GrGpuResourceCacheAccess.h"
Brian Salomon17726632017-05-12 14:09:46 -040017#include "GrRenderTargetContext.h"
Brian Salomon2ee084e2016-12-16 18:59:19 -050018#include "GrRenderTargetContextPriv.h"
csmartdaltonf9635992016-08-10 11:09:07 -070019#include "GrRenderTargetProxy.h"
bsalomon0ea80f42015-02-11 10:49:59 -080020#include "GrResourceCache.h"
Greg Daniel6be35232017-03-01 17:01:09 -050021#include "GrSemaphore.h"
Brian Salomon17726632017-05-12 14:09:46 -040022#include "GrSurfaceContextPriv.h"
Robert Phillips646e4292017-06-13 12:44:56 -040023#include "GrTexture.h"
Brian Osman3b655982017-03-07 16:58:08 -050024#include "SkGr.h"
Robert Phillips22f4a1f2016-12-20 08:57:26 -050025#include "SkImage_Gpu.h"
halcanary4dbbd042016-06-07 17:21:10 -070026#include "SkMathPriv.h"
mtkleinb9eb4ac2015-02-02 18:26:03 -080027#include "SkString.h"
Brian Salomon17726632017-05-12 14:09:46 -040028#include "ops/GrMeshDrawOp.h"
Brian Salomonf856fd12016-12-16 14:24:34 -050029#include "text/GrAtlasGlyphCache.h"
joshualitte8042922015-12-11 06:11:21 -080030#include "text/GrTextBlobCache.h"
31
joshualitt7f9c9eb2015-08-21 11:08:00 -070032namespace GrTest {
Brian Salomond17f6582017-07-19 18:28:58 -040033
joshualitt7f9c9eb2015-08-21 11:08:00 -070034void SetupAlwaysEvictAtlas(GrContext* context) {
35 // These sizes were selected because they allow each atlas to hold a single plot and will thus
36 // stress the atlas
Brian Salomon2ee084e2016-12-16 18:59:19 -050037 int dim = GrDrawOpAtlas::kGlyphMaxDim;
38 GrDrawOpAtlasConfig configs[3];
joshualitt7f9c9eb2015-08-21 11:08:00 -070039 configs[kA8_GrMaskFormat].fWidth = dim;
40 configs[kA8_GrMaskFormat].fHeight = dim;
jvanverth7023a002016-02-22 11:25:32 -080041 configs[kA8_GrMaskFormat].fLog2Width = SkNextLog2(dim);
42 configs[kA8_GrMaskFormat].fLog2Height = SkNextLog2(dim);
joshualitt7f9c9eb2015-08-21 11:08:00 -070043 configs[kA8_GrMaskFormat].fPlotWidth = dim;
44 configs[kA8_GrMaskFormat].fPlotHeight = dim;
45
46 configs[kA565_GrMaskFormat].fWidth = dim;
47 configs[kA565_GrMaskFormat].fHeight = dim;
jvanverth7023a002016-02-22 11:25:32 -080048 configs[kA565_GrMaskFormat].fLog2Width = SkNextLog2(dim);
49 configs[kA565_GrMaskFormat].fLog2Height = SkNextLog2(dim);
joshualitt7f9c9eb2015-08-21 11:08:00 -070050 configs[kA565_GrMaskFormat].fPlotWidth = dim;
51 configs[kA565_GrMaskFormat].fPlotHeight = dim;
52
53 configs[kARGB_GrMaskFormat].fWidth = dim;
54 configs[kARGB_GrMaskFormat].fHeight = dim;
jvanverth7023a002016-02-22 11:25:32 -080055 configs[kARGB_GrMaskFormat].fLog2Width = SkNextLog2(dim);
56 configs[kARGB_GrMaskFormat].fLog2Height = SkNextLog2(dim);
joshualitt7f9c9eb2015-08-21 11:08:00 -070057 configs[kARGB_GrMaskFormat].fPlotWidth = dim;
58 configs[kARGB_GrMaskFormat].fPlotHeight = dim;
59
60 context->setTextContextAtlasSizes_ForTesting(configs);
61}
Greg Daniel7ef28f32017-04-20 16:41:55 +000062
63GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
64 GrPixelConfig config, GrBackendObject handle) {
Brian Salomond17f6582017-07-19 18:28:58 -040065 switch (backend) {
Mike Reedd20b5c42017-06-14 06:03:10 -040066#ifdef SK_VULKAN
Brian Salomond17f6582017-07-19 18:28:58 -040067 case kVulkan_GrBackend: {
68 GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
69 return GrBackendTexture(width, height, *vkInfo);
70 }
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000071#endif
Brian Salomond17f6582017-07-19 18:28:58 -040072 case kOpenGL_GrBackend: {
73 GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
74 return GrBackendTexture(width, height, config, *glInfo);
75 }
76 case kMock_GrBackend: {
77 GrMockTextureInfo* mockInfo = (GrMockTextureInfo*)(handle);
78 return GrBackendTexture(width, height, config, *mockInfo);
79 }
80 default:
81 return GrBackendTexture();
82 }
Greg Daniel7ef28f32017-04-20 16:41:55 +000083}
Brian Salomond17f6582017-07-19 18:28:58 -040084
85} // namespace GrTest
joshualitt7f9c9eb2015-08-21 11:08:00 -070086
Robert Phillipseaa86252016-11-08 13:49:39 +000087bool GrSurfaceProxy::isWrapped_ForTesting() const {
88 return SkToBool(fTarget);
89}
90
91bool GrRenderTargetContext::isWrapped_ForTesting() const {
92 return fRenderTargetProxy->isWrapped_ForTesting();
93}
94
joshualitt17d833b2015-08-03 10:17:44 -070095void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) {
96 fTextBlobCache->setBudget(bytes);
97}
98
Brian Salomon2ee084e2016-12-16 18:59:19 -050099void GrContext::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
Brian Salomonf856fd12016-12-16 14:24:34 -0500100 fAtlasGlyphCache->setAtlasSizes_ForTesting(configs);
joshualittda04e0e2015-08-19 08:16:43 -0700101}
102
commit-bot@chromium.org78a10782013-08-21 19:27:48 +0000103///////////////////////////////////////////////////////////////////////////////
104
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +0000105void GrContext::purgeAllUnlockedResources() {
bsalomon0ea80f42015-02-11 10:49:59 -0800106 fResourceCache->purgeAllUnlocked();
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +0000107}
bsalomon33435572014-11-05 14:47:41 -0800108
joshualitte45c81c2015-12-02 09:05:37 -0800109void GrContext::resetGpuStats() const {
110#if GR_GPU_STATS
111 fGpu->stats()->reset();
112#endif
113}
114
mtkleinb9eb4ac2015-02-02 18:26:03 -0800115void GrContext::dumpCacheStats(SkString* out) const {
116#if GR_CACHE_STATS
bsalomon0ea80f42015-02-11 10:49:59 -0800117 fResourceCache->dumpStats(out);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800118#endif
119}
120
joshualittdc5685a2015-12-02 14:08:25 -0800121void GrContext::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
122 SkTArray<double>* values) const {
123#if GR_CACHE_STATS
124 fResourceCache->dumpStatsKeyValuePairs(keys, values);
125#endif
126}
127
mtkleinb9eb4ac2015-02-02 18:26:03 -0800128void GrContext::printCacheStats() const {
129 SkString out;
130 this->dumpCacheStats(&out);
kkinnunen297aaf92015-02-19 06:32:12 -0800131 SkDebugf("%s", out.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -0800132}
133
134void GrContext::dumpGpuStats(SkString* out) const {
135#if GR_GPU_STATS
136 return fGpu->stats()->dump(out);
137#endif
138}
139
joshualitte45c81c2015-12-02 09:05:37 -0800140void GrContext::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
141 SkTArray<double>* values) const {
142#if GR_GPU_STATS
143 return fGpu->stats()->dumpKeyValuePairs(keys, values);
144#endif
145}
146
mtkleinb9eb4ac2015-02-02 18:26:03 -0800147void GrContext::printGpuStats() const {
148 SkString out;
149 this->dumpGpuStats(&out);
kkinnunen297aaf92015-02-19 06:32:12 -0800150 SkDebugf("%s", out.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -0800151}
152
Robert Phillipsc37e6142017-01-20 10:03:25 -0500153sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format) {
Brian Salomonf856fd12016-12-16 14:24:34 -0500154 GrAtlasGlyphCache* cache = this->getAtlasGlyphCache();
jvanverth629162d2015-11-08 08:07:24 -0800155
Robert Phillips32f28182017-02-28 16:20:03 -0500156 sk_sp<GrTextureProxy> proxy = cache->getProxy(format);
157 if (!proxy) {
158 return nullptr;
159 }
160
Robert Phillipsb726d582017-03-09 16:36:32 -0500161 SkASSERT(proxy->priv().isExact());
162 sk_sp<SkImage> image(new SkImage_Gpu(this, kNeedNewImageUniqueID, kPremul_SkAlphaType,
163 std::move(proxy), nullptr, SkBudgeted::kNo));
Robert Phillips22f4a1f2016-12-20 08:57:26 -0500164 return image;
jvanverth0671b962015-12-08 18:53:44 -0800165}
jvanverth629162d2015-11-08 08:07:24 -0800166
mtkleinb9eb4ac2015-02-02 18:26:03 -0800167#if GR_GPU_STATS
168void GrGpu::Stats::dump(SkString* out) {
169 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
170 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
bsalomonb12ea412015-02-02 21:19:50 -0800171 out->appendf("Textures Created: %d\n", fTextureCreates);
172 out->appendf("Texture Uploads: %d\n", fTextureUploads);
jvanverth17aa0472016-01-05 10:41:27 -0800173 out->appendf("Transfers to Texture: %d\n", fTransfersToTexture);
egdaniel8dc7c3a2015-04-16 11:22:42 -0700174 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
joshualitt87a5c9f2015-09-08 13:42:05 -0700175 out->appendf("Number of draws: %d\n", fNumDraws);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800176}
joshualitte45c81c2015-12-02 09:05:37 -0800177
178void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) {
179 keys->push_back(SkString("render_target_binds")); values->push_back(fRenderTargetBinds);
180 keys->push_back(SkString("shader_compilations")); values->push_back(fShaderCompilations);
joshualitte45c81c2015-12-02 09:05:37 -0800181 keys->push_back(SkString("texture_uploads")); values->push_back(fTextureUploads);
joshualitte45c81c2015-12-02 09:05:37 -0800182 keys->push_back(SkString("number_of_draws")); values->push_back(fNumDraws);
bsalomon1d417a82016-03-23 11:50:26 -0700183 keys->push_back(SkString("number_of_failed_draws")); values->push_back(fNumFailedDraws);
joshualitte45c81c2015-12-02 09:05:37 -0800184}
185
mtkleinb9eb4ac2015-02-02 18:26:03 -0800186#endif
187
188#if GR_CACHE_STATS
robertphillips60029a52015-11-09 13:51:06 -0800189void GrResourceCache::getStats(Stats* stats) const {
190 stats->reset();
191
192 stats->fTotal = this->getResourceCount();
193 stats->fNumNonPurgeable = fNonpurgeableResources.count();
194 stats->fNumPurgeable = fPurgeableQueue.count();
195
196 for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
197 stats->update(fNonpurgeableResources[i]);
198 }
199 for (int i = 0; i < fPurgeableQueue.count(); ++i) {
200 stats->update(fPurgeableQueue.at(i));
201 }
202}
203
bsalomon0ea80f42015-02-11 10:49:59 -0800204void GrResourceCache::dumpStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -0800205 this->validate();
206
bsalomonf320e042015-02-17 15:09:34 -0800207 Stats stats;
208
robertphillips60029a52015-11-09 13:51:06 -0800209 this->getStats(&stats);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800210
211 float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
212 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
213
214 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
215 out->appendf("\t\tEntry Count: current %d"
kkinnunen2e6055b2016-04-22 01:48:29 -0700216 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
217 stats.fTotal, fBudgetedCount, stats.fWrapped, stats.fNumNonPurgeable,
218 stats.fScratch, countUtilization, fHighWaterCount);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800219 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n",
bsalomonf320e042015-02-17 15:09:34 -0800220 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
221 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
mtkleinb9eb4ac2015-02-02 18:26:03 -0800222}
223
joshualittdc5685a2015-12-02 14:08:25 -0800224void GrResourceCache::dumpStatsKeyValuePairs(SkTArray<SkString>* keys,
225 SkTArray<double>* values) const {
226 this->validate();
227
228 Stats stats;
229 this->getStats(&stats);
230
joshualittdc5685a2015-12-02 14:08:25 -0800231 keys->push_back(SkString("gpu_cache_purgable_entries")); values->push_back(stats.fNumPurgeable);
joshualittdc5685a2015-12-02 14:08:25 -0800232}
233
mtkleinb9eb4ac2015-02-02 18:26:03 -0800234#endif
235
bsalomonddf30e62015-02-19 11:38:44 -0800236///////////////////////////////////////////////////////////////////////////////
237
238void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newTimestamp; }
mtkleinb9eb4ac2015-02-02 18:26:03 -0800239
Brian Salomon1090da62017-01-06 12:04:19 -0500240#ifdef SK_DEBUG
241int GrResourceCache::countUniqueKeysWithTag(const char* tag) const {
242 int count = 0;
243 UniqueHash::ConstIter iter(&fUniqueHash);
244 while (!iter.done()) {
245 if (0 == strcmp(tag, (*iter).getUniqueKey().tag())) {
246 ++count;
247 }
248 ++iter;
249 }
250 return count;
251}
252#endif
253
bsalomon33435572014-11-05 14:47:41 -0800254///////////////////////////////////////////////////////////////////////////////
joshualittf5883a62016-01-13 07:47:38 -0800255
256#define ASSERT_SINGLE_OWNER \
Robert Phillipsa90aa2b2017-04-10 08:19:26 -0400257 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());)
joshualittf5883a62016-01-13 07:47:38 -0800258
Brian Salomonac70f842017-05-08 10:43:33 -0400259uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(std::unique_ptr<GrDrawOp> op) {
260 ASSERT_SINGLE_OWNER
261 if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
262 return SK_InvalidUniqueID;
263 }
264 SkDEBUGCODE(fRenderTargetContext->validate());
265 GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
266 "GrRenderTargetContext::testingOnly_addDrawOp");
267 return fRenderTargetContext->addDrawOp(GrNoClip(), std::move(op));
268}
269
joshualittf5883a62016-01-13 07:47:38 -0800270#undef ASSERT_SINGLE_OWNER
joshualittf5883a62016-01-13 07:47:38 -0800271
272///////////////////////////////////////////////////////////////////////////////
csmartdaltonf9635992016-08-10 11:09:07 -0700273
Robert Phillipsc4f0a822017-06-13 08:11:36 -0400274GrRenderTargetFlags GrRenderTargetProxy::testingOnly_getFlags() const {
Brian Salomondac5f6b2017-02-28 16:11:04 -0500275 return fRenderTargetFlags;
csmartdaltonf9635992016-08-10 11:09:07 -0700276}
277
Brian Salomon17726632017-05-12 14:09:46 -0400278//////////////////////////////////////////////////////////////////////////////
279
Chris Daltonfe199b72017-05-05 11:26:15 -0400280void GrContextPriv::testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
281 fContext->flush();
282 fContext->fDrawingManager->testingOnly_removeOnFlushCallbackObject(cb);
283}
284
285void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
286 int n = std::find(fOnFlushCBObjects.begin(), fOnFlushCBObjects.end(), cb) -
287 fOnFlushCBObjects.begin();
288 SkASSERT(n < fOnFlushCBObjects.count());
289 fOnFlushCBObjects.removeShuffle(n);
290}
Brian Salomon17726632017-05-12 14:09:46 -0400291
292//////////////////////////////////////////////////////////////////////////////
293
294#define DRAW_OP_TEST_EXTERN(Op) \
Brian Salomon815486c2017-07-11 08:52:13 -0400295 extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, GrContext*, GrFSAAType)
Brian Salomon17726632017-05-12 14:09:46 -0400296#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
297
Brian Salomon10978a62017-06-15 16:21:49 -0400298DRAW_OP_TEST_EXTERN(AAConvexPathOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400299DRAW_OP_TEST_EXTERN(AAFillRectOp);
Brian Salomonb2955732017-07-13 16:42:55 -0400300DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp);
Brian Salomona531f252017-07-07 13:29:28 -0400301DRAW_OP_TEST_EXTERN(AAHairlineOp);
Brian Salomonbaaf4392017-06-15 09:59:23 -0400302DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400303DRAW_OP_TEST_EXTERN(CircleOp);
Brian Salomon98222ac2017-07-12 15:27:54 -0400304DRAW_OP_TEST_EXTERN(DashOp);
Brian Salomonee3e0ba2017-07-13 16:40:46 -0400305DRAW_OP_TEST_EXTERN(DefaultPathOp);
Brian Salomon05441c42017-05-15 16:45:49 -0400306DRAW_OP_TEST_EXTERN(DIEllipseOp);
307DRAW_OP_TEST_EXTERN(EllipseOp);
Brian Salomon44acb5b2017-07-18 19:59:24 -0400308DRAW_OP_TEST_EXTERN(GrAtlasTextOp);
Brian Salomon0088f942017-07-12 11:51:27 -0400309DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
Brian Salomonc2f42542017-07-12 14:11:22 -0400310DRAW_OP_TEST_EXTERN(GrDrawVerticesOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400311DRAW_OP_TEST_EXTERN(NonAAFillRectOp);
312DRAW_OP_TEST_EXTERN(NonAALatticeOp);
Brian Salomonbaaf4392017-06-15 09:59:23 -0400313DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
Brian Salomon05969092017-07-13 11:20:51 -0400314DRAW_OP_TEST_EXTERN(ShadowRRectOp);
Brian Salomonfebbd232017-07-11 15:52:02 -0400315DRAW_OP_TEST_EXTERN(SmallPathOp);
Brian Salomonf0366322017-07-11 15:53:05 -0400316DRAW_OP_TEST_EXTERN(RegionOp);
Brian Salomon05441c42017-05-15 16:45:49 -0400317DRAW_OP_TEST_EXTERN(RRectOp);
Brian Salomon9530f7e2017-07-11 09:03:10 -0400318DRAW_OP_TEST_EXTERN(TesselatingPathOp);
Brian Salomon34169692017-08-28 15:32:01 -0400319DRAW_OP_TEST_EXTERN(TextureOp);
Brian Salomon17726632017-05-12 14:09:46 -0400320
321void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext, GrPaint&& paint) {
322 GrContext* context = renderTargetContext->surfPriv().getContext();
Brian Salomon17726632017-05-12 14:09:46 -0400323 using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*, GrContext*, GrFSAAType);
324 static constexpr MakeDrawOpFn* gFactories[] = {
Brian Salomon34169692017-08-28 15:32:01 -0400325 DRAW_OP_TEST_ENTRY(AAConvexPathOp),
326 DRAW_OP_TEST_ENTRY(AAFillRectOp),
327 DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
328 DRAW_OP_TEST_ENTRY(AAHairlineOp),
329 DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
330 DRAW_OP_TEST_ENTRY(CircleOp),
331 DRAW_OP_TEST_ENTRY(DashOp),
332 DRAW_OP_TEST_ENTRY(DefaultPathOp),
333 DRAW_OP_TEST_ENTRY(DIEllipseOp),
334 DRAW_OP_TEST_ENTRY(EllipseOp),
335 DRAW_OP_TEST_ENTRY(GrAtlasTextOp),
336 DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
337 DRAW_OP_TEST_ENTRY(GrDrawVerticesOp),
338 DRAW_OP_TEST_ENTRY(NonAAFillRectOp),
339 DRAW_OP_TEST_ENTRY(NonAALatticeOp),
340 DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
341 DRAW_OP_TEST_ENTRY(ShadowRRectOp),
342 DRAW_OP_TEST_ENTRY(SmallPathOp),
343 DRAW_OP_TEST_ENTRY(RegionOp),
344 DRAW_OP_TEST_ENTRY(RRectOp),
345 DRAW_OP_TEST_ENTRY(TesselatingPathOp),
346 DRAW_OP_TEST_ENTRY(TextureOp),
Brian Salomon17726632017-05-12 14:09:46 -0400347 };
348
Brian Salomonfc26f3c2017-07-14 15:27:56 -0400349 static constexpr size_t kTotal = SK_ARRAY_COUNT(gFactories);
Brian Salomon17726632017-05-12 14:09:46 -0400350 uint32_t index = random->nextULessThan(static_cast<uint32_t>(kTotal));
Brian Salomonfc26f3c2017-07-14 15:27:56 -0400351 auto op = gFactories[index](
352 std::move(paint), random, context, renderTargetContext->fsaaType());
353 SkASSERT(op);
354 renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
Brian Salomon17726632017-05-12 14:09:46 -0400355}