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 <map> | 9 #include <map> |
10 | 10 |
11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "cc/base/switches.h" |
20 #include "cc/input/input_handler.h" | 21 #include "cc/input/input_handler.h" |
21 #include "cc/layers/layer.h" | 22 #include "cc/layers/layer.h" |
22 #include "cc/output/compositor_frame.h" | 23 #include "cc/output/compositor_frame.h" |
23 #include "cc/output/context_provider.h" | 24 #include "cc/output/context_provider.h" |
24 #include "cc/output/output_surface.h" | 25 #include "cc/output/output_surface.h" |
25 #include "cc/resources/scoped_ui_resource.h" | 26 #include "cc/resources/scoped_ui_resource.h" |
26 #include "cc/resources/ui_resource_bitmap.h" | 27 #include "cc/resources/ui_resource_bitmap.h" |
27 #include "cc/trees/layer_tree_host.h" | 28 #include "cc/trees/layer_tree_host.h" |
28 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 29 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
29 #include "content/browser/gpu/gpu_surface_tracker.h" | 30 #include "content/browser/gpu/gpu_surface_tracker.h" |
30 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 31 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
31 #include "content/common/gpu/client/context_provider_command_buffer.h" | 32 #include "content/common/gpu/client/context_provider_command_buffer.h" |
32 #include "content/common/gpu/client/gl_helper.h" | 33 #include "content/common/gpu/client/gl_helper.h" |
33 #include "content/common/gpu/client/gpu_channel_host.h" | 34 #include "content/common/gpu/client/gpu_channel_host.h" |
34 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 35 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
35 #include "content/common/gpu/gpu_process_launch_causes.h" | 36 #include "content/common/gpu/gpu_process_launch_causes.h" |
36 #include "content/public/browser/android/compositor_client.h" | 37 #include "content/public/browser/android/compositor_client.h" |
37 #include "content/public/common/content_switches.h" | |
38 #include "gpu/command_buffer/client/gles2_interface.h" | 38 #include "gpu/command_buffer/client/gles2_interface.h" |
39 #include "third_party/khronos/GLES2/gl2.h" | 39 #include "third_party/khronos/GLES2/gl2.h" |
40 #include "third_party/khronos/GLES2/gl2ext.h" | 40 #include "third_party/khronos/GLES2/gl2ext.h" |
41 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 41 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
42 #include "ui/base/android/window_android.h" | 42 #include "ui/base/android/window_android.h" |
43 #include "ui/gfx/android/device_display_info.h" | 43 #include "ui/gfx/android/device_display_info.h" |
44 #include "ui/gfx/android/java_bitmap.h" | 44 #include "ui/gfx/android/java_bitmap.h" |
45 #include "ui/gfx/frame_time.h" | 45 #include "ui/gfx/frame_time.h" |
46 #include "webkit/common/gpu/context_provider_in_process.h" | 46 #include "webkit/common/gpu/context_provider_in_process.h" |
47 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 47 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } else if (!host_) { | 260 } else if (!host_) { |
261 cc::LayerTreeSettings settings; | 261 cc::LayerTreeSettings settings; |
262 settings.refresh_rate = 60.0; | 262 settings.refresh_rate = 60.0; |
263 settings.impl_side_painting = false; | 263 settings.impl_side_painting = false; |
264 settings.allow_antialiasing = false; | 264 settings.allow_antialiasing = false; |
265 settings.calculate_top_controls_position = false; | 265 settings.calculate_top_controls_position = false; |
266 settings.top_controls_height = 0.f; | 266 settings.top_controls_height = 0.f; |
267 settings.use_memory_management = false; | 267 settings.use_memory_management = false; |
268 settings.highp_threshold_min = 2048; | 268 settings.highp_threshold_min = 2048; |
269 | 269 |
| 270 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 271 settings.initial_debug_state.SetRecordRenderingStats( |
| 272 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); |
| 273 |
270 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings); | 274 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings); |
271 host_->SetRootLayer(root_layer_); | 275 host_->SetRootLayer(root_layer_); |
272 | 276 |
273 host_->SetVisible(true); | 277 host_->SetVisible(true); |
274 host_->SetLayerTreeHostClientReady(); | 278 host_->SetLayerTreeHostClientReady(); |
275 host_->SetViewportSize(size_); | 279 host_->SetViewportSize(size_); |
276 host_->set_has_transparent_background(has_transparent_background_); | 280 host_->set_has_transparent_background(has_transparent_background_); |
277 host_->SetDeviceScaleFactor(device_scale_factor_); | 281 host_->SetDeviceScaleFactor(device_scale_factor_); |
278 // Need to recreate the UI resources because a new LayerTreeHost has been | 282 // Need to recreate the UI resources because a new LayerTreeHost has been |
279 // created. | 283 // created. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 void CompositorImpl::DidAbortSwapBuffers() { | 459 void CompositorImpl::DidAbortSwapBuffers() { |
456 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); | 460 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); |
457 client_->OnSwapBuffersCompleted(); | 461 client_->OnSwapBuffersCompleted(); |
458 } | 462 } |
459 | 463 |
460 void CompositorImpl::DidCommit() { | 464 void CompositorImpl::DidCommit() { |
461 root_window_->OnCompositingDidCommit(); | 465 root_window_->OnCompositingDidCommit(); |
462 } | 466 } |
463 | 467 |
464 } // namespace content | 468 } // namespace content |
OLD | NEW |