| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/renderer_host/delegated_frame_host.h" | 5 #include "content/browser/renderer_host/delegated_frame_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 surface_factory_->RequestCopyOfSurface(local_frame_id_, | 397 surface_factory_->RequestCopyOfSurface(local_frame_id_, |
| 398 std::move(request)); | 398 std::move(request)); |
| 399 } else { | 399 } else { |
| 400 request->set_area(gfx::Rect(current_frame_size_in_dip_)); | 400 request->set_area(gfx::Rect(current_frame_size_in_dip_)); |
| 401 RequestCopyOfOutput(std::move(request)); | 401 RequestCopyOfOutput(std::move(request)); |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, | 405 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, |
| 406 cc::CompositorFrame frame) { | 406 cc::CompositorFrame frame) { |
| 407 DCHECK(frame.delegated_frame_data.get()); | |
| 408 #if defined(OS_CHROMEOS) | 407 #if defined(OS_CHROMEOS) |
| 409 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); | 408 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); |
| 410 #endif | 409 #endif |
| 411 cc::DelegatedFrameData* frame_data = frame.delegated_frame_data.get(); | |
| 412 float frame_device_scale_factor = frame.metadata.device_scale_factor; | 410 float frame_device_scale_factor = frame.metadata.device_scale_factor; |
| 413 | 411 |
| 414 DCHECK(!frame_data->render_pass_list.empty()); | 412 DCHECK(!frame.render_pass_list.empty()); |
| 415 | 413 |
| 416 cc::RenderPass* root_pass = frame_data->render_pass_list.back().get(); | 414 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
| 417 | 415 |
| 418 gfx::Size frame_size = root_pass->output_rect.size(); | 416 gfx::Size frame_size = root_pass->output_rect.size(); |
| 419 gfx::Size frame_size_in_dip = | 417 gfx::Size frame_size_in_dip = |
| 420 gfx::ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 418 gfx::ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 421 | 419 |
| 422 gfx::Rect damage_rect = root_pass->damage_rect; | 420 gfx::Rect damage_rect = root_pass->damage_rect; |
| 423 damage_rect.Intersect(gfx::Rect(frame_size)); | 421 damage_rect.Intersect(gfx::Rect(frame_size)); |
| 424 gfx::Rect damage_rect_in_dip = | 422 gfx::Rect damage_rect_in_dip = |
| 425 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); | 423 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); |
| 426 | 424 |
| 427 if (ShouldSkipFrame(frame_size_in_dip)) { | 425 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 428 cc::ReturnedResourceArray resources; | 426 cc::ReturnedResourceArray resources; |
| 429 cc::TransferableResource::ReturnResources(frame_data->resource_list, | 427 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); |
| 430 &resources); | |
| 431 | 428 |
| 432 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), | 429 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), |
| 433 frame.metadata.latency_info.begin(), | 430 frame.metadata.latency_info.begin(), |
| 434 frame.metadata.latency_info.end()); | 431 frame.metadata.latency_info.end()); |
| 435 | 432 |
| 436 client_->DelegatedFrameHostSendReclaimCompositorResources( | 433 client_->DelegatedFrameHostSendReclaimCompositorResources( |
| 437 compositor_frame_sink_id, true /* is_swap_ack*/, resources); | 434 compositor_frame_sink_id, true /* is_swap_ack*/, resources); |
| 438 skipped_frames_ = true; | 435 skipped_frames_ = true; |
| 439 return; | 436 return; |
| 440 } | 437 } |
| 441 | 438 |
| 442 if (skipped_frames_) { | 439 if (skipped_frames_) { |
| 443 skipped_frames_ = false; | 440 skipped_frames_ = false; |
| 444 damage_rect = gfx::Rect(frame_size); | 441 damage_rect = gfx::Rect(frame_size); |
| 445 damage_rect_in_dip = gfx::Rect(frame_size_in_dip); | 442 damage_rect_in_dip = gfx::Rect(frame_size_in_dip); |
| 446 | 443 |
| 447 // Give the same damage rect to the compositor. | 444 // Give the same damage rect to the compositor. |
| 448 cc::RenderPass* root_pass = frame_data->render_pass_list.back().get(); | 445 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
| 449 root_pass->damage_rect = damage_rect; | 446 root_pass->damage_rect = damage_rect; |
| 450 } | 447 } |
| 451 | 448 |
| 452 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) { | 449 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) { |
| 453 // Resource ids are scoped by the output surface. | 450 // Resource ids are scoped by the output surface. |
| 454 // If the originating output surface doesn't match the last one, it | 451 // If the originating output surface doesn't match the last one, it |
| 455 // indicates the renderer's output surface may have been recreated, in which | 452 // indicates the renderer's output surface may have been recreated, in which |
| 456 // case we should recreate the DelegatedRendererLayer, to avoid matching | 453 // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 457 // resources from the old one with resources from the new one which would | 454 // resources from the old one with resources from the new one which would |
| 458 // have the same id. Changing the layer to showing painted content destroys | 455 // have the same id. Changing the layer to showing painted content destroys |
| 459 // the DelegatedRendererLayer. | 456 // the DelegatedRendererLayer. |
| 460 EvictDelegatedFrame(); | 457 EvictDelegatedFrame(); |
| 461 | 458 |
| 462 surface_factory_.reset(); | 459 surface_factory_.reset(); |
| 463 if (!surface_returned_resources_.empty()) { | 460 if (!surface_returned_resources_.empty()) { |
| 464 SendReclaimCompositorResources(last_compositor_frame_sink_id_, | 461 SendReclaimCompositorResources(last_compositor_frame_sink_id_, |
| 465 false /* is_swap_ack */); | 462 false /* is_swap_ack */); |
| 466 } | 463 } |
| 467 last_compositor_frame_sink_id_ = compositor_frame_sink_id; | 464 last_compositor_frame_sink_id_ = compositor_frame_sink_id; |
| 468 } | 465 } |
| 469 bool skip_frame = false; | 466 bool skip_frame = false; |
| 470 pending_delegated_ack_count_++; | 467 pending_delegated_ack_count_++; |
| 471 | 468 |
| 472 background_color_ = frame.metadata.root_background_color; | 469 background_color_ = frame.metadata.root_background_color; |
| 473 | 470 |
| 474 if (frame_size.IsEmpty()) { | 471 if (frame_size.IsEmpty()) { |
| 475 DCHECK(frame_data->resource_list.empty()); | 472 DCHECK(frame.resource_list.empty()); |
| 476 EvictDelegatedFrame(); | 473 EvictDelegatedFrame(); |
| 477 } else { | 474 } else { |
| 478 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 475 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 479 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 476 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 480 if (!surface_factory_) { | 477 if (!surface_factory_) { |
| 481 surface_factory_ = | 478 surface_factory_ = |
| 482 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); | 479 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); |
| 483 } | 480 } |
| 484 if (local_frame_id_.is_null() || frame_size != current_surface_size_ || | 481 if (local_frame_id_.is_null() || frame_size != current_surface_size_ || |
| 485 frame_size_in_dip != current_frame_size_in_dip_) { | 482 frame_size_in_dip != current_frame_size_in_dip_) { |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 new_layer->SetShowSurface( | 903 new_layer->SetShowSurface( |
| 907 cc::SurfaceId(frame_sink_id_, local_frame_id_), | 904 cc::SurfaceId(frame_sink_id_, local_frame_id_), |
| 908 base::Bind(&SatisfyCallback, base::Unretained(manager)), | 905 base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 909 base::Bind(&RequireCallback, base::Unretained(manager)), | 906 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 910 current_surface_size_, current_scale_factor_, | 907 current_surface_size_, current_scale_factor_, |
| 911 current_frame_size_in_dip_); | 908 current_frame_size_in_dip_); |
| 912 } | 909 } |
| 913 } | 910 } |
| 914 | 911 |
| 915 } // namespace content | 912 } // namespace content |
| OLD | NEW |