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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "content/common/gpu/gpu_messages.h" | 26 #include "content/common/gpu/gpu_messages.h" |
27 #include "content/common/gpu/gpu_process_launch_causes.h" | 27 #include "content/common/gpu/gpu_process_launch_causes.h" |
28 #include "content/common/webkitplatformsupport_impl.h" | 28 #include "content/common/webkitplatformsupport_impl.h" |
29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
30 #include "gpu/GLES2/gl2extchromium.h" | 30 #include "gpu/GLES2/gl2extchromium.h" |
31 #include "gpu/ipc/command_buffer_proxy.h" | 31 #include "gpu/ipc/command_buffer_proxy.h" |
32 #include "third_party/khronos/GLES2/gl2.h" | 32 #include "third_party/khronos/GLES2/gl2.h" |
33 #include "third_party/khronos/GLES2/gl2ext.h" | 33 #include "third_party/khronos/GLES2/gl2ext.h" |
34 #include "ui/compositor/compositor.h" | 34 #include "ui/compositor/compositor.h" |
35 #include "ui/compositor/compositor_setup.h" | 35 #include "ui/compositor/compositor_setup.h" |
| 36 #include "ui/compositor/compositor_switches.h" |
36 #include "ui/compositor/test_web_graphics_context_3d.h" | 37 #include "ui/compositor/test_web_graphics_context_3d.h" |
37 #include "ui/gfx/native_widget_types.h" | 38 #include "ui/gfx/native_widget_types.h" |
38 #include "ui/gfx/size.h" | 39 #include "ui/gfx/size.h" |
39 | 40 |
40 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 42 #include "content/browser/renderer_host/software_output_device_win.h" |
41 #include "ui/surface/accelerated_surface_win.h" | 43 #include "ui/surface/accelerated_surface_win.h" |
| 44 #elif defined(USE_X11) |
| 45 #include "content/browser/renderer_host/software_output_device_linux.h" |
42 #endif | 46 #endif |
43 | 47 |
44 namespace content { | 48 namespace content { |
45 namespace { | 49 namespace { |
46 | 50 |
47 ImageTransportFactory* g_factory; | 51 ImageTransportFactory* g_factory; |
48 | 52 |
49 class DefaultTransportFactory | 53 class DefaultTransportFactory |
50 : public ui::DefaultContextFactory, | 54 : public ui::DefaultContextFactory, |
51 public ImageTransportFactory { | 55 public ImageTransportFactory { |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // Note: previous line destroyed this. Don't access members from now on. | 666 // Note: previous line destroyed this. Don't access members from now on. |
663 } | 667 } |
664 | 668 |
665 WebKit::WebGraphicsContext3D* CreateTestContext() { | 669 WebKit::WebGraphicsContext3D* CreateTestContext() { |
666 ui::TestWebGraphicsContext3D* test_context = | 670 ui::TestWebGraphicsContext3D* test_context = |
667 new ui::TestWebGraphicsContext3D(); | 671 new ui::TestWebGraphicsContext3D(); |
668 test_context->Initialize(); | 672 test_context->Initialize(); |
669 return test_context; | 673 return test_context; |
670 } | 674 } |
671 | 675 |
| 676 class SoftwareTransportFactory : public DefaultTransportFactory { |
| 677 public: |
| 678 cc::OutputSurface* CreateOutputSurface(ui::Compositor* compositor) { |
| 679 #if defined(OS_WIN) |
| 680 scoped_ptr<SoftwareOutputDeviceWin> software_device( |
| 681 new SoftwareOutputDeviceWin(compositor)); |
| 682 return new cc::OutputSurface( |
| 683 software_device.PassAs<cc::SoftwareOutputDevice>()); |
| 684 #elif defined(USE_X11) |
| 685 scoped_ptr<SoftwareOutputDeviceLinux> software_device( |
| 686 new SoftwareOutputDeviceLinux(compositor)); |
| 687 return new cc::OutputSurface( |
| 688 software_device.PassAs<cc::SoftwareOutputDevice>()); |
| 689 #else |
| 690 NOTIMPLEMENTED(); |
| 691 return NULL; |
| 692 #endif |
| 693 } |
| 694 }; |
| 695 |
672 } // anonymous namespace | 696 } // anonymous namespace |
673 | 697 |
674 // static | 698 // static |
675 void ImageTransportFactory::Initialize() { | 699 void ImageTransportFactory::Initialize() { |
676 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 700 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
677 if (command_line->HasSwitch(switches::kTestCompositor)) { | 701 if (command_line->HasSwitch(switches::kTestCompositor)) { |
678 ui::SetupTestCompositor(); | 702 ui::SetupTestCompositor(); |
679 } | 703 } |
680 if (ui::IsTestCompositorEnabled()) | 704 if (ui::IsTestCompositorEnabled()) { |
681 g_factory = new DefaultTransportFactory(); | 705 g_factory = new DefaultTransportFactory; |
682 else | 706 } else if (command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) { |
683 g_factory = new GpuProcessTransportFactory(); | 707 g_factory = new SoftwareTransportFactory; |
| 708 } else { |
| 709 g_factory = new GpuProcessTransportFactory; |
| 710 } |
684 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); | 711 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); |
685 } | 712 } |
686 | 713 |
687 // static | 714 // static |
688 void ImageTransportFactory::Terminate() { | 715 void ImageTransportFactory::Terminate() { |
689 ui::ContextFactory::SetInstance(NULL); | 716 ui::ContextFactory::SetInstance(NULL); |
690 delete g_factory; | 717 delete g_factory; |
691 g_factory = NULL; | 718 g_factory = NULL; |
692 } | 719 } |
693 | 720 |
694 // static | 721 // static |
695 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 722 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
696 return g_factory; | 723 return g_factory; |
697 } | 724 } |
698 | 725 |
699 } // namespace content | 726 } // namespace content |
OLD | NEW |