aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LazyProxyTest.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-01-16 16:14:41 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-17 14:58:26 +0000
commit94a6ce84ece51ff1c46c698753716f3f47585742 (patch)
tree6e8354476a3f3cc1a32906aae553813371af1d35 /tests/LazyProxyTest.cpp
parent4e6cf91b7e6f7908d941275dc56c829143345402 (diff)
Add ability for lazy proxy callback to free captured resources
This will be needed for DDLs that get recorded, but then deleted before the proxies actually get instantiated. Bug: skia: Change-Id: I745366fc7a7edbcd43bc617220d3d4997baa8319 Reviewed-on: https://skia-review.googlesource.com/95101 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests/LazyProxyTest.cpp')
-rw-r--r--tests/LazyProxyTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index a55593134d..1fe4fc4cb0 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -15,6 +15,7 @@
#include "GrRenderTargetContext.h"
#include "GrRenderTargetContextPriv.h"
#include "GrSurfaceProxy.h"
+#include "GrSurfaceProxyPriv.h"
#include "GrTexture.h"
#include "GrTextureProxy.h"
#include "GrTextureProxyPriv.h"
@@ -187,4 +188,40 @@ DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
}
}
+DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) {
+ GrMockOptions mockOptions;
+ sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
+
+ GrSurfaceDesc desc;
+ desc.fWidth = 16;
+ desc.fHeight = 16;
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+
+ for (bool doInstantiate : {true, false}) {
+ int testCount = 0;
+ int* testCountPtr = &testCount;
+ sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeLazy(
+ [testCountPtr](GrResourceProvider* resourceProvider, GrSurfaceOrigin* outOrigin) {
+ if (!resourceProvider) {
+ *testCountPtr = -1;
+ return sk_sp<GrTexture>();
+ }
+ *testCountPtr = 1;
+ return sk_sp<GrTexture>();
+ }, desc, GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kNo);
+
+ REPORTER_ASSERT(reporter, 0 == testCount);
+
+ 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);
+ }
+ }
+}
+
#endif