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

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

Issue 2612083002: DirectCompositorFrameSink Uses CompositorFrameSinkSupport (Closed)
Patch Set: Addressed comments 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 525
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_ = true;
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 670
665 auto compositor_frame_sink = 671 auto compositor_frame_sink =
666 vulkan_context_provider 672 vulkan_context_provider
667 ? base::MakeUnique<cc::DirectCompositorFrameSink>( 673 ? base::MakeUnique<cc::DirectCompositorFrameSink>(
668 frame_sink_id_, manager, display_.get(), 674 frame_sink_id_, manager, display_.get(),
669 vulkan_context_provider) 675 vulkan_context_provider)
670 : base::MakeUnique<cc::DirectCompositorFrameSink>( 676 : base::MakeUnique<cc::DirectCompositorFrameSink>(
671 frame_sink_id_, manager, display_.get(), context_provider, 677 frame_sink_id_, manager, display_.get(), context_provider,
672 nullptr, BrowserGpuMemoryBufferManager::current(), 678 nullptr, BrowserGpuMemoryBufferManager::current(),
673 HostSharedBitmapManager::current()); 679 HostSharedBitmapManager::current());
674
675 display_->SetVisible(true); 680 display_->SetVisible(true);
676 display_->Resize(size_); 681 display_->Resize(size_);
677 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); 682 host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
678 } 683 }
679 684
680 cc::UIResourceId CompositorImpl::CreateUIResource( 685 cc::UIResourceId CompositorImpl::CreateUIResource(
681 cc::UIResourceClient* client) { 686 cc::UIResourceClient* client) {
682 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); 687 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource");
683 return host_->GetUIResourceManager()->CreateUIResource(client); 688 return host_->GetUIResourceManager()->CreateUIResource(client);
684 } 689 }
(...skipping 14 matching lines...) Expand all
699 704
700 void CompositorImpl::DidReceiveCompositorFrameAck() { 705 void CompositorImpl::DidReceiveCompositorFrameAck() {
701 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck"); 706 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck");
702 DCHECK_GT(pending_swapbuffers_, 0U); 707 DCHECK_GT(pending_swapbuffers_, 0U);
703 pending_swapbuffers_--; 708 pending_swapbuffers_--;
704 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 709 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
705 } 710 }
706 711
707 void CompositorImpl::DidLoseCompositorFrameSink() { 712 void CompositorImpl::DidLoseCompositorFrameSink() {
708 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink"); 713 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink");
714 has_compositor_frame_sink_ = false;
709 client_->OnSwapBuffersCompleted(0); 715 client_->OnSwapBuffersCompleted(0);
710 } 716 }
711 717
712 void CompositorImpl::DidCommit() { 718 void CompositorImpl::DidCommit() {
713 root_window_->OnCompositingDidCommit(); 719 root_window_->OnCompositingDidCommit();
714 } 720 }
715 721
716 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 722 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
717 readback_layer_tree_->AddChild(layer); 723 readback_layer_tree_->AddChild(layer);
718 } 724 }
719 725
720 void CompositorImpl::RequestCopyOfOutputOnRootLayer( 726 void CompositorImpl::RequestCopyOfOutputOnRootLayer(
721 std::unique_ptr<cc::CopyOutputRequest> request) { 727 std::unique_ptr<cc::CopyOutputRequest> request) {
722 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request)); 728 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request));
723 } 729 }
724 730
725 void CompositorImpl::SetNeedsAnimate() { 731 void CompositorImpl::SetNeedsAnimate() {
726 needs_animate_ = true; 732 needs_animate_ = true;
727 if (!host_->IsVisible()) 733 if (!host_->IsVisible())
728 return; 734 return;
729 735
730 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 736 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
731 host_->SetNeedsAnimate(); 737 host_->SetNeedsAnimate();
732 } 738 }
733 739
734 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { 740 cc::FrameSinkId CompositorImpl::GetFrameSinkId() {
735 return frame_sink_id_; 741 return frame_sink_id_;
736 } 742 }
737 743
744 void CompositorImpl::AddChildFrameSink(cc::FrameSinkId frame_sink_id) {
745 if (!has_compositor_frame_sink_) {
boliu 2017/01/27 23:17:59 reverse the the condition and flip the body, it's
Alex Z. 2017/01/29 14:58:51 Done.
746 pending_child_frame_sink_ids_.insert(frame_sink_id);
747 } else {
748 // All pending child frame sink ids should be added upon the creation of
749 // compositor frame sink.
750 DCHECK(pending_child_frame_sink_ids_.empty());
boliu 2017/01/27 23:17:59 this DCHECK clearly doesn't hold when called from
Alex Z. 2017/01/29 14:58:51 My bad. I was thinking of two ways to approach thi
751 ui::ContextProviderFactory::GetInstance()
752 ->GetSurfaceManager()
753 ->RegisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id);
boliu 2017/01/27 23:17:59 it's not immediately clear to me why this can't be
Alex Z. 2017/01/29 14:58:51 ~CompositorFrameSinkSupport() calls InvalidateFram
754 }
755 }
756
738 bool CompositorImpl::HavePendingReadbacks() { 757 bool CompositorImpl::HavePendingReadbacks() {
739 return !readback_layer_tree_->children().empty(); 758 return !readback_layer_tree_->children().empty();
740 } 759 }
741 760
742 } // namespace content 761 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698