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