| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 gpu::VulkanSurface::CreateViewSurface(widget)); | 323 gpu::VulkanSurface::CreateViewSurface(widget)); |
| 324 if (!surface->Initialize(vulkan_context_provider()->GetDeviceQueue(), | 324 if (!surface->Initialize(vulkan_context_provider()->GetDeviceQueue(), |
| 325 gpu::VulkanSurface::DEFAULT_SURFACE_FORMAT)) { | 325 gpu::VulkanSurface::DEFAULT_SURFACE_FORMAT)) { |
| 326 return false; | 326 return false; |
| 327 } | 327 } |
| 328 surface_ = std::move(surface); | 328 surface_ = std::move(surface); |
| 329 | 329 |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool BindToClient(cc::OutputSurfaceClient* client) override { | 333 bool BindToClient(cc::OutputFrameSink* client) override { |
| 334 if (!OutputSurface::BindToClient(client)) | 334 if (!OutputSurface::BindToClient(client)) |
| 335 return false; | 335 return false; |
| 336 return true; | 336 return true; |
| 337 } | 337 } |
| 338 | 338 |
| 339 void SwapBuffers(cc::CompositorFrame frame) override { | 339 void SwapBuffers(cc::CompositorFrame frame) override { |
| 340 surface_->SwapBuffers(); | 340 surface_->SwapBuffers(); |
| 341 PostSwapBuffersComplete(); | 341 PostSwapBuffersComplete(); |
| 342 } | 342 } |
| 343 | 343 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 g_initialized = true; | 391 g_initialized = true; |
| 392 } | 392 } |
| 393 | 393 |
| 394 // static | 394 // static |
| 395 bool CompositorImpl::IsInitialized() { | 395 bool CompositorImpl::IsInitialized() { |
| 396 return g_initialized; | 396 return g_initialized; |
| 397 } | 397 } |
| 398 | 398 |
| 399 CompositorImpl::CompositorImpl(CompositorClient* client, | 399 CompositorImpl::CompositorImpl(CompositorClient* client, |
| 400 gfx::NativeWindow root_window) | 400 gfx::NativeWindow root_window) |
| 401 : surface_id_allocator_( | 401 : surface_id_allocator_(new cc::SurfaceIdAllocator( |
| 402 new cc::SurfaceIdAllocator(ui::ContextProviderFactory::GetInstance() | 402 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId())), |
| 403 ->AllocateSurfaceClientId())), | |
| 404 resource_manager_(root_window), | 403 resource_manager_(root_window), |
| 405 has_transparent_background_(false), | 404 has_transparent_background_(false), |
| 406 device_scale_factor_(1), | 405 device_scale_factor_(1), |
| 407 window_(NULL), | 406 window_(NULL), |
| 408 surface_handle_(gpu::kNullSurfaceHandle), | 407 surface_handle_(gpu::kNullSurfaceHandle), |
| 409 client_(client), | 408 client_(client), |
| 410 root_window_(root_window), | 409 root_window_(root_window), |
| 411 needs_animate_(false), | 410 needs_animate_(false), |
| 412 pending_swapbuffers_(0U), | 411 pending_swapbuffers_(0U), |
| 413 num_successive_context_creation_failures_(0), | 412 num_successive_context_creation_failures_(0), |
| 414 compositor_frame_sink_request_pending_(false), | 413 compositor_frame_sink_request_pending_(false), |
| 415 needs_begin_frames_(false), | 414 needs_begin_frames_(false), |
| 416 weak_factory_(this) { | 415 weak_factory_(this) { |
| 417 ui::ContextProviderFactory::GetInstance() | 416 ui::ContextProviderFactory::GetInstance() |
| 418 ->GetSurfaceManager() | 417 ->GetSurfaceManager() |
| 419 ->RegisterSurfaceClientId(surface_id_allocator_->client_id()); | 418 ->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id()); |
| 420 DCHECK(client); | 419 DCHECK(client); |
| 421 DCHECK(root_window); | 420 DCHECK(root_window); |
| 422 DCHECK(root_window->GetLayer() == nullptr); | 421 DCHECK(root_window->GetLayer() == nullptr); |
| 423 root_window->SetLayer(cc::Layer::Create()); | 422 root_window->SetLayer(cc::Layer::Create()); |
| 424 readback_layer_tree_ = cc::Layer::Create(); | 423 readback_layer_tree_ = cc::Layer::Create(); |
| 425 readback_layer_tree_->SetHideLayerAndSubtree(true); | 424 readback_layer_tree_->SetHideLayerAndSubtree(true); |
| 426 root_window->GetLayer()->AddChild(readback_layer_tree_); | 425 root_window->GetLayer()->AddChild(readback_layer_tree_); |
| 427 root_window->AttachCompositor(this); | 426 root_window->AttachCompositor(this); |
| 428 CreateLayerTreeHost(); | 427 CreateLayerTreeHost(); |
| 429 resource_manager_.Init(host_->GetUIResourceManager()); | 428 resource_manager_.Init(host_->GetUIResourceManager()); |
| 430 } | 429 } |
| 431 | 430 |
| 432 CompositorImpl::~CompositorImpl() { | 431 CompositorImpl::~CompositorImpl() { |
| 433 root_window_->DetachCompositor(); | 432 root_window_->DetachCompositor(); |
| 434 root_window_->SetLayer(nullptr); | 433 root_window_->SetLayer(nullptr); |
| 435 // Clean-up any surface references. | 434 // Clean-up any surface references. |
| 436 SetSurface(NULL); | 435 SetSurface(NULL); |
| 437 ui::ContextProviderFactory::GetInstance() | 436 ui::ContextProviderFactory::GetInstance() |
| 438 ->GetSurfaceManager() | 437 ->GetSurfaceManager() |
| 439 ->InvalidateSurfaceClientId(surface_id_allocator_->client_id()); | 438 ->InvalidateFrameSinkId(surface_id_allocator_->frame_sink_id()); |
| 440 } | 439 } |
| 441 | 440 |
| 442 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { | 441 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { |
| 443 return *this; | 442 return *this; |
| 444 } | 443 } |
| 445 | 444 |
| 446 ui::ResourceManager& CompositorImpl::GetResourceManager() { | 445 ui::ResourceManager& CompositorImpl::GetResourceManager() { |
| 447 return resource_manager_; | 446 return resource_manager_; |
| 448 } | 447 } |
| 449 | 448 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 params.client = this; | 513 params.client = this; |
| 515 params.shared_bitmap_manager = HostSharedBitmapManager::current(); | 514 params.shared_bitmap_manager = HostSharedBitmapManager::current(); |
| 516 params.gpu_memory_buffer_manager = BrowserGpuMemoryBufferManager::current(); | 515 params.gpu_memory_buffer_manager = BrowserGpuMemoryBufferManager::current(); |
| 517 params.task_graph_runner = g_task_graph_runner.Pointer(); | 516 params.task_graph_runner = g_task_graph_runner.Pointer(); |
| 518 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 517 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 519 params.settings = &settings; | 518 params.settings = &settings; |
| 520 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 519 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
| 521 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); | 520 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); |
| 522 DCHECK(!host_->IsVisible()); | 521 DCHECK(!host_->IsVisible()); |
| 523 host_->GetLayerTree()->SetRootLayer(root_window_->GetLayer()); | 522 host_->GetLayerTree()->SetRootLayer(root_window_->GetLayer()); |
| 524 host_->SetSurfaceClientId(surface_id_allocator_->client_id()); | 523 host_->SetFrameSinkId(surface_id_allocator_->frame_sink_id()); |
| 525 host_->GetLayerTree()->SetViewportSize(size_); | 524 host_->GetLayerTree()->SetViewportSize(size_); |
| 526 host_->GetLayerTree()->set_has_transparent_background( | 525 host_->GetLayerTree()->set_has_transparent_background( |
| 527 has_transparent_background_); | 526 has_transparent_background_); |
| 528 host_->GetLayerTree()->set_background_color(SK_ColorBLACK); | 527 host_->GetLayerTree()->set_background_color(SK_ColorBLACK); |
| 529 host_->GetLayerTree()->SetDeviceScaleFactor(device_scale_factor_); | 528 host_->GetLayerTree()->SetDeviceScaleFactor(device_scale_factor_); |
| 530 | 529 |
| 531 if (needs_animate_) | 530 if (needs_animate_) |
| 532 host_->SetNeedsAnimate(); | 531 host_->SetNeedsAnimate(); |
| 533 } | 532 } |
| 534 | 533 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 | 823 |
| 825 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 824 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
| 826 host_->SetNeedsAnimate(); | 825 host_->SetNeedsAnimate(); |
| 827 } | 826 } |
| 828 | 827 |
| 829 bool CompositorImpl::HavePendingReadbacks() { | 828 bool CompositorImpl::HavePendingReadbacks() { |
| 830 return !readback_layer_tree_->children().empty(); | 829 return !readback_layer_tree_->children().empty(); |
| 831 } | 830 } |
| 832 | 831 |
| 833 } // namespace content | 832 } // namespace content |
| OLD | NEW |