Index: ui/compositor/test/context_factories_for_test.cc |
diff --git a/ui/compositor/test/context_factories_for_test.cc b/ui/compositor/test/context_factories_for_test.cc |
index 0c452c529e4b2ff56f257b3cfd209530a953557c..63b2d3a2c74099d778ecb8f6cbe82835f717e125 100644 |
--- a/ui/compositor/test/context_factories_for_test.cc |
+++ b/ui/compositor/test/context_factories_for_test.cc |
@@ -12,19 +12,29 @@ |
#include "ui/compositor/test/test_context_factory.h" |
#include "ui/gl/gl_implementation.h" |
-namespace ui { |
+namespace { |
+ |
+static ui::ContextFactory* g_implicit_factory = NULL; |
+static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; |
-static ContextFactory* g_implicit_factory = NULL; |
+} // namespace |
+ |
+namespace ui { |
// static |
void InitializeContextFactoryForTests(bool enable_pixel_output) { |
DCHECK(!g_implicit_factory) << |
"ContextFactory for tests already initialized."; |
+ CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) |
+ enable_pixel_output = true; |
bool use_test_contexts = true; |
+ if (gfx::HasInitializedNullDrawGLBindings()) |
+ use_test_contexts = false; |
+ |
// Always use test contexts unless the disable command line flag is used. |
- CommandLine* command_line = CommandLine::ForCurrentProcess(); |
if (command_line->HasSwitch(switches::kDisableTestCompositor)) |
use_test_contexts = false; |
@@ -43,6 +53,8 @@ void InitializeContextFactoryForTests(bool enable_pixel_output) { |
} else { |
DCHECK_NE(gfx::kGLImplementationNone, gfx::GetGLImplementation()); |
DVLOG(1) << "Using InProcessContextFactory"; |
+ if (enable_pixel_output && gfx::HasInitializedNullDrawGLBindings()) |
+ g_disable_null_draw = new gfx::DisableNullDrawGLBindings; |
g_implicit_factory = new ui::InProcessContextFactory(); |
} |
ContextFactory::SetInstance(g_implicit_factory); |
@@ -52,6 +64,8 @@ void TerminateContextFactoryForTests() { |
ContextFactory::SetInstance(NULL); |
delete g_implicit_factory; |
g_implicit_factory = NULL; |
+ delete g_disable_null_draw; |
+ g_disable_null_draw = NULL; |
} |
} // namespace ui |