aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Test.cpp
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-29 15:28:45 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-29 15:28:45 +0000
commit0945bde5999da38b2de4a0998225a25901c4e429 (patch)
tree8ebbb4b37fc9d34e03101808372083bee2db868d /tests/Test.cpp
parent5afbbc47df9ede9031348857ab512836ba580f31 (diff)
Fix test app to ensure that we destroy our GPU resources.
The problem arises on devices like the Nexus 10 where we allow the destruction of resources using the destructor of a static variable. However, we have no guarentee that the GPU driver has not already cleaned up it's resources prior to our static destructor. Review URL: https://codereview.appspot.com/6851124 git-svn-id: http://skia.googlecode.com/svn/trunk@6599 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/Test.cpp')
-rw-r--r--tests/Test.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 07107bc934..bebb351253 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -83,15 +83,24 @@ bool Test::run() {
///////////////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+ static SkAutoTUnref<SkNativeGLContext> gGLContext;
+ static SkAutoTUnref<GrContext> gGrContext;
+#endif
-GrContext* GpuTest::GetContext() {
+void GpuTest::DestroyContext() {
#if SK_SUPPORT_GPU
// preserve this order, we want gGrContext destroyed after gEGLContext
- static SkTLazy<SkNativeGLContext> gGLContext;
- static SkAutoTUnref<GrContext> gGrContext;
+ gGLContext.reset(NULL);
+ gGrContext.reset(NULL);
+#endif
+}
+
+GrContext* GpuTest::GetContext() {
+#if SK_SUPPORT_GPU
if (NULL == gGrContext.get()) {
- gGLContext.init();
+ gGLContext.reset(new SkNativeGLContext());
if (gGLContext.get()->init(800, 600)) {
GrBackendContext ctx = reinterpret_cast<GrBackendContext>(gGLContext.get()->gl());
gGrContext.reset(GrContext::Create(kOpenGL_GrBackend, ctx));