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_impl.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
11 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" |
12 #include "content/browser/android/in_process/synchronous_compositor_registry_in_
proc.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_registry_in_
proc.h" |
13 #include "content/browser/android/in_process/synchronous_input_event_filter.h" | 15 #include "content/browser/android/in_process/synchronous_input_event_filter.h" |
14 #include "content/browser/gpu/gpu_process_host.h" | 16 #include "content/browser/gpu/gpu_process_host.h" |
15 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
16 #include "content/common/input/did_overscroll_params.h" | 18 #include "content/common/input/did_overscroll_params.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( | 158 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( |
157 const gfx::Size& surface_size, | 159 const gfx::Size& surface_size, |
158 const gfx::Transform& transform, | 160 const gfx::Transform& transform, |
159 const gfx::Rect& viewport, | 161 const gfx::Rect& viewport, |
160 const gfx::Rect& clip, | 162 const gfx::Rect& clip, |
161 const gfx::Rect& viewport_rect_for_tile_priority, | 163 const gfx::Rect& viewport_rect_for_tile_priority, |
162 const gfx::Transform& transform_for_tile_priority) { | 164 const gfx::Transform& transform_for_tile_priority) { |
163 DCHECK(CalledOnValidThread()); | 165 DCHECK(CalledOnValidThread()); |
164 DCHECK(output_surface_); | 166 DCHECK(output_surface_); |
165 DCHECK(begin_frame_source_); | 167 DCHECK(begin_frame_source_); |
| 168 DCHECK(!frame_holder_); |
166 | 169 |
167 scoped_ptr<cc::CompositorFrame> frame = | 170 output_surface_->DemandDrawHw(surface_size, transform, viewport, clip, |
168 output_surface_->DemandDrawHw(surface_size, | 171 viewport_rect_for_tile_priority, |
169 transform, | 172 transform_for_tile_priority); |
170 viewport, | |
171 clip, | |
172 viewport_rect_for_tile_priority, | |
173 transform_for_tile_priority); | |
174 | 173 |
175 if (frame.get()) | 174 if (frame_holder_) |
176 UpdateFrameMetaData(frame->metadata); | 175 UpdateFrameMetaData(frame_holder_->metadata); |
177 | 176 |
178 return frame.Pass(); | 177 return std::move(frame_holder_); |
179 } | 178 } |
180 | 179 |
181 void SynchronousCompositorImpl::ReturnResources( | 180 void SynchronousCompositorImpl::ReturnResources( |
182 const cc::CompositorFrameAck& frame_ack) { | 181 const cc::CompositorFrameAck& frame_ack) { |
183 DCHECK(CalledOnValidThread()); | 182 DCHECK(CalledOnValidThread()); |
184 output_surface_->ReturnResources(frame_ack); | 183 output_surface_->ReturnResources(frame_ack); |
185 } | 184 } |
186 | 185 |
187 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { | 186 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { |
188 DCHECK(CalledOnValidThread()); | 187 DCHECK(CalledOnValidThread()); |
189 DCHECK(output_surface_); | 188 DCHECK(output_surface_); |
190 DCHECK(begin_frame_source_); | 189 DCHECK(begin_frame_source_); |
| 190 DCHECK(!frame_holder_); |
191 | 191 |
192 scoped_ptr<cc::CompositorFrame> frame = | 192 output_surface_->DemandDrawSw(canvas); |
193 output_surface_->DemandDrawSw(canvas); | |
194 | 193 |
195 if (frame.get()) | 194 bool success = !!frame_holder_; |
196 UpdateFrameMetaData(frame->metadata); | 195 if (frame_holder_) { |
| 196 UpdateFrameMetaData(frame_holder_->metadata); |
| 197 frame_holder_.reset(); |
| 198 } |
197 | 199 |
198 return !!frame.get(); | 200 return success; |
| 201 } |
| 202 |
| 203 void SynchronousCompositorImpl::SwapBuffers(cc::CompositorFrame* frame) { |
| 204 DCHECK(!frame_holder_); |
| 205 frame_holder_.reset(new cc::CompositorFrame); |
| 206 frame->AssignTo(frame_holder_.get()); |
199 } | 207 } |
200 | 208 |
201 void SynchronousCompositorImpl::UpdateFrameMetaData( | 209 void SynchronousCompositorImpl::UpdateFrameMetaData( |
202 const cc::CompositorFrameMetadata& frame_metadata) { | 210 const cc::CompositorFrameMetadata& frame_metadata) { |
203 rwhva_->SynchronousFrameMetadata(frame_metadata); | 211 rwhva_->SynchronousFrameMetadata(frame_metadata); |
204 DeliverMessages(); | 212 DeliverMessages(); |
205 } | 213 } |
206 | 214 |
207 void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { | 215 void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { |
208 DCHECK(CalledOnValidThread()); | 216 DCHECK(CalledOnValidThread()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 357 } |
350 } | 358 } |
351 | 359 |
352 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 360 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
353 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. | 361 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. |
354 bool SynchronousCompositorImpl::CalledOnValidThread() const { | 362 bool SynchronousCompositorImpl::CalledOnValidThread() const { |
355 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 363 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
356 } | 364 } |
357 | 365 |
358 } // namespace content | 366 } // namespace content |
OLD | NEW |