2017-09-21 12:26:08 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This is a GPU-backend specific test.
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tests/Test.h"
|
|
|
|
|
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
|
|
#include "include/gpu/GrTexture.h"
|
|
|
|
#include "src/gpu/GrContextPriv.h"
|
|
|
|
#include "src/gpu/GrProxyProvider.h"
|
|
|
|
#include "src/gpu/GrResourceCache.h"
|
|
|
|
#include "src/gpu/GrResourceProvider.h"
|
2019-06-18 13:58:02 +00:00
|
|
|
#include "src/gpu/GrTextureProxy.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
|
|
|
|
#include "include/core/SkImage.h"
|
|
|
|
#include "src/gpu/SkGr.h"
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
int GrProxyProvider::numUniqueKeyProxies_TestOnly() const {
|
2017-09-21 12:26:08 +00:00
|
|
|
return fUniquelyKeyedProxies.count();
|
|
|
|
}
|
|
|
|
|
2019-08-05 16:58:39 +00:00
|
|
|
static constexpr auto kColorType = GrColorType::kRGBA_8888;
|
|
|
|
static constexpr auto kSize = SkISize::Make(64, 64);
|
2019-07-17 13:59:59 +00:00
|
|
|
static GrSurfaceDesc make_desc() {
|
2017-09-21 12:26:08 +00:00
|
|
|
GrSurfaceDesc desc;
|
2019-08-05 16:58:39 +00:00
|
|
|
desc.fWidth = kSize.width();
|
|
|
|
desc.fHeight = kSize.height();
|
|
|
|
desc.fConfig = GrColorTypeToPixelConfig(kColorType);
|
2017-09-21 12:26:08 +00:00
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Basic test
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContext* ctx,
|
2018-01-17 18:35:46 +00:00
|
|
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
2019-07-30 16:49:10 +00:00
|
|
|
const GrCaps* caps = ctx->priv().caps();
|
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
const GrSurfaceDesc desc = make_desc();
|
2019-08-05 16:58:39 +00:00
|
|
|
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kNo);
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2019-07-22 18:23:45 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(format, desc, GrRenderable::kNo, 1,
|
|
|
|
kBottomLeft_GrSurfaceOrigin, fit,
|
|
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
2017-09-21 12:26:08 +00:00
|
|
|
// Only budgeted & wrapped external proxies get to carry uniqueKeys
|
2017-09-26 16:49:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
|
|
|
|
return proxy;
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
|
2018-01-17 18:35:46 +00:00
|
|
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
2019-07-30 16:49:10 +00:00
|
|
|
const GrCaps* caps = ctx->priv().caps();
|
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
const GrSurfaceDesc desc = make_desc();
|
2019-07-30 16:49:10 +00:00
|
|
|
|
2019-08-05 16:58:39 +00:00
|
|
|
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2019-07-22 18:23:45 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(format, desc, GrRenderable::kYes, 1,
|
2019-07-19 18:24:36 +00:00
|
|
|
kBottomLeft_GrSurfaceOrigin, fit,
|
|
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
2017-09-21 12:26:08 +00:00
|
|
|
// Only budgeted & wrapped external proxies get to carry uniqueKeys
|
2017-09-26 16:49:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
|
2018-01-17 18:35:46 +00:00
|
|
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
2018-09-27 15:28:03 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
|
2019-08-05 16:58:39 +00:00
|
|
|
kSize, kColorType, GrRenderable::kNo, 1, kBottomLeft_GrSurfaceOrigin, fit,
|
|
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
2018-01-16 13:06:32 +00:00
|
|
|
// Only budgeted & wrapped external proxies get to carry uniqueKeys
|
2017-09-26 16:49:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
|
|
|
|
return proxy;
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
|
2018-01-17 18:35:46 +00:00
|
|
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
2017-09-26 16:49:26 +00:00
|
|
|
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
|
|
|
|
static int kUniqueKeyData = 0;
|
|
|
|
|
|
|
|
GrUniqueKey key;
|
|
|
|
|
|
|
|
GrUniqueKey::Builder builder(&key, d, 1, nullptr);
|
|
|
|
builder[0] = kUniqueKeyData++;
|
|
|
|
builder.finish();
|
|
|
|
|
2018-01-17 18:35:46 +00:00
|
|
|
// Only budgeted & wrapped external proxies get to carry uniqueKeys
|
2018-09-27 15:28:03 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
|
2019-08-05 16:58:39 +00:00
|
|
|
kSize, kColorType, GrRenderable::kNo, 1, kBottomLeft_GrSurfaceOrigin, fit,
|
|
|
|
SkBudgeted::kYes, GrProtected::kNo);
|
2018-01-17 18:35:46 +00:00
|
|
|
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
|
2017-09-26 16:49:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
|
|
|
|
return proxy;
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
|
|
|
|
sk_sp<GrTexture>* backingSurface) {
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
const GrSurfaceDesc desc = make_desc();
|
2019-08-05 16:58:39 +00:00
|
|
|
GrBackendFormat format =
|
|
|
|
proxyProvider->caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2019-08-05 16:58:39 +00:00
|
|
|
*backingSurface = resourceProvider->createTexture(desc, format, GrRenderable::kNo, 1,
|
|
|
|
SkBudgeted::kNo, GrProtected::kNo,
|
2019-04-09 22:41:27 +00:00
|
|
|
GrResourceProvider::Flags::kNoPendingIO);
|
2017-09-21 12:26:08 +00:00
|
|
|
if (!(*backingSurface)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-13 20:00:45 +00:00
|
|
|
GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2019-07-23 14:27:09 +00:00
|
|
|
return proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
|
|
|
|
kBottomLeft_GrSurfaceOrigin, kBorrow_GrWrapOwnership,
|
|
|
|
GrWrapCacheable::kYes, kRead_GrIOType);
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This tests the basic capabilities of the uniquely keyed texture proxies. Does assigning
|
|
|
|
// and looking them up work, etc.
|
|
|
|
static void basic_test(GrContext* context,
|
|
|
|
skiatest::Reporter* reporter,
|
2018-09-10 18:10:19 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy) {
|
2017-09-21 12:26:08 +00:00
|
|
|
static int id = 1;
|
|
|
|
|
2019-02-04 18:26:26 +00:00
|
|
|
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
GrResourceCache* cache = context->priv().getResourceCache();
|
2017-09-21 12:26:08 +00:00
|
|
|
|
|
|
|
int startCacheCount = cache->getResourceCount();
|
|
|
|
|
|
|
|
GrUniqueKey key;
|
2017-09-26 16:49:26 +00:00
|
|
|
if (proxy->getUniqueKey().isValid()) {
|
|
|
|
key = proxy->getUniqueKey();
|
|
|
|
} else {
|
|
|
|
GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
|
|
|
|
++id;
|
|
|
|
|
|
|
|
// Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
|
2018-01-17 18:35:46 +00:00
|
|
|
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
|
2017-09-26 16:49:26 +00:00
|
|
|
}
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, startCacheCount == cache->getResourceCount());
|
|
|
|
|
|
|
|
// setUniqueKey had better stick
|
|
|
|
REPORTER_ASSERT(reporter, key == proxy->getUniqueKey());
|
|
|
|
|
|
|
|
// We just added it, surely we can find it
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxyProvider->findOrCreateProxyByUniqueKey(
|
2019-08-11 23:10:31 +00:00
|
|
|
key, kColorType, kBottomLeft_GrSurfaceOrigin));
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2018-09-10 18:10:19 +00:00
|
|
|
int expectedCacheCount = startCacheCount + (proxy->isInstantiated() ? 0 : 1);
|
|
|
|
|
2017-09-21 12:26:08 +00:00
|
|
|
// Once instantiated, the backing resource should have the same key
|
2018-01-08 18:40:32 +00:00
|
|
|
SkAssertResult(proxy->instantiate(resourceProvider));
|
2019-01-24 17:18:33 +00:00
|
|
|
const GrUniqueKey texKey = proxy->peekSurface()->getUniqueKey();
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, texKey.isValid());
|
|
|
|
REPORTER_ASSERT(reporter, key == texKey);
|
|
|
|
|
2019-01-24 17:18:33 +00:00
|
|
|
// An Unbudgeted-cacheable resource will not get purged when a proxy with the same key is
|
|
|
|
// deleted.
|
|
|
|
bool expectResourceToOutliveProxy = proxy->peekSurface()->resourcePriv().budgetedType() ==
|
|
|
|
GrBudgetedType::kUnbudgetedCacheable;
|
|
|
|
|
|
|
|
// An Unbudgeted-uncacheable resource is never kept alive if it's ref cnt reaches zero even if
|
|
|
|
// it has a key.
|
|
|
|
bool expectDeletingProxyToDeleteResource =
|
|
|
|
proxy->peekSurface()->resourcePriv().budgetedType() ==
|
|
|
|
GrBudgetedType::kUnbudgetedUncacheable;
|
|
|
|
|
2017-09-21 12:26:08 +00:00
|
|
|
// deleting the proxy should delete it from the hash but not the cache
|
|
|
|
proxy = nullptr;
|
2019-01-24 17:18:33 +00:00
|
|
|
if (expectDeletingProxyToDeleteResource) {
|
|
|
|
expectedCacheCount -= 1;
|
|
|
|
}
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2018-09-10 18:10:19 +00:00
|
|
|
REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
|
2017-09-21 12:26:08 +00:00
|
|
|
|
|
|
|
// If the proxy was cached refinding it should bring it back to life
|
2019-08-11 23:10:31 +00:00
|
|
|
proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType,
|
|
|
|
kBottomLeft_GrSurfaceOrigin);
|
2018-09-10 18:10:19 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxy);
|
|
|
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
|
|
|
REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
|
2017-09-21 12:26:08 +00:00
|
|
|
|
|
|
|
// Mega-purging it should remove it from both the hash and the cache
|
|
|
|
proxy = nullptr;
|
|
|
|
cache->purgeAllUnlocked();
|
2019-01-24 17:18:33 +00:00
|
|
|
if (!expectResourceToOutliveProxy) {
|
|
|
|
expectedCacheCount--;
|
|
|
|
}
|
2018-09-10 18:10:19 +00:00
|
|
|
REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2019-01-24 17:18:33 +00:00
|
|
|
// If the texture was deleted then the proxy should no longer be findable. Otherwise, it should
|
|
|
|
// be.
|
2019-08-11 23:10:31 +00:00
|
|
|
proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType,
|
|
|
|
kBottomLeft_GrSurfaceOrigin);
|
2019-01-24 17:18:33 +00:00
|
|
|
REPORTER_ASSERT(reporter, expectResourceToOutliveProxy ? (bool)proxy : !proxy);
|
2018-09-10 18:10:19 +00:00
|
|
|
REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
|
2019-01-24 17:18:33 +00:00
|
|
|
|
|
|
|
if (expectResourceToOutliveProxy) {
|
|
|
|
proxy.reset();
|
2019-02-04 18:26:26 +00:00
|
|
|
GrUniqueKeyInvalidatedMessage msg(texKey, context->priv().contextID());
|
2019-01-24 17:18:33 +00:00
|
|
|
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
|
|
|
|
cache->purgeAsNeeded();
|
|
|
|
expectedCacheCount--;
|
2019-08-11 23:10:31 +00:00
|
|
|
proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kColorType,
|
|
|
|
kBottomLeft_GrSurfaceOrigin);
|
2019-01-24 17:18:33 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy);
|
|
|
|
REPORTER_ASSERT(reporter, expectedCacheCount == cache->getResourceCount());
|
|
|
|
}
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Invalidation test
|
|
|
|
|
|
|
|
// Test if invalidating unique ids operates as expected for texture proxies.
|
|
|
|
static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) {
|
|
|
|
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
GrResourceCache* cache = context->priv().getResourceCache();
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
|
|
|
|
sk_sp<SkImage> rasterImg;
|
|
|
|
|
|
|
|
{
|
|
|
|
SkImageInfo ii = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
|
|
|
|
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocPixels(ii);
|
|
|
|
|
|
|
|
rasterImg = SkImage::MakeFromBitmap(bm);
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
}
|
|
|
|
|
2019-08-14 17:19:04 +00:00
|
|
|
sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(context);
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
|
|
|
|
|
|
|
|
rasterImg = nullptr; // this invalidates the uniqueKey
|
|
|
|
|
|
|
|
// this forces the cache to respond to the inval msg
|
|
|
|
int maxNum;
|
|
|
|
size_t maxBytes;
|
|
|
|
context->getResourceCacheLimits(&maxNum, &maxBytes);
|
|
|
|
context->setResourceCacheLimits(maxNum-1, maxBytes);
|
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
|
|
|
|
|
|
|
|
textureImg = nullptr;
|
2019-02-06 20:12:53 +00:00
|
|
|
context->priv().testingOnly_purgeAllUnlockedResources();
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
}
|
|
|
|
|
2017-09-27 17:11:16 +00:00
|
|
|
// Test if invalidating unique ids prior to instantiating operates as expected
|
|
|
|
static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) {
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
|
|
|
GrResourceCache* cache = context->priv().getResourceCache();
|
2017-09-27 17:11:16 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
|
|
|
|
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
|
|
|
|
GrUniqueKey key;
|
|
|
|
GrUniqueKey::Builder builder(&key, d, 1, nullptr);
|
|
|
|
builder[0] = 0;
|
|
|
|
builder.finish();
|
|
|
|
|
|
|
|
// Create proxy, assign unique key
|
2018-11-16 20:43:41 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
|
|
|
|
SkBackingFit::kExact);
|
2018-01-17 18:35:46 +00:00
|
|
|
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
|
2017-09-27 17:11:16 +00:00
|
|
|
|
|
|
|
// Send an invalidation message, which will be sitting in the cache's inbox
|
2018-07-11 19:58:57 +00:00
|
|
|
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
|
2019-02-04 18:26:26 +00:00
|
|
|
GrUniqueKeyInvalidatedMessage(key, context->priv().contextID()));
|
2017-09-27 17:11:16 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-27 17:11:16 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
|
|
|
|
// Instantiate the proxy. This will trigger the message to be processed, so the resulting
|
|
|
|
// texture should *not* have the unique key on it!
|
2018-01-08 18:40:32 +00:00
|
|
|
SkAssertResult(proxy->instantiate(resourceProvider));
|
2017-09-27 17:11:16 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
|
2018-07-31 21:25:29 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy->peekTexture()->getUniqueKey().isValid());
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-27 17:11:16 +00:00
|
|
|
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
|
|
|
|
|
|
|
|
proxy = nullptr;
|
2019-02-06 20:12:53 +00:00
|
|
|
context->priv().testingOnly_purgeAllUnlockedResources();
|
2017-09-27 17:11:16 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-27 17:11:16 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
}
|
|
|
|
|
2017-09-21 12:26:08 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
|
|
|
|
GrContext* context = ctxInfo.grContext();
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
|
|
GrResourceCache* cache = context->priv().getResourceCache();
|
2017-09-21 12:26:08 +00:00
|
|
|
|
2018-01-08 18:40:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
|
|
|
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
2017-09-26 16:49:26 +00:00
|
|
|
for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
|
2017-09-21 12:26:08 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
2018-11-16 20:43:41 +00:00
|
|
|
basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
|
|
|
sk_sp<GrTexture> backingTex;
|
|
|
|
sk_sp<GrTextureProxy> proxy = create_wrapped_backend(context, fit, &backingTex);
|
2018-09-10 18:10:19 +00:00
|
|
|
basic_test(context, reporter, std::move(proxy));
|
2017-09-21 12:26:08 +00:00
|
|
|
|
|
|
|
backingTex = nullptr;
|
|
|
|
cache->purgeAllUnlocked();
|
|
|
|
}
|
|
|
|
|
|
|
|
invalidation_test(context, reporter);
|
2017-10-04 12:42:28 +00:00
|
|
|
invalidation_and_instantiation_test(context, reporter);
|
2017-09-21 12:26:08 +00:00
|
|
|
}
|