| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 #endif | 291 #endif |
| 292 | 292 |
| 293 base::LazyInstance<scoped_refptr<cc::VulkanInProcessContextProvider>> | 293 base::LazyInstance<scoped_refptr<cc::VulkanInProcessContextProvider>> |
| 294 g_shared_vulkan_context_provider_android_ = LAZY_INSTANCE_INITIALIZER; | 294 g_shared_vulkan_context_provider_android_ = LAZY_INSTANCE_INITIALIZER; |
| 295 | 295 |
| 296 static bool g_initialized = false; | 296 static bool g_initialized = false; |
| 297 | 297 |
| 298 base::LazyInstance<cc::SurfaceManager> g_surface_manager = | 298 base::LazyInstance<cc::SurfaceManager> g_surface_manager = |
| 299 LAZY_INSTANCE_INITIALIZER; | 299 LAZY_INSTANCE_INITIALIZER; |
| 300 | 300 |
| 301 int g_surface_id_namespace = 0; | 301 int g_surface_client_id = 0; |
| 302 | 302 |
| 303 class SingleThreadTaskGraphRunner : public cc::SingleThreadTaskGraphRunner { | 303 class SingleThreadTaskGraphRunner : public cc::SingleThreadTaskGraphRunner { |
| 304 public: | 304 public: |
| 305 SingleThreadTaskGraphRunner() { | 305 SingleThreadTaskGraphRunner() { |
| 306 Start("CompositorTileWorker1", base::SimpleThread::Options()); | 306 Start("CompositorTileWorker1", base::SimpleThread::Options()); |
| 307 } | 307 } |
| 308 | 308 |
| 309 ~SingleThreadTaskGraphRunner() override { | 309 ~SingleThreadTaskGraphRunner() override { |
| 310 Shutdown(); | 310 Shutdown(); |
| 311 } | 311 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 335 | 335 |
| 336 // static | 336 // static |
| 337 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { | 337 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { |
| 338 return g_surface_manager.Pointer(); | 338 return g_surface_manager.Pointer(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 // static | 341 // static |
| 342 std::unique_ptr<cc::SurfaceIdAllocator> | 342 std::unique_ptr<cc::SurfaceIdAllocator> |
| 343 CompositorImpl::CreateSurfaceIdAllocator() { | 343 CompositorImpl::CreateSurfaceIdAllocator() { |
| 344 std::unique_ptr<cc::SurfaceIdAllocator> allocator( | 344 std::unique_ptr<cc::SurfaceIdAllocator> allocator( |
| 345 new cc::SurfaceIdAllocator(++g_surface_id_namespace)); | 345 new cc::SurfaceIdAllocator(0 /* gpu_id */, ++g_surface_client_id)); |
| 346 cc::SurfaceManager* manager = GetSurfaceManager(); | 346 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 347 DCHECK(manager); | 347 DCHECK(manager); |
| 348 allocator->RegisterSurfaceIdNamespace(manager); | 348 allocator->RegisterSurfaceClientId(manager); |
| 349 return allocator; | 349 return allocator; |
| 350 } | 350 } |
| 351 | 351 |
| 352 // static | 352 // static |
| 353 scoped_refptr<cc::VulkanInProcessContextProvider> | 353 scoped_refptr<cc::VulkanInProcessContextProvider> |
| 354 CompositorImpl::SharedVulkanContextProviderAndroid() { | 354 CompositorImpl::SharedVulkanContextProviderAndroid() { |
| 355 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 355 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 356 switches::kEnableVulkan)) { | 356 switches::kEnableVulkan)) { |
| 357 scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider = | 357 scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider = |
| 358 g_shared_vulkan_context_provider_android_.Pointer(); | 358 g_shared_vulkan_context_provider_android_.Pointer(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 params.client = this; | 468 params.client = this; |
| 469 params.shared_bitmap_manager = HostSharedBitmapManager::current(); | 469 params.shared_bitmap_manager = HostSharedBitmapManager::current(); |
| 470 params.gpu_memory_buffer_manager = BrowserGpuMemoryBufferManager::current(); | 470 params.gpu_memory_buffer_manager = BrowserGpuMemoryBufferManager::current(); |
| 471 params.task_graph_runner = g_task_graph_runner.Pointer(); | 471 params.task_graph_runner = g_task_graph_runner.Pointer(); |
| 472 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 472 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 473 params.settings = &settings; | 473 params.settings = &settings; |
| 474 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 474 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
| 475 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 475 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
| 476 DCHECK(!host_->visible()); | 476 DCHECK(!host_->visible()); |
| 477 host_->SetRootLayer(root_layer_); | 477 host_->SetRootLayer(root_layer_); |
| 478 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); | 478 host_->set_surface_client_id(surface_id_allocator_->client_id()); |
| 479 host_->SetViewportSize(size_); | 479 host_->SetViewportSize(size_); |
| 480 host_->set_has_transparent_background(has_transparent_background_); | 480 host_->set_has_transparent_background(has_transparent_background_); |
| 481 host_->SetDeviceScaleFactor(device_scale_factor_); | 481 host_->SetDeviceScaleFactor(device_scale_factor_); |
| 482 | 482 |
| 483 if (needs_animate_) | 483 if (needs_animate_) |
| 484 host_->SetNeedsAnimate(); | 484 host_->SetNeedsAnimate(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void CompositorImpl::SetVisible(bool visible) { | 487 void CompositorImpl::SetVisible(bool visible) { |
| 488 TRACE_EVENT1("cc", "CompositorImpl::SetVisible", "visible", visible); | 488 TRACE_EVENT1("cc", "CompositorImpl::SetVisible", "visible", visible); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 698 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
| 699 std::unique_ptr<ExternalBeginFrameSource> begin_frame_source( | 699 std::unique_ptr<ExternalBeginFrameSource> begin_frame_source( |
| 700 new ExternalBeginFrameSource(this)); | 700 new ExternalBeginFrameSource(this)); |
| 701 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 701 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 702 begin_frame_source.get(), task_runner, | 702 begin_frame_source.get(), task_runner, |
| 703 display_output_surface->capabilities().max_frames_pending)); | 703 display_output_surface->capabilities().max_frames_pending)); |
| 704 | 704 |
| 705 display_.reset(new cc::Display( | 705 display_.reset(new cc::Display( |
| 706 manager, HostSharedBitmapManager::current(), | 706 manager, HostSharedBitmapManager::current(), |
| 707 BrowserGpuMemoryBufferManager::current(), | 707 BrowserGpuMemoryBufferManager::current(), |
| 708 host_->settings().renderer_settings, | 708 host_->settings().renderer_settings, surface_id_allocator_->client_id(), |
| 709 surface_id_allocator_->id_namespace(), std::move(begin_frame_source), | 709 std::move(begin_frame_source), std::move(display_output_surface), |
| 710 std::move(display_output_surface), std::move(scheduler), | 710 std::move(scheduler), |
| 711 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); | 711 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); |
| 712 | 712 |
| 713 std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface( | 713 std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface( |
| 714 vulkan_context_provider | 714 vulkan_context_provider |
| 715 ? new cc::SurfaceDisplayOutputSurface( | 715 ? new cc::SurfaceDisplayOutputSurface( |
| 716 manager, surface_id_allocator_.get(), display_.get(), | 716 manager, surface_id_allocator_.get(), display_.get(), |
| 717 static_cast<scoped_refptr<cc::VulkanContextProvider>>( | 717 static_cast<scoped_refptr<cc::VulkanContextProvider>>( |
| 718 vulkan_context_provider)) | 718 vulkan_context_provider)) |
| 719 : new cc::SurfaceDisplayOutputSurface( | 719 : new cc::SurfaceDisplayOutputSurface( |
| 720 manager, surface_id_allocator_.get(), display_.get(), | 720 manager, surface_id_allocator_.get(), display_.get(), |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 void CompositorImpl::SetNeedsAnimate() { | 803 void CompositorImpl::SetNeedsAnimate() { |
| 804 needs_animate_ = true; | 804 needs_animate_ = true; |
| 805 if (!host_->visible()) | 805 if (!host_->visible()) |
| 806 return; | 806 return; |
| 807 | 807 |
| 808 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 808 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
| 809 host_->SetNeedsAnimate(); | 809 host_->SetNeedsAnimate(); |
| 810 } | 810 } |
| 811 | 811 |
| 812 } // namespace content | 812 } // namespace content |
| OLD | NEW |