| 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/compositor/delegated_frame_host.h" | 5 #include "content/browser/compositor/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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 if (resource_collection_.get()) { | 403 if (resource_collection_.get()) { |
| 404 resource_collection_->SetClient(NULL); | 404 resource_collection_->SetClient(NULL); |
| 405 | 405 |
| 406 if (resource_collection_->LoseAllResources()) | 406 if (resource_collection_->LoseAllResources()) |
| 407 SendReturnedDelegatedResources(last_output_surface_id_); | 407 SendReturnedDelegatedResources(last_output_surface_id_); |
| 408 | 408 |
| 409 resource_collection_ = NULL; | 409 resource_collection_ = NULL; |
| 410 } | 410 } |
| 411 last_output_surface_id_ = output_surface_id; | 411 last_output_surface_id_ = output_surface_id; |
| 412 } | 412 } |
| 413 bool immediate_ack = !compositor_; | 413 bool skip_frame_size_mismatch = false; |
| 414 pending_delegated_ack_count_++; | 414 pending_delegated_ack_count_++; |
| 415 | 415 |
| 416 if (frame_size.IsEmpty()) { | 416 if (frame_size.IsEmpty()) { |
| 417 DCHECK(frame_data->resource_list.empty()); | 417 DCHECK(frame_data->resource_list.empty()); |
| 418 EvictDelegatedFrame(); | 418 EvictDelegatedFrame(); |
| 419 } else { | 419 } else { |
| 420 if (use_surfaces_) { | 420 if (use_surfaces_) { |
| 421 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 421 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 422 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 422 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 423 if (!surface_factory_) { | 423 if (!surface_factory_) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 440 current_scale_factor_ = frame_device_scale_factor; | 440 current_scale_factor_ = frame_device_scale_factor; |
| 441 } | 441 } |
| 442 | 442 |
| 443 frame->metadata.latency_info.insert(frame->metadata.latency_info.end(), | 443 frame->metadata.latency_info.insert(frame->metadata.latency_info.end(), |
| 444 skipped_latency_info_list_.begin(), | 444 skipped_latency_info_list_.begin(), |
| 445 skipped_latency_info_list_.end()); | 445 skipped_latency_info_list_.end()); |
| 446 skipped_latency_info_list_.clear(); | 446 skipped_latency_info_list_.clear(); |
| 447 | 447 |
| 448 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); | 448 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); |
| 449 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) | 449 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) |
| 450 immediate_ack = true; | 450 skip_frame_size_mismatch = true; |
| 451 | 451 |
| 452 cc::SurfaceFactory::DrawCallback ack_callback; | 452 cc::SurfaceFactory::DrawCallback ack_callback; |
| 453 if (compositor_ && !immediate_ack) { | 453 if (compositor_ && !skip_frame_size_mismatch) { |
| 454 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, | 454 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, |
| 455 AsWeakPtr(), output_surface_id); | 455 AsWeakPtr(), output_surface_id); |
| 456 } | 456 } |
| 457 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 457 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
| 458 ack_callback); | 458 ack_callback); |
| 459 } else { | 459 } else { |
| 460 if (!resource_collection_.get()) { | 460 if (!resource_collection_.get()) { |
| 461 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 461 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
| 462 resource_collection_->SetClient(this); | 462 resource_collection_->SetClient(this); |
| 463 } | 463 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 released_front_lock_ = NULL; | 481 released_front_lock_ = NULL; |
| 482 current_frame_size_in_dip_ = frame_size_in_dip; | 482 current_frame_size_in_dip_ = frame_size_in_dip; |
| 483 CheckResizeLock(); | 483 CheckResizeLock(); |
| 484 | 484 |
| 485 if (!damage_rect_in_dip.IsEmpty()) | 485 if (!damage_rect_in_dip.IsEmpty()) |
| 486 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( | 486 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( |
| 487 damage_rect_in_dip); | 487 damage_rect_in_dip); |
| 488 | 488 |
| 489 if (immediate_ack) { | 489 // Note that |compositor_| may be reset by SetShowSurface or |
| 490 // SetShowDelegatedContent above. |
| 491 if (!compositor_ || skip_frame_size_mismatch) { |
| 490 SendDelegatedFrameAck(output_surface_id); | 492 SendDelegatedFrameAck(output_surface_id); |
| 491 } else if (!use_surfaces_) { | 493 } else if (!use_surfaces_) { |
| 492 std::vector<ui::LatencyInfo>::const_iterator it; | 494 std::vector<ui::LatencyInfo>::const_iterator it; |
| 493 for (it = frame->metadata.latency_info.begin(); | 495 for (it = frame->metadata.latency_info.begin(); |
| 494 it != frame->metadata.latency_info.end(); ++it) | 496 it != frame->metadata.latency_info.end(); ++it) |
| 495 compositor_->SetLatencyInfo(*it); | 497 compositor_->SetLatencyInfo(*it); |
| 496 // If we've previously skipped any latency infos add them. | 498 // If we've previously skipped any latency infos add them. |
| 497 for (it = skipped_latency_info_list_.begin(); | 499 for (it = skipped_latency_info_list_.begin(); |
| 498 it != skipped_latency_info_list_.end(); | 500 it != skipped_latency_info_list_.end(); |
| 499 ++it) | 501 ++it) |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1078 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1077 new_layer->SetShowSurface( | 1079 new_layer->SetShowSurface( |
| 1078 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1080 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 1079 base::Bind(&RequireCallback, base::Unretained(manager)), | 1081 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 1080 current_surface_size_, current_scale_factor_, | 1082 current_surface_size_, current_scale_factor_, |
| 1081 current_frame_size_in_dip_); | 1083 current_frame_size_in_dip_); |
| 1082 } | 1084 } |
| 1083 } | 1085 } |
| 1084 | 1086 |
| 1085 } // namespace content | 1087 } // namespace content |
| OLD | NEW |