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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 bool use_swap_compositor_frame_message) | 38 bool use_swap_compositor_frame_message) |
39 : OutputSurface(context_provider, | 39 : OutputSurface(context_provider, |
40 worker_context_provider, | 40 worker_context_provider, |
41 std::move(software_device)), | 41 std::move(software_device)), |
42 output_surface_id_(output_surface_id), | 42 output_surface_id_(output_surface_id), |
43 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), | 43 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), |
44 output_surface_filter_(RenderThreadImpl::current() | 44 output_surface_filter_(RenderThreadImpl::current() |
45 ->compositor_message_filter()), | 45 ->compositor_message_filter()), |
46 frame_swap_message_queue_(swap_frame_message_queue), | 46 frame_swap_message_queue_(swap_frame_message_queue), |
47 routing_id_(routing_id), | 47 routing_id_(routing_id), |
48 #if defined(OS_ANDROID) | |
49 prefers_smoothness_(false), | |
50 main_thread_runner_(base::MessageLoop::current()->task_runner()), | |
51 #endif | |
52 layout_test_mode_(RenderThreadImpl::current()->layout_test_mode()), | 48 layout_test_mode_(RenderThreadImpl::current()->layout_test_mode()), |
53 weak_ptrs_(this) { | 49 weak_ptrs_(this) { |
54 DCHECK(output_surface_filter_.get()); | 50 DCHECK(output_surface_filter_.get()); |
55 DCHECK(frame_swap_message_queue_.get()); | 51 DCHECK(frame_swap_message_queue_.get()); |
56 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); | 52 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); |
57 DCHECK(message_sender_.get()); | 53 DCHECK(message_sender_.get()); |
58 } | 54 } |
59 | 55 |
60 CompositorOutputSurface::~CompositorOutputSurface() {} | 56 CompositorOutputSurface::~CompositorOutputSurface() {} |
61 | 57 |
(...skipping 17 matching lines...) Expand all Loading... |
79 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 75 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
80 base::SharedMemory::GetHandleLimit() / 3)); | 76 base::SharedMemory::GetHandleLimit() / 3)); |
81 } | 77 } |
82 | 78 |
83 return true; | 79 return true; |
84 } | 80 } |
85 | 81 |
86 void CompositorOutputSurface::DetachFromClient() { | 82 void CompositorOutputSurface::DetachFromClient() { |
87 if (!HasClient()) | 83 if (!HasClient()) |
88 return; | 84 return; |
89 UpdateSmoothnessTakesPriority(false); | |
90 if (output_surface_proxy_.get()) | 85 if (output_surface_proxy_.get()) |
91 output_surface_proxy_->ClearOutputSurface(); | 86 output_surface_proxy_->ClearOutputSurface(); |
92 output_surface_filter_->RemoveHandlerOnCompositorThread( | 87 output_surface_filter_->RemoveHandlerOnCompositorThread( |
93 routing_id_, output_surface_filter_handler_); | 88 routing_id_, output_surface_filter_handler_); |
94 cc::OutputSurface::DetachFromClient(); | 89 cc::OutputSurface::DetachFromClient(); |
95 } | 90 } |
96 | 91 |
97 void CompositorOutputSurface::ShortcutSwapAck( | 92 void CompositorOutputSurface::ShortcutSwapAck( |
98 uint32_t output_surface_id, | 93 uint32_t output_surface_id, |
99 scoped_ptr<cc::GLFrameData> gl_frame_data) { | 94 scoped_ptr<cc::GLFrameData> gl_frame_data) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // (e.g. after a lost context). | 190 // (e.g. after a lost context). |
196 if (output_surface_id != output_surface_id_) | 191 if (output_surface_id != output_surface_id_) |
197 return; | 192 return; |
198 ReclaimResources(&ack); | 193 ReclaimResources(&ack); |
199 } | 194 } |
200 | 195 |
201 bool CompositorOutputSurface::Send(IPC::Message* message) { | 196 bool CompositorOutputSurface::Send(IPC::Message* message) { |
202 return message_sender_->Send(message); | 197 return message_sender_->Send(message); |
203 } | 198 } |
204 | 199 |
205 #if defined(OS_ANDROID) | |
206 namespace { | |
207 void SetThreadPriorityToIdle() { | |
208 base::PlatformThread::SetCurrentThreadPriority( | |
209 base::ThreadPriority::BACKGROUND); | |
210 } | |
211 void SetThreadPriorityToDefault() { | |
212 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::NORMAL); | |
213 } | |
214 } // namespace | |
215 #endif | |
216 | |
217 void CompositorOutputSurface::UpdateSmoothnessTakesPriority( | |
218 bool prefers_smoothness) { | |
219 #if defined(OS_ANDROID) | |
220 if (prefers_smoothness_ == prefers_smoothness) | |
221 return; | |
222 prefers_smoothness_ = prefers_smoothness; | |
223 if (prefers_smoothness) { | |
224 main_thread_runner_->PostTask(FROM_HERE, | |
225 base::Bind(&SetThreadPriorityToIdle)); | |
226 } else { | |
227 main_thread_runner_->PostTask(FROM_HERE, | |
228 base::Bind(&SetThreadPriorityToDefault)); | |
229 } | |
230 #endif | |
231 } | |
232 | |
233 } // namespace content | 200 } // namespace content |
OLD | NEW |