| 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_frame_sink.h" | 5 #include "content/renderer/android/synchronous_compositor_frame_sink.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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 214 } |
| 215 | 215 |
| 216 static void NoOpDrawCallback() {} | 216 static void NoOpDrawCallback() {} |
| 217 | 217 |
| 218 void SynchronousCompositorFrameSink::SubmitCompositorFrame( | 218 void SynchronousCompositorFrameSink::SubmitCompositorFrame( |
| 219 cc::CompositorFrame frame) { | 219 cc::CompositorFrame frame) { |
| 220 DCHECK(CalledOnValidThread()); | 220 DCHECK(CalledOnValidThread()); |
| 221 DCHECK(sync_client_); | 221 DCHECK(sync_client_); |
| 222 | 222 |
| 223 if (fallback_tick_running_) { | 223 if (fallback_tick_running_) { |
| 224 DCHECK(frame.resource_list.empty()); | 224 DCHECK(frame.delegated_frame_data->resource_list.empty()); |
| 225 cc::ReturnedResourceArray return_resources; | 225 cc::ReturnedResourceArray return_resources; |
| 226 ReturnResources(return_resources); | 226 ReturnResources(return_resources); |
| 227 did_submit_frame_ = true; | 227 did_submit_frame_ = true; |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 | 230 |
| 231 cc::CompositorFrame submit_frame; | 231 cc::CompositorFrame submit_frame; |
| 232 | 232 |
| 233 if (in_software_draw_) { | 233 if (in_software_draw_) { |
| 234 // The frame we send to the client is actually just the metadata. Preserve | 234 // The frame we send to the client is actually just the metadata. Preserve |
| 235 // the |frame| for the software path below. | 235 // the |frame| for the software path below. |
| 236 submit_frame.metadata = frame.metadata.Clone(); | 236 submit_frame.metadata = frame.metadata.Clone(); |
| 237 | 237 |
| 238 if (!root_local_frame_id_.is_valid()) { | 238 if (!root_local_frame_id_.is_valid()) { |
| 239 root_local_frame_id_ = surface_id_allocator_->GenerateId(); | 239 root_local_frame_id_ = surface_id_allocator_->GenerateId(); |
| 240 surface_factory_->Create(root_local_frame_id_); | 240 surface_factory_->Create(root_local_frame_id_); |
| 241 child_local_frame_id_ = surface_id_allocator_->GenerateId(); | 241 child_local_frame_id_ = surface_id_allocator_->GenerateId(); |
| 242 surface_factory_->Create(child_local_frame_id_); | 242 surface_factory_->Create(child_local_frame_id_); |
| 243 } | 243 } |
| 244 | 244 |
| 245 display_->SetLocalFrameId(root_local_frame_id_, | 245 display_->SetLocalFrameId(root_local_frame_id_, |
| 246 frame.metadata.device_scale_factor); | 246 frame.metadata.device_scale_factor); |
| 247 | 247 |
| 248 // The layer compositor should be giving a frame that covers the | 248 // The layer compositor should be giving a frame that covers the |
| 249 // |sw_viewport_for_current_draw_| but at 0,0. | 249 // |sw_viewport_for_current_draw_| but at 0,0. |
| 250 gfx::Size child_size = sw_viewport_for_current_draw_.size(); | 250 gfx::Size child_size = sw_viewport_for_current_draw_.size(); |
| 251 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); | 251 DCHECK(gfx::Rect(child_size) == |
| 252 frame.delegated_frame_data->render_pass_list.back()->output_rect); |
| 252 | 253 |
| 253 // Make a size that covers from 0,0 and includes the area coming from the | 254 // Make a size that covers from 0,0 and includes the area coming from the |
| 254 // layer compositor. | 255 // layer compositor. |
| 255 gfx::Size display_size(sw_viewport_for_current_draw_.right(), | 256 gfx::Size display_size(sw_viewport_for_current_draw_.right(), |
| 256 sw_viewport_for_current_draw_.bottom()); | 257 sw_viewport_for_current_draw_.bottom()); |
| 257 display_->Resize(display_size); | 258 display_->Resize(display_size); |
| 258 | 259 |
| 259 // The offset for the child frame relative to the origin of the canvas being | 260 // The offset for the child frame relative to the origin of the canvas being |
| 260 // drawn into. | 261 // drawn into. |
| 261 gfx::Transform child_transform; | 262 gfx::Transform child_transform; |
| 262 child_transform.Translate( | 263 child_transform.Translate( |
| 263 gfx::Vector2dF(sw_viewport_for_current_draw_.OffsetFromOrigin())); | 264 gfx::Vector2dF(sw_viewport_for_current_draw_.OffsetFromOrigin())); |
| 264 | 265 |
| 265 // Make a root frame that embeds the frame coming from the layer compositor | 266 // Make a root frame that embeds the frame coming from the layer compositor |
| 266 // and positions it based on the provided viewport. | 267 // and positions it based on the provided viewport. |
| 267 // TODO(danakj): We could apply the transform here instead of passing it to | 268 // TODO(danakj): We could apply the transform here instead of passing it to |
| 268 // the CompositorFrameSink client too? (We'd have to do the same for | 269 // the CompositorFrameSink client too? (We'd have to do the same for |
| 269 // hardware frames in SurfacesInstance?) | 270 // hardware frames in SurfacesInstance?) |
| 270 cc::CompositorFrame embed_frame; | 271 cc::CompositorFrame embed_frame; |
| 271 embed_frame.render_pass_list.push_back(cc::RenderPass::Create()); | 272 embed_frame.delegated_frame_data = |
| 273 base::MakeUnique<cc::DelegatedFrameData>(); |
| 274 embed_frame.delegated_frame_data->render_pass_list.push_back( |
| 275 cc::RenderPass::Create()); |
| 272 | 276 |
| 273 // The embedding RenderPass covers the entire Display's area. | 277 // The embedding RenderPass covers the entire Display's area. |
| 274 const auto& embed_render_pass = embed_frame.render_pass_list.back(); | 278 const auto& embed_render_pass = |
| 279 embed_frame.delegated_frame_data->render_pass_list.back(); |
| 275 embed_render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(display_size), | 280 embed_render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(display_size), |
| 276 gfx::Rect(display_size), gfx::Transform(), false); | 281 gfx::Rect(display_size), gfx::Transform(), false); |
| 277 | 282 |
| 278 // The RenderPass has a single SurfaceDrawQuad (and SharedQuadState for it). | 283 // The RenderPass has a single SurfaceDrawQuad (and SharedQuadState for it). |
| 279 auto* shared_quad_state = | 284 auto* shared_quad_state = |
| 280 embed_render_pass->CreateAndAppendSharedQuadState(); | 285 embed_render_pass->CreateAndAppendSharedQuadState(); |
| 281 auto* surface_quad = | 286 auto* surface_quad = |
| 282 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 287 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
| 283 shared_quad_state->SetAll( | 288 shared_quad_state->SetAll( |
| 284 child_transform, child_size, gfx::Rect(child_size), | 289 child_transform, child_size, gfx::Rect(child_size), |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 client_->ReclaimResources(resources); | 467 client_->ReclaimResources(resources); |
| 463 } | 468 } |
| 464 | 469 |
| 465 void SynchronousCompositorFrameSink::SetBeginFrameSource( | 470 void SynchronousCompositorFrameSink::SetBeginFrameSource( |
| 466 cc::BeginFrameSource* begin_frame_source) { | 471 cc::BeginFrameSource* begin_frame_source) { |
| 467 // Software output is synchronous and doesn't use a BeginFrameSource. | 472 // Software output is synchronous and doesn't use a BeginFrameSource. |
| 468 NOTREACHED(); | 473 NOTREACHED(); |
| 469 } | 474 } |
| 470 | 475 |
| 471 } // namespace content | 476 } // namespace content |
| OLD | NEW |