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 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 21 #include "base/threading/simple_thread.h" |
21 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
22 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
23 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
24 #include "cc/input/input_handler.h" | 25 #include "cc/input/input_handler.h" |
25 #include "cc/layers/layer.h" | 26 #include "cc/layers/layer.h" |
26 #include "cc/output/compositor_frame.h" | 27 #include "cc/output/compositor_frame.h" |
27 #include "cc/output/context_provider.h" | 28 #include "cc/output/context_provider.h" |
28 #include "cc/output/output_surface.h" | 29 #include "cc/output/output_surface.h" |
29 #include "cc/output/output_surface_client.h" | 30 #include "cc/output/output_surface_client.h" |
| 31 #include "cc/resources/task_graph_runner.h" |
30 #include "cc/scheduler/begin_frame_source.h" | 32 #include "cc/scheduler/begin_frame_source.h" |
31 #include "cc/surfaces/onscreen_display_client.h" | 33 #include "cc/surfaces/onscreen_display_client.h" |
32 #include "cc/surfaces/surface_display_output_surface.h" | 34 #include "cc/surfaces/surface_display_output_surface.h" |
33 #include "cc/surfaces/surface_id_allocator.h" | 35 #include "cc/surfaces/surface_id_allocator.h" |
34 #include "cc/surfaces/surface_manager.h" | 36 #include "cc/surfaces/surface_manager.h" |
35 #include "cc/trees/layer_tree_host.h" | 37 #include "cc/trees/layer_tree_host.h" |
36 #include "content/browser/android/child_process_launcher_android.h" | 38 #include "content/browser/android/child_process_launcher_android.h" |
37 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 39 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
38 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 40 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
39 #include "content/browser/gpu/compositor_util.h" | 41 #include "content/browser/gpu/compositor_util.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 132 |
131 static bool g_initialized = false; | 133 static bool g_initialized = false; |
132 | 134 |
133 bool g_use_surface_manager = false; | 135 bool g_use_surface_manager = false; |
134 base::LazyInstance<cc::SurfaceManager> g_surface_manager = | 136 base::LazyInstance<cc::SurfaceManager> g_surface_manager = |
135 LAZY_INSTANCE_INITIALIZER; | 137 LAZY_INSTANCE_INITIALIZER; |
136 | 138 |
137 | 139 |
138 int g_surface_id_namespace = 0; | 140 int g_surface_id_namespace = 0; |
139 | 141 |
| 142 class SingleThreadTaskGraphRunner |
| 143 : public cc::TaskGraphRunner, |
| 144 public base::DelegateSimpleThread::Delegate { |
| 145 public: |
| 146 SingleThreadTaskGraphRunner() : worker_thread_(this, "CompositorWorker") { |
| 147 worker_thread_.Start(); |
| 148 } |
| 149 |
| 150 ~SingleThreadTaskGraphRunner() override { |
| 151 Shutdown(); |
| 152 worker_thread_.Join(); |
| 153 } |
| 154 |
| 155 private: |
| 156 // Overridden from base::DelegateSimpleThread::Delegate: |
| 157 void Run() override { cc::TaskGraphRunner::Run(); } |
| 158 |
| 159 base::DelegateSimpleThread worker_thread_; |
| 160 }; |
| 161 |
| 162 base::LazyInstance<SingleThreadTaskGraphRunner> g_task_graph_runner = |
| 163 LAZY_INSTANCE_INITIALIZER; |
| 164 |
140 } // anonymous namespace | 165 } // anonymous namespace |
141 | 166 |
142 // static | 167 // static |
143 Compositor* Compositor::Create(CompositorClient* client, | 168 Compositor* Compositor::Create(CompositorClient* client, |
144 gfx::NativeWindow root_window) { | 169 gfx::NativeWindow root_window) { |
145 return client ? new CompositorImpl(client, root_window) : NULL; | 170 return client ? new CompositorImpl(client, root_window) : NULL; |
146 } | 171 } |
147 | 172 |
148 // static | 173 // static |
149 void Compositor::Initialize() { | 174 void Compositor::Initialize() { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 413 |
389 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 414 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
390 settings.initial_debug_state.SetRecordRenderingStats( | 415 settings.initial_debug_state.SetRecordRenderingStats( |
391 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); | 416 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); |
392 settings.initial_debug_state.show_fps_counter = | 417 settings.initial_debug_state.show_fps_counter = |
393 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); | 418 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); |
394 // TODO(enne): Update this this compositor to use the scheduler. | 419 // TODO(enne): Update this this compositor to use the scheduler. |
395 settings.single_thread_proxy_scheduler = false; | 420 settings.single_thread_proxy_scheduler = false; |
396 | 421 |
397 host_ = cc::LayerTreeHost::CreateSingleThreaded( | 422 host_ = cc::LayerTreeHost::CreateSingleThreaded( |
398 this, | 423 this, this, HostSharedBitmapManager::current(), |
399 this, | 424 BrowserGpuMemoryBufferManager::current(), g_task_graph_runner.Pointer(), |
400 HostSharedBitmapManager::current(), | 425 settings, base::MessageLoopProxy::current(), nullptr); |
401 BrowserGpuMemoryBufferManager::current(), | |
402 settings, | |
403 base::MessageLoopProxy::current(), | |
404 nullptr); | |
405 host_->SetRootLayer(root_layer_); | 426 host_->SetRootLayer(root_layer_); |
406 | 427 |
407 host_->SetVisible(true); | 428 host_->SetVisible(true); |
408 host_->SetLayerTreeHostClientReady(); | 429 host_->SetLayerTreeHostClientReady(); |
409 host_->SetViewportSize(size_); | 430 host_->SetViewportSize(size_); |
410 host_->set_has_transparent_background(has_transparent_background_); | 431 host_->set_has_transparent_background(has_transparent_background_); |
411 host_->SetDeviceScaleFactor(device_scale_factor_); | 432 host_->SetDeviceScaleFactor(device_scale_factor_); |
412 | 433 |
413 if (needs_animate_) | 434 if (needs_animate_) |
414 host_->SetNeedsAnimate(); | 435 host_->SetNeedsAnimate(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 719 |
699 void CompositorImpl::SetNeedsAnimate() { | 720 void CompositorImpl::SetNeedsAnimate() { |
700 needs_animate_ = true; | 721 needs_animate_ = true; |
701 if (!host_) | 722 if (!host_) |
702 return; | 723 return; |
703 | 724 |
704 host_->SetNeedsAnimate(); | 725 host_->SetNeedsAnimate(); |
705 } | 726 } |
706 | 727 |
707 } // namespace content | 728 } // namespace content |
OLD | NEW |