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

Side by Side Diff: content/browser/aura/image_transport_factory.cc

Issue 21052007: aura: Clean up compositor initialization/destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanupcompositor: UseRealGLBindings for CompositingRWHVBrowserTests on win_rel Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/aura/image_transport_factory.h" 5 #include "content/browser/aura/image_transport_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/aura/gpu_process_transport_factory.h" 8 #include "content/browser/aura/gpu_process_transport_factory.h"
9 #include "content/browser/aura/no_transport_image_transport_factory.h" 9 #include "content/browser/aura/no_transport_image_transport_factory.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "ui/compositor/compositor_setup.h" 11 #include "ui/compositor/compositor.h"
12 #include "ui/compositor/compositor_switches.h"
13
14 #if defined(OS_CHROMEOS)
15 #include "base/chromeos/chromeos_version.h"
16 #endif
12 17
13 namespace content { 18 namespace content {
14 19
15 namespace { 20 namespace {
16 ImageTransportFactory* g_factory; 21 ImageTransportFactory* g_factory;
17 } 22 }
18 23
24
25 static bool UseTestContextAndTransportFactory() {
26 #if defined(OS_CHROMEOS)
27 // If the test is running on the chromeos envrionment (such as
28 // device or vm bots), always use real contexts.
29 if (base::chromeos::IsRunningOnChromeOS())
30 return false;
31 #endif
32
33 // Only used if the enable command line flag is used.
34 CommandLine* command_line = CommandLine::ForCurrentProcess();
35 if (!command_line->HasSwitch(switches::kTestCompositor))
36 return false;
37
38 // The disable command line flag preempts the enable flag.
39 if (!command_line->HasSwitch(switches::kDisableTestCompositor))
40 return true;
41
42 return false;
43 }
44
19 // static 45 // static
20 void ImageTransportFactory::Initialize() { 46 void ImageTransportFactory::Initialize() {
21 CommandLine* command_line = CommandLine::ForCurrentProcess(); 47 if (UseTestContextAndTransportFactory()) {
22 if (command_line->HasSwitch(switches::kTestCompositor)) { 48 g_factory =
23 ui::SetupTestCompositor(); 49 new NoTransportImageTransportFactory(new ui::TestContextFactory);
24 }
25 if (ui::IsTestCompositorEnabled()) {
26 g_factory = new NoTransportImageTransportFactory(
27 new ui::TestContextFactory);
28 } else { 50 } else {
29 g_factory = new GpuProcessTransportFactory; 51 g_factory = new GpuProcessTransportFactory;
30 } 52 }
31 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); 53 ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
32 } 54 }
33 55
34 // static 56 // static
35 void ImageTransportFactory::Terminate() { 57 void ImageTransportFactory::Terminate() {
36 ui::ContextFactory::SetInstance(NULL); 58 ui::ContextFactory::SetInstance(NULL);
37 delete g_factory; 59 delete g_factory;
38 g_factory = NULL; 60 g_factory = NULL;
39 } 61 }
40 62
41 // static 63 // static
42 ImageTransportFactory* ImageTransportFactory::GetInstance() { 64 ImageTransportFactory* ImageTransportFactory::GetInstance() {
43 return g_factory; 65 return g_factory;
44 } 66 }
45 67
46 } // namespace content 68 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698