| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // If the originating output surface doesn't match the last one, it | 435 // If the originating output surface doesn't match the last one, it |
| 436 // indicates the renderer's output surface may have been recreated, in which | 436 // indicates the renderer's output surface may have been recreated, in which |
| 437 // case we should recreate the DelegatedRendererLayer, to avoid matching | 437 // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 438 // resources from the old one with resources from the new one which would | 438 // resources from the old one with resources from the new one which would |
| 439 // have the same id. Changing the layer to showing painted content destroys | 439 // have the same id. Changing the layer to showing painted content destroys |
| 440 // the DelegatedRendererLayer. | 440 // the DelegatedRendererLayer. |
| 441 EvictDelegatedFrame(); | 441 EvictDelegatedFrame(); |
| 442 | 442 |
| 443 surface_factory_.reset(); | 443 surface_factory_.reset(); |
| 444 if (!surface_returned_resources_.empty()) | 444 if (!surface_returned_resources_.empty()) |
| 445 SendReturnedDelegatedResources(last_output_surface_id_); | 445 SendDelegatedFrameAck(last_output_surface_id_); |
| 446 | 446 |
| 447 last_output_surface_id_ = output_surface_id; | 447 last_output_surface_id_ = output_surface_id; |
| 448 } | 448 } |
| 449 bool skip_frame = false; | 449 bool skip_frame = false; |
| 450 pending_delegated_ack_count_++; | 450 pending_delegated_ack_count_++; |
| 451 | 451 |
| 452 background_color_ = frame.metadata.root_background_color; | 452 background_color_ = frame.metadata.root_background_color; |
| 453 | 453 |
| 454 if (frame_size.IsEmpty()) { | 454 if (frame_size.IsEmpty()) { |
| 455 DCHECK(frame_data->resource_list.empty()); | 455 DCHECK(frame_data->resource_list.empty()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 client_->DelegatedFrameHostSendCompositorSwapAck(output_surface_id, ack); | 528 client_->DelegatedFrameHostSendCompositorSwapAck(output_surface_id, ack); |
| 529 DCHECK_GT(pending_delegated_ack_count_, 0); | 529 DCHECK_GT(pending_delegated_ack_count_, 0); |
| 530 pending_delegated_ack_count_--; | 530 pending_delegated_ack_count_--; |
| 531 } | 531 } |
| 532 | 532 |
| 533 void DelegatedFrameHost::SurfaceDrawn(uint32_t output_surface_id, | 533 void DelegatedFrameHost::SurfaceDrawn(uint32_t output_surface_id, |
| 534 cc::SurfaceDrawStatus drawn) { | 534 cc::SurfaceDrawStatus drawn) { |
| 535 SendDelegatedFrameAck(output_surface_id); | 535 SendDelegatedFrameAck(output_surface_id); |
| 536 } | 536 } |
| 537 | 537 |
| 538 void DelegatedFrameHost::SendReturnedDelegatedResources( | |
| 539 uint32_t output_surface_id) { | |
| 540 cc::CompositorFrameAck ack; | |
| 541 DCHECK(!surface_returned_resources_.empty()); | |
| 542 ack.resources.swap(surface_returned_resources_); | |
| 543 | |
| 544 client_->DelegatedFrameHostSendReclaimCompositorResources(output_surface_id, | |
| 545 ack); | |
| 546 } | |
| 547 | |
| 548 void DelegatedFrameHost::ReturnResources( | 538 void DelegatedFrameHost::ReturnResources( |
| 549 const cc::ReturnedResourceArray& resources) { | 539 const cc::ReturnedResourceArray& resources) { |
| 550 if (resources.empty()) | 540 if (resources.empty()) |
| 551 return; | 541 return; |
| 552 std::copy(resources.begin(), resources.end(), | 542 std::copy(resources.begin(), resources.end(), |
| 553 std::back_inserter(surface_returned_resources_)); | 543 std::back_inserter(surface_returned_resources_)); |
| 554 if (!pending_delegated_ack_count_) | 544 if (!pending_delegated_ack_count_) |
| 555 SendReturnedDelegatedResources(last_output_surface_id_); | 545 SendDelegatedFrameAck(last_output_surface_id_); |
| 556 } | 546 } |
| 557 | 547 |
| 558 void DelegatedFrameHost::WillDrawSurface(const cc::SurfaceId& id, | 548 void DelegatedFrameHost::WillDrawSurface(const cc::SurfaceId& id, |
| 559 const gfx::Rect& damage_rect) { | 549 const gfx::Rect& damage_rect) { |
| 560 // Frame subscribers are only interested in changes to the target surface, so | 550 // Frame subscribers are only interested in changes to the target surface, so |
| 561 // do not attempt capture if |damage_rect| is empty. This prevents the draws | 551 // do not attempt capture if |damage_rect| is empty. This prevents the draws |
| 562 // of parent surfaces from triggering extra frame captures, which can affect | 552 // of parent surfaces from triggering extra frame captures, which can affect |
| 563 // smoothness. | 553 // smoothness. |
| 564 if (id != surface_id_ || damage_rect.IsEmpty()) | 554 if (id != surface_id_ || damage_rect.IsEmpty()) |
| 565 return; | 555 return; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 889 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 900 new_layer->SetShowSurface( | 890 new_layer->SetShowSurface( |
| 901 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 891 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 902 base::Bind(&RequireCallback, base::Unretained(manager)), | 892 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 903 current_surface_size_, current_scale_factor_, | 893 current_surface_size_, current_scale_factor_, |
| 904 current_frame_size_in_dip_); | 894 current_frame_size_in_dip_); |
| 905 } | 895 } |
| 906 } | 896 } |
| 907 | 897 |
| 908 } // namespace content | 898 } // namespace content |
| OLD | NEW |