| 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/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "cc/compositor_frame.h" | 8 #include "cc/compositor_frame.h" |
| 9 #include "cc/compositor_frame_ack.h" |
| 9 #include "cc/output_surface_client.h" | 10 #include "cc/output_surface_client.h" |
| 10 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
| 11 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
| 12 #include "ipc/ipc_forwarding_message_filter.h" | 13 #include "ipc/ipc_forwarding_message_filter.h" |
| 13 #include "ipc/ipc_sync_channel.h" | 14 #include "ipc/ipc_sync_channel.h" |
| 14 #include "ipc/ipc_sync_message_filter.h" | 15 #include "ipc/ipc_sync_message_filter.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 16 | 17 |
| 17 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
| 18 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | 19 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 //------------------------------------------------------------------------------ | 35 //------------------------------------------------------------------------------ |
| 35 | 36 |
| 36 // static | 37 // static |
| 37 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 38 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
| 38 base::TaskRunner* target_task_runner) | 39 base::TaskRunner* target_task_runner) |
| 39 { | 40 { |
| 40 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 41 uint32 messages_to_filter[] = { |
| 42 ViewMsg_UpdateVSyncParameters::ID, |
| 43 ViewMsg_SwapCompositorFrameAck::ID |
| 44 }; |
| 45 |
| 41 return new IPC::ForwardingMessageFilter( | 46 return new IPC::ForwardingMessageFilter( |
| 42 messages_to_filter, arraysize(messages_to_filter), | 47 messages_to_filter, arraysize(messages_to_filter), |
| 43 target_task_runner); | 48 target_task_runner); |
| 44 } | 49 } |
| 45 | 50 |
| 46 CompositorOutputSurface::CompositorOutputSurface( | 51 CompositorOutputSurface::CompositorOutputSurface( |
| 47 int32 routing_id, | 52 int32 routing_id, |
| 48 WebGraphicsContext3D* context3D, | 53 WebGraphicsContext3D* context3D, |
| 49 cc::SoftwareOutputDevice* software_device) | 54 cc::SoftwareOutputDevice* software_device) |
| 50 : OutputSurface(make_scoped_ptr(context3D), | 55 : OutputSurface(make_scoped_ptr(context3D), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 DCHECK(CalledOnValidThread()); | 95 DCHECK(CalledOnValidThread()); |
| 91 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); | 96 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); |
| 92 } | 97 } |
| 93 | 98 |
| 94 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 99 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 95 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
| 96 if (!client_) | 101 if (!client_) |
| 97 return; | 102 return; |
| 98 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 103 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 99 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 104 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
| 105 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 100 IPC_END_MESSAGE_MAP() | 106 IPC_END_MESSAGE_MAP() |
| 101 } | 107 } |
| 102 | 108 |
| 103 void CompositorOutputSurface::OnUpdateVSyncParameters( | 109 void CompositorOutputSurface::OnUpdateVSyncParameters( |
| 104 base::TimeTicks timebase, base::TimeDelta interval) { | 110 base::TimeTicks timebase, base::TimeDelta interval) { |
| 105 DCHECK(CalledOnValidThread()); | 111 DCHECK(CalledOnValidThread()); |
| 106 DCHECK(client_); | 112 DCHECK(client_); |
| 107 client_->OnVSyncParametersChanged(timebase, interval); | 113 client_->OnVSyncParametersChanged(timebase, interval); |
| 108 } | 114 } |
| 109 | 115 |
| 116 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { |
| 117 client_->OnSendFrameToParentCompositorAck(ack); |
| 118 } |
| 119 |
| 110 bool CompositorOutputSurface::Send(IPC::Message* message) { | 120 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 111 return ChildThread::current()->sync_message_filter()->Send(message); | 121 return ChildThread::current()->sync_message_filter()->Send(message); |
| 112 } | 122 } |
| 113 | 123 |
| 114 namespace { | 124 namespace { |
| 115 #if defined(OS_ANDROID) | 125 #if defined(OS_ANDROID) |
| 116 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | 126 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 117 void SetThreadsPriorityToIdle(base::PlatformThreadId id) { | 127 void SetThreadsPriorityToIdle(base::PlatformThreadId id) { |
| 118 int nice_value = 10; // Idle priority. | 128 int nice_value = 10; // Idle priority. |
| 119 setpriority(PRIO_PROCESS, id, nice_value); | 129 setpriority(PRIO_PROCESS, id, nice_value); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 147 // If this is the last surface to stop preferring smoothness, | 157 // If this is the last surface to stop preferring smoothness, |
| 148 // Reset the main thread's priority to the default. | 158 // Reset the main thread's priority to the default. |
| 149 if (prefers_smoothness_ == true && | 159 if (prefers_smoothness_ == true && |
| 150 --g_prefer_smoothness_count == 0) { | 160 --g_prefer_smoothness_count == 0) { |
| 151 SetThreadsPriorityToDefault(main_thread_id_); | 161 SetThreadsPriorityToDefault(main_thread_id_); |
| 152 } | 162 } |
| 153 prefers_smoothness_ = prefers_smoothness; | 163 prefers_smoothness_ = prefers_smoothness; |
| 154 } | 164 } |
| 155 | 165 |
| 156 } // namespace content | 166 } // namespace content |
| OLD | NEW |