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 | |
21 using WebKit::WebGraphicsContext3D; | |
22 | 20 |
23 namespace { | 21 namespace { |
24 // There are several compositor surfaces in a process, but they share the same | 22 // There are several compositor surfaces in a process, but they share the same |
25 // compositor thread, so we use a simple int here to track prefer-smoothness. | 23 // compositor thread, so we use a simple int here to track prefer-smoothness. |
26 int g_prefer_smoothness_count = 0; | 24 int g_prefer_smoothness_count = 0; |
27 } // namespace | 25 } // namespace |
28 | 26 |
29 namespace content { | 27 namespace content { |
30 | 28 |
31 //------------------------------------------------------------------------------ | 29 //------------------------------------------------------------------------------ |
(...skipping 11 matching lines...) Expand all Loading... |
43 }; | 41 }; |
44 | 42 |
45 return new IPC::ForwardingMessageFilter( | 43 return new IPC::ForwardingMessageFilter( |
46 messages_to_filter, arraysize(messages_to_filter), | 44 messages_to_filter, arraysize(messages_to_filter), |
47 target_task_runner); | 45 target_task_runner); |
48 } | 46 } |
49 | 47 |
50 CompositorOutputSurface::CompositorOutputSurface( | 48 CompositorOutputSurface::CompositorOutputSurface( |
51 int32 routing_id, | 49 int32 routing_id, |
52 uint32 output_surface_id, | 50 uint32 output_surface_id, |
53 WebGraphicsContext3DCommandBufferImpl* context3D, | 51 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
54 cc::SoftwareOutputDevice* software_device, | 52 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
55 bool use_swap_compositor_frame_message) | 53 bool use_swap_compositor_frame_message) |
56 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context3D), | 54 : OutputSurface(context_provider, software_device.Pass()), |
57 make_scoped_ptr(software_device)), | |
58 output_surface_id_(output_surface_id), | 55 output_surface_id_(output_surface_id), |
59 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), | 56 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), |
60 output_surface_filter_( | 57 output_surface_filter_( |
61 RenderThreadImpl::current()->compositor_output_surface_filter()), | 58 RenderThreadImpl::current()->compositor_output_surface_filter()), |
62 routing_id_(routing_id), | 59 routing_id_(routing_id), |
63 prefers_smoothness_(false), | 60 prefers_smoothness_(false), |
64 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
65 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. | 62 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. |
66 main_thread_handle_(base::PlatformThreadHandle()) | 63 main_thread_handle_(base::PlatformThreadHandle()) |
67 #else | 64 #else |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 101 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
105 if (use_swap_compositor_frame_message_) { | 102 if (use_swap_compositor_frame_message_) { |
106 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, | 103 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, |
107 output_surface_id_, | 104 output_surface_id_, |
108 *frame)); | 105 *frame)); |
109 DidSwapBuffers(); | 106 DidSwapBuffers(); |
110 return; | 107 return; |
111 } | 108 } |
112 | 109 |
113 if (frame->gl_frame_data) { | 110 if (frame->gl_frame_data) { |
114 WebGraphicsContext3DCommandBufferImpl* command_buffer = | 111 WebGraphicsContext3DCommandBufferImpl* command_buffer_context = |
115 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); | 112 static_cast<WebGraphicsContext3DCommandBufferImpl*>( |
| 113 context_provider_->Context3d()); |
116 CommandBufferProxyImpl* command_buffer_proxy = | 114 CommandBufferProxyImpl* command_buffer_proxy = |
117 command_buffer->GetCommandBufferProxy(); | 115 command_buffer_context->GetCommandBufferProxy(); |
118 DCHECK(command_buffer_proxy); | 116 DCHECK(command_buffer_proxy); |
119 context3d()->shallowFlushCHROMIUM(); | 117 context_provider_->Context3d()->shallowFlushCHROMIUM(); |
120 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); | 118 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); |
121 } | 119 } |
122 | 120 |
123 OutputSurface::SwapBuffers(frame); | 121 OutputSurface::SwapBuffers(frame); |
124 } | 122 } |
125 | 123 |
126 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 124 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
127 DCHECK(CalledOnValidThread()); | 125 DCHECK(CalledOnValidThread()); |
128 if (!HasClient()) | 126 if (!HasClient()) |
129 return; | 127 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, | 202 // If this is the last surface to stop preferring smoothness, |
205 // Reset the main thread's priority to the default. | 203 // Reset the main thread's priority to the default. |
206 if (prefers_smoothness_ == true && | 204 if (prefers_smoothness_ == true && |
207 --g_prefer_smoothness_count == 0) { | 205 --g_prefer_smoothness_count == 0) { |
208 SetThreadPriorityToDefault(main_thread_handle_); | 206 SetThreadPriorityToDefault(main_thread_handle_); |
209 } | 207 } |
210 prefers_smoothness_ = prefers_smoothness; | 208 prefers_smoothness_ = prefers_smoothness; |
211 } | 209 } |
212 | 210 |
213 } // namespace content | 211 } // namespace content |
OLD | NEW |