| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/image_transport_factory.h" | 5 #include "content/browser/compositor/image_transport_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/compositor/gpu_process_transport_factory.h" | 8 #include "content/browser/compositor/gpu_process_transport_factory.h" |
| 9 #include "content/browser/compositor/no_transport_image_transport_factory.h" | 9 #include "content/browser/compositor/no_transport_image_transport_factory.h" |
| 10 #include "content/common/host_shared_bitmap_manager.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/gl/gl_implementation.h" | 13 #include "ui/gl/gl_implementation.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 ImageTransportFactory* g_factory = NULL; | 18 ImageTransportFactory* g_factory = NULL; |
| 18 bool g_initialized_for_unit_tests = false; | 19 bool g_initialized_for_unit_tests = false; |
| 19 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; | 20 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // static | 23 // static |
| 23 void ImageTransportFactory::Initialize() { | 24 void ImageTransportFactory::Initialize() { |
| 24 DCHECK(!g_factory || g_initialized_for_unit_tests); | 25 DCHECK(!g_factory || g_initialized_for_unit_tests); |
| 25 if (g_initialized_for_unit_tests) | 26 if (g_initialized_for_unit_tests) |
| 26 return; | 27 return; |
| 27 g_factory = new GpuProcessTransportFactory; | 28 g_factory = new GpuProcessTransportFactory; |
| 28 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); | 29 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); |
| 30 ui::Compositor::SetSharedBitmapManager(HostSharedBitmapManager::current()); |
| 29 } | 31 } |
| 30 | 32 |
| 31 void ImageTransportFactory::InitializeForUnitTests( | 33 void ImageTransportFactory::InitializeForUnitTests( |
| 32 scoped_ptr<ui::ContextFactory> test_factory) { | 34 scoped_ptr<ui::ContextFactory> test_factory) { |
| 33 DCHECK(!g_factory); | 35 DCHECK(!g_factory); |
| 34 DCHECK(!g_initialized_for_unit_tests); | 36 DCHECK(!g_initialized_for_unit_tests); |
| 35 g_initialized_for_unit_tests = true; | 37 g_initialized_for_unit_tests = true; |
| 36 | 38 |
| 37 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 39 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 38 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) | 40 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 51 g_disable_null_draw = NULL; | 53 g_disable_null_draw = NULL; |
| 52 g_initialized_for_unit_tests = false; | 54 g_initialized_for_unit_tests = false; |
| 53 } | 55 } |
| 54 | 56 |
| 55 // static | 57 // static |
| 56 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 58 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
| 57 return g_factory; | 59 return g_factory; |
| 58 } | 60 } |
| 59 | 61 |
| 60 } // namespace content | 62 } // namespace content |
| OLD | NEW |