blob: 8f70e6897a731ad11e03c0ef5623d8c1b19c3925 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "tests/Test.h"
Robert Phillipsae7d3f32017-09-21 08:26:08 -040011
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/gpu/GrBackendSurface.h"
13#include "include/gpu/GrTexture.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/GrContextPriv.h"
15#include "src/gpu/GrProxyProvider.h"
16#include "src/gpu/GrResourceCache.h"
17#include "src/gpu/GrResourceProvider.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040018#include "src/gpu/GrTextureProxy.h"
Robert Phillipsae7d3f32017-09-21 08:26:08 -040019
Mike Kleinc0bd9f92019-04-23 12:05:21 -050020#include "include/core/SkImage.h"
21#include "src/gpu/SkGr.h"
Robert Phillipsae7d3f32017-09-21 08:26:08 -040022
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
Brian Salomon4eb38b72019-08-05 12:58:39 -040027static constexpr auto kColorType = GrColorType::kRGBA_8888;
28static constexpr auto kSize = SkISize::Make(64, 64);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040029
30///////////////////////////////////////////////////////////////////////////////////////////////////
31// Basic test
32
Greg Daniel4065d452018-11-16 15:43:41 -050033static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050034 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Robert Phillips0a15cc62019-07-30 12:49:10 -040035 const GrCaps* caps = ctx->priv().caps();
36
Brian Salomon4eb38b72019-08-05 12:58:39 -040037 GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kNo);
Greg Daniel47c20e82020-01-21 14:29:57 -050038 GrSwizzle swizzle = caps->getReadSwizzle(format, kColorType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040039
Greg Daniel3a365112020-02-14 10:47:18 -050040 sk_sp<GrTextureProxy> proxy =
41 proxyProvider->createProxy(format, kSize, swizzle, GrRenderable::kNo, 1,
42 GrMipMapped::kNo, fit, SkBudgeted::kYes, GrProtected::kNo);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040043 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040044 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
45 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040046}
47
Greg Daniel4065d452018-11-16 15:43:41 -050048static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050049 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Robert Phillips0a15cc62019-07-30 12:49:10 -040050 const GrCaps* caps = ctx->priv().caps();
51
Brian Salomon4eb38b72019-08-05 12:58:39 -040052 GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
Greg Daniel47c20e82020-01-21 14:29:57 -050053 GrSwizzle swizzle = caps->getReadSwizzle(format, kColorType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040054
Greg Daniel3a365112020-02-14 10:47:18 -050055 sk_sp<GrTextureProxy> proxy =
56 proxyProvider->createProxy(format, kSize, swizzle, GrRenderable::kYes, 1,
57 GrMipMapped::kNo, fit, SkBudgeted::kYes, GrProtected::kNo);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040058 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040059 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
60 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040061}
62
Greg Daniel4065d452018-11-16 15:43:41 -050063static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050064 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Chris Daltond004e0b2018-09-27 09:28:03 -060065 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Greg Daniel3a365112020-02-14 10:47:18 -050066 kSize, kColorType, GrRenderable::kNo, 1, fit, SkBudgeted::kYes, GrProtected::kNo);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050067 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040068 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
69 return proxy;
70}
71
Greg Daniel4065d452018-11-16 15:43:41 -050072static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050073 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Greg Danielcd871402017-09-26 12:49:26 -040074 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
75 static int kUniqueKeyData = 0;
76
77 GrUniqueKey key;
78
79 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
80 builder[0] = kUniqueKeyData++;
81 builder.finish();
82
Robert Phillipsadbe1322018-01-17 13:35:46 -050083 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Chris Daltond004e0b2018-09-27 09:28:03 -060084 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Greg Daniel3a365112020-02-14 10:47:18 -050085 kSize, kColorType, GrRenderable::kNo, 1, fit, SkBudgeted::kYes, GrProtected::kNo);
Robert Phillipsadbe1322018-01-17 13:35:46 -050086 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -040087 REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
88 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040089}
90
91static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
92 sk_sp<GrTexture>* backingSurface) {
Robert Phillips9da87e02019-02-04 13:26:26 -050093 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
94 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
Robert Phillipsae7d3f32017-09-21 08:26:08 -040095
Brian Salomon4eb38b72019-08-05 12:58:39 -040096 GrBackendFormat format =
97 proxyProvider->caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040098
Brian Salomona90382f2019-09-17 09:01:56 -040099 *backingSurface =
Brian Salomona56a7462020-02-07 14:17:25 -0500100 resourceProvider->createTexture(kSize, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
Brian Salomona90382f2019-09-17 09:01:56 -0400101 SkBudgeted::kNo, GrProtected::kNo);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400102 if (!(*backingSurface)) {
103 return nullptr;
104 }
105
Robert Phillipsb67821d2017-12-13 15:00:45 -0500106 GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400107
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400108 return proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
Greg Daniel3a365112020-02-14 10:47:18 -0500109 kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
110 kRead_GrIOType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400111}
112
113
114// This tests the basic capabilities of the uniquely keyed texture proxies. Does assigning
115// and looking them up work, etc.
116static void basic_test(GrContext* context,
117 skiatest::Reporter* reporter,
Greg Daniel303e83e2018-09-10 14:10:19 -0400118 sk_sp<GrTextureProxy> proxy) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400119 static int id = 1;
120
Robert Phillips9da87e02019-02-04 13:26:26 -0500121 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
122 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
123 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400124
125 int startCacheCount = cache->getResourceCount();
126
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400127 GrUniqueKey key;
Greg Danielcd871402017-09-26 12:49:26 -0400128 if (proxy->getUniqueKey().isValid()) {
129 key = proxy->getUniqueKey();
130 } else {
131 GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
132 ++id;
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400133
Greg Danielcd871402017-09-26 12:49:26 -0400134 // Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500135 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsadbe1322018-01-17 13:35:46 -0500136 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -0400137 }
138
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500139 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400140 REPORTER_ASSERT(reporter, startCacheCount == cache->getResourceCount());
141
142 // setUniqueKey had better stick
143 REPORTER_ASSERT(reporter, key == proxy->getUniqueKey());
144
145 // We just added it, surely we can find it
Greg Daniel3a365112020-02-14 10:47:18 -0500146 REPORTER_ASSERT(reporter, proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType));
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500147 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400148
Greg Daniel303e83e2018-09-10 14:10:19 -0400149 int expectedCacheCount = startCacheCount + (proxy->isInstantiated() ? 0 : 1);
150
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400151 // Once instantiated, the backing resource should have the same key
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500152 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Salomon9bc76d92019-01-24 12:18:33 -0500153 const GrUniqueKey texKey = proxy->peekSurface()->getUniqueKey();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400154 REPORTER_ASSERT(reporter, texKey.isValid());
155 REPORTER_ASSERT(reporter, key == texKey);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400156
Brian Salomon9bc76d92019-01-24 12:18:33 -0500157 // An Unbudgeted-cacheable resource will not get purged when a proxy with the same key is
158 // deleted.
159 bool expectResourceToOutliveProxy = proxy->peekSurface()->resourcePriv().budgetedType() ==
160 GrBudgetedType::kUnbudgetedCacheable;
161
162 // An Unbudgeted-uncacheable resource is never kept alive if it's ref cnt reaches zero even if
163 // it has a key.
164 bool expectDeletingProxyToDeleteResource =
165 proxy->peekSurface()->resourcePriv().budgetedType() ==
166 GrBudgetedType::kUnbudgetedUncacheable;
167
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400168 // deleting the proxy should delete it from the hash but not the cache
169 proxy = nullptr;
Brian Salomon9bc76d92019-01-24 12:18:33 -0500170 if (expectDeletingProxyToDeleteResource) {
171 expectedCacheCount -= 1;
172 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500173 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Greg Daniel303e83e2018-09-10 14:10:19 -0400174 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400175
176 // If the proxy was cached refinding it should bring it back to life
Greg Daniel3a365112020-02-14 10:47:18 -0500177 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType);
Greg Daniel303e83e2018-09-10 14:10:19 -0400178 REPORTER_ASSERT(reporter, proxy);
179 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
180 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400181
182 // Mega-purging it should remove it from both the hash and the cache
183 proxy = nullptr;
184 cache->purgeAllUnlocked();
Brian Salomon9bc76d92019-01-24 12:18:33 -0500185 if (!expectResourceToOutliveProxy) {
186 expectedCacheCount--;
187 }
Greg Daniel303e83e2018-09-10 14:10:19 -0400188 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400189
Brian Salomon9bc76d92019-01-24 12:18:33 -0500190 // If the texture was deleted then the proxy should no longer be findable. Otherwise, it should
191 // be.
Greg Daniel3a365112020-02-14 10:47:18 -0500192 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType);
Brian Salomon9bc76d92019-01-24 12:18:33 -0500193 REPORTER_ASSERT(reporter, expectResourceToOutliveProxy ? (bool)proxy : !proxy);
Greg Daniel303e83e2018-09-10 14:10:19 -0400194 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500195
196 if (expectResourceToOutliveProxy) {
197 proxy.reset();
Robert Phillips9da87e02019-02-04 13:26:26 -0500198 GrUniqueKeyInvalidatedMessage msg(texKey, context->priv().contextID());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500199 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
200 cache->purgeAsNeeded();
201 expectedCacheCount--;
Greg Daniel3a365112020-02-14 10:47:18 -0500202 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType);
Brian Salomon9bc76d92019-01-24 12:18:33 -0500203 REPORTER_ASSERT(reporter, !proxy);
204 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
205 }
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400206}
207
208///////////////////////////////////////////////////////////////////////////////////////////////////
209// Invalidation test
210
211// Test if invalidating unique ids operates as expected for texture proxies.
212static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) {
213
Robert Phillips9da87e02019-02-04 13:26:26 -0500214 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
215 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400216 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
217
218 sk_sp<SkImage> rasterImg;
219
220 {
221 SkImageInfo ii = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
222
223 SkBitmap bm;
224 bm.allocPixels(ii);
225
226 rasterImg = SkImage::MakeFromBitmap(bm);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500227 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400228 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
229 }
230
Brian Osmand566e2e2019-08-14 13:19:04 -0400231 sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(context);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500232 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400233 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
234
235 rasterImg = nullptr; // this invalidates the uniqueKey
236
237 // this forces the cache to respond to the inval msg
Robert Phillipscf39f372019-09-03 10:29:20 -0400238 size_t maxBytes = context->getResourceCacheLimit();
239 context->setResourceCacheLimit(maxBytes-1);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400240
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500241 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400242 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
243
244 textureImg = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500245 context->priv().testingOnly_purgeAllUnlockedResources();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400246
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500247 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400248 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
249}
250
Brian Osman28c434b2017-09-27 13:11:16 -0400251// Test if invalidating unique ids prior to instantiating operates as expected
252static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) {
Robert Phillips9da87e02019-02-04 13:26:26 -0500253 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
254 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
255 GrResourceCache* cache = context->priv().getResourceCache();
Brian Osman28c434b2017-09-27 13:11:16 -0400256 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
257
258 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
259 GrUniqueKey key;
260 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
261 builder[0] = 0;
262 builder.finish();
263
264 // Create proxy, assign unique key
Greg Daniel4065d452018-11-16 15:43:41 -0500265 sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
266 SkBackingFit::kExact);
Robert Phillipsadbe1322018-01-17 13:35:46 -0500267 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Brian Osman28c434b2017-09-27 13:11:16 -0400268
269 // Send an invalidation message, which will be sitting in the cache's inbox
Brian Salomon238069b2018-07-11 15:58:57 -0400270 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
Robert Phillips9da87e02019-02-04 13:26:26 -0500271 GrUniqueKeyInvalidatedMessage(key, context->priv().contextID()));
Brian Osman28c434b2017-09-27 13:11:16 -0400272
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500273 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400274 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
275
276 // Instantiate the proxy. This will trigger the message to be processed, so the resulting
277 // texture should *not* have the unique key on it!
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500278 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Osman28c434b2017-09-27 13:11:16 -0400279
280 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400281 REPORTER_ASSERT(reporter, !proxy->peekTexture()->getUniqueKey().isValid());
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500282 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400283 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
284
285 proxy = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500286 context->priv().testingOnly_purgeAllUnlockedResources();
Brian Osman28c434b2017-09-27 13:11:16 -0400287
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500288 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400289 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
290}
291
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400292DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
293 GrContext* context = ctxInfo.grContext();
Robert Phillips9da87e02019-02-04 13:26:26 -0500294 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
295 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400296
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500297 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400298 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
299
300 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
Greg Danielcd871402017-09-26 12:49:26 -0400301 for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400302 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
Greg Daniel4065d452018-11-16 15:43:41 -0500303 basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400304 }
305
306 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
307 sk_sp<GrTexture> backingTex;
308 sk_sp<GrTextureProxy> proxy = create_wrapped_backend(context, fit, &backingTex);
Greg Daniel303e83e2018-09-10 14:10:19 -0400309 basic_test(context, reporter, std::move(proxy));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400310
311 backingTex = nullptr;
312 cache->purgeAllUnlocked();
313 }
314
315 invalidation_test(context, reporter);
Robert Phillipsfa8c0802017-10-04 08:42:28 -0400316 invalidation_and_instantiation_test(context, reporter);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400317}