| 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 "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
| 10 #include "ui/compositor/compositor_switches.h" | 10 #include "ui/compositor/compositor_switches.h" |
| 11 #include "ui/compositor/test/default_context_factory.h" | 11 #include "ui/compositor/test/default_context_factory.h" |
| 12 #include "ui/compositor/test/test_context_factory.h" | 12 #include "ui/compositor/test/test_context_factory.h" |
| 13 #include "ui/gl/gl_implementation.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 static ContextFactory* g_implicit_factory = NULL; | 17 static ContextFactory* g_implicit_factory = NULL; |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 void InitializeContextFactoryForTests(bool allow_test_contexts) { | 20 void InitializeContextFactoryForTests(bool allow_test_contexts) { |
| 20 DCHECK(!g_implicit_factory) << | 21 DCHECK(!g_implicit_factory) << |
| 21 "ContextFactory for tests already initialized."; | 22 "ContextFactory for tests already initialized."; |
| 22 | 23 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 if (base::SysInfo::IsRunningOnChromeOS()) | 34 if (base::SysInfo::IsRunningOnChromeOS()) |
| 34 use_test_contexts = false; | 35 use_test_contexts = false; |
| 35 #endif | 36 #endif |
| 36 | 37 |
| 37 if (!allow_test_contexts) | 38 if (!allow_test_contexts) |
| 38 use_test_contexts = false; | 39 use_test_contexts = false; |
| 39 | 40 |
| 40 if (use_test_contexts) { | 41 if (use_test_contexts) { |
| 41 g_implicit_factory = new ui::TestContextFactory; | 42 g_implicit_factory = new ui::TestContextFactory; |
| 42 } else { | 43 } else { |
| 44 DCHECK_NE(gfx::kGLImplementationNone, gfx::GetGLImplementation()); |
| 43 DVLOG(1) << "Using DefaultContextFactory"; | 45 DVLOG(1) << "Using DefaultContextFactory"; |
| 44 scoped_ptr<ui::DefaultContextFactory> instance( | 46 g_implicit_factory = new ui::DefaultContextFactory(); |
| 45 new ui::DefaultContextFactory()); | |
| 46 if (instance->Initialize()) | |
| 47 g_implicit_factory = instance.release(); | |
| 48 } | 47 } |
| 49 ContextFactory::SetInstance(g_implicit_factory); | 48 ContextFactory::SetInstance(g_implicit_factory); |
| 50 } | 49 } |
| 51 | 50 |
| 52 void TerminateContextFactoryForTests() { | 51 void TerminateContextFactoryForTests() { |
| 53 ContextFactory::SetInstance(NULL); | 52 ContextFactory::SetInstance(NULL); |
| 54 delete g_implicit_factory; | 53 delete g_implicit_factory; |
| 55 g_implicit_factory = NULL; | 54 g_implicit_factory = NULL; |
| 56 } | 55 } |
| 57 | 56 |
| 58 } // namespace ui | 57 } // namespace ui |
| OLD | NEW |