blob: 5b19f1e117b47da118813c0bf42a76d2cbe54e84 [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"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/GrContextPriv.h"
14#include "src/gpu/GrProxyProvider.h"
15#include "src/gpu/GrResourceCache.h"
16#include "src/gpu/GrResourceProvider.h"
Greg Daniel456f9b52020-03-05 19:14:18 +000017#include "src/gpu/GrTexture.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);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040038
Greg Daniel3a365112020-02-14 10:47:18 -050039 sk_sp<GrTextureProxy> proxy =
Brian Salomondf1bd6d2020-03-26 20:37:01 -040040 proxyProvider->createProxy(format, kSize, GrRenderable::kNo, 1, GrMipMapped::kNo, fit,
41 SkBudgeted::kYes, GrProtected::kNo);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040042 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040043 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
44 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040045}
46
Greg Daniel4065d452018-11-16 15:43:41 -050047static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050048 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Robert Phillips0a15cc62019-07-30 12:49:10 -040049 const GrCaps* caps = ctx->priv().caps();
50
Brian Salomon4eb38b72019-08-05 12:58:39 -040051 GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040052
Greg Daniel3a365112020-02-14 10:47:18 -050053 sk_sp<GrTextureProxy> proxy =
Brian Salomondf1bd6d2020-03-26 20:37:01 -040054 proxyProvider->createProxy(format, kSize, GrRenderable::kYes, 1, GrMipMapped::kNo, fit,
55 SkBudgeted::kYes, GrProtected::kNo);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040056 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040057 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
58 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040059}
60
Greg Daniel4065d452018-11-16 15:43:41 -050061static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050062 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Chris Daltond004e0b2018-09-27 09:28:03 -060063 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Greg Daniel3a365112020-02-14 10:47:18 -050064 kSize, kColorType, GrRenderable::kNo, 1, fit, SkBudgeted::kYes, GrProtected::kNo);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050065 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040066 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
67 return proxy;
68}
69
Greg Daniel4065d452018-11-16 15:43:41 -050070static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050071 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Greg Danielcd871402017-09-26 12:49:26 -040072 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
73 static int kUniqueKeyData = 0;
74
75 GrUniqueKey key;
76
77 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
78 builder[0] = kUniqueKeyData++;
79 builder.finish();
80
Robert Phillipsadbe1322018-01-17 13:35:46 -050081 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Chris Daltond004e0b2018-09-27 09:28:03 -060082 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Greg Daniel3a365112020-02-14 10:47:18 -050083 kSize, kColorType, GrRenderable::kNo, 1, fit, SkBudgeted::kYes, GrProtected::kNo);
Robert Phillipsadbe1322018-01-17 13:35:46 -050084 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -040085 REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
86 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040087}
88
89static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
90 sk_sp<GrTexture>* backingSurface) {
Robert Phillips9da87e02019-02-04 13:26:26 -050091 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
92 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
Robert Phillipsae7d3f32017-09-21 08:26:08 -040093
Brian Salomon4eb38b72019-08-05 12:58:39 -040094 GrBackendFormat format =
95 proxyProvider->caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040096
Brian Salomona90382f2019-09-17 09:01:56 -040097 *backingSurface =
Brian Salomona56a7462020-02-07 14:17:25 -050098 resourceProvider->createTexture(kSize, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
Brian Salomona90382f2019-09-17 09:01:56 -040099 SkBudgeted::kNo, GrProtected::kNo);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400100 if (!(*backingSurface)) {
101 return nullptr;
102 }
103
Robert Phillipsb67821d2017-12-13 15:00:45 -0500104 GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400105
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400106 return proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
Greg Daniel3a365112020-02-14 10:47:18 -0500107 kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
108 kRead_GrIOType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400109}
110
111
112// This tests the basic capabilities of the uniquely keyed texture proxies. Does assigning
113// and looking them up work, etc.
114static void basic_test(GrContext* context,
115 skiatest::Reporter* reporter,
Greg Daniel303e83e2018-09-10 14:10:19 -0400116 sk_sp<GrTextureProxy> proxy) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400117 static int id = 1;
118
Robert Phillips9da87e02019-02-04 13:26:26 -0500119 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
120 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
121 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400122
123 int startCacheCount = cache->getResourceCount();
124
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400125 GrUniqueKey key;
Greg Danielcd871402017-09-26 12:49:26 -0400126 if (proxy->getUniqueKey().isValid()) {
127 key = proxy->getUniqueKey();
128 } else {
129 GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
130 ++id;
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400131
Greg Danielcd871402017-09-26 12:49:26 -0400132 // Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500133 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsadbe1322018-01-17 13:35:46 -0500134 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -0400135 }
136
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500137 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400138 REPORTER_ASSERT(reporter, startCacheCount == cache->getResourceCount());
139
140 // setUniqueKey had better stick
141 REPORTER_ASSERT(reporter, key == proxy->getUniqueKey());
142
143 // We just added it, surely we can find it
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400144 REPORTER_ASSERT(reporter, proxyProvider->findOrCreateProxyByUniqueKey(key));
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500145 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400146
Greg Daniel303e83e2018-09-10 14:10:19 -0400147 int expectedCacheCount = startCacheCount + (proxy->isInstantiated() ? 0 : 1);
148
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400149 // Once instantiated, the backing resource should have the same key
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500150 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Salomon9bc76d92019-01-24 12:18:33 -0500151 const GrUniqueKey texKey = proxy->peekSurface()->getUniqueKey();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400152 REPORTER_ASSERT(reporter, texKey.isValid());
153 REPORTER_ASSERT(reporter, key == texKey);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400154
Brian Salomon9bc76d92019-01-24 12:18:33 -0500155 // An Unbudgeted-cacheable resource will not get purged when a proxy with the same key is
156 // deleted.
157 bool expectResourceToOutliveProxy = proxy->peekSurface()->resourcePriv().budgetedType() ==
158 GrBudgetedType::kUnbudgetedCacheable;
159
160 // An Unbudgeted-uncacheable resource is never kept alive if it's ref cnt reaches zero even if
161 // it has a key.
162 bool expectDeletingProxyToDeleteResource =
163 proxy->peekSurface()->resourcePriv().budgetedType() ==
164 GrBudgetedType::kUnbudgetedUncacheable;
165
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400166 // deleting the proxy should delete it from the hash but not the cache
167 proxy = nullptr;
Brian Salomon9bc76d92019-01-24 12:18:33 -0500168 if (expectDeletingProxyToDeleteResource) {
169 expectedCacheCount -= 1;
170 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500171 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Greg Daniel303e83e2018-09-10 14:10:19 -0400172 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400173
174 // If the proxy was cached refinding it should bring it back to life
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400175 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key);
Greg Daniel303e83e2018-09-10 14:10:19 -0400176 REPORTER_ASSERT(reporter, proxy);
177 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
178 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400179
180 // Mega-purging it should remove it from both the hash and the cache
181 proxy = nullptr;
182 cache->purgeAllUnlocked();
Brian Salomon9bc76d92019-01-24 12:18:33 -0500183 if (!expectResourceToOutliveProxy) {
184 expectedCacheCount--;
185 }
Greg Daniel303e83e2018-09-10 14:10:19 -0400186 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400187
Brian Salomon9bc76d92019-01-24 12:18:33 -0500188 // If the texture was deleted then the proxy should no longer be findable. Otherwise, it should
189 // be.
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400190 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key);
Brian Salomon9bc76d92019-01-24 12:18:33 -0500191 REPORTER_ASSERT(reporter, expectResourceToOutliveProxy ? (bool)proxy : !proxy);
Greg Daniel303e83e2018-09-10 14:10:19 -0400192 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500193
194 if (expectResourceToOutliveProxy) {
195 proxy.reset();
Robert Phillips9da87e02019-02-04 13:26:26 -0500196 GrUniqueKeyInvalidatedMessage msg(texKey, context->priv().contextID());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500197 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
198 cache->purgeAsNeeded();
199 expectedCacheCount--;
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400200 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key);
Brian Salomon9bc76d92019-01-24 12:18:33 -0500201 REPORTER_ASSERT(reporter, !proxy);
202 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
203 }
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400204}
205
206///////////////////////////////////////////////////////////////////////////////////////////////////
207// Invalidation test
208
209// Test if invalidating unique ids operates as expected for texture proxies.
210static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) {
211
Robert Phillips9da87e02019-02-04 13:26:26 -0500212 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
213 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400214 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
215
216 sk_sp<SkImage> rasterImg;
217
218 {
219 SkImageInfo ii = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
220
221 SkBitmap bm;
222 bm.allocPixels(ii);
223
224 rasterImg = SkImage::MakeFromBitmap(bm);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500225 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400226 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
227 }
228
Brian Osmand566e2e2019-08-14 13:19:04 -0400229 sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(context);
Brian Salomonbc074a62020-03-18 10:06:13 -0400230 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400231 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
232
233 rasterImg = nullptr; // this invalidates the uniqueKey
234
235 // this forces the cache to respond to the inval msg
Robert Phillipscf39f372019-09-03 10:29:20 -0400236 size_t maxBytes = context->getResourceCacheLimit();
237 context->setResourceCacheLimit(maxBytes-1);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400238
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500239 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400240 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
241
242 textureImg = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500243 context->priv().testingOnly_purgeAllUnlockedResources();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400244
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500245 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400246 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
247}
248
Brian Osman28c434b2017-09-27 13:11:16 -0400249// Test if invalidating unique ids prior to instantiating operates as expected
250static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) {
Robert Phillips9da87e02019-02-04 13:26:26 -0500251 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
252 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
253 GrResourceCache* cache = context->priv().getResourceCache();
Brian Osman28c434b2017-09-27 13:11:16 -0400254 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
255
256 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
257 GrUniqueKey key;
258 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
259 builder[0] = 0;
260 builder.finish();
261
262 // Create proxy, assign unique key
Greg Daniel4065d452018-11-16 15:43:41 -0500263 sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
264 SkBackingFit::kExact);
Robert Phillipsadbe1322018-01-17 13:35:46 -0500265 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Brian Osman28c434b2017-09-27 13:11:16 -0400266
267 // Send an invalidation message, which will be sitting in the cache's inbox
Brian Salomon238069b2018-07-11 15:58:57 -0400268 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
Robert Phillips9da87e02019-02-04 13:26:26 -0500269 GrUniqueKeyInvalidatedMessage(key, context->priv().contextID()));
Brian Osman28c434b2017-09-27 13:11:16 -0400270
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500271 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400272 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
273
274 // Instantiate the proxy. This will trigger the message to be processed, so the resulting
275 // texture should *not* have the unique key on it!
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500276 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Osman28c434b2017-09-27 13:11:16 -0400277
278 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400279 REPORTER_ASSERT(reporter, !proxy->peekTexture()->getUniqueKey().isValid());
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500280 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400281 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
282
283 proxy = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500284 context->priv().testingOnly_purgeAllUnlockedResources();
Brian Osman28c434b2017-09-27 13:11:16 -0400285
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500286 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400287 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
288}
289
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400290DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
291 GrContext* context = ctxInfo.grContext();
Robert Phillips9da87e02019-02-04 13:26:26 -0500292 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
293 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400294
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500295 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400296 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
297
298 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
Greg Danielcd871402017-09-26 12:49:26 -0400299 for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400300 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
Greg Daniel4065d452018-11-16 15:43:41 -0500301 basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400302 }
303
304 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
305 sk_sp<GrTexture> backingTex;
306 sk_sp<GrTextureProxy> proxy = create_wrapped_backend(context, fit, &backingTex);
Greg Daniel303e83e2018-09-10 14:10:19 -0400307 basic_test(context, reporter, std::move(proxy));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400308
309 backingTex = nullptr;
310 cache->purgeAllUnlocked();
311 }
312
313 invalidation_test(context, reporter);
Robert Phillipsfa8c0802017-10-04 08:42:28 -0400314 invalidation_and_instantiation_test(context, reporter);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400315}