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 380 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 818 |
820 void CompositorImpl::SetNeedsAnimate() { | 819 void CompositorImpl::SetNeedsAnimate() { |
821 needs_animate_ = true; | 820 needs_animate_ = true; |
822 if (!host_->IsVisible()) | 821 if (!host_->IsVisible()) |
823 return; | 822 return; |
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 uint32_t CompositorImpl::GetSurfaceClientId() { | 828 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { |
830 return surface_id_allocator_->client_id(); | 829 return surface_id_allocator_->frame_sink_id(); |
831 } | 830 } |
832 | 831 |
833 bool CompositorImpl::HavePendingReadbacks() { | 832 bool CompositorImpl::HavePendingReadbacks() { |
834 return !readback_layer_tree_->children().empty(); | 833 return !readback_layer_tree_->children().empty(); |
835 } | 834 } |
836 | 835 |
837 } // namespace content | 836 } // namespace content |
OLD | NEW |