| 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" |
| 11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
| 12 #include "cc/output/output_surface_client.h" | 12 #include "cc/output/output_surface_client.h" |
| 13 #include "cc/output/software_output_device.h" | 13 #include "cc/output/software_output_device.h" |
| 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| 15 #include "content/browser/gpu/compositor_util.h" | 15 #include "content/browser/gpu/compositor_util.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 17 #include "gpu/command_buffer/client/gles2_interface.h" | 18 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 19 #include "third_party/skia/include/core/SkCanvas.h" | 20 #include "third_party/skia/include/core/SkCanvas.h" |
| 20 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
| 21 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 22 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 61 } |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 SynchronousCompositorOutputSurface* surface_; | 64 SynchronousCompositorOutputSurface* surface_; |
| 64 SkCanvas null_canvas_; | 65 SkCanvas null_canvas_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); | 67 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 70 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
| 70 int routing_id) | 71 int routing_id, |
| 72 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) |
| 71 : cc::OutputSurface( | 73 : cc::OutputSurface( |
| 72 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 74 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), |
| 73 routing_id_(routing_id), | 75 routing_id_(routing_id), |
| 74 needs_begin_frame_(false), | 76 needs_begin_frame_(false), |
| 75 invoking_composite_(false), | 77 invoking_composite_(false), |
| 76 current_sw_canvas_(NULL), | 78 current_sw_canvas_(NULL), |
| 77 memory_policy_(0), | 79 memory_policy_(0), |
| 78 output_surface_client_(NULL) { | 80 output_surface_client_(NULL), |
| 81 frame_swap_message_queue_(frame_swap_message_queue) { |
| 79 capabilities_.deferred_gl_initialization = true; | 82 capabilities_.deferred_gl_initialization = true; |
| 80 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 83 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
| 81 capabilities_.adjust_deadline_for_parent = false; | 84 capabilities_.adjust_deadline_for_parent = false; |
| 82 capabilities_.delegated_rendering = true; | 85 capabilities_.delegated_rendering = true; |
| 83 capabilities_.max_frames_pending = 1; | 86 capabilities_.max_frames_pending = 1; |
| 84 // Cannot call out to GetDelegate() here as the output surface is not | 87 // Cannot call out to GetDelegate() here as the output surface is not |
| 85 // constructed on the correct thread. | 88 // constructed on the correct thread. |
| 86 | 89 |
| 87 memory_policy_.priority_cutoff_when_visible = | 90 memory_policy_.priority_cutoff_when_visible = |
| 88 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 91 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 250 void SynchronousCompositorOutputSurface::SetMemoryPolicy( |
| 248 const SynchronousCompositorMemoryPolicy& policy) { | 251 const SynchronousCompositorMemoryPolicy& policy) { |
| 249 DCHECK(CalledOnValidThread()); | 252 DCHECK(CalledOnValidThread()); |
| 250 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; | 253 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; |
| 251 memory_policy_.num_resources_limit = policy.num_resources_limit; | 254 memory_policy_.num_resources_limit = policy.num_resources_limit; |
| 252 | 255 |
| 253 if (output_surface_client_) | 256 if (output_surface_client_) |
| 254 output_surface_client_->SetMemoryPolicy(memory_policy_); | 257 output_surface_client_->SetMemoryPolicy(memory_policy_); |
| 255 } | 258 } |
| 256 | 259 |
| 260 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( |
| 261 ScopedVector<IPC::Message>* messages) { |
| 262 DCHECK(CalledOnValidThread()); |
| 263 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = |
| 264 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 265 frame_swap_message_queue_->DrainMessages(messages); |
| 266 } |
| 267 |
| 257 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 268 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 258 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 269 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
| 259 // thread. | 270 // thread. |
| 260 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 271 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 261 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 272 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 262 } | 273 } |
| 263 | 274 |
| 264 SynchronousCompositorOutputSurfaceDelegate* | 275 SynchronousCompositorOutputSurfaceDelegate* |
| 265 SynchronousCompositorOutputSurface::GetDelegate() { | 276 SynchronousCompositorOutputSurface::GetDelegate() { |
| 266 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 277 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 267 } | 278 } |
| 268 | 279 |
| 269 } // namespace content | 280 } // namespace content |
| OLD | NEW |