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