| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 synchronous_input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings( | 143 synchronous_input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings( |
| 144 nullptr); | 144 nullptr); |
| 145 | 145 |
| 146 synchronous_input_handler_proxy_ = nullptr; | 146 synchronous_input_handler_proxy_ = nullptr; |
| 147 begin_frame_source_ = nullptr; | 147 begin_frame_source_ = nullptr; |
| 148 output_surface_ = nullptr; | 148 output_surface_ = nullptr; |
| 149 // Don't propogate this signal from one renderer to the next. | 149 // Don't propogate this signal from one renderer to the next. |
| 150 need_animate_input_ = false; | 150 need_animate_input_ = false; |
| 151 } | 151 } |
| 152 | 152 |
| 153 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( | 153 SynchronousCompositor::Frame SynchronousCompositorImpl::DemandDrawHw( |
| 154 const gfx::Size& surface_size, | 154 const gfx::Size& surface_size, |
| 155 const gfx::Transform& transform, | 155 const gfx::Transform& transform, |
| 156 const gfx::Rect& viewport, | 156 const gfx::Rect& viewport, |
| 157 const gfx::Rect& clip, | 157 const gfx::Rect& clip, |
| 158 const gfx::Rect& viewport_rect_for_tile_priority, | 158 const gfx::Rect& viewport_rect_for_tile_priority, |
| 159 const gfx::Transform& transform_for_tile_priority) { | 159 const gfx::Transform& transform_for_tile_priority) { |
| 160 DCHECK(CalledOnValidThread()); | 160 DCHECK(CalledOnValidThread()); |
| 161 DCHECK(output_surface_); | 161 DCHECK(output_surface_); |
| 162 DCHECK(begin_frame_source_); | 162 DCHECK(begin_frame_source_); |
| 163 DCHECK(!frame_holder_); | 163 DCHECK(!frame_holder_.frame); |
| 164 | 164 |
| 165 output_surface_->DemandDrawHw(surface_size, transform, viewport, clip, | 165 output_surface_->DemandDrawHw(surface_size, transform, viewport, clip, |
| 166 viewport_rect_for_tile_priority, | 166 viewport_rect_for_tile_priority, |
| 167 transform_for_tile_priority); | 167 transform_for_tile_priority); |
| 168 | 168 |
| 169 if (frame_holder_) | 169 if (frame_holder_.frame) |
| 170 UpdateFrameMetaData(frame_holder_->metadata); | 170 UpdateFrameMetaData(frame_holder_.frame->metadata); |
| 171 | 171 |
| 172 return std::move(frame_holder_); | 172 return std::move(frame_holder_); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void SynchronousCompositorImpl::ReturnResources( | 175 void SynchronousCompositorImpl::ReturnResources( |
| 176 uint32_t output_surface_id, |
| 176 const cc::CompositorFrameAck& frame_ack) { | 177 const cc::CompositorFrameAck& frame_ack) { |
| 177 DCHECK(CalledOnValidThread()); | 178 DCHECK(CalledOnValidThread()); |
| 178 output_surface_->ReturnResources(frame_ack); | 179 output_surface_->ReturnResources(output_surface_id, frame_ack); |
| 179 } | 180 } |
| 180 | 181 |
| 181 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { | 182 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { |
| 182 DCHECK(CalledOnValidThread()); | 183 DCHECK(CalledOnValidThread()); |
| 183 DCHECK(output_surface_); | 184 DCHECK(output_surface_); |
| 184 DCHECK(begin_frame_source_); | 185 DCHECK(begin_frame_source_); |
| 185 DCHECK(!frame_holder_); | 186 DCHECK(!frame_holder_.frame); |
| 186 | 187 |
| 187 output_surface_->DemandDrawSw(canvas); | 188 output_surface_->DemandDrawSw(canvas); |
| 188 | 189 |
| 189 bool success = !!frame_holder_; | 190 bool success = !!frame_holder_.frame; |
| 190 if (frame_holder_) { | 191 if (frame_holder_.frame) { |
| 191 UpdateFrameMetaData(frame_holder_->metadata); | 192 UpdateFrameMetaData(frame_holder_.frame->metadata); |
| 192 frame_holder_.reset(); | 193 frame_holder_.frame.reset(); |
| 193 } | 194 } |
| 194 | 195 |
| 195 return success; | 196 return success; |
| 196 } | 197 } |
| 197 | 198 |
| 198 void SynchronousCompositorImpl::SwapBuffers(cc::CompositorFrame* frame) { | 199 void SynchronousCompositorImpl::SwapBuffers(uint32_t output_surface_id, |
| 199 DCHECK(!frame_holder_); | 200 cc::CompositorFrame* frame) { |
| 200 frame_holder_.reset(new cc::CompositorFrame); | 201 DCHECK(!frame_holder_.frame); |
| 201 frame->AssignTo(frame_holder_.get()); | 202 frame_holder_.output_surface_id = output_surface_id; |
| 203 frame_holder_.frame.reset(new cc::CompositorFrame); |
| 204 frame->AssignTo(frame_holder_.frame.get()); |
| 202 } | 205 } |
| 203 | 206 |
| 204 void SynchronousCompositorImpl::UpdateFrameMetaData( | 207 void SynchronousCompositorImpl::UpdateFrameMetaData( |
| 205 const cc::CompositorFrameMetadata& frame_metadata) { | 208 const cc::CompositorFrameMetadata& frame_metadata) { |
| 206 rwhva_->SynchronousFrameMetadata(frame_metadata); | 209 rwhva_->SynchronousFrameMetadata(frame_metadata); |
| 207 DeliverMessages(); | 210 DeliverMessages(); |
| 208 } | 211 } |
| 209 | 212 |
| 210 void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { | 213 void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { |
| 211 DCHECK(CalledOnValidThread()); | 214 DCHECK(CalledOnValidThread()); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 362 } |
| 360 } | 363 } |
| 361 | 364 |
| 362 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 365 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 363 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. | 366 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. |
| 364 bool SynchronousCompositorImpl::CalledOnValidThread() const { | 367 bool SynchronousCompositorImpl::CalledOnValidThread() const { |
| 365 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 368 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 366 } | 369 } |
| 367 | 370 |
| 368 } // namespace content | 371 } // namespace content |
| OLD | NEW |