blob: 3c6046712db626c0d7519917f3b8604a775c109e [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"
Robert Phillipsc4039ea2018-03-01 11:36:45 -050029#include "text/GrGlyphCache.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
Robert Phillipsd2e9f762018-03-07 11:54:37 -050034void SetupAlwaysEvictAtlas(GrContext* context, int dim) {
joshualitt7f9c9eb2015-08-21 11:08:00 -070035 // 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 GrDrawOpAtlasConfig configs[3];
joshualitt7f9c9eb2015-08-21 11:08:00 -070038 configs[kA8_GrMaskFormat].fWidth = dim;
39 configs[kA8_GrMaskFormat].fHeight = dim;
40 configs[kA8_GrMaskFormat].fPlotWidth = dim;
41 configs[kA8_GrMaskFormat].fPlotHeight = dim;
42
43 configs[kA565_GrMaskFormat].fWidth = dim;
44 configs[kA565_GrMaskFormat].fHeight = dim;
45 configs[kA565_GrMaskFormat].fPlotWidth = dim;
46 configs[kA565_GrMaskFormat].fPlotHeight = dim;
47
48 configs[kARGB_GrMaskFormat].fWidth = dim;
49 configs[kARGB_GrMaskFormat].fHeight = dim;
50 configs[kARGB_GrMaskFormat].fPlotWidth = dim;
51 configs[kARGB_GrMaskFormat].fPlotHeight = dim;
52
Robert Phillips0c4b7b12018-03-06 08:20:37 -050053 context->contextPriv().setTextContextAtlasSizes_ForTesting(configs);
joshualitt7f9c9eb2015-08-21 11:08:00 -070054}
Greg Daniel7ef28f32017-04-20 16:41:55 +000055
Brian Salomond17f6582017-07-19 18:28:58 -040056} // namespace GrTest
joshualitt7f9c9eb2015-08-21 11:08:00 -070057
Robert Phillipseaa86252016-11-08 13:49:39 +000058bool GrSurfaceProxy::isWrapped_ForTesting() const {
59 return SkToBool(fTarget);
60}
61
62bool GrRenderTargetContext::isWrapped_ForTesting() const {
63 return fRenderTargetProxy->isWrapped_ForTesting();
64}
65
Robert Phillips0c4b7b12018-03-06 08:20:37 -050066void GrContextPriv::setTextBlobCacheLimit_ForTesting(size_t bytes) {
67 fContext->fTextBlobCache->setBudget(bytes);
joshualitt17d833b2015-08-03 10:17:44 -070068}
69
Robert Phillips0c4b7b12018-03-06 08:20:37 -050070void GrContextPriv::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
Robert Phillips5a66efb2018-03-07 15:13:18 -050071 GrAtlasManager* atlasManager = this->getAtlasManager();
Robert Phillips1056eb82018-03-01 14:16:41 -050072 if (atlasManager) {
73 atlasManager->setAtlasSizes_ForTesting(configs);
74 }
joshualittda04e0e2015-08-19 08:16:43 -070075}
76
commit-bot@chromium.org78a10782013-08-21 19:27:48 +000077///////////////////////////////////////////////////////////////////////////////
78
Robert Phillips0c4b7b12018-03-06 08:20:37 -050079void GrContextPriv::purgeAllUnlockedResources_ForTesting() {
80 fContext->fResourceCache->purgeAllUnlocked();
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000081}
bsalomon33435572014-11-05 14:47:41 -080082
Robert Phillips0c4b7b12018-03-06 08:20:37 -050083void GrContextPriv::resetGpuStats() const {
joshualitte45c81c2015-12-02 09:05:37 -080084#if GR_GPU_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050085 fContext->fGpu->stats()->reset();
joshualitte45c81c2015-12-02 09:05:37 -080086#endif
87}
88
Robert Phillips0c4b7b12018-03-06 08:20:37 -050089void GrContextPriv::dumpCacheStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -080090#if GR_CACHE_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050091 fContext->fResourceCache->dumpStats(out);
mtkleinb9eb4ac2015-02-02 18:26:03 -080092#endif
93}
94
Robert Phillips0c4b7b12018-03-06 08:20:37 -050095void GrContextPriv::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
96 SkTArray<double>* values) const {
joshualittdc5685a2015-12-02 14:08:25 -080097#if GR_CACHE_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -050098 fContext->fResourceCache->dumpStatsKeyValuePairs(keys, values);
joshualittdc5685a2015-12-02 14:08:25 -080099#endif
100}
101
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500102void GrContextPriv::printCacheStats() const {
mtkleinb9eb4ac2015-02-02 18:26:03 -0800103 SkString out;
104 this->dumpCacheStats(&out);
kkinnunen297aaf92015-02-19 06:32:12 -0800105 SkDebugf("%s", out.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -0800106}
107
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500108void GrContextPriv::dumpGpuStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -0800109#if GR_GPU_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500110 return fContext->fGpu->stats()->dump(out);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800111#endif
112}
113
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500114void GrContextPriv::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
115 SkTArray<double>* values) const {
joshualitte45c81c2015-12-02 09:05:37 -0800116#if GR_GPU_STATS
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500117 return fContext->fGpu->stats()->dumpKeyValuePairs(keys, values);
joshualitte45c81c2015-12-02 09:05:37 -0800118#endif
119}
120
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500121void GrContextPriv::printGpuStats() const {
mtkleinb9eb4ac2015-02-02 18:26:03 -0800122 SkString out;
123 this->dumpGpuStats(&out);
kkinnunen297aaf92015-02-19 06:32:12 -0800124 SkDebugf("%s", out.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -0800125}
126
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500127sk_sp<SkImage> GrContextPriv::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
Robert Phillips5a66efb2018-03-07 15:13:18 -0500128 auto atlasManager = this->getAtlasManager();
129 if (!atlasManager) {
130 return nullptr;
131 }
jvanverth629162d2015-11-08 08:07:24 -0800132
Robert Phillipsf3690dd2018-02-20 15:18:59 -0500133 unsigned int numProxies;
Robert Phillips5a66efb2018-03-07 15:13:18 -0500134 const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(format, &numProxies);
Robert Phillipsf3690dd2018-02-20 15:18:59 -0500135 if (index >= numProxies || !proxies[index]) {
Robert Phillips32f28182017-02-28 16:20:03 -0500136 return nullptr;
137 }
138
Jim Van Verth87d18ce2018-01-22 12:45:47 -0500139 SkASSERT(proxies[index]->priv().isExact());
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500140 sk_sp<SkImage> image(new SkImage_Gpu(fContext, kNeedNewImageUniqueID, kPremul_SkAlphaType,
Robert Phillipsde9cef22018-01-23 10:59:47 -0500141 proxies[index], nullptr, SkBudgeted::kNo));
Robert Phillips22f4a1f2016-12-20 08:57:26 -0500142 return image;
jvanverth0671b962015-12-08 18:53:44 -0800143}
jvanverth629162d2015-11-08 08:07:24 -0800144
mtkleinb9eb4ac2015-02-02 18:26:03 -0800145#if GR_GPU_STATS
146void GrGpu::Stats::dump(SkString* out) {
147 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
148 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
bsalomonb12ea412015-02-02 21:19:50 -0800149 out->appendf("Textures Created: %d\n", fTextureCreates);
150 out->appendf("Texture Uploads: %d\n", fTextureUploads);
jvanverth17aa0472016-01-05 10:41:27 -0800151 out->appendf("Transfers to Texture: %d\n", fTransfersToTexture);
egdaniel8dc7c3a2015-04-16 11:22:42 -0700152 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
joshualitt87a5c9f2015-09-08 13:42:05 -0700153 out->appendf("Number of draws: %d\n", fNumDraws);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800154}
joshualitte45c81c2015-12-02 09:05:37 -0800155
156void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) {
157 keys->push_back(SkString("render_target_binds")); values->push_back(fRenderTargetBinds);
158 keys->push_back(SkString("shader_compilations")); values->push_back(fShaderCompilations);
joshualitte45c81c2015-12-02 09:05:37 -0800159 keys->push_back(SkString("texture_uploads")); values->push_back(fTextureUploads);
joshualitte45c81c2015-12-02 09:05:37 -0800160 keys->push_back(SkString("number_of_draws")); values->push_back(fNumDraws);
bsalomon1d417a82016-03-23 11:50:26 -0700161 keys->push_back(SkString("number_of_failed_draws")); values->push_back(fNumFailedDraws);
joshualitte45c81c2015-12-02 09:05:37 -0800162}
163
mtkleinb9eb4ac2015-02-02 18:26:03 -0800164#endif
165
Brian Salomon52e943a2018-03-13 09:32:39 -0400166GrBackendTexture GrGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
Brian Salomonbdecacf2018-02-02 20:32:49 -0500167 SkColorType colorType, bool isRenderTarget,
168 GrMipMapped mipMapped) {
169 GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, *this->caps());
Greg Daniel0a7aa142018-02-21 13:02:32 -0500170 if (kUnknown_GrPixelConfig == config) {
171 return GrBackendTexture();
172 }
Brian Salomonbdecacf2018-02-02 20:32:49 -0500173 return this->createTestingOnlyBackendTexture(pixels, w, h, config, isRenderTarget, mipMapped);
174}
175
mtkleinb9eb4ac2015-02-02 18:26:03 -0800176#if GR_CACHE_STATS
robertphillips60029a52015-11-09 13:51:06 -0800177void GrResourceCache::getStats(Stats* stats) const {
178 stats->reset();
179
180 stats->fTotal = this->getResourceCount();
181 stats->fNumNonPurgeable = fNonpurgeableResources.count();
182 stats->fNumPurgeable = fPurgeableQueue.count();
183
184 for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
185 stats->update(fNonpurgeableResources[i]);
186 }
187 for (int i = 0; i < fPurgeableQueue.count(); ++i) {
188 stats->update(fPurgeableQueue.at(i));
189 }
190}
191
bsalomon0ea80f42015-02-11 10:49:59 -0800192void GrResourceCache::dumpStats(SkString* out) const {
mtkleinb9eb4ac2015-02-02 18:26:03 -0800193 this->validate();
194
bsalomonf320e042015-02-17 15:09:34 -0800195 Stats stats;
196
robertphillips60029a52015-11-09 13:51:06 -0800197 this->getStats(&stats);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800198
199 float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
200 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
201
202 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
203 out->appendf("\t\tEntry Count: current %d"
kkinnunen2e6055b2016-04-22 01:48:29 -0700204 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
205 stats.fTotal, fBudgetedCount, stats.fWrapped, stats.fNumNonPurgeable,
206 stats.fScratch, countUtilization, fHighWaterCount);
mtkleinb9eb4ac2015-02-02 18:26:03 -0800207 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n",
bsalomonf320e042015-02-17 15:09:34 -0800208 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
209 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
mtkleinb9eb4ac2015-02-02 18:26:03 -0800210}
211
joshualittdc5685a2015-12-02 14:08:25 -0800212void GrResourceCache::dumpStatsKeyValuePairs(SkTArray<SkString>* keys,
213 SkTArray<double>* values) const {
214 this->validate();
215
216 Stats stats;
217 this->getStats(&stats);
218
joshualittdc5685a2015-12-02 14:08:25 -0800219 keys->push_back(SkString("gpu_cache_purgable_entries")); values->push_back(stats.fNumPurgeable);
joshualittdc5685a2015-12-02 14:08:25 -0800220}
221
mtkleinb9eb4ac2015-02-02 18:26:03 -0800222#endif
223
bsalomonddf30e62015-02-19 11:38:44 -0800224///////////////////////////////////////////////////////////////////////////////
225
226void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newTimestamp; }
mtkleinb9eb4ac2015-02-02 18:26:03 -0800227
Brian Salomon1090da62017-01-06 12:04:19 -0500228#ifdef SK_DEBUG
229int GrResourceCache::countUniqueKeysWithTag(const char* tag) const {
230 int count = 0;
231 UniqueHash::ConstIter iter(&fUniqueHash);
232 while (!iter.done()) {
233 if (0 == strcmp(tag, (*iter).getUniqueKey().tag())) {
234 ++count;
235 }
236 ++iter;
237 }
238 return count;
239}
240#endif
241
bsalomon33435572014-11-05 14:47:41 -0800242///////////////////////////////////////////////////////////////////////////////
joshualittf5883a62016-01-13 07:47:38 -0800243
244#define ASSERT_SINGLE_OWNER \
Robert Phillipsa90aa2b2017-04-10 08:19:26 -0400245 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());)
joshualittf5883a62016-01-13 07:47:38 -0800246
Chris Dalton706a6ff2017-11-29 22:01:06 -0700247
Chris Daltona32a3c32017-12-05 10:05:21 -0700248uint32_t GrRenderTargetContextPriv::testingOnly_getOpListID() {
249 return fRenderTargetContext->getOpList()->uniqueID();
250}
251
Brian Salomonac70f842017-05-08 10:43:33 -0400252uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(std::unique_ptr<GrDrawOp> op) {
Chris Dalton706a6ff2017-11-29 22:01:06 -0700253 return this->testingOnly_addDrawOp(GrNoClip(), std::move(op));
254}
255
256uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(const GrClip& clip,
257 std::unique_ptr<GrDrawOp> op) {
Brian Salomonac70f842017-05-08 10:43:33 -0400258 ASSERT_SINGLE_OWNER
259 if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
260 return SK_InvalidUniqueID;
261 }
262 SkDEBUGCODE(fRenderTargetContext->validate());
263 GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
264 "GrRenderTargetContext::testingOnly_addDrawOp");
Chris Dalton706a6ff2017-11-29 22:01:06 -0700265 return fRenderTargetContext->addDrawOp(clip, std::move(op));
Brian Salomonac70f842017-05-08 10:43:33 -0400266}
267
joshualittf5883a62016-01-13 07:47:38 -0800268#undef ASSERT_SINGLE_OWNER
joshualittf5883a62016-01-13 07:47:38 -0800269
270///////////////////////////////////////////////////////////////////////////////
csmartdaltonf9635992016-08-10 11:09:07 -0700271
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400272GrInternalSurfaceFlags GrSurfaceProxy::testingOnly_getFlags() const {
273 return fSurfaceFlags;
csmartdaltonf9635992016-08-10 11:09:07 -0700274}
275
Brian Salomon17726632017-05-12 14:09:46 -0400276//////////////////////////////////////////////////////////////////////////////
277
Chris Daltonfe199b72017-05-05 11:26:15 -0400278void GrContextPriv::testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
279 fContext->flush();
280 fContext->fDrawingManager->testingOnly_removeOnFlushCallbackObject(cb);
281}
282
283void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
284 int n = std::find(fOnFlushCBObjects.begin(), fOnFlushCBObjects.end(), cb) -
285 fOnFlushCBObjects.begin();
286 SkASSERT(n < fOnFlushCBObjects.count());
287 fOnFlushCBObjects.removeShuffle(n);
288}
Brian Salomon17726632017-05-12 14:09:46 -0400289
290//////////////////////////////////////////////////////////////////////////////
291
Greg Daniel8a3f55c2018-03-14 17:32:12 +0000292GrPixelConfig GrBackendTexture::testingOnly_getPixelConfig() const {
293 return fConfig;
294}
295
296GrPixelConfig GrBackendRenderTarget::testingOnly_getPixelConfig() const {
297 return fConfig;
298}
299
300//////////////////////////////////////////////////////////////////////////////
301
Brian Salomon17726632017-05-12 14:09:46 -0400302#define DRAW_OP_TEST_EXTERN(Op) \
Brian Salomon815486c2017-07-11 08:52:13 -0400303 extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, GrContext*, GrFSAAType)
Brian Salomon17726632017-05-12 14:09:46 -0400304#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
305
Brian Salomon10978a62017-06-15 16:21:49 -0400306DRAW_OP_TEST_EXTERN(AAConvexPathOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400307DRAW_OP_TEST_EXTERN(AAFillRectOp);
Brian Salomonb2955732017-07-13 16:42:55 -0400308DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp);
Brian Salomona531f252017-07-07 13:29:28 -0400309DRAW_OP_TEST_EXTERN(AAHairlineOp);
Brian Salomonbaaf4392017-06-15 09:59:23 -0400310DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400311DRAW_OP_TEST_EXTERN(CircleOp);
Brian Salomon98222ac2017-07-12 15:27:54 -0400312DRAW_OP_TEST_EXTERN(DashOp);
Brian Salomonee3e0ba2017-07-13 16:40:46 -0400313DRAW_OP_TEST_EXTERN(DefaultPathOp);
Brian Salomon05441c42017-05-15 16:45:49 -0400314DRAW_OP_TEST_EXTERN(DIEllipseOp);
315DRAW_OP_TEST_EXTERN(EllipseOp);
Brian Salomon44acb5b2017-07-18 19:59:24 -0400316DRAW_OP_TEST_EXTERN(GrAtlasTextOp);
Brian Salomon0088f942017-07-12 11:51:27 -0400317DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
Brian Salomonc2f42542017-07-12 14:11:22 -0400318DRAW_OP_TEST_EXTERN(GrDrawVerticesOp);
Brian Salomon815486c2017-07-11 08:52:13 -0400319DRAW_OP_TEST_EXTERN(NonAAFillRectOp);
320DRAW_OP_TEST_EXTERN(NonAALatticeOp);
Brian Salomonbaaf4392017-06-15 09:59:23 -0400321DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
Brian Salomon05969092017-07-13 11:20:51 -0400322DRAW_OP_TEST_EXTERN(ShadowRRectOp);
Brian Salomonfebbd232017-07-11 15:52:02 -0400323DRAW_OP_TEST_EXTERN(SmallPathOp);
Brian Salomonf0366322017-07-11 15:53:05 -0400324DRAW_OP_TEST_EXTERN(RegionOp);
Brian Salomon05441c42017-05-15 16:45:49 -0400325DRAW_OP_TEST_EXTERN(RRectOp);
Brian Salomon9530f7e2017-07-11 09:03:10 -0400326DRAW_OP_TEST_EXTERN(TesselatingPathOp);
Brian Salomon34169692017-08-28 15:32:01 -0400327DRAW_OP_TEST_EXTERN(TextureOp);
Brian Salomon17726632017-05-12 14:09:46 -0400328
329void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext, GrPaint&& paint) {
330 GrContext* context = renderTargetContext->surfPriv().getContext();
Brian Salomon17726632017-05-12 14:09:46 -0400331 using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*, GrContext*, GrFSAAType);
332 static constexpr MakeDrawOpFn* gFactories[] = {
Brian Salomon34169692017-08-28 15:32:01 -0400333 DRAW_OP_TEST_ENTRY(AAConvexPathOp),
334 DRAW_OP_TEST_ENTRY(AAFillRectOp),
335 DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
336 DRAW_OP_TEST_ENTRY(AAHairlineOp),
337 DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
338 DRAW_OP_TEST_ENTRY(CircleOp),
339 DRAW_OP_TEST_ENTRY(DashOp),
340 DRAW_OP_TEST_ENTRY(DefaultPathOp),
341 DRAW_OP_TEST_ENTRY(DIEllipseOp),
342 DRAW_OP_TEST_ENTRY(EllipseOp),
343 DRAW_OP_TEST_ENTRY(GrAtlasTextOp),
344 DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
345 DRAW_OP_TEST_ENTRY(GrDrawVerticesOp),
346 DRAW_OP_TEST_ENTRY(NonAAFillRectOp),
347 DRAW_OP_TEST_ENTRY(NonAALatticeOp),
348 DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
349 DRAW_OP_TEST_ENTRY(ShadowRRectOp),
350 DRAW_OP_TEST_ENTRY(SmallPathOp),
351 DRAW_OP_TEST_ENTRY(RegionOp),
352 DRAW_OP_TEST_ENTRY(RRectOp),
353 DRAW_OP_TEST_ENTRY(TesselatingPathOp),
354 DRAW_OP_TEST_ENTRY(TextureOp),
Brian Salomon17726632017-05-12 14:09:46 -0400355 };
356
Brian Salomonfc26f3c2017-07-14 15:27:56 -0400357 static constexpr size_t kTotal = SK_ARRAY_COUNT(gFactories);
Brian Salomon17726632017-05-12 14:09:46 -0400358 uint32_t index = random->nextULessThan(static_cast<uint32_t>(kTotal));
Brian Salomonfc26f3c2017-07-14 15:27:56 -0400359 auto op = gFactories[index](
360 std::move(paint), random, context, renderTargetContext->fsaaType());
361 SkASSERT(op);
362 renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
Brian Salomon17726632017-05-12 14:09:46 -0400363}