diff options
Diffstat (limited to 'tests/Test.cpp')
-rw-r--r-- | tests/Test.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/Test.cpp b/tests/Test.cpp index 2bcd3e0..1c3b691 100644 --- a/tests/Test.cpp +++ b/tests/Test.cpp @@ -1,5 +1,16 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ #include "Test.h" +#include "GrContext.h" +#include "SkNativeGLContext.h" +#include "SkTLazy.h" + using namespace skiatest; Reporter::Reporter() { @@ -63,3 +74,24 @@ bool Test::run() { return fReporter->getCurrSuccess(); } +/////////////////////////////////////////////////////////////////////////////// + + +GrContext* GpuTest::GetContext() { + // preserve this order, we want gGrContext destroyed after gEGLContext + static SkTLazy<SkNativeGLContext> gGLContext; + static SkAutoTUnref<GrContext> gGrContext; + + if (NULL == gGrContext.get()) { + gGLContext.init(); + if (gGLContext.get()->init(800, 600)) { + GrPlatform3DContext ctx = reinterpret_cast<GrPlatform3DContext>(gGLContext.get()->gl()); + gGrContext.reset(GrContext::Create(kOpenGL_Shaders_GrEngine, ctx)); + } + } + if (gGLContext.get()) { + gGLContext.get()->makeCurrent(); + } + return gGrContext.get(); +} + |