| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 cc::CompositorFrame submit_frame; | 238 cc::CompositorFrame submit_frame; |
| 239 | 239 |
| 240 if (in_software_draw_) { | 240 if (in_software_draw_) { |
| 241 // The frame we send to the client is actually just the metadata. Preserve | 241 // The frame we send to the client is actually just the metadata. Preserve |
| 242 // the |frame| for the software path below. | 242 // the |frame| for the software path below. |
| 243 submit_frame.metadata = frame.metadata.Clone(); | 243 submit_frame.metadata = frame.metadata.Clone(); |
| 244 | 244 |
| 245 if (!root_local_surface_id_.is_valid()) { | |
| 246 root_local_surface_id_ = local_surface_id_allocator_->GenerateId(); | |
| 247 child_local_surface_id_ = local_surface_id_allocator_->GenerateId(); | |
| 248 } | |
| 249 | |
| 250 display_->SetLocalSurfaceId(root_local_surface_id_, | |
| 251 frame.metadata.device_scale_factor); | |
| 252 | |
| 253 // The layer compositor should be giving a frame that covers the | 245 // The layer compositor should be giving a frame that covers the |
| 254 // |sw_viewport_for_current_draw_| but at 0,0. | 246 // |sw_viewport_for_current_draw_| but at 0,0. |
| 255 gfx::Size child_size = sw_viewport_for_current_draw_.size(); | 247 gfx::Size child_size = sw_viewport_for_current_draw_.size(); |
| 256 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); | 248 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); |
| 257 | 249 |
| 258 // Make a size that covers from 0,0 and includes the area coming from the | 250 // Make a size that covers from 0,0 and includes the area coming from the |
| 259 // layer compositor. | 251 // layer compositor. |
| 260 gfx::Size display_size(sw_viewport_for_current_draw_.right(), | 252 gfx::Size display_size(sw_viewport_for_current_draw_.right(), |
| 261 sw_viewport_for_current_draw_.bottom()); | 253 sw_viewport_for_current_draw_.bottom()); |
| 262 display_->Resize(display_size); | 254 display_->Resize(display_size); |
| 263 | 255 |
| 256 if (!root_local_surface_id_.is_valid() || display_size_ != display_size || |
| 257 device_scale_factor_ != frame.metadata.device_scale_factor) { |
| 258 root_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 259 display_size_ = display_size; |
| 260 device_scale_factor_ = frame.metadata.device_scale_factor; |
| 261 } |
| 262 |
| 263 if (!child_local_surface_id_.is_valid() || child_size_ != child_size || |
| 264 device_scale_factor_ != frame.metadata.device_scale_factor) { |
| 265 child_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 266 child_size_ = child_size; |
| 267 device_scale_factor_ = frame.metadata.device_scale_factor; |
| 268 } |
| 269 |
| 270 display_->SetLocalSurfaceId(root_local_surface_id_, |
| 271 frame.metadata.device_scale_factor); |
| 272 |
| 264 // The offset for the child frame relative to the origin of the canvas being | 273 // The offset for the child frame relative to the origin of the canvas being |
| 265 // drawn into. | 274 // drawn into. |
| 266 gfx::Transform child_transform; | 275 gfx::Transform child_transform; |
| 267 child_transform.Translate( | 276 child_transform.Translate( |
| 268 gfx::Vector2dF(sw_viewport_for_current_draw_.OffsetFromOrigin())); | 277 gfx::Vector2dF(sw_viewport_for_current_draw_.OffsetFromOrigin())); |
| 269 | 278 |
| 270 // Make a root frame that embeds the frame coming from the layer compositor | 279 // Make a root frame that embeds the frame coming from the layer compositor |
| 271 // and positions it based on the provided viewport. | 280 // and positions it based on the provided viewport. |
| 272 // TODO(danakj): We could apply the transform here instead of passing it to | 281 // TODO(danakj): We could apply the transform here instead of passing it to |
| 273 // the CompositorFrameSink client too? (We'd have to do the same for | 282 // the CompositorFrameSink client too? (We'd have to do the same for |
| 274 // hardware frames in SurfacesInstance?) | 283 // hardware frames in SurfacesInstance?) |
| 275 cc::CompositorFrame embed_frame; | 284 cc::CompositorFrame embed_frame; |
| 276 embed_frame.metadata.begin_frame_ack = frame.metadata.begin_frame_ack; | 285 embed_frame.metadata.begin_frame_ack = frame.metadata.begin_frame_ack; |
| 286 embed_frame.metadata.device_scale_factor = |
| 287 frame.metadata.device_scale_factor; |
| 277 embed_frame.render_pass_list.push_back(cc::RenderPass::Create()); | 288 embed_frame.render_pass_list.push_back(cc::RenderPass::Create()); |
| 278 | 289 |
| 279 // The embedding RenderPass covers the entire Display's area. | 290 // The embedding RenderPass covers the entire Display's area. |
| 280 const auto& embed_render_pass = embed_frame.render_pass_list.back(); | 291 const auto& embed_render_pass = embed_frame.render_pass_list.back(); |
| 281 embed_render_pass->SetNew(1, gfx::Rect(display_size), | 292 embed_render_pass->SetNew(1, gfx::Rect(display_size), |
| 282 gfx::Rect(display_size), gfx::Transform()); | 293 gfx::Rect(display_size), gfx::Transform()); |
| 283 embed_render_pass->has_transparent_background = false; | 294 embed_render_pass->has_transparent_background = false; |
| 284 | 295 |
| 285 // The RenderPass has a single SurfaceDrawQuad (and SharedQuadState for it). | 296 // The RenderPass has a single SurfaceDrawQuad (and SharedQuadState for it). |
| 286 auto* shared_quad_state = | 297 auto* shared_quad_state = |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 const cc::ReturnedResourceArray& resources) { | 485 const cc::ReturnedResourceArray& resources) { |
| 475 DCHECK(resources.empty()); | 486 DCHECK(resources.empty()); |
| 476 client_->ReclaimResources(resources); | 487 client_->ReclaimResources(resources); |
| 477 } | 488 } |
| 478 | 489 |
| 479 void SynchronousCompositorFrameSink::WillDrawSurface( | 490 void SynchronousCompositorFrameSink::WillDrawSurface( |
| 480 const cc::LocalSurfaceId& local_surface_id, | 491 const cc::LocalSurfaceId& local_surface_id, |
| 481 const gfx::Rect& damage_rect) {} | 492 const gfx::Rect& damage_rect) {} |
| 482 | 493 |
| 483 } // namespace content | 494 } // namespace content |
| OLD | NEW |