| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 261 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| 262 if (delegate) | 262 if (delegate) |
| 263 delegate->SetContinuousInvalidate(needs_begin_frame_); | 263 delegate->SetContinuousInvalidate(needs_begin_frame_); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void SynchronousCompositorOutputSurface::ReturnResources( | 266 void SynchronousCompositorOutputSurface::ReturnResources( |
| 267 const cc::CompositorFrameAck& frame_ack) { | 267 const cc::CompositorFrameAck& frame_ack) { |
| 268 ReclaimResources(&frame_ack); | 268 ReclaimResources(&frame_ack); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 271 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) { |
| 272 const SynchronousCompositorMemoryPolicy& policy) { | |
| 273 DCHECK(CalledOnValidThread()); | 272 DCHECK(CalledOnValidThread()); |
| 274 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; | 273 memory_policy_.bytes_limit_when_visible = bytes_limit; |
| 275 memory_policy_.num_resources_limit = policy.num_resources_limit; | |
| 276 | 274 |
| 277 if (output_surface_client_) | 275 if (output_surface_client_) |
| 278 output_surface_client_->SetMemoryPolicy(memory_policy_); | 276 output_surface_client_->SetMemoryPolicy(memory_policy_); |
| 279 } | 277 } |
| 280 | 278 |
| 281 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( | 279 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( |
| 282 ScopedVector<IPC::Message>* messages) { | 280 ScopedVector<IPC::Message>* messages) { |
| 283 DCHECK(CalledOnValidThread()); | 281 DCHECK(CalledOnValidThread()); |
| 284 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = | 282 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = |
| 285 frame_swap_message_queue_->AcquireSendMessageScope(); | 283 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 286 frame_swap_message_queue_->DrainMessages(messages); | 284 frame_swap_message_queue_->DrainMessages(messages); |
| 287 } | 285 } |
| 288 | 286 |
| 289 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 287 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 290 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 288 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
| 291 // thread. | 289 // thread. |
| 292 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 290 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 293 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 291 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 294 } | 292 } |
| 295 | 293 |
| 296 SynchronousCompositorOutputSurfaceDelegate* | 294 SynchronousCompositorOutputSurfaceDelegate* |
| 297 SynchronousCompositorOutputSurface::GetDelegate() { | 295 SynchronousCompositorOutputSurface::GetDelegate() { |
| 298 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 296 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 299 } | 297 } |
| 300 | 298 |
| 301 } // namespace content | 299 } // namespace content |
| OLD | NEW |