Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 #include "cc/output/output_surface.h" 37 #include "cc/output/output_surface.h"
38 #include "cc/output/output_surface_client.h" 38 #include "cc/output/output_surface_client.h"
39 #include "cc/output/texture_mailbox_deleter.h" 39 #include "cc/output/texture_mailbox_deleter.h"
40 #include "cc/output/vulkan_in_process_context_provider.h" 40 #include "cc/output/vulkan_in_process_context_provider.h"
41 #include "cc/raster/single_thread_task_graph_runner.h" 41 #include "cc/raster/single_thread_task_graph_runner.h"
42 #include "cc/resources/ui_resource_manager.h" 42 #include "cc/resources/ui_resource_manager.h"
43 #include "cc/scheduler/begin_frame_source.h" 43 #include "cc/scheduler/begin_frame_source.h"
44 #include "cc/surfaces/direct_compositor_frame_sink.h" 44 #include "cc/surfaces/direct_compositor_frame_sink.h"
45 #include "cc/surfaces/display.h" 45 #include "cc/surfaces/display.h"
46 #include "cc/surfaces/display_scheduler.h" 46 #include "cc/surfaces/display_scheduler.h"
47 #include "cc/surfaces/surface_id_allocator.h"
48 #include "cc/trees/layer_tree_host_in_process.h" 47 #include "cc/trees/layer_tree_host_in_process.h"
49 #include "cc/trees/layer_tree_settings.h" 48 #include "cc/trees/layer_tree_settings.h"
50 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h" 49 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h"
51 #include "components/display_compositor/gl_helper.h" 50 #include "components/display_compositor/gl_helper.h"
52 #include "content/browser/android/child_process_launcher_android.h" 51 #include "content/browser/android/child_process_launcher_android.h"
53 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 52 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
54 #include "content/browser/gpu/compositor_util.h" 53 #include "content/browser/gpu/compositor_util.h"
55 #include "content/browser/gpu/gpu_surface_tracker.h" 54 #include "content/browser/gpu/gpu_surface_tracker.h"
56 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" 55 #include "content/browser/renderer_host/context_provider_factory_impl_android.h"
57 #include "content/browser/renderer_host/render_widget_host_impl.h" 56 #include "content/browser/renderer_host/render_widget_host_impl.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 g_initialized = true; 390 g_initialized = true;
392 } 391 }
393 392
394 // static 393 // static
395 bool CompositorImpl::IsInitialized() { 394 bool CompositorImpl::IsInitialized() {
396 return g_initialized; 395 return g_initialized;
397 } 396 }
398 397
399 CompositorImpl::CompositorImpl(CompositorClient* client, 398 CompositorImpl::CompositorImpl(CompositorClient* client,
400 gfx::NativeWindow root_window) 399 gfx::NativeWindow root_window)
401 : surface_id_allocator_(new cc::SurfaceIdAllocator( 400 : frame_sink_id_(
402 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId())), 401 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()),
403 resource_manager_(root_window), 402 resource_manager_(root_window),
404 has_transparent_background_(false), 403 has_transparent_background_(false),
405 device_scale_factor_(1), 404 device_scale_factor_(1),
406 window_(NULL), 405 window_(NULL),
407 surface_handle_(gpu::kNullSurfaceHandle), 406 surface_handle_(gpu::kNullSurfaceHandle),
408 client_(client), 407 client_(client),
409 root_window_(root_window), 408 root_window_(root_window),
410 needs_animate_(false), 409 needs_animate_(false),
411 pending_swapbuffers_(0U), 410 pending_swapbuffers_(0U),
412 num_successive_context_creation_failures_(0), 411 num_successive_context_creation_failures_(0),
413 compositor_frame_sink_request_pending_(false), 412 compositor_frame_sink_request_pending_(false),
414 needs_begin_frames_(false), 413 needs_begin_frames_(false),
415 weak_factory_(this) { 414 weak_factory_(this) {
416 ui::ContextProviderFactory::GetInstance() 415 ui::ContextProviderFactory::GetInstance()
417 ->GetSurfaceManager() 416 ->GetSurfaceManager()
418 ->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id()); 417 ->RegisterFrameSinkId(frame_sink_id_);
419 DCHECK(client); 418 DCHECK(client);
420 DCHECK(root_window); 419 DCHECK(root_window);
421 DCHECK(root_window->GetLayer() == nullptr); 420 DCHECK(root_window->GetLayer() == nullptr);
422 root_window->SetLayer(cc::Layer::Create()); 421 root_window->SetLayer(cc::Layer::Create());
423 readback_layer_tree_ = cc::Layer::Create(); 422 readback_layer_tree_ = cc::Layer::Create();
424 readback_layer_tree_->SetHideLayerAndSubtree(true); 423 readback_layer_tree_->SetHideLayerAndSubtree(true);
425 root_window->GetLayer()->AddChild(readback_layer_tree_); 424 root_window->GetLayer()->AddChild(readback_layer_tree_);
426 root_window->AttachCompositor(this); 425 root_window->AttachCompositor(this);
427 CreateLayerTreeHost(); 426 CreateLayerTreeHost();
428 resource_manager_.Init(host_->GetUIResourceManager()); 427 resource_manager_.Init(host_->GetUIResourceManager());
429 } 428 }
430 429
431 CompositorImpl::~CompositorImpl() { 430 CompositorImpl::~CompositorImpl() {
432 root_window_->DetachCompositor(); 431 root_window_->DetachCompositor();
433 root_window_->SetLayer(nullptr); 432 root_window_->SetLayer(nullptr);
434 // Clean-up any surface references. 433 // Clean-up any surface references.
435 SetSurface(NULL); 434 SetSurface(NULL);
436 ui::ContextProviderFactory::GetInstance() 435 ui::ContextProviderFactory::GetInstance()
437 ->GetSurfaceManager() 436 ->GetSurfaceManager()
438 ->InvalidateFrameSinkId(surface_id_allocator_->frame_sink_id()); 437 ->InvalidateFrameSinkId(frame_sink_id_);
439 } 438 }
440 439
441 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { 440 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() {
442 return *this; 441 return *this;
443 } 442 }
444 443
445 ui::ResourceManager& CompositorImpl::GetResourceManager() { 444 ui::ResourceManager& CompositorImpl::GetResourceManager() {
446 return resource_manager_; 445 return resource_manager_;
447 } 446 }
448 447
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 params.client = this; 512 params.client = this;
514 params.shared_bitmap_manager = HostSharedBitmapManager::current(); 513 params.shared_bitmap_manager = HostSharedBitmapManager::current();
515 params.gpu_memory_buffer_manager = BrowserGpuMemoryBufferManager::current(); 514 params.gpu_memory_buffer_manager = BrowserGpuMemoryBufferManager::current();
516 params.task_graph_runner = g_task_graph_runner.Pointer(); 515 params.task_graph_runner = g_task_graph_runner.Pointer();
517 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); 516 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
518 params.settings = &settings; 517 params.settings = &settings;
519 params.animation_host = cc::AnimationHost::CreateMainInstance(); 518 params.animation_host = cc::AnimationHost::CreateMainInstance();
520 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, &params); 519 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, &params);
521 DCHECK(!host_->IsVisible()); 520 DCHECK(!host_->IsVisible());
522 host_->GetLayerTree()->SetRootLayer(root_window_->GetLayer()); 521 host_->GetLayerTree()->SetRootLayer(root_window_->GetLayer());
523 host_->SetFrameSinkId(surface_id_allocator_->frame_sink_id()); 522 host_->SetFrameSinkId(frame_sink_id_);
524 host_->GetLayerTree()->SetViewportSize(size_); 523 host_->GetLayerTree()->SetViewportSize(size_);
525 host_->GetLayerTree()->set_has_transparent_background( 524 host_->GetLayerTree()->set_has_transparent_background(
526 has_transparent_background_); 525 has_transparent_background_);
527 host_->GetLayerTree()->set_background_color(SK_ColorBLACK); 526 host_->GetLayerTree()->set_background_color(SK_ColorBLACK);
528 host_->GetLayerTree()->SetDeviceScaleFactor(device_scale_factor_); 527 host_->GetLayerTree()->SetDeviceScaleFactor(device_scale_factor_);
529 528
530 if (needs_animate_) 529 if (needs_animate_)
531 host_->SetNeedsAnimate(); 530 host_->SetNeedsAnimate();
532 } 531 }
533 532
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 717
719 display_.reset(new cc::Display( 718 display_.reset(new cc::Display(
720 HostSharedBitmapManager::current(), 719 HostSharedBitmapManager::current(),
721 BrowserGpuMemoryBufferManager::current(), 720 BrowserGpuMemoryBufferManager::current(),
722 host_->GetSettings().renderer_settings, std::move(begin_frame_source), 721 host_->GetSettings().renderer_settings, std::move(begin_frame_source),
723 std::move(display_output_surface), std::move(scheduler), 722 std::move(display_output_surface), std::move(scheduler),
724 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); 723 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner)));
725 724
726 auto compositor_frame_sink = 725 auto compositor_frame_sink =
727 vulkan_context_provider ? base::MakeUnique<cc::DirectCompositorFrameSink>( 726 vulkan_context_provider ? base::MakeUnique<cc::DirectCompositorFrameSink>(
728 manager, surface_id_allocator_.get(), 727 frame_sink_id_, manager, display_.get(),
729 display_.get(), vulkan_context_provider) 728 vulkan_context_provider)
730 : base::MakeUnique<cc::DirectCompositorFrameSink>( 729 : base::MakeUnique<cc::DirectCompositorFrameSink>(
731 manager, surface_id_allocator_.get(), 730 frame_sink_id_, manager, display_.get(),
732 display_.get(), context_provider, nullptr); 731 context_provider, nullptr);
733 732
734 display_->SetVisible(true); 733 display_->SetVisible(true);
735 display_->Resize(size_); 734 display_->Resize(size_);
736 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); 735 host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
737 } 736 }
738 737
739 void CompositorImpl::PopulateGpuCapabilities( 738 void CompositorImpl::PopulateGpuCapabilities(
740 gpu::Capabilities gpu_capabilities) { 739 gpu::Capabilities gpu_capabilities) {
741 gpu_capabilities_ = gpu_capabilities; 740 gpu_capabilities_ = gpu_capabilities;
742 } 741 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 void CompositorImpl::SetNeedsAnimate() { 818 void CompositorImpl::SetNeedsAnimate() {
820 needs_animate_ = true; 819 needs_animate_ = true;
821 if (!host_->IsVisible()) 820 if (!host_->IsVisible())
822 return; 821 return;
823 822
824 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 823 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
825 host_->SetNeedsAnimate(); 824 host_->SetNeedsAnimate();
826 } 825 }
827 826
828 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { 827 cc::FrameSinkId CompositorImpl::GetFrameSinkId() {
829 return surface_id_allocator_->frame_sink_id(); 828 return frame_sink_id_;
830 } 829 }
831 830
832 bool CompositorImpl::HavePendingReadbacks() { 831 bool CompositorImpl::HavePendingReadbacks() {
833 return !readback_layer_tree_->children().empty(); 832 return !readback_layer_tree_->children().empty();
834 } 833 }
835 834
836 } // namespace content 835 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/browser/renderer_host/delegated_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698