Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/compositor/test/context_factories_for_test.cc

Issue 135213003: Ensure GL initialization only happens once, and provide common init path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initgl: compile3 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/compositor/test/default_context_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/compositor/test/default_context_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698