blob: f26dbb7f27976c2796a050808d70858e69e4cf52 [file] [log] [blame]
Robert Phillipsae7d3f32017-09-21 08:26:08 -04001/*
2 * Copyright 2017 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// This is a GPU-backend specific test.
9
10#include "Test.h"
11
Robert Phillipsae7d3f32017-09-21 08:26:08 -040012#include "GrBackendSurface.h"
13#include "GrContextPriv.h"
14#include "GrResourceCache.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050015#include "GrProxyProvider.h"
Robert Phillipsae7d3f32017-09-21 08:26:08 -040016#include "GrResourceProvider.h"
Robert Phillipsae7d3f32017-09-21 08:26:08 -040017#include "GrTexture.h"
18#include "GrTextureProxy.h"
19
20#include "SkGr.h"
21#include "SkImage.h"
22
Robert Phillips1afd4cd2018-01-08 13:40:32 -050023int GrProxyProvider::numUniqueKeyProxies_TestOnly() const {
Robert Phillipsae7d3f32017-09-21 08:26:08 -040024 return fUniquelyKeyedProxies.count();
25}
26
Robert Phillipsfe0253f2018-03-16 16:47:25 -040027static GrSurfaceDesc make_desc(GrSurfaceDescFlags descFlags) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -040028 GrSurfaceDesc desc;
Robert Phillipsfe0253f2018-03-16 16:47:25 -040029 desc.fFlags = descFlags;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040030 desc.fWidth = 64;
31 desc.fHeight = 64;
32 desc.fConfig = kRGBA_8888_GrPixelConfig;
Brian Salomonbdecacf2018-02-02 20:32:49 -050033 desc.fSampleCnt = 1;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040034
35 return desc;
36}
37
38///////////////////////////////////////////////////////////////////////////////////////////////////
39// Basic test
40
Greg Daniel4065d452018-11-16 15:43:41 -050041static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050042 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -050043 const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
Greg Daniel4065d452018-11-16 15:43:41 -050044 GrBackendFormat format =
Robert Phillips9da87e02019-02-04 13:26:26 -050045 ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040046
Brian Salomon2a4f9832018-03-03 22:43:43 -050047 sk_sp<GrTextureProxy> proxy =
Greg Daniel4065d452018-11-16 15:43:41 -050048 proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin, fit,
Robert Phillips7eeb74f2019-03-29 07:26:46 -040049 SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040050 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040051 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
52 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040053}
54
Greg Daniel4065d452018-11-16 15:43:41 -050055static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050056 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -050057 const GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
Greg Daniel4065d452018-11-16 15:43:41 -050058 GrBackendFormat format =
Robert Phillips9da87e02019-02-04 13:26:26 -050059 ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040060
Brian Salomon2a4f9832018-03-03 22:43:43 -050061 sk_sp<GrTextureProxy> proxy =
Robert Phillips7eeb74f2019-03-29 07:26:46 -040062 proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin, fit,
63 SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040064 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040065 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
66 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040067}
68
Greg Daniel4065d452018-11-16 15:43:41 -050069static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050070 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -050071 const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
Robert Phillips1afd4cd2018-01-08 13:40:32 -050072
Chris Daltond004e0b2018-09-27 09:28:03 -060073 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Brian Salomon2a4f9832018-03-03 22:43:43 -050074 desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050075 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040076 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
77 return proxy;
78}
79
Greg Daniel4065d452018-11-16 15:43:41 -050080static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050081 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Greg Danielcd871402017-09-26 12:49:26 -040082 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
83 static int kUniqueKeyData = 0;
84
85 GrUniqueKey key;
86
87 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
88 builder[0] = kUniqueKeyData++;
89 builder.finish();
90
Robert Phillips0bd24dc2018-01-16 08:06:32 -050091 const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
Greg Danielcd871402017-09-26 12:49:26 -040092
Robert Phillipsadbe1322018-01-17 13:35:46 -050093 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Chris Daltond004e0b2018-09-27 09:28:03 -060094 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Robert Phillipsfe0253f2018-03-16 16:47:25 -040095 desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
Robert Phillipsadbe1322018-01-17 13:35:46 -050096 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -040097 REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
98 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040099}
100
101static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
102 sk_sp<GrTexture>* backingSurface) {
Robert Phillips9da87e02019-02-04 13:26:26 -0500103 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
104 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400105
Robert Phillipsb67821d2017-12-13 15:00:45 -0500106 const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400107
Robert Phillips9313aa72019-04-09 18:41:27 -0400108 *backingSurface = resourceProvider->createTexture(desc, SkBudgeted::kNo,
109 GrResourceProvider::Flags::kNoPendingIO);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400110 if (!(*backingSurface)) {
111 return nullptr;
112 }
113
Robert Phillipsb67821d2017-12-13 15:00:45 -0500114 GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
Greg Daniel108bb232018-07-03 16:18:29 -0400115 backendTex.setPixelConfig(desc.fConfig);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400116
Brian Salomonc67c31c2018-12-06 10:00:03 -0500117 return proxyProvider->wrapBackendTexture(backendTex, kBottomLeft_GrSurfaceOrigin,
Brian Salomonaa6ca0a2019-01-24 16:03:07 -0500118 kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
119 kRead_GrIOType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400120}
121
122
123// This tests the basic capabilities of the uniquely keyed texture proxies. Does assigning
124// and looking them up work, etc.
125static void basic_test(GrContext* context,
126 skiatest::Reporter* reporter,
Greg Daniel303e83e2018-09-10 14:10:19 -0400127 sk_sp<GrTextureProxy> proxy) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400128 static int id = 1;
129
Robert Phillips9da87e02019-02-04 13:26:26 -0500130 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
131 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
132 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400133
134 int startCacheCount = cache->getResourceCount();
135
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400136 GrUniqueKey key;
Greg Danielcd871402017-09-26 12:49:26 -0400137 if (proxy->getUniqueKey().isValid()) {
138 key = proxy->getUniqueKey();
139 } else {
140 GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
141 ++id;
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400142
Greg Danielcd871402017-09-26 12:49:26 -0400143 // Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500144 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsadbe1322018-01-17 13:35:46 -0500145 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -0400146 }
147
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500148 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400149 REPORTER_ASSERT(reporter, startCacheCount == cache->getResourceCount());
150
151 // setUniqueKey had better stick
152 REPORTER_ASSERT(reporter, key == proxy->getUniqueKey());
153
154 // We just added it, surely we can find it
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500155 REPORTER_ASSERT(reporter, proxyProvider->findOrCreateProxyByUniqueKey(
156 key, kBottomLeft_GrSurfaceOrigin));
157 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400158
Greg Daniel303e83e2018-09-10 14:10:19 -0400159 int expectedCacheCount = startCacheCount + (proxy->isInstantiated() ? 0 : 1);
160
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400161 // Once instantiated, the backing resource should have the same key
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500162 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Salomon9bc76d92019-01-24 12:18:33 -0500163 const GrUniqueKey texKey = proxy->peekSurface()->getUniqueKey();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400164 REPORTER_ASSERT(reporter, texKey.isValid());
165 REPORTER_ASSERT(reporter, key == texKey);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400166
Brian Salomon9bc76d92019-01-24 12:18:33 -0500167 // An Unbudgeted-cacheable resource will not get purged when a proxy with the same key is
168 // deleted.
169 bool expectResourceToOutliveProxy = proxy->peekSurface()->resourcePriv().budgetedType() ==
170 GrBudgetedType::kUnbudgetedCacheable;
171
172 // An Unbudgeted-uncacheable resource is never kept alive if it's ref cnt reaches zero even if
173 // it has a key.
174 bool expectDeletingProxyToDeleteResource =
175 proxy->peekSurface()->resourcePriv().budgetedType() ==
176 GrBudgetedType::kUnbudgetedUncacheable;
177
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400178 // deleting the proxy should delete it from the hash but not the cache
179 proxy = nullptr;
Brian Salomon9bc76d92019-01-24 12:18:33 -0500180 if (expectDeletingProxyToDeleteResource) {
181 expectedCacheCount -= 1;
182 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500183 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Greg Daniel303e83e2018-09-10 14:10:19 -0400184 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400185
186 // If the proxy was cached refinding it should bring it back to life
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500187 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
Greg Daniel303e83e2018-09-10 14:10:19 -0400188 REPORTER_ASSERT(reporter, proxy);
189 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
190 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400191
192 // Mega-purging it should remove it from both the hash and the cache
193 proxy = nullptr;
194 cache->purgeAllUnlocked();
Brian Salomon9bc76d92019-01-24 12:18:33 -0500195 if (!expectResourceToOutliveProxy) {
196 expectedCacheCount--;
197 }
Greg Daniel303e83e2018-09-10 14:10:19 -0400198 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400199
Brian Salomon9bc76d92019-01-24 12:18:33 -0500200 // If the texture was deleted then the proxy should no longer be findable. Otherwise, it should
201 // be.
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500202 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
Brian Salomon9bc76d92019-01-24 12:18:33 -0500203 REPORTER_ASSERT(reporter, expectResourceToOutliveProxy ? (bool)proxy : !proxy);
Greg Daniel303e83e2018-09-10 14:10:19 -0400204 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500205
206 if (expectResourceToOutliveProxy) {
207 proxy.reset();
Robert Phillips9da87e02019-02-04 13:26:26 -0500208 GrUniqueKeyInvalidatedMessage msg(texKey, context->priv().contextID());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500209 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
210 cache->purgeAsNeeded();
211 expectedCacheCount--;
212 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
213 REPORTER_ASSERT(reporter, !proxy);
214 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
215 }
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400216}
217
218///////////////////////////////////////////////////////////////////////////////////////////////////
219// Invalidation test
220
221// Test if invalidating unique ids operates as expected for texture proxies.
222static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) {
223
Robert Phillips9da87e02019-02-04 13:26:26 -0500224 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
225 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400226 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
227
228 sk_sp<SkImage> rasterImg;
229
230 {
231 SkImageInfo ii = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
232
233 SkBitmap bm;
234 bm.allocPixels(ii);
235
236 rasterImg = SkImage::MakeFromBitmap(bm);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500237 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400238 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
239 }
240
241 sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(context, nullptr);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500242 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400243 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
244
245 rasterImg = nullptr; // this invalidates the uniqueKey
246
247 // this forces the cache to respond to the inval msg
248 int maxNum;
249 size_t maxBytes;
250 context->getResourceCacheLimits(&maxNum, &maxBytes);
251 context->setResourceCacheLimits(maxNum-1, maxBytes);
252
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500253 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400254 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
255
256 textureImg = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500257 context->priv().testingOnly_purgeAllUnlockedResources();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400258
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500259 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400260 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
261}
262
Brian Osman28c434b2017-09-27 13:11:16 -0400263// Test if invalidating unique ids prior to instantiating operates as expected
264static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) {
Robert Phillips9da87e02019-02-04 13:26:26 -0500265 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
266 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
267 GrResourceCache* cache = context->priv().getResourceCache();
Brian Osman28c434b2017-09-27 13:11:16 -0400268 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
269
270 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
271 GrUniqueKey key;
272 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
273 builder[0] = 0;
274 builder.finish();
275
276 // Create proxy, assign unique key
Greg Daniel4065d452018-11-16 15:43:41 -0500277 sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
278 SkBackingFit::kExact);
Robert Phillipsadbe1322018-01-17 13:35:46 -0500279 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Brian Osman28c434b2017-09-27 13:11:16 -0400280
281 // Send an invalidation message, which will be sitting in the cache's inbox
Brian Salomon238069b2018-07-11 15:58:57 -0400282 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
Robert Phillips9da87e02019-02-04 13:26:26 -0500283 GrUniqueKeyInvalidatedMessage(key, context->priv().contextID()));
Brian Osman28c434b2017-09-27 13:11:16 -0400284
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500285 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400286 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
287
288 // Instantiate the proxy. This will trigger the message to be processed, so the resulting
289 // texture should *not* have the unique key on it!
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500290 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Osman28c434b2017-09-27 13:11:16 -0400291
292 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400293 REPORTER_ASSERT(reporter, !proxy->peekTexture()->getUniqueKey().isValid());
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500294 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400295 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
296
297 proxy = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500298 context->priv().testingOnly_purgeAllUnlockedResources();
Brian Osman28c434b2017-09-27 13:11:16 -0400299
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500300 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400301 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
302}
303
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400304DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
305 GrContext* context = ctxInfo.grContext();
Robert Phillips9da87e02019-02-04 13:26:26 -0500306 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
307 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400308
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500309 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400310 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
311
312 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
Greg Danielcd871402017-09-26 12:49:26 -0400313 for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400314 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
Greg Daniel4065d452018-11-16 15:43:41 -0500315 basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400316 }
317
318 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
319 sk_sp<GrTexture> backingTex;
320 sk_sp<GrTextureProxy> proxy = create_wrapped_backend(context, fit, &backingTex);
Greg Daniel303e83e2018-09-10 14:10:19 -0400321 basic_test(context, reporter, std::move(proxy));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400322
323 backingTex = nullptr;
324 cache->purgeAllUnlocked();
325 }
326
327 invalidation_test(context, reporter);
Robert Phillipsfa8c0802017-10-04 08:42:28 -0400328 invalidation_and_instantiation_test(context, reporter);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400329}