OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "content/renderer/input/input_handler_manager.h" | 32 #include "content/renderer/input/input_handler_manager.h" |
33 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
34 #include "gpu/command_buffer/client/gles2_interface.h" | 34 #include "gpu/command_buffer/client/gles2_interface.h" |
35 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" | 35 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" |
36 #include "third_party/WebKit/public/platform/WebSize.h" | 36 #include "third_party/WebKit/public/platform/WebSize.h" |
37 #include "third_party/WebKit/public/web/WebWidget.h" | 37 #include "third_party/WebKit/public/web/WebWidget.h" |
38 #include "ui/gfx/frame_time.h" | 38 #include "ui/gfx/frame_time.h" |
39 #include "ui/gl/gl_switches.h" | 39 #include "ui/gl/gl_switches.h" |
40 #include "ui/native_theme/native_theme_switches.h" | 40 #include "ui/native_theme/native_theme_switches.h" |
41 | 41 |
| 42 #if defined(OS_ANDROID) |
| 43 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 44 #endif |
| 45 |
42 namespace base { | 46 namespace base { |
43 class Value; | 47 class Value; |
44 } | 48 } |
45 | 49 |
46 namespace cc { | 50 namespace cc { |
47 class Layer; | 51 class Layer; |
48 } | 52 } |
49 | 53 |
50 using blink::WebFloatPoint; | 54 using blink::WebFloatPoint; |
51 using blink::WebSize; | 55 using blink::WebSize; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 96 |
93 settings.throttle_frame_production = | 97 settings.throttle_frame_production = |
94 !cmd->HasSwitch(switches::kDisableGpuVsync); | 98 !cmd->HasSwitch(switches::kDisableGpuVsync); |
95 settings.begin_frame_scheduling_enabled = | 99 settings.begin_frame_scheduling_enabled = |
96 cmd->HasSwitch(switches::kEnableBeginFrameScheduling); | 100 cmd->HasSwitch(switches::kEnableBeginFrameScheduling); |
97 settings.main_frame_before_activation_enabled = | 101 settings.main_frame_before_activation_enabled = |
98 cmd->HasSwitch(cc::switches::kEnableMainFrameBeforeActivation) && | 102 cmd->HasSwitch(cc::switches::kEnableMainFrameBeforeActivation) && |
99 !cmd->HasSwitch(cc::switches::kDisableMainFrameBeforeActivation); | 103 !cmd->HasSwitch(cc::switches::kDisableMainFrameBeforeActivation); |
100 settings.main_frame_before_draw_enabled = | 104 settings.main_frame_before_draw_enabled = |
101 !cmd->HasSwitch(cc::switches::kDisableMainFrameBeforeDraw); | 105 !cmd->HasSwitch(cc::switches::kDisableMainFrameBeforeDraw); |
102 settings.using_synchronous_renderer_compositor = | 106 settings.report_overscroll_only_for_scrollable_axes = true; |
103 widget->UsingSynchronousRendererCompositor(); | |
104 settings.report_overscroll_only_for_scrollable_axes = | |
105 !widget->UsingSynchronousRendererCompositor(); | |
106 settings.accelerated_animation_enabled = | 107 settings.accelerated_animation_enabled = |
107 !cmd->HasSwitch(cc::switches::kDisableThreadedAnimation); | 108 !cmd->HasSwitch(cc::switches::kDisableThreadedAnimation); |
108 settings.touch_hit_testing = | 109 settings.touch_hit_testing = |
109 !cmd->HasSwitch(cc::switches::kDisableCompositorTouchHitTesting); | 110 !cmd->HasSwitch(cc::switches::kDisableCompositorTouchHitTesting); |
110 | 111 |
111 int default_tile_width = settings.default_tile_size.width(); | 112 int default_tile_width = settings.default_tile_size.width(); |
112 if (cmd->HasSwitch(switches::kDefaultTileWidth)) { | 113 if (cmd->HasSwitch(switches::kDefaultTileWidth)) { |
113 GetSwitchValueAsInt(*cmd, switches::kDefaultTileWidth, 1, | 114 GetSwitchValueAsInt(*cmd, switches::kDefaultTileWidth, 1, |
114 std::numeric_limits<int>::max(), &default_tile_width); | 115 std::numeric_limits<int>::max(), &default_tile_width); |
115 } | 116 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 &max_unused_resource_memory_percentage)) { | 254 &max_unused_resource_memory_percentage)) { |
254 settings.max_unused_resource_memory_percentage = | 255 settings.max_unused_resource_memory_percentage = |
255 max_unused_resource_memory_percentage; | 256 max_unused_resource_memory_percentage; |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 settings.strict_layer_property_change_checking = | 260 settings.strict_layer_property_change_checking = |
260 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); | 261 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); |
261 | 262 |
262 #if defined(OS_ANDROID) | 263 #if defined(OS_ANDROID) |
| 264 SynchronousCompositorFactory* synchronous_compositor_factory = |
| 265 SynchronousCompositorFactory::GetInstance(); |
| 266 |
| 267 settings.using_synchronous_renderer_compositor = |
| 268 synchronous_compositor_factory; |
| 269 settings.record_full_layer = |
| 270 synchronous_compositor_factory && |
| 271 synchronous_compositor_factory->RecordFullLayer(); |
| 272 settings.report_overscroll_only_for_scrollable_axes = |
| 273 !synchronous_compositor_factory; |
263 settings.max_partial_texture_updates = 0; | 274 settings.max_partial_texture_updates = 0; |
264 if (widget->UsingSynchronousRendererCompositor()) { | 275 if (synchronous_compositor_factory) { |
265 // Android WebView uses system scrollbars, so make ours invisible. | 276 // Android WebView uses system scrollbars, so make ours invisible. |
266 settings.scrollbar_animator = cc::LayerTreeSettings::NoAnimator; | 277 settings.scrollbar_animator = cc::LayerTreeSettings::NoAnimator; |
267 settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; | 278 settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; |
268 } else { | 279 } else { |
269 settings.scrollbar_animator = cc::LayerTreeSettings::LinearFade; | 280 settings.scrollbar_animator = cc::LayerTreeSettings::LinearFade; |
270 settings.scrollbar_fade_delay_ms = 300; | 281 settings.scrollbar_fade_delay_ms = 300; |
271 settings.scrollbar_fade_duration_ms = 300; | 282 settings.scrollbar_fade_duration_ms = 300; |
272 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | 283 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); |
273 } | 284 } |
274 settings.highp_threshold_min = 2048; | 285 settings.highp_threshold_min = 2048; |
275 // Android WebView handles root layer flings itself. | 286 // Android WebView handles root layer flings itself. |
276 settings.ignore_root_layer_flings = | 287 settings.ignore_root_layer_flings = |
277 widget->UsingSynchronousRendererCompositor(); | 288 synchronous_compositor_factory; |
278 // RGBA_4444 textures are only enabled for low end devices | 289 // RGBA_4444 textures are only enabled for low end devices |
279 // and are disabled for Android WebView as it doesn't support the format. | 290 // and are disabled for Android WebView as it doesn't support the format. |
280 settings.use_rgba_4444_textures = | 291 settings.use_rgba_4444_textures = |
281 base::SysInfo::IsLowEndDevice() && | 292 base::SysInfo::IsLowEndDevice() && |
282 !widget->UsingSynchronousRendererCompositor(); | 293 !synchronous_compositor_factory; |
283 if (widget->UsingSynchronousRendererCompositor()) { | 294 if (synchronous_compositor_factory) { |
284 // TODO(boliu): Set this ratio for Webview. | 295 // TODO(boliu): Set this ratio for Webview. |
285 } else if (base::SysInfo::IsLowEndDevice()) { | 296 } else if (base::SysInfo::IsLowEndDevice()) { |
286 // On low-end we want to be very carefull about killing other | 297 // On low-end we want to be very carefull about killing other |
287 // apps. So initially we use 50% more memory to avoid flickering | 298 // apps. So initially we use 50% more memory to avoid flickering |
288 // or raster-on-demand. | 299 // or raster-on-demand. |
289 settings.max_memory_for_prepaint_percentage = 67; | 300 settings.max_memory_for_prepaint_percentage = 67; |
290 } else { | 301 } else { |
291 // On other devices we have increased memory excessively to avoid | 302 // On other devices we have increased memory excessively to avoid |
292 // raster-on-demand already, so now we reserve 50% _only_ to avoid | 303 // raster-on-demand already, so now we reserve 50% _only_ to avoid |
293 // raster-on-demand, and use 50% of the memory otherwise. | 304 // raster-on-demand, and use 50% of the memory otherwise. |
294 settings.max_memory_for_prepaint_percentage = 50; | 305 settings.max_memory_for_prepaint_percentage = 50; |
295 } | 306 } |
296 // Webview does not own the surface so should not clear it. | 307 // Webview does not own the surface so should not clear it. |
297 settings.should_clear_root_render_pass = | 308 settings.should_clear_root_render_pass = |
298 !widget->UsingSynchronousRendererCompositor(); | 309 !synchronous_compositor_factory; |
299 | 310 |
300 #elif !defined(OS_MACOSX) | 311 #elif !defined(OS_MACOSX) |
301 if (ui::IsOverlayScrollbarEnabled()) { | 312 if (ui::IsOverlayScrollbarEnabled()) { |
302 settings.scrollbar_animator = cc::LayerTreeSettings::Thinning; | 313 settings.scrollbar_animator = cc::LayerTreeSettings::Thinning; |
303 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | 314 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); |
304 } else if (cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport)) { | 315 } else if (cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport)) { |
305 // use_pinch_zoom_scrollbars is only true on desktop when non-overlay | 316 // use_pinch_zoom_scrollbars is only true on desktop when non-overlay |
306 // scrollbars are in use. | 317 // scrollbars are in use. |
307 settings.use_pinch_zoom_scrollbars = true; | 318 settings.use_pinch_zoom_scrollbars = true; |
308 settings.scrollbar_animator = cc::LayerTreeSettings::LinearFade; | 319 settings.scrollbar_animator = cc::LayerTreeSettings::LinearFade; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 widget_->OnSwapBuffersAborted(); | 711 widget_->OnSwapBuffersAborted(); |
701 } | 712 } |
702 | 713 |
703 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 714 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
704 cc::ContextProvider* provider = | 715 cc::ContextProvider* provider = |
705 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 716 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
706 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 717 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
707 } | 718 } |
708 | 719 |
709 } // namespace content | 720 } // namespace content |
OLD | NEW |