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/renderer_host/image_transport_factory.h" | 5 #include "content/browser/renderer_host/image_transport_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "cc/output_surface.h" | 16 #include "cc/output_surface.h" |
17 #include "cc/output_surface_client.h" | 17 #include "cc/output_surface_client.h" |
18 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 18 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
19 #include "content/browser/gpu/gpu_data_manager_impl.h" | 19 #include "content/browser/gpu/gpu_data_manager_impl.h" |
20 #include "content/browser/gpu/gpu_process_host.h" | 20 #include "content/browser/gpu/gpu_process_host.h" |
21 #include "content/browser/gpu/gpu_surface_tracker.h" | 21 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 22 #include "content/browser/renderer_host/software_output_device.h" |
22 #include "content/common/gpu/client/context_provider_command_buffer.h" | 23 #include "content/common/gpu/client/context_provider_command_buffer.h" |
23 #include "content/common/gpu/client/gl_helper.h" | 24 #include "content/common/gpu/client/gl_helper.h" |
24 #include "content/common/gpu/client/gpu_channel_host.h" | 25 #include "content/common/gpu/client/gpu_channel_host.h" |
25 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 26 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
26 #include "content/common/gpu/gpu_messages.h" | 27 #include "content/common/gpu/gpu_messages.h" |
27 #include "content/common/gpu/gpu_process_launch_causes.h" | 28 #include "content/common/gpu/gpu_process_launch_causes.h" |
28 #include "content/common/webkitplatformsupport_impl.h" | 29 #include "content/common/webkitplatformsupport_impl.h" |
29 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
30 #include "gpu/GLES2/gl2extchromium.h" | 31 #include "gpu/GLES2/gl2extchromium.h" |
31 #include "gpu/ipc/command_buffer_proxy.h" | 32 #include "gpu/ipc/command_buffer_proxy.h" |
32 #include "third_party/khronos/GLES2/gl2.h" | 33 #include "third_party/khronos/GLES2/gl2.h" |
33 #include "third_party/khronos/GLES2/gl2ext.h" | 34 #include "third_party/khronos/GLES2/gl2ext.h" |
34 #include "ui/compositor/compositor.h" | 35 #include "ui/compositor/compositor.h" |
35 #include "ui/compositor/compositor_setup.h" | 36 #include "ui/compositor/compositor_setup.h" |
| 37 #include "ui/compositor/compositor_switches.h" |
36 #include "ui/compositor/test_web_graphics_context_3d.h" | 38 #include "ui/compositor/test_web_graphics_context_3d.h" |
37 #include "ui/gfx/native_widget_types.h" | 39 #include "ui/gfx/native_widget_types.h" |
38 #include "ui/gfx/size.h" | 40 #include "ui/gfx/size.h" |
39 | 41 |
40 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
41 #include "ui/surface/accelerated_surface_win.h" | 43 #include "ui/surface/accelerated_surface_win.h" |
42 #endif | 44 #endif |
43 | 45 |
44 namespace content { | 46 namespace content { |
45 namespace { | 47 namespace { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // Note: previous line destroyed this. Don't access members from now on. | 664 // Note: previous line destroyed this. Don't access members from now on. |
663 } | 665 } |
664 | 666 |
665 WebKit::WebGraphicsContext3D* CreateTestContext() { | 667 WebKit::WebGraphicsContext3D* CreateTestContext() { |
666 ui::TestWebGraphicsContext3D* test_context = | 668 ui::TestWebGraphicsContext3D* test_context = |
667 new ui::TestWebGraphicsContext3D(); | 669 new ui::TestWebGraphicsContext3D(); |
668 test_context->Initialize(); | 670 test_context->Initialize(); |
669 return test_context; | 671 return test_context; |
670 } | 672 } |
671 | 673 |
| 674 class SoftwareTransportFactory : public DefaultTransportFactory { |
| 675 public: |
| 676 cc::OutputSurface* CreateOutputSurface(ui::Compositor* compositor) { |
| 677 scoped_ptr<SoftwareOutputDevice> software_device( |
| 678 new SoftwareOutputDevice(compositor)); |
| 679 return new cc::OutputSurface( |
| 680 software_device.PassAs<cc::SoftwareOutputDevice>()); |
| 681 } |
| 682 }; |
| 683 |
672 } // anonymous namespace | 684 } // anonymous namespace |
673 | 685 |
674 // static | 686 // static |
675 void ImageTransportFactory::Initialize() { | 687 void ImageTransportFactory::Initialize() { |
676 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 688 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
677 if (command_line->HasSwitch(switches::kTestCompositor)) { | 689 if (command_line->HasSwitch(switches::kTestCompositor)) { |
678 ui::SetupTestCompositor(); | 690 ui::SetupTestCompositor(); |
679 } | 691 } |
680 if (ui::IsTestCompositorEnabled()) | 692 if (ui::IsTestCompositorEnabled()) { |
681 g_factory = new DefaultTransportFactory(); | 693 g_factory = new DefaultTransportFactory(); |
682 else | 694 } else if (command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) { |
683 g_factory = new GpuProcessTransportFactory(); | 695 g_factory = new SoftwareTransportFactory; |
| 696 } else { |
| 697 g_factory = new GpuProcessTransportFactory; |
| 698 } |
684 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); | 699 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); |
685 } | 700 } |
686 | 701 |
687 // static | 702 // static |
688 void ImageTransportFactory::Terminate() { | 703 void ImageTransportFactory::Terminate() { |
689 ui::ContextFactory::SetInstance(NULL); | 704 ui::ContextFactory::SetInstance(NULL); |
690 delete g_factory; | 705 delete g_factory; |
691 g_factory = NULL; | 706 g_factory = NULL; |
692 } | 707 } |
693 | 708 |
694 // static | 709 // static |
695 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 710 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
696 return g_factory; | 711 return g_factory; |
697 } | 712 } |
698 | 713 |
699 } // namespace content | 714 } // namespace content |
OLD | NEW |