Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: content/browser/renderer_host/delegated_frame_host.cc

Issue 2713553013: Revert of Getting rid of immediate ack in DelegatedFrameHost (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
435 // indicates the renderer's output surface may have been recreated, in which 435 // indicates the renderer's output surface may have been recreated, in which
436 // case we should recreate the DelegatedRendererLayer, to avoid matching 436 // case we should recreate the DelegatedRendererLayer, to avoid matching
437 // resources from the old one with resources from the new one which would 437 // resources from the old one with resources from the new one which would
438 // have the same id. Changing the layer to showing painted content destroys 438 // have the same id. Changing the layer to showing painted content destroys
439 // the DelegatedRendererLayer. 439 // the DelegatedRendererLayer.
440 EvictDelegatedFrame(); 440 EvictDelegatedFrame();
441 surface_factory_->Reset(); 441 surface_factory_->Reset();
442 surface_returned_resources_.clear(); 442 surface_returned_resources_.clear();
443 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 443 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
444 } 444 }
445 bool skip_frame = false;
445 pending_delegated_ack_count_++; 446 pending_delegated_ack_count_++;
446 447
447 background_color_ = frame.metadata.root_background_color; 448 background_color_ = frame.metadata.root_background_color;
448 449
449 if (frame_size.IsEmpty()) { 450 if (frame_size.IsEmpty()) {
450 DCHECK(frame.resource_list.empty()); 451 DCHECK(frame.resource_list.empty());
451 EvictDelegatedFrame(); 452 EvictDelegatedFrame();
452 } else { 453 } else {
453 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 454 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
454 cc::SurfaceManager* manager = 455 cc::SurfaceManager* manager =
455 factory->GetContextFactoryPrivate()->GetSurfaceManager(); 456 factory->GetContextFactoryPrivate()->GetSurfaceManager();
456 bool allocated_new_local_surface_id = false; 457 bool allocated_new_local_surface_id = false;
457 if (!local_surface_id_.is_valid() || frame_size != current_surface_size_ || 458 if (!local_surface_id_.is_valid() || frame_size != current_surface_size_ ||
458 frame_size_in_dip != current_frame_size_in_dip_) { 459 frame_size_in_dip != current_frame_size_in_dip_) {
459 local_surface_id_ = id_allocator_->GenerateId(); 460 local_surface_id_ = id_allocator_->GenerateId();
460 allocated_new_local_surface_id = true; 461 allocated_new_local_surface_id = true;
461 } 462 }
462 463
463 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(), 464 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP();
464 skipped_latency_info_list_.begin(), 465 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) {
465 skipped_latency_info_list_.end()); 466 skip_frame = true;
466 skipped_latency_info_list_.clear(); 467 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(),
468 frame.metadata.latency_info.begin(),
469 frame.metadata.latency_info.end());
470 frame.metadata.latency_info.clear();
471 } else {
472 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(),
473 skipped_latency_info_list_.begin(),
474 skipped_latency_info_list_.end());
475 skipped_latency_info_list_.clear();
476 }
467 477
468 auto ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, 478 cc::SurfaceFactory::DrawCallback ack_callback;
469 AsWeakPtr(), compositor_frame_sink_id); 479 if (!skip_frame) {
480 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(),
481 compositor_frame_sink_id);
482 }
470 surface_factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), 483 surface_factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame),
471 ack_callback); 484 ack_callback);
472 if (allocated_new_local_surface_id) { 485 if (allocated_new_local_surface_id) {
473 // manager must outlive compositors using it. 486 // manager must outlive compositors using it.
474 cc::SurfaceId surface_id(frame_sink_id_, local_surface_id_); 487 cc::SurfaceId surface_id(frame_sink_id_, local_surface_id_);
475 cc::SurfaceInfo surface_info(surface_id, frame_device_scale_factor, 488 cc::SurfaceInfo surface_info(surface_id, frame_device_scale_factor,
476 frame_size); 489 frame_size);
477 client_->DelegatedFrameHostGetLayer()->SetShowSurface( 490 client_->DelegatedFrameHostGetLayer()->SetShowSurface(
478 surface_info, manager->reference_factory()); 491 surface_info, manager->reference_factory());
479 current_surface_size_ = frame_size; 492 current_surface_size_ = frame_size;
480 current_scale_factor_ = frame_device_scale_factor; 493 current_scale_factor_ = frame_device_scale_factor;
481 } 494 }
482 } 495 }
483 released_front_lock_ = NULL; 496 released_front_lock_ = NULL;
484 current_frame_size_in_dip_ = frame_size_in_dip; 497 current_frame_size_in_dip_ = frame_size_in_dip;
485 CheckResizeLock(); 498 CheckResizeLock();
486 499
487 UpdateGutters(); 500 UpdateGutters();
488 501
489 if (!damage_rect_in_dip.IsEmpty()) { 502 if (!damage_rect_in_dip.IsEmpty()) {
490 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( 503 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage(
491 damage_rect_in_dip); 504 damage_rect_in_dip);
492 } 505 }
493 506
494 if (compositor_) 507 if (skip_frame) {
508 SendReclaimCompositorResources(compositor_frame_sink_id,
509 true /* is_swap_ack */);
510 }
511
512 if (compositor_ && !skip_frame)
495 can_lock_compositor_ = NO_PENDING_COMMIT; 513 can_lock_compositor_ = NO_PENDING_COMMIT;
496 514
497 if (local_surface_id_.is_valid()) { 515 if (local_surface_id_.is_valid()) {
498 delegated_frame_evictor_->SwappedFrame( 516 delegated_frame_evictor_->SwappedFrame(
499 client_->DelegatedFrameHostIsVisible()); 517 client_->DelegatedFrameHostIsVisible());
500 } 518 }
501 // Note: the frame may have been evicted immediately. 519 // Note: the frame may have been evicted immediately.
502 } 520 }
503 521
504 void DelegatedFrameHost::ClearDelegatedFrame() { 522 void DelegatedFrameHost::ClearDelegatedFrame() {
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 std::move(request)); 862 std::move(request));
845 } 863 }
846 } 864 }
847 865
848 void DelegatedFrameHost::UnlockResources() { 866 void DelegatedFrameHost::UnlockResources() {
849 DCHECK(local_surface_id_.is_valid()); 867 DCHECK(local_surface_id_.is_valid());
850 delegated_frame_evictor_->UnlockFrame(); 868 delegated_frame_evictor_->UnlockFrame();
851 } 869 }
852 870
853 } // namespace content 871 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698