| OLD | NEW |
| 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.h" | 11 #include "ui/compositor/compositor_setup.h" |
| 12 #include "ui/compositor/compositor_switches.h" | |
| 13 | |
| 14 #if defined(OS_CHROMEOS) | |
| 15 #include "base/chromeos/chromeos_version.h" | |
| 16 #endif | |
| 17 | 12 |
| 18 namespace content { | 13 namespace content { |
| 19 | 14 |
| 20 namespace { | 15 namespace { |
| 21 ImageTransportFactory* g_factory; | 16 ImageTransportFactory* g_factory; |
| 22 } | 17 } |
| 23 | 18 |
| 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 | |
| 45 // static | 19 // static |
| 46 void ImageTransportFactory::Initialize() { | 20 void ImageTransportFactory::Initialize() { |
| 47 if (UseTestContextAndTransportFactory()) { | 21 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 48 g_factory = | 22 if (command_line->HasSwitch(switches::kTestCompositor)) { |
| 49 new NoTransportImageTransportFactory(new ui::TestContextFactory); | 23 ui::SetupTestCompositor(); |
| 24 } |
| 25 if (ui::IsTestCompositorEnabled()) { |
| 26 g_factory = new NoTransportImageTransportFactory( |
| 27 new ui::TestContextFactory); |
| 50 } else { | 28 } else { |
| 51 g_factory = new GpuProcessTransportFactory; | 29 g_factory = new GpuProcessTransportFactory; |
| 52 } | 30 } |
| 53 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); | 31 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); |
| 54 } | 32 } |
| 55 | 33 |
| 56 // static | 34 // static |
| 57 void ImageTransportFactory::Terminate() { | 35 void ImageTransportFactory::Terminate() { |
| 58 ui::ContextFactory::SetInstance(NULL); | 36 ui::ContextFactory::SetInstance(NULL); |
| 59 delete g_factory; | 37 delete g_factory; |
| 60 g_factory = NULL; | 38 g_factory = NULL; |
| 61 } | 39 } |
| 62 | 40 |
| 63 // static | 41 // static |
| 64 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 42 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
| 65 return g_factory; | 43 return g_factory; |
| 66 } | 44 } |
| 67 | 45 |
| 68 } // namespace content | 46 } // namespace content |
| OLD | NEW |