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