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/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
| 10 #include "components/display_compositor/display_compositor.h" |
10 #include "ui/compositor/compositor.h" | 11 #include "ui/compositor/compositor.h" |
11 #include "ui/compositor/compositor_switches.h" | 12 #include "ui/compositor/compositor_switches.h" |
12 #include "ui/compositor/test/in_process_context_factory.h" | 13 #include "ui/compositor/test/in_process_context_factory.h" |
13 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 static cc::SurfaceManager* g_surface_manager = nullptr; | 18 static display_compositor::DisplayCompositor* g_display_compositor = nullptr; |
18 static ui::InProcessContextFactory* g_implicit_factory = NULL; | 19 static ui::InProcessContextFactory* g_implicit_factory = NULL; |
19 static gl::DisableNullDrawGLBindings* g_disable_null_draw = NULL; | 20 static gl::DisableNullDrawGLBindings* g_disable_null_draw = NULL; |
20 | 21 |
21 } // namespace | 22 } // namespace |
22 | 23 |
23 namespace ui { | 24 namespace ui { |
24 | 25 |
25 // static | 26 // static |
26 void InitializeContextFactoryForTests( | 27 void InitializeContextFactoryForTests( |
27 bool enable_pixel_output, | 28 bool enable_pixel_output, |
28 ui::ContextFactory** context_factory, | 29 ui::ContextFactory** context_factory, |
29 ui::ContextFactoryPrivate** context_factory_private) { | 30 ui::ContextFactoryPrivate** context_factory_private) { |
30 DCHECK(!g_implicit_factory) << | 31 DCHECK(!g_implicit_factory) << |
31 "ContextFactory for tests already initialized."; | 32 "ContextFactory for tests already initialized."; |
32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 33 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
33 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) | 34 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) |
34 enable_pixel_output = true; | 35 enable_pixel_output = true; |
35 if (enable_pixel_output) | 36 if (enable_pixel_output) |
36 g_disable_null_draw = new gl::DisableNullDrawGLBindings; | 37 g_disable_null_draw = new gl::DisableNullDrawGLBindings; |
37 bool context_factory_for_test = true; | 38 bool context_factory_for_test = true; |
38 g_surface_manager = new cc::SurfaceManager; | 39 g_display_compositor = new display_compositor::DisplayCompositor(); |
39 g_implicit_factory = | 40 g_implicit_factory = new InProcessContextFactory(context_factory_for_test, |
40 new InProcessContextFactory(context_factory_for_test, g_surface_manager); | 41 g_display_compositor); |
41 *context_factory = g_implicit_factory; | 42 *context_factory = g_implicit_factory; |
42 *context_factory_private = g_implicit_factory; | 43 *context_factory_private = g_implicit_factory; |
43 } | 44 } |
44 | 45 |
45 void TerminateContextFactoryForTests() { | 46 void TerminateContextFactoryForTests() { |
46 if (g_implicit_factory) { | 47 if (g_implicit_factory) { |
47 g_implicit_factory->SendOnLostResources(); | 48 g_implicit_factory->SendOnLostResources(); |
48 delete g_implicit_factory; | 49 delete g_implicit_factory; |
49 g_implicit_factory = NULL; | 50 g_implicit_factory = NULL; |
50 } | 51 } |
51 delete g_surface_manager; | 52 delete g_display_compositor; |
52 g_surface_manager = nullptr; | 53 g_display_compositor = nullptr; |
53 delete g_disable_null_draw; | 54 delete g_disable_null_draw; |
54 g_disable_null_draw = NULL; | 55 g_disable_null_draw = NULL; |
55 } | 56 } |
56 | 57 |
57 } // namespace ui | 58 } // namespace ui |
OLD | NEW |