| 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/gpu/compositor_output_surface.h" | 5 #include "content/renderer/gpu/compositor_output_surface.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
| 11 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" |
| 12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 13 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 13 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 14 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 15 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 16 #include "content/renderer/render_thread_impl.h" | 17 #include "content/renderer/render_thread_impl.h" |
| 17 #include "ipc/ipc_forwarding_message_filter.h" | 18 #include "ipc/ipc_forwarding_message_filter.h" |
| 18 #include "ipc/ipc_sync_channel.h" | 19 #include "ipc/ipc_sync_channel.h" |
| 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 20 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 20 | 21 |
| 21 using WebKit::WebGraphicsContext3D; | 22 using WebKit::WebGraphicsContext3D; |
| 22 | 23 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 return new IPC::ForwardingMessageFilter( | 46 return new IPC::ForwardingMessageFilter( |
| 46 messages_to_filter, arraysize(messages_to_filter), | 47 messages_to_filter, arraysize(messages_to_filter), |
| 47 target_task_runner); | 48 target_task_runner); |
| 48 } | 49 } |
| 49 | 50 |
| 50 CompositorOutputSurface::CompositorOutputSurface( | 51 CompositorOutputSurface::CompositorOutputSurface( |
| 51 int32 routing_id, | 52 int32 routing_id, |
| 52 uint32 output_surface_id, | 53 uint32 output_surface_id, |
| 53 WebGraphicsContext3DCommandBufferImpl* context3D, | 54 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 54 cc::SoftwareOutputDevice* software_device, | 55 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
| 55 bool use_swap_compositor_frame_message) | 56 bool use_swap_compositor_frame_message) |
| 56 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context3D), | 57 : OutputSurface(context_provider, software_device.Pass()), |
| 57 make_scoped_ptr(software_device)), | |
| 58 output_surface_id_(output_surface_id), | 58 output_surface_id_(output_surface_id), |
| 59 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), | 59 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), |
| 60 command_buffer_context_(context_provider->Context3d()), |
| 60 output_surface_filter_( | 61 output_surface_filter_( |
| 61 RenderThreadImpl::current()->compositor_output_surface_filter()), | 62 RenderThreadImpl::current()->compositor_output_surface_filter()), |
| 62 routing_id_(routing_id), | 63 routing_id_(routing_id), |
| 63 prefers_smoothness_(false), | 64 prefers_smoothness_(false), |
| 64 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 65 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. | 66 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. |
| 66 main_thread_handle_(base::PlatformThreadHandle()) | 67 main_thread_handle_(base::PlatformThreadHandle()) |
| 67 #else | 68 #else |
| 68 main_thread_handle_(base::PlatformThread::CurrentHandle()) | 69 main_thread_handle_(base::PlatformThread::CurrentHandle()) |
| 69 #endif | 70 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 105 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| 105 if (use_swap_compositor_frame_message_) { | 106 if (use_swap_compositor_frame_message_) { |
| 106 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, | 107 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, |
| 107 output_surface_id_, | 108 output_surface_id_, |
| 108 *frame)); | 109 *frame)); |
| 109 DidSwapBuffers(); | 110 DidSwapBuffers(); |
| 110 return; | 111 return; |
| 111 } | 112 } |
| 112 | 113 |
| 113 if (frame->gl_frame_data) { | 114 if (frame->gl_frame_data) { |
| 114 WebGraphicsContext3DCommandBufferImpl* command_buffer = | |
| 115 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); | |
| 116 CommandBufferProxyImpl* command_buffer_proxy = | 115 CommandBufferProxyImpl* command_buffer_proxy = |
| 117 command_buffer->GetCommandBufferProxy(); | 116 command_buffer_context_->GetCommandBufferProxy(); |
| 118 DCHECK(command_buffer_proxy); | 117 DCHECK(command_buffer_proxy); |
| 119 context3d()->shallowFlushCHROMIUM(); | 118 context_provider_->Context3d()->shallowFlushCHROMIUM(); |
| 120 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); | 119 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); |
| 121 } | 120 } |
| 122 | 121 |
| 123 OutputSurface::SwapBuffers(frame); | 122 OutputSurface::SwapBuffers(frame); |
| 124 } | 123 } |
| 125 | 124 |
| 126 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 125 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 127 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
| 128 if (!HasClient()) | 127 if (!HasClient()) |
| 129 return; | 128 return; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // If this is the last surface to stop preferring smoothness, | 203 // If this is the last surface to stop preferring smoothness, |
| 205 // Reset the main thread's priority to the default. | 204 // Reset the main thread's priority to the default. |
| 206 if (prefers_smoothness_ == true && | 205 if (prefers_smoothness_ == true && |
| 207 --g_prefer_smoothness_count == 0) { | 206 --g_prefer_smoothness_count == 0) { |
| 208 SetThreadPriorityToDefault(main_thread_handle_); | 207 SetThreadPriorityToDefault(main_thread_handle_); |
| 209 } | 208 } |
| 210 prefers_smoothness_ = prefers_smoothness; | 209 prefers_smoothness_ = prefers_smoothness; |
| 211 } | 210 } |
| 212 | 211 |
| 213 } // namespace content | 212 } // namespace content |
| OLD | NEW |