aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ResourceCacheTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-03-10 13:59:15 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-10 19:38:37 +0000
commitcccda60aca592d2320d79e2871e057778b2688ab (patch)
treecd61c576ec6ae1e85a08ab36d27392eca1d098bb /tests/ResourceCacheTest.cpp
parentdc175eaab60f7399fd3d232d2911511be187c436 (diff)
Treat cross context images as Ganesh-created resources
Always create them budgeted, and register them with the cache (not as wrapped resources). BUG=skia: Change-Id: Id18ecf6e9e512db4be21b4f2bfd8e8c060bbe805 Reviewed-on: https://skia-review.googlesource.com/9497 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/ResourceCacheTest.cpp')
-rw-r--r--tests/ResourceCacheTest.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index a2064ae557..24545369cb 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -208,12 +208,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
return;
}
- GrBackendObject texHandles[2];
+ GrBackendObject texHandles[3];
static const int kW = 100;
static const int kH = 100;
texHandles[0] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
texHandles[1] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
+ texHandles[2] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
context->resetContext();
@@ -230,26 +231,40 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
sk_sp<GrTexture> adopted(context->resourceProvider()->wrapBackendTexture(
desc, kAdopt_GrWrapOwnership));
- REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
- if (!borrowed || !adopted) {
+ desc.fTextureHandle = texHandles[2];
+ sk_sp<GrTexture> adoptedAndCached(context->resourceProvider()->wrapBackendTexture(
+ desc, kAdoptAndCache_GrWrapOwnership));
+
+ REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr &&
+ adoptedAndCached != nullptr);
+ if (!borrowed || !adopted || !adoptedAndCached) {
return;
}
borrowed.reset(nullptr);
adopted.reset(nullptr);
+ adoptedAndCached.reset(nullptr);
context->flush();
bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[0]);
bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[1]);
+ bool adoptedAndCachedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[2]);
REPORTER_ASSERT(reporter, borrowedIsAlive);
REPORTER_ASSERT(reporter, !adoptedIsAlive);
+ REPORTER_ASSERT(reporter, adoptedAndCachedIsAlive); // Still alive because it's in the cache
gpu->deleteTestingOnlyBackendTexture(texHandles[0], !borrowedIsAlive);
gpu->deleteTestingOnlyBackendTexture(texHandles[1], !adoptedIsAlive);
+ // We can't delete texHandles[2] - we've given control of the lifetime to the context/cache
context->resetContext();
+
+ // Purge the cache. This should force texHandles[2] to be deleted
+ context->getResourceCache()->purgeAllUnlocked();
+ adoptedAndCachedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[2]);
+ REPORTER_ASSERT(reporter, !adoptedAndCachedIsAlive);
}
class TestResource : public GrGpuResource {