aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LazyProxyTest.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-08 15:05:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-08 20:33:40 +0000
commit457469c7a0c879b9d8ff8ed9fabe3f3dcab06097 (patch)
tree92ef5dcb793bbe9406730b1576c51bcc6042b86c /tests/LazyProxyTest.cpp
parent5635631c8887db678e6123c191ae68456b60d2a7 (diff)
Make non-ddl lazy proxys clean-up and delete their callbacks immediately after instanstation.
This makes sure resources are released and free'd as soon as possible if we no longer need them. Bug: skia: Change-Id: Ic216987649c54183f8cbbff90a633860a97754b3 Reviewed-on: https://skia-review.googlesource.com/105721 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/LazyProxyTest.cpp')
-rw-r--r--tests/LazyProxyTest.cpp51
1 files changed, 32 insertions, 19 deletions
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 1994eeb5c9..5a0211d717 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -213,29 +213,42 @@ DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) {
desc.fHeight = kSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ using LazyInstantiationType = GrSurfaceProxy::LazyInstantiationType;
for (bool doInstantiate : {true, false}) {
- int testCount = 0;
- int* testCountPtr = &testCount;
- sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [testCountPtr](GrResourceProvider* resourceProvider, GrSurfaceOrigin* outOrigin) {
- if (!resourceProvider) {
- *testCountPtr = -1;
+ for (auto lazyType : {LazyInstantiationType::kSingleUse,
+ LazyInstantiationType::kMultipleUse}) {
+ int testCount = 0;
+ int* testCountPtr = &testCount;
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
+ [testCountPtr](GrResourceProvider* resourceProvider,
+ GrSurfaceOrigin* /*outOrigin*/) {
+ if (!resourceProvider) {
+ *testCountPtr = -1;
+ return sk_sp<GrTexture>();
+ }
+ *testCountPtr = 1;
return sk_sp<GrTexture>();
- }
- *testCountPtr = 1;
- return sk_sp<GrTexture>();
- }, desc, GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kNo);
+ }, desc, GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kNo);
- REPORTER_ASSERT(reporter, 0 == testCount);
+ proxy->priv().testingOnly_setLazyInstantiationType(lazyType);
- if (doInstantiate) {
- proxy->priv().doLazyInstantiation(ctx->contextPriv().resourceProvider());
- REPORTER_ASSERT(reporter, 1 == testCount);
- proxy.reset();
- REPORTER_ASSERT(reporter, -1 == testCount);
- } else {
- proxy.reset();
- REPORTER_ASSERT(reporter, -1 == testCount);
+ REPORTER_ASSERT(reporter, 0 == testCount);
+
+ if (doInstantiate) {
+ proxy->priv().doLazyInstantiation(ctx->contextPriv().resourceProvider());
+ if (LazyInstantiationType::kSingleUse == proxy->priv().lazyInstantiationType()) {
+ // In SingleUse we will call the cleanup and delete the callback in the
+ // doLazyInstantiationCall.
+ REPORTER_ASSERT(reporter, -1 == testCount);
+ } else {
+ REPORTER_ASSERT(reporter, 1 == testCount);
+ }
+ proxy.reset();
+ REPORTER_ASSERT(reporter, -1 == testCount);
+ } else {
+ proxy.reset();
+ REPORTER_ASSERT(reporter, -1 == testCount);
+ }
}
}
}