blob: e4f1104ace7c166a56ea43a2ca5fe438d1828a92 [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 Salomonf2c2ba92019-07-17 09:59:59 -040027static GrSurfaceDesc make_desc() {
Robert Phillipsae7d3f32017-09-21 08:26:08 -040028 GrSurfaceDesc desc;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040029 desc.fWidth = 64;
30 desc.fHeight = 64;
31 desc.fConfig = kRGBA_8888_GrPixelConfig;
Brian Salomonbdecacf2018-02-02 20:32:49 -050032 desc.fSampleCnt = 1;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040033
34 return desc;
35}
36
37///////////////////////////////////////////////////////////////////////////////////////////////////
38// Basic test
39
Greg Daniel4065d452018-11-16 15:43:41 -050040static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050041 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Brian Salomonf2c2ba92019-07-17 09:59:59 -040042 const GrSurfaceDesc desc = make_desc();
Greg Daniel4065d452018-11-16 15:43:41 -050043 GrBackendFormat format =
Greg Daniel627d0532019-07-08 16:48:14 -040044 ctx->priv().caps()->getBackendFormatFromColorType(GrColorType::kRGBA_8888);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040045
Brian Salomonf2c2ba92019-07-17 09:59:59 -040046 sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
47 format, desc, GrRenderable::kNo, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040048 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040049 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
50 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040051}
52
Greg Daniel4065d452018-11-16 15:43:41 -050053static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050054 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Brian Salomonf2c2ba92019-07-17 09:59:59 -040055 const GrSurfaceDesc desc = make_desc();
Greg Daniel4065d452018-11-16 15:43:41 -050056 GrBackendFormat format =
Greg Daniel627d0532019-07-08 16:48:14 -040057 ctx->priv().caps()->getBackendFormatFromColorType(GrColorType::kRGBA_8888);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040058
Brian Salomonf2c2ba92019-07-17 09:59:59 -040059 sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
60 format, desc, GrRenderable::kYes, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
Robert Phillipsae7d3f32017-09-21 08:26:08 -040061 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040062 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
63 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040064}
65
Greg Daniel4065d452018-11-16 15:43:41 -050066static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050067 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Brian Salomonf2c2ba92019-07-17 09:59:59 -040068 const GrSurfaceDesc desc = make_desc();
Robert Phillips1afd4cd2018-01-08 13:40:32 -050069
Chris Daltond004e0b2018-09-27 09:28:03 -060070 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Brian Salomonf2c2ba92019-07-17 09:59:59 -040071 desc, GrRenderable::kNo, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050072 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Greg Danielcd871402017-09-26 12:49:26 -040073 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
74 return proxy;
75}
76
Greg Daniel4065d452018-11-16 15:43:41 -050077static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
Robert Phillipsadbe1322018-01-17 13:35:46 -050078 GrProxyProvider* proxyProvider, SkBackingFit fit) {
Greg Danielcd871402017-09-26 12:49:26 -040079 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
80 static int kUniqueKeyData = 0;
81
82 GrUniqueKey key;
83
84 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
85 builder[0] = kUniqueKeyData++;
86 builder.finish();
87
Brian Salomonf2c2ba92019-07-17 09:59:59 -040088 const GrSurfaceDesc desc = make_desc();
Greg Danielcd871402017-09-26 12:49:26 -040089
Robert Phillipsadbe1322018-01-17 13:35:46 -050090 // Only budgeted & wrapped external proxies get to carry uniqueKeys
Chris Daltond004e0b2018-09-27 09:28:03 -060091 sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
Brian Salomonf2c2ba92019-07-17 09:59:59 -040092 desc, GrRenderable::kNo, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
Robert Phillipsadbe1322018-01-17 13:35:46 -050093 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -040094 REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
95 return proxy;
Robert Phillipsae7d3f32017-09-21 08:26:08 -040096}
97
98static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
99 sk_sp<GrTexture>* backingSurface) {
Robert Phillips9da87e02019-02-04 13:26:26 -0500100 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
101 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400102
Brian Salomonf2c2ba92019-07-17 09:59:59 -0400103 const GrSurfaceDesc desc = make_desc();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400104
Brian Salomonf2c2ba92019-07-17 09:59:59 -0400105 *backingSurface = resourceProvider->createTexture(desc, GrRenderable::kNo, SkBudgeted::kNo,
Robert Phillips9313aa72019-04-09 18:41:27 -0400106 GrResourceProvider::Flags::kNoPendingIO);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400107 if (!(*backingSurface)) {
108 return nullptr;
109 }
110
Robert Phillipsb67821d2017-12-13 15:00:45 -0500111 GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
Greg Daniel108bb232018-07-03 16:18:29 -0400112 backendTex.setPixelConfig(desc.fConfig);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400113
Robert Phillipsdd399802019-07-18 12:28:00 +0000114 return proxyProvider->wrapBackendTexture(backendTex, kBottomLeft_GrSurfaceOrigin,
115 kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
116 kRead_GrIOType);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400117}
118
119
120// This tests the basic capabilities of the uniquely keyed texture proxies. Does assigning
121// and looking them up work, etc.
122static void basic_test(GrContext* context,
123 skiatest::Reporter* reporter,
Greg Daniel303e83e2018-09-10 14:10:19 -0400124 sk_sp<GrTextureProxy> proxy) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400125 static int id = 1;
126
Robert Phillips9da87e02019-02-04 13:26:26 -0500127 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
128 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
129 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400130
131 int startCacheCount = cache->getResourceCount();
132
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400133 GrUniqueKey key;
Greg Danielcd871402017-09-26 12:49:26 -0400134 if (proxy->getUniqueKey().isValid()) {
135 key = proxy->getUniqueKey();
136 } else {
137 GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
138 ++id;
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400139
Greg Danielcd871402017-09-26 12:49:26 -0400140 // Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500141 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsadbe1322018-01-17 13:35:46 -0500142 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Greg Danielcd871402017-09-26 12:49:26 -0400143 }
144
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500145 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400146 REPORTER_ASSERT(reporter, startCacheCount == cache->getResourceCount());
147
148 // setUniqueKey had better stick
149 REPORTER_ASSERT(reporter, key == proxy->getUniqueKey());
150
151 // We just added it, surely we can find it
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500152 REPORTER_ASSERT(reporter, proxyProvider->findOrCreateProxyByUniqueKey(
153 key, kBottomLeft_GrSurfaceOrigin));
154 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400155
Greg Daniel303e83e2018-09-10 14:10:19 -0400156 int expectedCacheCount = startCacheCount + (proxy->isInstantiated() ? 0 : 1);
157
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400158 // Once instantiated, the backing resource should have the same key
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500159 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Salomon9bc76d92019-01-24 12:18:33 -0500160 const GrUniqueKey texKey = proxy->peekSurface()->getUniqueKey();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400161 REPORTER_ASSERT(reporter, texKey.isValid());
162 REPORTER_ASSERT(reporter, key == texKey);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400163
Brian Salomon9bc76d92019-01-24 12:18:33 -0500164 // An Unbudgeted-cacheable resource will not get purged when a proxy with the same key is
165 // deleted.
166 bool expectResourceToOutliveProxy = proxy->peekSurface()->resourcePriv().budgetedType() ==
167 GrBudgetedType::kUnbudgetedCacheable;
168
169 // An Unbudgeted-uncacheable resource is never kept alive if it's ref cnt reaches zero even if
170 // it has a key.
171 bool expectDeletingProxyToDeleteResource =
172 proxy->peekSurface()->resourcePriv().budgetedType() ==
173 GrBudgetedType::kUnbudgetedUncacheable;
174
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400175 // deleting the proxy should delete it from the hash but not the cache
176 proxy = nullptr;
Brian Salomon9bc76d92019-01-24 12:18:33 -0500177 if (expectDeletingProxyToDeleteResource) {
178 expectedCacheCount -= 1;
179 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500180 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Greg Daniel303e83e2018-09-10 14:10:19 -0400181 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400182
183 // If the proxy was cached refinding it should bring it back to life
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500184 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
Greg Daniel303e83e2018-09-10 14:10:19 -0400185 REPORTER_ASSERT(reporter, proxy);
186 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
187 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400188
189 // Mega-purging it should remove it from both the hash and the cache
190 proxy = nullptr;
191 cache->purgeAllUnlocked();
Brian Salomon9bc76d92019-01-24 12:18:33 -0500192 if (!expectResourceToOutliveProxy) {
193 expectedCacheCount--;
194 }
Greg Daniel303e83e2018-09-10 14:10:19 -0400195 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400196
Brian Salomon9bc76d92019-01-24 12:18:33 -0500197 // If the texture was deleted then the proxy should no longer be findable. Otherwise, it should
198 // be.
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500199 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
Brian Salomon9bc76d92019-01-24 12:18:33 -0500200 REPORTER_ASSERT(reporter, expectResourceToOutliveProxy ? (bool)proxy : !proxy);
Greg Daniel303e83e2018-09-10 14:10:19 -0400201 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500202
203 if (expectResourceToOutliveProxy) {
204 proxy.reset();
Robert Phillips9da87e02019-02-04 13:26:26 -0500205 GrUniqueKeyInvalidatedMessage msg(texKey, context->priv().contextID());
Brian Salomon9bc76d92019-01-24 12:18:33 -0500206 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
207 cache->purgeAsNeeded();
208 expectedCacheCount--;
209 proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
210 REPORTER_ASSERT(reporter, !proxy);
211 REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
212 }
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400213}
214
215///////////////////////////////////////////////////////////////////////////////////////////////////
216// Invalidation test
217
218// Test if invalidating unique ids operates as expected for texture proxies.
219static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) {
220
Robert Phillips9da87e02019-02-04 13:26:26 -0500221 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
222 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400223 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
224
225 sk_sp<SkImage> rasterImg;
226
227 {
228 SkImageInfo ii = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
229
230 SkBitmap bm;
231 bm.allocPixels(ii);
232
233 rasterImg = SkImage::MakeFromBitmap(bm);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500234 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400235 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
236 }
237
238 sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(context, nullptr);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500239 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400240 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
241
242 rasterImg = nullptr; // this invalidates the uniqueKey
243
244 // this forces the cache to respond to the inval msg
245 int maxNum;
246 size_t maxBytes;
247 context->getResourceCacheLimits(&maxNum, &maxBytes);
248 context->setResourceCacheLimits(maxNum-1, maxBytes);
249
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500250 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400251 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
252
253 textureImg = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500254 context->priv().testingOnly_purgeAllUnlockedResources();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400255
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500256 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400257 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
258}
259
Brian Osman28c434b2017-09-27 13:11:16 -0400260// Test if invalidating unique ids prior to instantiating operates as expected
261static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) {
Robert Phillips9da87e02019-02-04 13:26:26 -0500262 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
263 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
264 GrResourceCache* cache = context->priv().getResourceCache();
Brian Osman28c434b2017-09-27 13:11:16 -0400265 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
266
267 static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
268 GrUniqueKey key;
269 GrUniqueKey::Builder builder(&key, d, 1, nullptr);
270 builder[0] = 0;
271 builder.finish();
272
273 // Create proxy, assign unique key
Greg Daniel4065d452018-11-16 15:43:41 -0500274 sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
275 SkBackingFit::kExact);
Robert Phillipsadbe1322018-01-17 13:35:46 -0500276 SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
Brian Osman28c434b2017-09-27 13:11:16 -0400277
278 // Send an invalidation message, which will be sitting in the cache's inbox
Brian Salomon238069b2018-07-11 15:58:57 -0400279 SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
Robert Phillips9da87e02019-02-04 13:26:26 -0500280 GrUniqueKeyInvalidatedMessage(key, context->priv().contextID()));
Brian Osman28c434b2017-09-27 13:11:16 -0400281
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500282 REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400283 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
284
285 // Instantiate the proxy. This will trigger the message to be processed, so the resulting
286 // texture should *not* have the unique key on it!
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500287 SkAssertResult(proxy->instantiate(resourceProvider));
Brian Osman28c434b2017-09-27 13:11:16 -0400288
289 REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400290 REPORTER_ASSERT(reporter, !proxy->peekTexture()->getUniqueKey().isValid());
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500291 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400292 REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
293
294 proxy = nullptr;
Robert Phillipsdbaf3172019-02-06 15:12:53 -0500295 context->priv().testingOnly_purgeAllUnlockedResources();
Brian Osman28c434b2017-09-27 13:11:16 -0400296
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500297 REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
Brian Osman28c434b2017-09-27 13:11:16 -0400298 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
299}
300
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400301DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
302 GrContext* context = ctxInfo.grContext();
Robert Phillips9da87e02019-02-04 13:26:26 -0500303 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
304 GrResourceCache* cache = context->priv().getResourceCache();
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400305
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500306 REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400307 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
308
309 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
Greg Danielcd871402017-09-26 12:49:26 -0400310 for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400311 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
Greg Daniel4065d452018-11-16 15:43:41 -0500312 basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400313 }
314
315 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
316 sk_sp<GrTexture> backingTex;
317 sk_sp<GrTextureProxy> proxy = create_wrapped_backend(context, fit, &backingTex);
Greg Daniel303e83e2018-09-10 14:10:19 -0400318 basic_test(context, reporter, std::move(proxy));
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400319
320 backingTex = nullptr;
321 cache->purgeAllUnlocked();
322 }
323
324 invalidation_test(context, reporter);
Robert Phillipsfa8c0802017-10-04 08:42:28 -0400325 invalidation_and_instantiation_test(context, reporter);
Robert Phillipsae7d3f32017-09-21 08:26:08 -0400326}