Correct comment added on r267371
[chromium-blink-merge.git] / ui / compositor / test / context_factories_for_test.cc
blob6e842dd830d5f867e6c2766b36a590deeea9a669
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 "cc/test/test_shared_bitmap_manager.h"
10 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/compositor_switches.h"
12 #include "ui/compositor/test/in_process_context_factory.h"
13 #include "ui/gl/gl_implementation.h"
15 namespace {
17 static ui::ContextFactory* g_implicit_factory = NULL;
18 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;
19 static cc::TestSharedBitmapManager* g_shared_bitmap_manager = NULL;
21 } // namespace
23 namespace ui {
25 // static
26 void InitializeContextFactoryForTests(bool enable_pixel_output) {
27 DCHECK(!g_implicit_factory) <<
28 "ContextFactory for tests already initialized.";
29 CommandLine* command_line = CommandLine::ForCurrentProcess();
30 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests))
31 enable_pixel_output = true;
32 if (enable_pixel_output)
33 g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
34 g_implicit_factory = new InProcessContextFactory();
35 ContextFactory::SetInstance(g_implicit_factory);
36 g_shared_bitmap_manager = new cc::TestSharedBitmapManager();
37 Compositor::SetSharedBitmapManager(g_shared_bitmap_manager);
40 void TerminateContextFactoryForTests() {
41 ContextFactory::SetInstance(NULL);
42 delete g_implicit_factory;
43 g_implicit_factory = NULL;
44 Compositor::SetSharedBitmapManager(NULL);
45 delete g_shared_bitmap_manager;
46 g_shared_bitmap_manager = NULL;
47 delete g_disable_null_draw;
48 g_disable_null_draw = NULL;
51 } // namespace ui