1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/compositor/test/context_factories_for_test.h"
7 #include "base/command_line.h"
8 #include "base/sys_info.h"
9 #include "ui/compositor/compositor.h"
10 #include "ui/compositor/compositor_switches.h"
11 #include "ui/compositor/test/in_process_context_factory.h"
12 #include "ui/gl/gl_implementation.h"
16 static ui::ContextFactory
* g_implicit_factory
= NULL
;
17 static gfx::DisableNullDrawGLBindings
* g_disable_null_draw
= NULL
;
24 ui::ContextFactory
* InitializeContextFactoryForTests(bool enable_pixel_output
) {
25 DCHECK(!g_implicit_factory
) <<
26 "ContextFactory for tests already initialized.";
27 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
28 if (command_line
->HasSwitch(switches::kEnablePixelOutputInTests
))
29 enable_pixel_output
= true;
30 if (enable_pixel_output
)
31 g_disable_null_draw
= new gfx::DisableNullDrawGLBindings
;
32 bool context_factory_for_test
= true;
34 new InProcessContextFactory(context_factory_for_test
, nullptr);
35 return g_implicit_factory
;
38 void TerminateContextFactoryForTests() {
39 delete g_implicit_factory
;
40 g_implicit_factory
= NULL
;
41 delete g_disable_null_draw
;
42 g_disable_null_draw
= NULL
;