OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/compositor/test/context_factories_for_test.h" | 5 #include "ui/compositor/test/context_factories_for_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "cc/test/test_shared_bitmap_manager.h" | |
10 #include "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
11 #include "ui/compositor/compositor_switches.h" | 10 #include "ui/compositor/compositor_switches.h" |
12 #include "ui/compositor/test/in_process_context_factory.h" | 11 #include "ui/compositor/test/in_process_context_factory.h" |
13 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 static ui::ContextFactory* g_implicit_factory = NULL; | 16 static ui::ContextFactory* g_implicit_factory = NULL; |
18 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; | 17 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; |
19 static cc::TestSharedBitmapManager* g_shared_bitmap_manager = NULL; | |
20 | 18 |
21 } // namespace | 19 } // namespace |
22 | 20 |
23 namespace ui { | 21 namespace ui { |
24 | 22 |
25 // static | 23 // static |
26 void InitializeContextFactoryForTests(bool enable_pixel_output) { | 24 void InitializeContextFactoryForTests(bool enable_pixel_output) { |
27 DCHECK(!g_implicit_factory) << | 25 DCHECK(!g_implicit_factory) << |
28 "ContextFactory for tests already initialized."; | 26 "ContextFactory for tests already initialized."; |
29 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 27 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
30 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) | 28 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) |
31 enable_pixel_output = true; | 29 enable_pixel_output = true; |
32 if (enable_pixel_output) | 30 if (enable_pixel_output) |
33 g_disable_null_draw = new gfx::DisableNullDrawGLBindings; | 31 g_disable_null_draw = new gfx::DisableNullDrawGLBindings; |
34 g_implicit_factory = new InProcessContextFactory(); | 32 g_implicit_factory = new InProcessContextFactory(); |
35 ContextFactory::SetInstance(g_implicit_factory); | 33 ContextFactory::SetInstance(g_implicit_factory); |
36 g_shared_bitmap_manager = new cc::TestSharedBitmapManager(); | |
37 Compositor::SetSharedBitmapManager(g_shared_bitmap_manager); | |
38 } | 34 } |
39 | 35 |
40 void TerminateContextFactoryForTests() { | 36 void TerminateContextFactoryForTests() { |
41 ContextFactory::SetInstance(NULL); | 37 ContextFactory::SetInstance(NULL); |
42 delete g_implicit_factory; | 38 delete g_implicit_factory; |
43 g_implicit_factory = NULL; | 39 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; | 40 delete g_disable_null_draw; |
48 g_disable_null_draw = NULL; | 41 g_disable_null_draw = NULL; |
49 } | 42 } |
50 | 43 |
51 } // namespace ui | 44 } // namespace ui |
OLD | NEW |