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

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

Issue 2683663002: Add AddChildFrameSink() and RemoveChildFrameSink() To WindowAndroidCompositor (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
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 DCHECK(host_->IsVisible()); 459 DCHECK(host_->IsVisible());
460 460
461 // Make a best effort to try to complete pending readbacks. 461 // Make a best effort to try to complete pending readbacks.
462 // TODO(crbug.com/637035): Consider doing this in a better way, 462 // TODO(crbug.com/637035): Consider doing this in a better way,
463 // ideally with the guarantee of readbacks completing. 463 // ideally with the guarantee of readbacks completing.
464 if (display_.get() && HavePendingReadbacks()) 464 if (display_.get() && HavePendingReadbacks())
465 display_->ForceImmediateDrawAndSwapIfPossible(); 465 display_->ForceImmediateDrawAndSwapIfPossible();
466 466
467 host_->SetVisible(false); 467 host_->SetVisible(false);
468 host_->ReleaseCompositorFrameSink(); 468 host_->ReleaseCompositorFrameSink();
469 has_compositor_frame_sink_ = false;
469 pending_swapbuffers_ = 0; 470 pending_swapbuffers_ = 0;
470 display_.reset(); 471 display_.reset();
471 } else { 472 } else {
472 host_->SetVisible(true); 473 host_->SetVisible(true);
473 if (compositor_frame_sink_request_pending_) 474 if (compositor_frame_sink_request_pending_)
474 HandlePendingCompositorFrameSinkRequest(); 475 HandlePendingCompositorFrameSinkRequest();
475 } 476 }
476 } 477 }
477 478
478 void CompositorImpl::SetWindowBounds(const gfx::Size& size) { 479 void CompositorImpl::SetWindowBounds(const gfx::Size& size) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 void CompositorImpl::RequestNewCompositorFrameSink() { 526 void CompositorImpl::RequestNewCompositorFrameSink() {
526 DCHECK(!compositor_frame_sink_request_pending_) 527 DCHECK(!compositor_frame_sink_request_pending_)
527 << "Output Surface Request is already pending?"; 528 << "Output Surface Request is already pending?";
528 529
529 compositor_frame_sink_request_pending_ = true; 530 compositor_frame_sink_request_pending_ = true;
530 HandlePendingCompositorFrameSinkRequest(); 531 HandlePendingCompositorFrameSinkRequest();
531 } 532 }
532 533
533 void CompositorImpl::DidInitializeCompositorFrameSink() { 534 void CompositorImpl::DidInitializeCompositorFrameSink() {
534 compositor_frame_sink_request_pending_ = false; 535 compositor_frame_sink_request_pending_ = false;
536 has_compositor_frame_sink_ = true;
537 for (auto& frame_sink_id : pending_child_frame_sink_ids_)
538 AddChildFrameSink(frame_sink_id);
539
540 pending_child_frame_sink_ids_.clear();
535 } 541 }
536 542
537 void CompositorImpl::DidFailToInitializeCompositorFrameSink() { 543 void CompositorImpl::DidFailToInitializeCompositorFrameSink() {
538 // The context is bound/initialized before handing it to the 544 // The context is bound/initialized before handing it to the
539 // CompositorFrameSink. 545 // CompositorFrameSink.
540 NOTREACHED(); 546 NOTREACHED();
541 } 547 }
542 548
543 void CompositorImpl::HandlePendingCompositorFrameSinkRequest() { 549 void CompositorImpl::HandlePendingCompositorFrameSinkRequest() {
544 DCHECK(compositor_frame_sink_request_pending_); 550 DCHECK(compositor_frame_sink_request_pending_);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 705
700 void CompositorImpl::DidReceiveCompositorFrameAck() { 706 void CompositorImpl::DidReceiveCompositorFrameAck() {
701 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck"); 707 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck");
702 DCHECK_GT(pending_swapbuffers_, 0U); 708 DCHECK_GT(pending_swapbuffers_, 0U);
703 pending_swapbuffers_--; 709 pending_swapbuffers_--;
704 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 710 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
705 } 711 }
706 712
707 void CompositorImpl::DidLoseCompositorFrameSink() { 713 void CompositorImpl::DidLoseCompositorFrameSink() {
708 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink"); 714 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink");
715 has_compositor_frame_sink_ = false;
709 client_->OnSwapBuffersCompleted(0); 716 client_->OnSwapBuffersCompleted(0);
710 } 717 }
711 718
712 void CompositorImpl::DidCommit() { 719 void CompositorImpl::DidCommit() {
713 root_window_->OnCompositingDidCommit(); 720 root_window_->OnCompositingDidCommit();
714 } 721 }
715 722
716 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 723 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
717 readback_layer_tree_->AddChild(layer); 724 readback_layer_tree_->AddChild(layer);
718 } 725 }
719 726
720 void CompositorImpl::RequestCopyOfOutputOnRootLayer( 727 void CompositorImpl::RequestCopyOfOutputOnRootLayer(
721 std::unique_ptr<cc::CopyOutputRequest> request) { 728 std::unique_ptr<cc::CopyOutputRequest> request) {
722 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request)); 729 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request));
723 } 730 }
724 731
725 void CompositorImpl::SetNeedsAnimate() { 732 void CompositorImpl::SetNeedsAnimate() {
726 needs_animate_ = true; 733 needs_animate_ = true;
727 if (!host_->IsVisible()) 734 if (!host_->IsVisible())
728 return; 735 return;
729 736
730 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 737 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
731 host_->SetNeedsAnimate(); 738 host_->SetNeedsAnimate();
732 } 739 }
733 740
734 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { 741 cc::FrameSinkId CompositorImpl::GetFrameSinkId() {
735 return frame_sink_id_; 742 return frame_sink_id_;
736 } 743 }
737 744
745 void CompositorImpl::AddChildFrameSink(const cc::FrameSinkId& frame_sink_id) {
746 if (has_compositor_frame_sink_) {
747 ui::ContextProviderFactory::GetInstance()
748 ->GetSurfaceManager()
749 ->RegisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id);
750 } else {
751 pending_child_frame_sink_ids_.insert(frame_sink_id);
752 }
753 }
754
755 void CompositorImpl::RemoveChildFrameSink(
756 const cc::FrameSinkId& frame_sink_id) {
757 auto it = pending_child_frame_sink_ids_.find(frame_sink_id);
758 if (it != pending_child_frame_sink_ids_.end()) {
759 pending_child_frame_sink_ids_.erase(it);
760 return;
761 }
762 ui::ContextProviderFactory::GetInstance()
763 ->GetSurfaceManager()
764 ->UnregisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id);
765 }
766
738 bool CompositorImpl::HavePendingReadbacks() { 767 bool CompositorImpl::HavePendingReadbacks() {
739 return !readback_layer_tree_->children().empty(); 768 return !readback_layer_tree_->children().empty();
740 } 769 }
741 770
742 } // namespace content 771 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698