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

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

Issue 2242633002: Android: Force draw for pending readbacks during Display teardown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tn1
Patch Set: fix Created 4 years, 4 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 | « content/browser/renderer_host/compositor_impl_android.h ('k') | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/compositor_impl_android.h" 5 #include "content/browser/renderer_host/compositor_impl_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <unordered_set> 10 #include <unordered_set>
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 output_surface_request_pending_(false), 397 output_surface_request_pending_(false),
398 needs_begin_frames_(false), 398 needs_begin_frames_(false),
399 weak_factory_(this) { 399 weak_factory_(this) {
400 ui::ContextProviderFactory::GetInstance() 400 ui::ContextProviderFactory::GetInstance()
401 ->GetSurfaceManager() 401 ->GetSurfaceManager()
402 ->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 402 ->RegisterSurfaceClientId(surface_id_allocator_->client_id());
403 DCHECK(client); 403 DCHECK(client);
404 DCHECK(root_window); 404 DCHECK(root_window);
405 DCHECK(root_window->GetLayer() == nullptr); 405 DCHECK(root_window->GetLayer() == nullptr);
406 root_window->SetLayer(cc::Layer::Create()); 406 root_window->SetLayer(cc::Layer::Create());
407 readback_layer_tree_ = cc::Layer::Create();
408 readback_layer_tree_->SetHideLayerAndSubtree(true);
409 root_window->GetLayer()->AddChild(readback_layer_tree_);
407 root_window->AttachCompositor(this); 410 root_window->AttachCompositor(this);
408 CreateLayerTreeHost(); 411 CreateLayerTreeHost();
409 resource_manager_.Init(host_.get()); 412 resource_manager_.Init(host_.get());
410 } 413 }
411 414
412 CompositorImpl::~CompositorImpl() { 415 CompositorImpl::~CompositorImpl() {
413 root_window_->DetachCompositor(); 416 root_window_->DetachCompositor();
414 root_window_->SetLayer(nullptr); 417 root_window_->SetLayer(nullptr);
415 // Clean-up any surface references. 418 // Clean-up any surface references.
416 SetSurface(NULL); 419 SetSurface(NULL);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 host_->SetDeviceScaleFactor(device_scale_factor_); 510 host_->SetDeviceScaleFactor(device_scale_factor_);
508 511
509 if (needs_animate_) 512 if (needs_animate_)
510 host_->SetNeedsAnimate(); 513 host_->SetNeedsAnimate();
511 } 514 }
512 515
513 void CompositorImpl::SetVisible(bool visible) { 516 void CompositorImpl::SetVisible(bool visible) {
514 TRACE_EVENT1("cc", "CompositorImpl::SetVisible", "visible", visible); 517 TRACE_EVENT1("cc", "CompositorImpl::SetVisible", "visible", visible);
515 if (!visible) { 518 if (!visible) {
516 DCHECK(host_->visible()); 519 DCHECK(host_->visible());
520
521 // Make a best effort to try to complete pending readbacks.
522 // TODO(crbug.com/637035): Consider doing this in a better way,
523 // ideally with the guarantee of readbacks completing.
524 if (display_.get() && HavePendingReadbacks())
525 display_->ForceImmediateDrawAndSwapIfPossible();
526
517 host_->SetVisible(false); 527 host_->SetVisible(false);
518 if (!host_->output_surface_lost()) 528 if (!host_->output_surface_lost())
519 host_->ReleaseOutputSurface(); 529 host_->ReleaseOutputSurface();
520 pending_swapbuffers_ = 0; 530 pending_swapbuffers_ = 0;
521 display_.reset(); 531 display_.reset();
522 } else { 532 } else {
523 host_->SetVisible(true); 533 host_->SetVisible(true);
524 if (output_surface_request_pending_) 534 if (output_surface_request_pending_)
525 HandlePendingOutputSurfaceRequest(); 535 HandlePendingOutputSurfaceRequest();
526 } 536 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if (host_->visible()) 754 if (host_->visible())
745 host_->SetNeedsCommit(); 755 host_->SetNeedsCommit();
746 client_->OnSwapBuffersCompleted(0); 756 client_->OnSwapBuffersCompleted(0);
747 } 757 }
748 758
749 void CompositorImpl::DidCommit() { 759 void CompositorImpl::DidCommit() {
750 root_window_->OnCompositingDidCommit(); 760 root_window_->OnCompositingDidCommit();
751 } 761 }
752 762
753 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 763 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
754 root_window_->GetLayer()->AddChild(layer); 764 readback_layer_tree_->AddChild(layer);
755 } 765 }
756 766
757 void CompositorImpl::RequestCopyOfOutputOnRootLayer( 767 void CompositorImpl::RequestCopyOfOutputOnRootLayer(
758 std::unique_ptr<cc::CopyOutputRequest> request) { 768 std::unique_ptr<cc::CopyOutputRequest> request) {
759 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request)); 769 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request));
760 } 770 }
761 771
762 void CompositorImpl::OnVSync(base::TimeTicks frame_time, 772 void CompositorImpl::OnVSync(base::TimeTicks frame_time,
763 base::TimeDelta vsync_period) { 773 base::TimeDelta vsync_period) {
764 FOR_EACH_OBSERVER(VSyncObserver, observer_list_, 774 FOR_EACH_OBSERVER(VSyncObserver, observer_list_,
(...skipping 13 matching lines...) Expand all
778 788
779 void CompositorImpl::SetNeedsAnimate() { 789 void CompositorImpl::SetNeedsAnimate() {
780 needs_animate_ = true; 790 needs_animate_ = true;
781 if (!host_->visible()) 791 if (!host_->visible())
782 return; 792 return;
783 793
784 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 794 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
785 host_->SetNeedsAnimate(); 795 host_->SetNeedsAnimate();
786 } 796 }
787 797
798 bool CompositorImpl::HavePendingReadbacks() {
799 return !readback_layer_tree_->children().empty();
800 }
801
788 } // namespace content 802 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698