| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 window_(NULL), | 332 window_(NULL), |
| 333 surface_handle_(gpu::kNullSurfaceHandle), | 333 surface_handle_(gpu::kNullSurfaceHandle), |
| 334 client_(client), | 334 client_(client), |
| 335 root_window_(root_window), | 335 root_window_(root_window), |
| 336 needs_animate_(false), | 336 needs_animate_(false), |
| 337 pending_swapbuffers_(0U), | 337 pending_swapbuffers_(0U), |
| 338 num_successive_context_creation_failures_(0), | 338 num_successive_context_creation_failures_(0), |
| 339 compositor_frame_sink_request_pending_(false), | 339 compositor_frame_sink_request_pending_(false), |
| 340 weak_factory_(this) { | 340 weak_factory_(this) { |
| 341 ui::ContextProviderFactory::GetInstance() | 341 ui::ContextProviderFactory::GetInstance() |
| 342 ->GetSurfaceManager() | 342 ->GetFrameSinkManager() |
| 343 ->RegisterFrameSinkId(frame_sink_id_); | 343 ->RegisterFrameSinkId(frame_sink_id_); |
| 344 DCHECK(client); | 344 DCHECK(client); |
| 345 DCHECK(root_window); | 345 DCHECK(root_window); |
| 346 DCHECK(root_window->GetLayer() == nullptr); | 346 DCHECK(root_window->GetLayer() == nullptr); |
| 347 root_window->SetLayer(cc::Layer::Create()); | 347 root_window->SetLayer(cc::Layer::Create()); |
| 348 readback_layer_tree_ = cc::Layer::Create(); | 348 readback_layer_tree_ = cc::Layer::Create(); |
| 349 readback_layer_tree_->SetHideLayerAndSubtree(true); | 349 readback_layer_tree_->SetHideLayerAndSubtree(true); |
| 350 root_window->GetLayer()->AddChild(readback_layer_tree_); | 350 root_window->GetLayer()->AddChild(readback_layer_tree_); |
| 351 root_window->AttachCompositor(this); | 351 root_window->AttachCompositor(this); |
| 352 CreateLayerTreeHost(); | 352 CreateLayerTreeHost(); |
| 353 resource_manager_.Init(host_->GetUIResourceManager()); | 353 resource_manager_.Init(host_->GetUIResourceManager()); |
| 354 } | 354 } |
| 355 | 355 |
| 356 CompositorImpl::~CompositorImpl() { | 356 CompositorImpl::~CompositorImpl() { |
| 357 root_window_->DetachCompositor(); | 357 root_window_->DetachCompositor(); |
| 358 root_window_->SetLayer(nullptr); | 358 root_window_->SetLayer(nullptr); |
| 359 // Clean-up any surface references. | 359 // Clean-up any surface references. |
| 360 SetSurface(NULL); | 360 SetSurface(NULL); |
| 361 ui::ContextProviderFactory::GetInstance() | 361 ui::ContextProviderFactory::GetInstance() |
| 362 ->GetSurfaceManager() | 362 ->GetFrameSinkManager() |
| 363 ->InvalidateFrameSinkId(frame_sink_id_); | 363 ->InvalidateFrameSinkId(frame_sink_id_); |
| 364 } | 364 } |
| 365 | 365 |
| 366 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { | 366 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { |
| 367 return *this; | 367 return *this; |
| 368 } | 368 } |
| 369 | 369 |
| 370 ui::ResourceManager& CompositorImpl::GetResourceManager() { | 370 ui::ResourceManager& CompositorImpl::GetResourceManager() { |
| 371 return resource_manager_; | 371 return resource_manager_; |
| 372 } | 372 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 num_successive_context_creation_failures_ = 0; | 643 num_successive_context_creation_failures_ = 0; |
| 644 | 644 |
| 645 if (context_provider) { | 645 if (context_provider) { |
| 646 gpu_capabilities_ = context_provider->ContextCapabilities(); | 646 gpu_capabilities_ = context_provider->ContextCapabilities(); |
| 647 } else { | 647 } else { |
| 648 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. | 648 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. |
| 649 } | 649 } |
| 650 | 650 |
| 651 cc::SurfaceManager* manager = | 651 cc::SurfaceManager* manager = |
| 652 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); | 652 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); |
| 653 cc::FrameSinkManager* framesink_manager = |
| 654 ui::ContextProviderFactory::GetInstance()->GetFrameSinkManager(); |
| 653 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 655 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
| 654 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 656 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 655 task_runner, display_output_surface->capabilities().max_frames_pending)); | 657 task_runner, display_output_surface->capabilities().max_frames_pending)); |
| 656 | 658 |
| 657 display_.reset(new cc::Display( | 659 display_.reset(new cc::Display( |
| 658 HostSharedBitmapManager::current(), | 660 HostSharedBitmapManager::current(), |
| 659 BrowserGpuMemoryBufferManager::current(), | 661 BrowserGpuMemoryBufferManager::current(), |
| 660 host_->GetSettings().renderer_settings, frame_sink_id_, | 662 host_->GetSettings().renderer_settings, frame_sink_id_, |
| 661 root_window_->GetBeginFrameSource(), std::move(display_output_surface), | 663 root_window_->GetBeginFrameSource(), std::move(display_output_surface), |
| 662 std::move(scheduler), | 664 std::move(scheduler), |
| 663 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); | 665 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); |
| 664 | 666 |
| 665 auto compositor_frame_sink = | 667 auto compositor_frame_sink = |
| 666 vulkan_context_provider | 668 vulkan_context_provider |
| 667 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 669 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 668 frame_sink_id_, manager, display_.get(), | 670 frame_sink_id_, manager, framesink_manager, display_.get(), |
| 669 vulkan_context_provider) | 671 vulkan_context_provider) |
| 670 : base::MakeUnique<cc::DirectCompositorFrameSink>( | 672 : base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 671 frame_sink_id_, manager, display_.get(), context_provider, | 673 frame_sink_id_, manager, framesink_manager, display_.get(), |
| 672 nullptr, BrowserGpuMemoryBufferManager::current(), | 674 context_provider, nullptr, |
| 675 BrowserGpuMemoryBufferManager::current(), |
| 673 HostSharedBitmapManager::current()); | 676 HostSharedBitmapManager::current()); |
| 674 | 677 |
| 675 display_->SetVisible(true); | 678 display_->SetVisible(true); |
| 676 display_->Resize(size_); | 679 display_->Resize(size_); |
| 677 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 680 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 678 } | 681 } |
| 679 | 682 |
| 680 cc::UIResourceId CompositorImpl::CreateUIResource( | 683 cc::UIResourceId CompositorImpl::CreateUIResource( |
| 681 cc::UIResourceClient* client) { | 684 cc::UIResourceClient* client) { |
| 682 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); | 685 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 | 736 |
| 734 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { | 737 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { |
| 735 return frame_sink_id_; | 738 return frame_sink_id_; |
| 736 } | 739 } |
| 737 | 740 |
| 738 bool CompositorImpl::HavePendingReadbacks() { | 741 bool CompositorImpl::HavePendingReadbacks() { |
| 739 return !readback_layer_tree_->children().empty(); | 742 return !readback_layer_tree_->children().empty(); |
| 740 } | 743 } |
| 741 | 744 |
| 742 } // namespace content | 745 } // namespace content |
| OLD | NEW |