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/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/renderer/gpu/frame_swap_message_queue.h" | |
16 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
17 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 18 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
18 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
19 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
20 #include "ui/gfx/skia_util.h" | 21 #include "ui/gfx/skia_util.h" |
21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 namespace { | 26 namespace { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 } | 60 } |
60 | 61 |
61 private: | 62 private: |
62 SynchronousCompositorOutputSurface* surface_; | 63 SynchronousCompositorOutputSurface* surface_; |
63 SkCanvas null_canvas_; | 64 SkCanvas null_canvas_; |
64 | 65 |
65 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); | 66 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); |
66 }; | 67 }; |
67 | 68 |
68 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 69 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
69 int routing_id) | 70 int routing_id, |
71 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) | |
70 : cc::OutputSurface( | 72 : cc::OutputSurface( |
71 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 73 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), |
72 routing_id_(routing_id), | 74 routing_id_(routing_id), |
73 needs_begin_frame_(false), | 75 needs_begin_frame_(false), |
74 invoking_composite_(false), | 76 invoking_composite_(false), |
75 did_swap_buffer_(false), | 77 did_swap_buffer_(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 weak_ptr_factory_(this) { | 82 weak_ptr_factory_(this) { |
80 capabilities_.deferred_gl_initialization = true; | 83 capabilities_.deferred_gl_initialization = true; |
81 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 84 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
82 capabilities_.adjust_deadline_for_parent = false; | 85 capabilities_.adjust_deadline_for_parent = false; |
83 // Cannot call out to GetDelegate() here as the output surface is not | 86 // Cannot call out to GetDelegate() here as the output surface is not |
84 // constructed on the correct thread. | 87 // constructed on the correct thread. |
85 | 88 |
86 memory_policy_.priority_cutoff_when_visible = | 89 memory_policy_.priority_cutoff_when_visible = |
87 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 90 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
88 } | 91 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 cc::CompositorFrame* frame) { | 140 cc::CompositorFrame* frame) { |
138 DCHECK(CalledOnValidThread()); | 141 DCHECK(CalledOnValidThread()); |
139 if (!ForcedDrawToSoftwareDevice()) { | 142 if (!ForcedDrawToSoftwareDevice()) { |
140 DCHECK(context_provider_); | 143 DCHECK(context_provider_); |
141 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); | 144 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); |
142 } | 145 } |
143 UpdateFrameMetaData(frame->metadata); | 146 UpdateFrameMetaData(frame->metadata); |
144 | 147 |
145 did_swap_buffer_ = true; | 148 did_swap_buffer_ = true; |
146 client_->DidSwapBuffers(); | 149 client_->DidSwapBuffers(); |
150 | |
151 // We don't care about the SendMessageScope since we're already on the UI | |
boliu
2014/05/23 06:27:00
This might not be UI in webview until we turn on u
mkosiba (inactive)
2014/05/23 15:50:38
What?! Then the DCHECK(CalledOnValidThread()); on
| |
152 // thread. | |
153 std::vector<IPC::Message> messages_to_deliver_with_frame; | |
154 frame_swap_message_queue_->DrainMessages(client_->GetSourceFrameNumber(), | |
boliu
2014/05/23 06:27:00
Should the SourceFrameNumber be part of Compositor
mkosiba (inactive)
2014/05/23 15:50:38
Don't need it at all now.
| |
155 &messages_to_deliver_with_frame); | |
156 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | |
157 if (delegate) | |
158 delegate->DeliverMessages(messages_to_deliver_with_frame); | |
147 } | 159 } |
148 | 160 |
149 void SynchronousCompositorOutputSurface::UpdateFrameMetaData( | 161 void SynchronousCompositorOutputSurface::UpdateFrameMetaData( |
150 const cc::CompositorFrameMetadata& frame_info) { | 162 const cc::CompositorFrameMetadata& frame_info) { |
151 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 163 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
152 BrowserThread::PostTask( | 164 BrowserThread::PostTask( |
153 BrowserThread::UI, | 165 BrowserThread::UI, |
154 FROM_HERE, | 166 FROM_HERE, |
155 base::Bind(&SynchronousCompositorOutputSurface::UpdateFrameMetaData, | 167 base::Bind(&SynchronousCompositorOutputSurface::UpdateFrameMetaData, |
156 weak_ptr_factory_.GetWeakPtr(), | 168 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 287 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
276 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 288 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
277 } | 289 } |
278 | 290 |
279 SynchronousCompositorOutputSurfaceDelegate* | 291 SynchronousCompositorOutputSurfaceDelegate* |
280 SynchronousCompositorOutputSurface::GetDelegate() { | 292 SynchronousCompositorOutputSurface::GetDelegate() { |
281 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 293 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
282 } | 294 } |
283 | 295 |
284 } // namespace content | 296 } // namespace content |
OLD | NEW |