Make GPU unit tests use GrContexts of different GL types.
Review URL: https://codereview.appspot.com/7281046
git-svn-id: http://skia.googlecode.com/svn/trunk@7540 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/Test.cpp b/tests/Test.cpp
index de5e793..e0b997a 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -84,33 +84,20 @@
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
- static SkAutoTUnref<SkNativeGLContext> gGLContext;
- static SkAutoTUnref<GrContext> gGrContext;
+#include "GrContextFactory.h"
+GrContextFactory gGrContextFactory;
#endif
-void GpuTest::DestroyContext() {
+GrContextFactory* GpuTest::GetGrContextFactory() {
#if SK_SUPPORT_GPU
- // preserve this order, we want gGrContext destroyed before gGLContext
- gGrContext.reset(NULL);
- gGLContext.reset(NULL);
+ return &gGrContextFactory;
+#else
+ return NULL;
#endif
}
-
-GrContext* GpuTest::GetContext() {
+void GpuTest::DestroyContexts() {
#if SK_SUPPORT_GPU
- if (NULL == gGrContext.get()) {
- 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));
- }
- }
- if (gGLContext.get()) {
- gGLContext.get()->makeCurrent();
- }
- return gGrContext.get();
-#else
- return NULL;
+ gGrContextFactory.destroyContexts();
#endif
}