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 if (IsDelegatedRendererEnabled()) { | 85 if (IsDelegatedRendererEnabled()) { |
83 capabilities_.delegated_rendering = true; | 86 capabilities_.delegated_rendering = true; |
84 capabilities_.max_frames_pending = 1; | 87 capabilities_.max_frames_pending = 1; |
85 } | 88 } |
86 // Cannot call out to GetDelegate() here as the output surface is not | 89 // Cannot call out to GetDelegate() here as the output surface is not |
87 // constructed on the correct thread. | 90 // constructed on the correct thread. |
88 | 91 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 259 void SynchronousCompositorOutputSurface::SetMemoryPolicy( |
257 const SynchronousCompositorMemoryPolicy& policy) { | 260 const SynchronousCompositorMemoryPolicy& policy) { |
258 DCHECK(CalledOnValidThread()); | 261 DCHECK(CalledOnValidThread()); |
259 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; | 262 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; |
260 memory_policy_.num_resources_limit = policy.num_resources_limit; | 263 memory_policy_.num_resources_limit = policy.num_resources_limit; |
261 | 264 |
262 if (output_surface_client_) | 265 if (output_surface_client_) |
263 output_surface_client_->SetMemoryPolicy(memory_policy_); | 266 output_surface_client_->SetMemoryPolicy(memory_policy_); |
264 } | 267 } |
265 | 268 |
| 269 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( |
| 270 std::vector<IPC::Message>* messages) { |
| 271 DCHECK(CalledOnValidThread()); |
| 272 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = |
| 273 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 274 frame_swap_message_queue_->DrainMessages(messages); |
| 275 } |
| 276 |
266 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 277 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
267 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 278 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
268 // thread. | 279 // thread. |
269 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 280 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
270 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 281 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
271 } | 282 } |
272 | 283 |
273 SynchronousCompositorOutputSurfaceDelegate* | 284 SynchronousCompositorOutputSurfaceDelegate* |
274 SynchronousCompositorOutputSurface::GetDelegate() { | 285 SynchronousCompositorOutputSurface::GetDelegate() { |
275 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 286 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
276 } | 287 } |
277 | 288 |
278 } // namespace content | 289 } // namespace content |
OLD | NEW |