Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 | 664 |
| 665 auto compositor_frame_sink = | 665 auto compositor_frame_sink = |
| 666 vulkan_context_provider | 666 vulkan_context_provider |
| 667 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 667 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 668 frame_sink_id_, manager, display_.get(), | 668 frame_sink_id_, manager, display_.get(), |
| 669 vulkan_context_provider) | 669 vulkan_context_provider) |
| 670 : base::MakeUnique<cc::DirectCompositorFrameSink>( | 670 : base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 671 frame_sink_id_, manager, display_.get(), context_provider, | 671 frame_sink_id_, manager, display_.get(), context_provider, |
| 672 nullptr, BrowserGpuMemoryBufferManager::current(), | 672 nullptr, BrowserGpuMemoryBufferManager::current(), |
| 673 HostSharedBitmapManager::current()); | 673 HostSharedBitmapManager::current()); |
| 674 | 674 for (auto& frame_sink_id : pending_child_frame_sink_ids_) { |
|
Fady Samuel
2017/01/25 22:36:51
This should probably go in DidInitializeCompositor
Alex Z.
2017/01/26 01:33:56
Done.
| |
| 675 AddChildFrameSink(frame_sink_id); | |
| 676 } | |
| 677 pending_child_frame_sink_ids_.clear(); | |
| 678 has_compositor_frame_sink_ = true; | |
|
Fady Samuel
2017/01/25 22:36:51
I don't think this is necessary.
Alex Z.
2017/01/26 01:33:56
We need the flag to change when DirectCompositorFr
| |
| 675 display_->SetVisible(true); | 679 display_->SetVisible(true); |
| 676 display_->Resize(size_); | 680 display_->Resize(size_); |
| 677 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 681 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 678 } | 682 } |
| 679 | 683 |
| 680 cc::UIResourceId CompositorImpl::CreateUIResource( | 684 cc::UIResourceId CompositorImpl::CreateUIResource( |
| 681 cc::UIResourceClient* client) { | 685 cc::UIResourceClient* client) { |
| 682 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); | 686 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); |
| 683 return host_->GetUIResourceManager()->CreateUIResource(client); | 687 return host_->GetUIResourceManager()->CreateUIResource(client); |
| 684 } | 688 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 699 | 703 |
| 700 void CompositorImpl::DidReceiveCompositorFrameAck() { | 704 void CompositorImpl::DidReceiveCompositorFrameAck() { |
| 701 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck"); | 705 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck"); |
| 702 DCHECK_GT(pending_swapbuffers_, 0U); | 706 DCHECK_GT(pending_swapbuffers_, 0U); |
| 703 pending_swapbuffers_--; | 707 pending_swapbuffers_--; |
| 704 client_->OnSwapBuffersCompleted(pending_swapbuffers_); | 708 client_->OnSwapBuffersCompleted(pending_swapbuffers_); |
| 705 } | 709 } |
| 706 | 710 |
| 707 void CompositorImpl::DidLoseCompositorFrameSink() { | 711 void CompositorImpl::DidLoseCompositorFrameSink() { |
| 708 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink"); | 712 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink"); |
| 713 has_compositor_frame_sink_ = false; | |
| 709 client_->OnSwapBuffersCompleted(0); | 714 client_->OnSwapBuffersCompleted(0); |
| 710 } | 715 } |
| 711 | 716 |
| 712 void CompositorImpl::DidCommit() { | 717 void CompositorImpl::DidCommit() { |
| 713 root_window_->OnCompositingDidCommit(); | 718 root_window_->OnCompositingDidCommit(); |
| 714 } | 719 } |
| 715 | 720 |
| 716 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { | 721 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { |
| 717 readback_layer_tree_->AddChild(layer); | 722 readback_layer_tree_->AddChild(layer); |
| 718 } | 723 } |
| 719 | 724 |
| 720 void CompositorImpl::RequestCopyOfOutputOnRootLayer( | 725 void CompositorImpl::RequestCopyOfOutputOnRootLayer( |
| 721 std::unique_ptr<cc::CopyOutputRequest> request) { | 726 std::unique_ptr<cc::CopyOutputRequest> request) { |
| 722 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request)); | 727 root_window_->GetLayer()->RequestCopyOfOutput(std::move(request)); |
| 723 } | 728 } |
| 724 | 729 |
| 725 void CompositorImpl::SetNeedsAnimate() { | 730 void CompositorImpl::SetNeedsAnimate() { |
| 726 needs_animate_ = true; | 731 needs_animate_ = true; |
| 727 if (!host_->IsVisible()) | 732 if (!host_->IsVisible()) |
| 728 return; | 733 return; |
| 729 | 734 |
| 730 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 735 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
| 731 host_->SetNeedsAnimate(); | 736 host_->SetNeedsAnimate(); |
| 732 } | 737 } |
| 733 | 738 |
| 734 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { | 739 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { |
| 735 return frame_sink_id_; | 740 return frame_sink_id_; |
| 736 } | 741 } |
| 737 | 742 |
| 743 void CompositorImpl::AddChildFrameSink(cc::FrameSinkId frame_sink_id) { | |
| 744 if (!has_compositor_frame_sink_) { | |
|
Fady Samuel
2017/01/25 22:36:51
if (compositor_frame_sink_request_pending_)
Alex Z.
2017/01/26 01:33:56
compositor_frame_sink_request_pending_ gets flippe
| |
| 745 pending_child_frame_sink_ids_.insert(frame_sink_id); | |
| 746 } else { | |
| 747 // All pending child frame sink ids should be added upon the creation of | |
| 748 // compositor frame sink. | |
| 749 DCHECK(pending_child_frame_sink_ids_.empty()); | |
| 750 ui::ContextProviderFactory::GetInstance() | |
| 751 ->GetSurfaceManager() | |
| 752 ->RegisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id); | |
| 753 } | |
| 754 } | |
| 755 | |
| 738 bool CompositorImpl::HavePendingReadbacks() { | 756 bool CompositorImpl::HavePendingReadbacks() { |
| 739 return !readback_layer_tree_->children().empty(); | 757 return !readback_layer_tree_->children().empty(); |
| 740 } | 758 } |
| 741 | 759 |
| 742 } // namespace content | 760 } // namespace content |
| OLD | NEW |