aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LazyProxyTest.cpp
diff options
context:
space:
mode:
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