Chromium Code Reviews| 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/renderer/android/synchronous_compositor_output_surface.h" | 5 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 // Intentional no-op: surface size is controlled by the embedder. | 190 // Intentional no-op: surface size is controlled by the embedder. |
| 191 } | 191 } |
| 192 | 192 |
| 193 static void NoOpDrawCallback(cc::SurfaceDrawStatus s) {} | 193 static void NoOpDrawCallback(cc::SurfaceDrawStatus s) {} |
| 194 | 194 |
| 195 void SynchronousCompositorOutputSurface::SwapBuffers( | 195 void SynchronousCompositorOutputSurface::SwapBuffers( |
| 196 cc::CompositorFrame frame) { | 196 cc::CompositorFrame frame) { |
| 197 DCHECK(CalledOnValidThread()); | 197 DCHECK(CalledOnValidThread()); |
| 198 DCHECK(sync_client_); | 198 DCHECK(sync_client_); |
| 199 | 199 |
| 200 client_->DidSwapBuffers(); | |
|
boliu
2016/07/07 21:30:31
sync_client_->SwapBuffers sends the reply of the s
| |
| 201 | |
| 202 if (fallback_tick_running_) { | |
| 203 client_->DidSwapBuffersComplete(); | |
| 204 cc::ReturnedResourceArray return_resources; | |
| 205 cc::TransferableResource::ReturnResources( | |
| 206 frame.delegated_frame_data->resource_list, &return_resources); | |
| 207 ReturnResources(return_resources); | |
|
boliu
2016/07/07 21:30:31
again, can we skip this and just DCHECK there are
danakj
2016/07/07 22:08:34
DCHECKing empty, but still sending back the ack to
| |
| 208 return; | |
| 209 } | |
| 210 | |
| 200 cc::CompositorFrame swap_frame; | 211 cc::CompositorFrame swap_frame; |
| 201 | 212 |
| 202 if (in_software_draw_) { | 213 if (in_software_draw_) { |
| 203 // The frame we send to the client is actually just the metadata. Preserve | 214 // The frame we send to the client is actually just the metadata. Preserve |
| 204 // the |frame| for the software path below. | 215 // the |frame| for the software path below. |
| 205 swap_frame.metadata = frame.metadata.Clone(); | 216 swap_frame.metadata = frame.metadata.Clone(); |
| 206 | 217 |
| 207 if (delegated_surface_id_.is_null()) { | 218 if (delegated_surface_id_.is_null()) { |
| 208 delegated_surface_id_ = surface_id_allocator_->GenerateId(); | 219 delegated_surface_id_ = surface_id_allocator_->GenerateId(); |
| 209 surface_factory_->Create(delegated_surface_id_); | 220 surface_factory_->Create(delegated_surface_id_); |
| 210 } | 221 } |
| 211 | 222 |
| 212 display_->SetSurfaceId(delegated_surface_id_, | 223 display_->SetSurfaceId(delegated_surface_id_, |
| 213 frame.metadata.device_scale_factor); | 224 frame.metadata.device_scale_factor); |
| 214 | 225 |
| 215 gfx::Size frame_size = | 226 gfx::Size frame_size = |
| 216 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 227 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
| 217 display_->Resize(frame_size); | 228 display_->Resize(frame_size); |
| 218 | 229 |
| 219 surface_factory_->SubmitCompositorFrame( | 230 surface_factory_->SubmitCompositorFrame( |
| 220 delegated_surface_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); | 231 delegated_surface_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); |
| 221 display_->DrawAndSwap(); | 232 display_->DrawAndSwap(); |
| 222 } else { | 233 } else { |
| 234 // For hardware draws we send the whole frame to the client so it can draw | |
| 235 // the content in it. | |
| 223 swap_frame = std::move(frame); | 236 swap_frame = std::move(frame); |
| 224 } | 237 } |
| 225 | 238 |
| 226 if (!fallback_tick_running_) { | 239 sync_client_->SwapBuffers(output_surface_id_, std::move(swap_frame)); |
| 227 sync_client_->SwapBuffers(output_surface_id_, std::move(swap_frame)); | 240 DeliverMessages(); |
| 228 DeliverMessages(); | |
| 229 } | |
| 230 client_->DidSwapBuffers(); | |
| 231 did_swap_ = true; | 241 did_swap_ = true; |
| 232 } | 242 } |
| 233 | 243 |
| 234 void SynchronousCompositorOutputSurface::CancelFallbackTick() { | 244 void SynchronousCompositorOutputSurface::CancelFallbackTick() { |
| 235 fallback_tick_.Cancel(); | 245 fallback_tick_.Cancel(); |
| 236 fallback_tick_pending_ = false; | 246 fallback_tick_pending_ = false; |
| 237 } | 247 } |
| 238 | 248 |
| 239 void SynchronousCompositorOutputSurface::FallbackTickFired() { | 249 void SynchronousCompositorOutputSurface::FallbackTickFired() { |
| 240 DCHECK(CalledOnValidThread()); | 250 DCHECK(CalledOnValidThread()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 client_->ReclaimResources(&ack); | 403 client_->ReclaimResources(&ack); |
| 394 } | 404 } |
| 395 | 405 |
| 396 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 406 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
| 397 cc::BeginFrameSource* begin_frame_source) { | 407 cc::BeginFrameSource* begin_frame_source) { |
| 398 // Software output is synchronous and doesn't use a BeginFrameSource. | 408 // Software output is synchronous and doesn't use a BeginFrameSource. |
| 399 NOTREACHED(); | 409 NOTREACHED(); |
| 400 } | 410 } |
| 401 | 411 |
| 402 } // namespace content | 412 } // namespace content |
| OLD | NEW |