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/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
11 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" |
12 #include "cc/output/software_output_device.h" | 12 #include "cc/output/software_output_device.h" |
13 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.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/android/in_process/synchronous_compositor_registry.h" | 15 #include "content/browser/android/in_process/synchronous_compositor_registry.h" |
16 #include "content/browser/gpu/compositor_util.h" | 16 #include "content/browser/gpu/compositor_util.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/renderer/gpu/frame_swap_message_queue.h" | 18 #include "content/renderer/gpu/frame_update_message_queue.h" |
19 #include "gpu/command_buffer/client/gles2_interface.h" | 19 #include "gpu/command_buffer/client/gles2_interface.h" |
20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
21 #include "third_party/skia/include/core/SkCanvas.h" | 21 #include "third_party/skia/include/core/SkCanvas.h" |
22 #include "ui/gfx/geometry/rect_conversions.h" | 22 #include "ui/gfx/geometry/rect_conversions.h" |
23 #include "ui/gfx/skia_util.h" | 23 #include "ui/gfx/skia_util.h" |
24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 namespace { | 28 namespace { |
(...skipping 30 matching lines...) Expand all Loading... |
59 SynchronousCompositorOutputSurface* surface_; | 59 SynchronousCompositorOutputSurface* surface_; |
60 SkCanvas null_canvas_; | 60 SkCanvas null_canvas_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); | 62 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); |
63 }; | 63 }; |
64 | 64 |
65 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 65 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
66 const scoped_refptr<cc::ContextProvider>& context_provider, | 66 const scoped_refptr<cc::ContextProvider>& context_provider, |
67 const scoped_refptr<cc::ContextProvider>& worker_context_provider, | 67 const scoped_refptr<cc::ContextProvider>& worker_context_provider, |
68 int routing_id, | 68 int routing_id, |
69 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) | 69 scoped_refptr<FrameUpdateMessageQueue> frame_update_message_queue) |
70 : cc::OutputSurface( | 70 : cc::OutputSurface( |
71 context_provider, | 71 context_provider, |
72 worker_context_provider, | 72 worker_context_provider, |
73 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 73 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), |
74 routing_id_(routing_id), | 74 routing_id_(routing_id), |
75 registered_(false), | 75 registered_(false), |
76 current_sw_canvas_(nullptr), | 76 current_sw_canvas_(nullptr), |
77 memory_policy_(0), | 77 memory_policy_(0), |
78 frame_swap_message_queue_(frame_swap_message_queue) { | 78 frame_update_message_queue_(frame_update_message_queue) { |
79 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 79 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
80 capabilities_.adjust_deadline_for_parent = false; | 80 capabilities_.adjust_deadline_for_parent = false; |
81 capabilities_.delegated_rendering = true; | 81 capabilities_.delegated_rendering = true; |
82 capabilities_.max_frames_pending = 1; | 82 capabilities_.max_frames_pending = 1; |
83 memory_policy_.priority_cutoff_when_visible = | 83 memory_policy_.priority_cutoff_when_visible = |
84 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 84 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
85 } | 85 } |
86 | 86 |
87 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { | 87 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { |
88 DCHECK(CalledOnValidThread()); | 88 DCHECK(CalledOnValidThread()); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (client_) | 252 if (client_) |
253 client_->SetMemoryPolicy(memory_policy_); | 253 client_->SetMemoryPolicy(memory_policy_); |
254 } | 254 } |
255 | 255 |
256 void SynchronousCompositorOutputSurface::SetTreeActivationCallback( | 256 void SynchronousCompositorOutputSurface::SetTreeActivationCallback( |
257 const base::Closure& callback) { | 257 const base::Closure& callback) { |
258 DCHECK(client_); | 258 DCHECK(client_); |
259 client_->SetTreeActivationCallback(callback); | 259 client_->SetTreeActivationCallback(callback); |
260 } | 260 } |
261 | 261 |
262 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( | 262 void SynchronousCompositorOutputSurface::GetSwapMessagesToDeliver( |
263 ScopedVector<IPC::Message>* messages) { | 263 ScopedVector<IPC::Message>* messages) { |
| 264 // called by |
| 265 // SynchronousCompositorImpl::UpdateFrameMetaData (on swap) -> |
| 266 // SynchronousCompositorImpl::DeliverMessages -> |
| 267 // GetSwapMessagesToDeliver |
264 DCHECK(CalledOnValidThread()); | 268 DCHECK(CalledOnValidThread()); |
265 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = | 269 scoped_ptr<FrameUpdateMessageQueue::SendMessageScope> send_message_scope = |
266 frame_swap_message_queue_->AcquireSendMessageScope(); | 270 frame_update_message_queue_->AcquireSendMessageScope(); |
267 frame_swap_message_queue_->DrainMessages(messages); | 271 frame_update_message_queue_->DrainMessagesForSwap(messages); |
268 } | 272 } |
269 | 273 |
270 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 274 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
271 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 275 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
272 // thread. | 276 // thread. |
273 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 277 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
274 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 278 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
275 } | 279 } |
276 | 280 |
277 } // namespace content | 281 } // namespace content |
OLD | NEW |