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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 } | 985 } |
986 #endif | 986 #endif |
987 | 987 |
988 const base::CommandLine& command_line = | 988 const base::CommandLine& command_line = |
989 *base::CommandLine::ForCurrentProcess(); | 989 *base::CommandLine::ForCurrentProcess(); |
990 bool use_software = fallback; | 990 bool use_software = fallback; |
991 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) | 991 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) |
992 use_software = true; | 992 use_software = true; |
993 | 993 |
994 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 994 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
| 995 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; |
995 if (!use_software) { | 996 if (!use_software) { |
996 context_provider = ContextProviderCommandBuffer::Create( | 997 context_provider = ContextProviderCommandBuffer::Create( |
997 CreateGraphicsContext3D(), "RenderCompositor"); | 998 CreateGraphicsContext3D(), "RenderCompositor"); |
998 if (!context_provider.get()) { | 999 if (!context_provider.get()) { |
999 // Cause the compositor to wait and try again. | 1000 // Cause the compositor to wait and try again. |
1000 return scoped_ptr<cc::OutputSurface>(); | 1001 return scoped_ptr<cc::OutputSurface>(); |
1001 } | 1002 } |
| 1003 |
| 1004 worker_context_provider = ContextProviderCommandBuffer::Create( |
| 1005 CreateGraphicsContext3D(), "RenderWorker"); |
| 1006 if (!worker_context_provider.get()) { |
| 1007 // Cause the compositor to wait and try again. |
| 1008 return scoped_ptr<cc::OutputSurface>(); |
| 1009 } |
1002 } | 1010 } |
1003 | 1011 |
1004 uint32 output_surface_id = next_output_surface_id_++; | 1012 uint32 output_surface_id = next_output_surface_id_++; |
1005 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { | 1013 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { |
1006 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); | 1014 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); |
1007 return scoped_ptr<cc::OutputSurface>(new DelegatedCompositorOutputSurface( | 1015 return scoped_ptr<cc::OutputSurface>(new DelegatedCompositorOutputSurface( |
1008 routing_id(), output_surface_id, context_provider, nullptr, | 1016 routing_id(), output_surface_id, context_provider, |
1009 frame_swap_message_queue_)); | 1017 worker_context_provider, frame_swap_message_queue_)); |
1010 } | 1018 } |
1011 if (!context_provider.get()) { | 1019 if (!context_provider.get()) { |
1012 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 1020 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
1013 new CompositorSoftwareOutputDevice()); | 1021 new CompositorSoftwareOutputDevice()); |
1014 | 1022 |
1015 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( | 1023 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
1016 routing_id(), output_surface_id, nullptr, nullptr, | 1024 routing_id(), output_surface_id, nullptr, nullptr, |
1017 software_device.Pass(), frame_swap_message_queue_, true)); | 1025 software_device.Pass(), frame_swap_message_queue_, true)); |
1018 } | 1026 } |
1019 | 1027 |
1020 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 1028 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
1021 // Composite-to-mailbox is currently used for layout tests in order to cause | 1029 // Composite-to-mailbox is currently used for layout tests in order to cause |
1022 // them to draw inside in the renderer to do the readback there. This should | 1030 // them to draw inside in the renderer to do the readback there. This should |
1023 // no longer be the case when crbug.com/311404 is fixed. | 1031 // no longer be the case when crbug.com/311404 is fixed. |
1024 DCHECK(RenderThreadImpl::current()->layout_test_mode()); | 1032 DCHECK(RenderThreadImpl::current()->layout_test_mode()); |
1025 cc::ResourceFormat format = cc::RGBA_8888; | 1033 cc::ResourceFormat format = cc::RGBA_8888; |
1026 if (base::SysInfo::IsLowEndDevice()) | 1034 if (base::SysInfo::IsLowEndDevice()) |
1027 format = cc::RGB_565; | 1035 format = cc::RGB_565; |
1028 return scoped_ptr<cc::OutputSurface>(new MailboxOutputSurface( | 1036 return scoped_ptr<cc::OutputSurface>(new MailboxOutputSurface( |
1029 routing_id(), output_surface_id, context_provider, nullptr, | 1037 routing_id(), output_surface_id, context_provider, |
1030 scoped_ptr<cc::SoftwareOutputDevice>(), frame_swap_message_queue_, | 1038 worker_context_provider, scoped_ptr<cc::SoftwareOutputDevice>(), |
1031 format)); | 1039 frame_swap_message_queue_, format)); |
1032 } | 1040 } |
1033 bool use_swap_compositor_frame_message = false; | 1041 bool use_swap_compositor_frame_message = false; |
1034 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( | 1042 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
1035 routing_id(), output_surface_id, context_provider, nullptr, | 1043 routing_id(), output_surface_id, context_provider, |
1036 scoped_ptr<cc::SoftwareOutputDevice>(), frame_swap_message_queue_, | 1044 worker_context_provider, scoped_ptr<cc::SoftwareOutputDevice>(), |
1037 use_swap_compositor_frame_message)); | 1045 frame_swap_message_queue_, use_swap_compositor_frame_message)); |
1038 } | 1046 } |
1039 | 1047 |
1040 void RenderWidget::OnSwapBuffersAborted() { | 1048 void RenderWidget::OnSwapBuffersAborted() { |
1041 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 1049 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
1042 // Schedule another frame so the compositor learns about it. | 1050 // Schedule another frame so the compositor learns about it. |
1043 scheduleComposite(); | 1051 scheduleComposite(); |
1044 } | 1052 } |
1045 | 1053 |
1046 void RenderWidget::OnSwapBuffersPosted() { | 1054 void RenderWidget::OnSwapBuffersPosted() { |
1047 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); | 1055 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2423 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2416 video_hole_frames_.AddObserver(frame); | 2424 video_hole_frames_.AddObserver(frame); |
2417 } | 2425 } |
2418 | 2426 |
2419 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2427 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2420 video_hole_frames_.RemoveObserver(frame); | 2428 video_hole_frames_.RemoveObserver(frame); |
2421 } | 2429 } |
2422 #endif // defined(VIDEO_HOLE) | 2430 #endif // defined(VIDEO_HOLE) |
2423 | 2431 |
2424 } // namespace content | 2432 } // namespace content |
OLD | NEW |