| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 cc::CompositorFrame submit_frame; | 241 cc::CompositorFrame submit_frame; |
| 242 | 242 |
| 243 if (in_software_draw_) { | 243 if (in_software_draw_) { |
| 244 // The frame we send to the client is actually just the metadata. Preserve | 244 // The frame we send to the client is actually just the metadata. Preserve |
| 245 // the |frame| for the software path below. | 245 // the |frame| for the software path below. |
| 246 submit_frame.metadata = frame.metadata.Clone(); | 246 submit_frame.metadata = frame.metadata.Clone(); |
| 247 | 247 |
| 248 if (!root_local_frame_id_.is_valid()) { | 248 if (!root_local_surface_id_.is_valid()) { |
| 249 root_local_frame_id_ = surface_id_allocator_->GenerateId(); | 249 root_local_surface_id_ = surface_id_allocator_->GenerateId(); |
| 250 child_local_frame_id_ = surface_id_allocator_->GenerateId(); | 250 child_local_surface_id_ = surface_id_allocator_->GenerateId(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 display_->SetLocalFrameId(root_local_frame_id_, | 253 display_->SetLocalSurfaceId(root_local_surface_id_, |
| 254 frame.metadata.device_scale_factor); | 254 frame.metadata.device_scale_factor); |
| 255 | 255 |
| 256 // The layer compositor should be giving a frame that covers the | 256 // The layer compositor should be giving a frame that covers the |
| 257 // |sw_viewport_for_current_draw_| but at 0,0. | 257 // |sw_viewport_for_current_draw_| but at 0,0. |
| 258 gfx::Size child_size = sw_viewport_for_current_draw_.size(); | 258 gfx::Size child_size = sw_viewport_for_current_draw_.size(); |
| 259 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); | 259 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); |
| 260 | 260 |
| 261 // Make a size that covers from 0,0 and includes the area coming from the | 261 // Make a size that covers from 0,0 and includes the area coming from the |
| 262 // layer compositor. | 262 // layer compositor. |
| 263 gfx::Size display_size(sw_viewport_for_current_draw_.right(), | 263 gfx::Size display_size(sw_viewport_for_current_draw_.right(), |
| 264 sw_viewport_for_current_draw_.bottom()); | 264 sw_viewport_for_current_draw_.bottom()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 288 auto* shared_quad_state = | 288 auto* shared_quad_state = |
| 289 embed_render_pass->CreateAndAppendSharedQuadState(); | 289 embed_render_pass->CreateAndAppendSharedQuadState(); |
| 290 auto* surface_quad = | 290 auto* surface_quad = |
| 291 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 291 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
| 292 shared_quad_state->SetAll( | 292 shared_quad_state->SetAll( |
| 293 child_transform, child_size, gfx::Rect(child_size), | 293 child_transform, child_size, gfx::Rect(child_size), |
| 294 gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */, | 294 gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */, |
| 295 SkBlendMode::kSrcOver, 0 /* sorting_context_id */); | 295 SkBlendMode::kSrcOver, 0 /* sorting_context_id */); |
| 296 surface_quad->SetNew( | 296 surface_quad->SetNew( |
| 297 shared_quad_state, gfx::Rect(child_size), gfx::Rect(child_size), | 297 shared_quad_state, gfx::Rect(child_size), gfx::Rect(child_size), |
| 298 cc::SurfaceId(kChildFrameSinkId, child_local_frame_id_)); | 298 cc::SurfaceId(kChildFrameSinkId, child_local_surface_id_)); |
| 299 | 299 |
| 300 child_factory_->SubmitCompositorFrame( | 300 child_factory_->SubmitCompositorFrame(child_local_surface_id_, |
| 301 child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); | 301 std::move(frame), |
| 302 root_factory_->SubmitCompositorFrame(root_local_frame_id_, | 302 base::Bind(&NoOpDrawCallback)); |
| 303 root_factory_->SubmitCompositorFrame(root_local_surface_id_, |
| 303 std::move(embed_frame), | 304 std::move(embed_frame), |
| 304 base::Bind(&NoOpDrawCallback)); | 305 base::Bind(&NoOpDrawCallback)); |
| 305 display_->DrawAndSwap(); | 306 display_->DrawAndSwap(); |
| 306 } else { | 307 } else { |
| 307 // For hardware draws we send the whole frame to the client so it can draw | 308 // For hardware draws we send the whole frame to the client so it can draw |
| 308 // the content in it. | 309 // the content in it. |
| 309 submit_frame = std::move(frame); | 310 submit_frame = std::move(frame); |
| 310 } | 311 } |
| 311 | 312 |
| 312 sync_client_->SubmitCompositorFrame(compositor_frame_sink_id_, | 313 sync_client_->SubmitCompositorFrame(compositor_frame_sink_id_, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 client_->ReclaimResources(resources); | 471 client_->ReclaimResources(resources); |
| 471 } | 472 } |
| 472 | 473 |
| 473 void SynchronousCompositorFrameSink::SetBeginFrameSource( | 474 void SynchronousCompositorFrameSink::SetBeginFrameSource( |
| 474 cc::BeginFrameSource* begin_frame_source) { | 475 cc::BeginFrameSource* begin_frame_source) { |
| 475 // Software output is synchronous and doesn't use a BeginFrameSource. | 476 // Software output is synchronous and doesn't use a BeginFrameSource. |
| 476 NOTREACHED(); | 477 NOTREACHED(); |
| 477 } | 478 } |
| 478 | 479 |
| 479 } // namespace content | 480 } // namespace content |
| OLD | NEW |