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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 245 void SynchronousCompositorOutputSurface::SetMemoryPolicy( |
243 const SynchronousCompositorMemoryPolicy& policy) { | 246 const SynchronousCompositorMemoryPolicy& policy) { |
244 DCHECK(CalledOnValidThread()); | 247 DCHECK(CalledOnValidThread()); |
245 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; | 248 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; |
246 memory_policy_.num_resources_limit = policy.num_resources_limit; | 249 memory_policy_.num_resources_limit = policy.num_resources_limit; |
247 | 250 |
248 if (output_surface_client_) | 251 if (output_surface_client_) |
249 output_surface_client_->SetMemoryPolicy(memory_policy_); | 252 output_surface_client_->SetMemoryPolicy(memory_policy_); |
250 } | 253 } |
251 | 254 |
| 255 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( |
| 256 ScopedVector<IPC::Message>* messages) { |
| 257 DCHECK(CalledOnValidThread()); |
| 258 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = |
| 259 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 260 frame_swap_message_queue_->DrainMessages(messages); |
| 261 } |
| 262 |
252 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 263 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
253 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 264 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
254 // thread. | 265 // thread. |
255 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 266 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
256 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 267 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
257 } | 268 } |
258 | 269 |
259 SynchronousCompositorOutputSurfaceDelegate* | 270 SynchronousCompositorOutputSurfaceDelegate* |
260 SynchronousCompositorOutputSurface::GetDelegate() { | 271 SynchronousCompositorOutputSurface::GetDelegate() { |
261 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 272 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
262 } | 273 } |
263 | 274 |
264 } // namespace content | 275 } // namespace content |
OLD | NEW |