aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
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
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')
-rw-r--r--tests/Test.cpp17
-rw-r--r--tests/Test.h1
-rw-r--r--tests/skia_test.cpp1
3 files changed, 15 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));
diff --git a/tests/Test.h b/tests/Test.h
index f87a7a07b2..2cbd00b594 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -104,6 +104,7 @@ namespace skiatest {
fContext = GetContext();
}
static GrContext* GetContext();
+ static void DestroyContext();
protected:
GrContext* fContext;
private:
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 560abb23d3..a744801ddf 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -186,6 +186,7 @@ int tool_main(int argc, char** argv) {
#endif
SkGraphics::Term();
+ GpuTest::DestroyContext();
return (failCount == 0) ? 0 : 1;
}