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 <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "cc/input/layer_selection_bound.h" | 31 #include "cc/input/layer_selection_bound.h" |
32 #include "cc/layers/layer.h" | 32 #include "cc/layers/layer.h" |
33 #include "cc/output/begin_frame_args.h" | 33 #include "cc/output/begin_frame_args.h" |
34 #include "cc/output/copy_output_request.h" | 34 #include "cc/output/copy_output_request.h" |
35 #include "cc/output/copy_output_result.h" | 35 #include "cc/output/copy_output_result.h" |
36 #include "cc/output/latency_info_swap_promise.h" | 36 #include "cc/output/latency_info_swap_promise.h" |
37 #include "cc/output/swap_promise.h" | 37 #include "cc/output/swap_promise.h" |
38 #include "cc/proto/compositor_message.pb.h" | 38 #include "cc/proto/compositor_message.pb.h" |
39 #include "cc/resources/single_release_callback.h" | 39 #include "cc/resources/single_release_callback.h" |
40 #include "cc/scheduler/begin_frame_source.h" | 40 #include "cc/scheduler/begin_frame_source.h" |
41 #include "cc/tiles/picture_layer_tiling.h" | |
enne (OOO)
2016/06/28 18:39:02
?
| |
41 #include "cc/trees/latency_info_swap_promise_monitor.h" | 42 #include "cc/trees/latency_info_swap_promise_monitor.h" |
42 #include "cc/trees/layer_tree_host.h" | 43 #include "cc/trees/layer_tree_host.h" |
43 #include "cc/trees/remote_proto_channel.h" | 44 #include "cc/trees/remote_proto_channel.h" |
44 #include "components/scheduler/renderer/renderer_scheduler.h" | 45 #include "components/scheduler/renderer/renderer_scheduler.h" |
45 #include "content/common/content_switches_internal.h" | 46 #include "content/common/content_switches_internal.h" |
46 #include "content/common/gpu/client/context_provider_command_buffer.h" | 47 #include "content/common/gpu/client/context_provider_command_buffer.h" |
47 #include "content/public/common/content_client.h" | 48 #include "content/public/common/content_client.h" |
48 #include "content/public/common/content_switches.h" | 49 #include "content/public/common/content_switches.h" |
49 #include "content/renderer/gpu/render_widget_compositor_delegate.h" | 50 #include "content/renderer/gpu/render_widget_compositor_delegate.h" |
50 #include "content/renderer/input/input_handler_manager.h" | 51 #include "content/renderer/input/input_handler_manager.h" |
51 #include "gpu/command_buffer/client/gles2_interface.h" | 52 #include "gpu/command_buffer/client/gles2_interface.h" |
52 #include "gpu/command_buffer/service/gpu_switches.h" | 53 #include "gpu/command_buffer/service/gpu_switches.h" |
53 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" | 54 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" |
54 #include "third_party/WebKit/public/platform/WebCompositorMutatorClient.h" | 55 #include "third_party/WebKit/public/platform/WebCompositorMutatorClient.h" |
55 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" | 56 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" |
56 #include "third_party/WebKit/public/platform/WebSize.h" | 57 #include "third_party/WebKit/public/platform/WebSize.h" |
57 #include "third_party/WebKit/public/web/WebKit.h" | 58 #include "third_party/WebKit/public/web/WebKit.h" |
58 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 59 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
59 #include "third_party/WebKit/public/web/WebSelection.h" | 60 #include "third_party/WebKit/public/web/WebSelection.h" |
60 #include "ui/gl/gl_switches.h" | 61 #include "ui/gl/gl_switches.h" |
61 #include "ui/native_theme/native_theme_switches.h" | 62 #include "ui/native_theme/native_theme_switches.h" |
62 | 63 |
63 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
64 #include "base/android/build_info.h" | 65 #include "base/android/build_info.h" |
65 #include "ui/gfx/android/device_display_info.h" | |
66 #endif | 66 #endif |
67 | 67 |
68 namespace base { | 68 namespace base { |
69 class Value; | 69 class Value; |
70 } | 70 } |
71 | 71 |
72 namespace cc { | 72 namespace cc { |
73 class Layer; | 73 class Layer; |
74 } | 74 } |
75 | 75 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 cc::LayerSelection ConvertWebSelection(const WebSelection& web_selection) { | 129 cc::LayerSelection ConvertWebSelection(const WebSelection& web_selection) { |
130 cc::LayerSelection cc_selection; | 130 cc::LayerSelection cc_selection; |
131 cc_selection.start = ConvertWebSelectionBound(web_selection, true); | 131 cc_selection.start = ConvertWebSelectionBound(web_selection, true); |
132 cc_selection.end = ConvertWebSelectionBound(web_selection, false); | 132 cc_selection.end = ConvertWebSelectionBound(web_selection, false); |
133 cc_selection.is_editable = web_selection.isEditable(); | 133 cc_selection.is_editable = web_selection.isEditable(); |
134 cc_selection.is_empty_text_form_control = | 134 cc_selection.is_empty_text_form_control = |
135 web_selection.isEmptyTextFormControl(); | 135 web_selection.isEmptyTextFormControl(); |
136 return cc_selection; | 136 return cc_selection; |
137 } | 137 } |
138 | 138 |
139 gfx::Size CalculateDefaultTileSize(float initial_device_scale_factor) { | |
140 int default_tile_size = 256; | |
141 #if defined(OS_ANDROID) | |
142 // TODO(epenner): unify this for all platforms if it | |
143 // makes sense (http://crbug.com/159524) | |
144 | |
145 gfx::DeviceDisplayInfo info; | |
146 bool real_size_supported = true; | |
147 int display_width = info.GetPhysicalDisplayWidth(); | |
148 int display_height = info.GetPhysicalDisplayHeight(); | |
149 if (display_width == 0 || display_height == 0) { | |
150 real_size_supported = false; | |
151 display_width = info.GetDisplayWidth(); | |
152 display_height = info.GetDisplayHeight(); | |
153 } | |
154 | |
155 int portrait_width = std::min(display_width, display_height); | |
156 int landscape_width = std::max(display_width, display_height); | |
157 | |
158 if (real_size_supported) { | |
159 // Maximum HD dimensions should be 768x1280 | |
160 // Maximum FHD dimensions should be 1200x1920 | |
161 if (portrait_width > 768 || landscape_width > 1280) | |
162 default_tile_size = 384; | |
163 if (portrait_width > 1200 || landscape_width > 1920) | |
164 default_tile_size = 512; | |
165 | |
166 // Adjust for some resolutions that barely straddle an extra | |
167 // tile when in portrait mode. This helps worst case scroll/raster | |
168 // by not needing a full extra tile for each row. | |
169 if (default_tile_size == 256 && portrait_width == 768) | |
170 default_tile_size += 32; | |
171 if (default_tile_size == 384 && portrait_width == 1200) | |
172 default_tile_size += 32; | |
173 } else { | |
174 // We don't know the exact resolution due to screen controls etc. | |
175 // So this just estimates the values above using tile counts. | |
176 int numTiles = (display_width * display_height) / (256 * 256); | |
177 if (numTiles > 16) | |
178 default_tile_size = 384; | |
179 if (numTiles >= 40) | |
180 default_tile_size = 512; | |
181 } | |
182 #elif defined(OS_CHROMEOS) || defined(OS_MACOSX) | |
183 // Use 512 for high DPI (dsf=2.0f) devices. | |
184 if (initial_device_scale_factor >= 2.0f) | |
185 default_tile_size = 512; | |
186 #endif | |
187 | |
188 return gfx::Size(default_tile_size, default_tile_size); | |
189 } | |
190 | |
191 // Check cc::TopControlsState, and blink::WebTopControlsState | 139 // Check cc::TopControlsState, and blink::WebTopControlsState |
192 // are kept in sync. | 140 // are kept in sync. |
193 static_assert(int(blink::WebTopControlsBoth) == int(cc::BOTH), | 141 static_assert(int(blink::WebTopControlsBoth) == int(cc::BOTH), |
194 "mismatching enums: BOTH"); | 142 "mismatching enums: BOTH"); |
195 static_assert(int(blink::WebTopControlsHidden) == int(cc::HIDDEN), | 143 static_assert(int(blink::WebTopControlsHidden) == int(cc::HIDDEN), |
196 "mismatching enums: HIDDEN"); | 144 "mismatching enums: HIDDEN"); |
197 static_assert(int(blink::WebTopControlsShown) == int(cc::SHOWN), | 145 static_assert(int(blink::WebTopControlsShown) == int(cc::SHOWN), |
198 "mismatching enums: SHOWN"); | 146 "mismatching enums: SHOWN"); |
199 | 147 |
200 static cc::TopControlsState ConvertTopControlsState( | 148 static cc::TopControlsState ConvertTopControlsState( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 } else if (display_vsync_string == "beginframe") { | 230 } else if (display_vsync_string == "beginframe") { |
283 settings.wait_for_beginframe_interval = false; | 231 settings.wait_for_beginframe_interval = false; |
284 } else { | 232 } else { |
285 settings.renderer_settings.disable_display_vsync = true; | 233 settings.renderer_settings.disable_display_vsync = true; |
286 settings.wait_for_beginframe_interval = false; | 234 settings.wait_for_beginframe_interval = false; |
287 } | 235 } |
288 } | 236 } |
289 settings.main_frame_before_activation_enabled = | 237 settings.main_frame_before_activation_enabled = |
290 cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation); | 238 cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation); |
291 | 239 |
292 // TODO(danakj): This should not be a setting O_O; it should change when the | |
293 // device scale factor on LayerTreeHost changes. | |
294 settings.default_tile_size = CalculateDefaultTileSize(device_scale_factor); | |
295 if (cmd.HasSwitch(switches::kDefaultTileWidth)) { | |
296 int tile_width = 0; | |
297 GetSwitchValueAsInt(cmd, switches::kDefaultTileWidth, 1, | |
298 std::numeric_limits<int>::max(), &tile_width); | |
299 settings.default_tile_size.set_width(tile_width); | |
300 } | |
301 if (cmd.HasSwitch(switches::kDefaultTileHeight)) { | |
302 int tile_height = 0; | |
303 GetSwitchValueAsInt(cmd, switches::kDefaultTileHeight, 1, | |
304 std::numeric_limits<int>::max(), &tile_height); | |
305 settings.default_tile_size.set_height(tile_height); | |
306 } | |
307 | |
308 int max_untiled_layer_width = settings.max_untiled_layer_size.width(); | |
309 if (cmd.HasSwitch(switches::kMaxUntiledLayerWidth)) { | |
310 GetSwitchValueAsInt(cmd, switches::kMaxUntiledLayerWidth, 1, | |
311 std::numeric_limits<int>::max(), | |
312 &max_untiled_layer_width); | |
313 } | |
314 int max_untiled_layer_height = settings.max_untiled_layer_size.height(); | |
315 if (cmd.HasSwitch(switches::kMaxUntiledLayerHeight)) { | |
316 GetSwitchValueAsInt(cmd, switches::kMaxUntiledLayerHeight, 1, | |
317 std::numeric_limits<int>::max(), | |
318 &max_untiled_layer_height); | |
319 } | |
320 | |
321 settings.max_untiled_layer_size = gfx::Size(max_untiled_layer_width, | |
322 max_untiled_layer_height); | |
323 | |
324 settings.gpu_rasterization_msaa_sample_count = | 240 settings.gpu_rasterization_msaa_sample_count = |
325 compositor_deps->GetGpuRasterizationMSAASampleCount(); | 241 compositor_deps->GetGpuRasterizationMSAASampleCount(); |
326 settings.gpu_rasterization_forced = | 242 settings.gpu_rasterization_forced = |
327 compositor_deps->IsGpuRasterizationForced(); | 243 compositor_deps->IsGpuRasterizationForced(); |
328 settings.gpu_rasterization_enabled = | 244 settings.gpu_rasterization_enabled = |
329 compositor_deps->IsGpuRasterizationEnabled(); | 245 compositor_deps->IsGpuRasterizationEnabled(); |
330 settings.async_worker_context_enabled = | 246 settings.async_worker_context_enabled = |
331 compositor_deps->IsAsyncWorkerContextEnabled(); | 247 compositor_deps->IsAsyncWorkerContextEnabled(); |
332 | 248 |
333 settings.can_use_lcd_text = compositor_deps->IsLcdTextEnabled(); | 249 settings.can_use_lcd_text = compositor_deps->IsLcdTextEnabled(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 GetSwitchValueAsInt( | 314 GetSwitchValueAsInt( |
399 cmd, cc::switches::kSlowDownRasterScaleFactor, kMinSlowDownScaleFactor, | 315 cmd, cc::switches::kSlowDownRasterScaleFactor, kMinSlowDownScaleFactor, |
400 kMaxSlowDownScaleFactor, | 316 kMaxSlowDownScaleFactor, |
401 &settings.initial_debug_state.slow_down_raster_scale_factor); | 317 &settings.initial_debug_state.slow_down_raster_scale_factor); |
402 } | 318 } |
403 | 319 |
404 #if defined(OS_ANDROID) | 320 #if defined(OS_ANDROID) |
405 bool using_synchronous_compositor = | 321 bool using_synchronous_compositor = |
406 GetContentClient()->UsingSynchronousCompositing(); | 322 GetContentClient()->UsingSynchronousCompositing(); |
407 | 323 |
324 // TODO(crbug.com/622885): Android viewport is assumed to be fixed forever. | |
325 settings.use_viewport_for_tile_size = true; | |
326 | |
408 // We can't use GPU rasterization on low-end devices, because the Ganesh | 327 // We can't use GPU rasterization on low-end devices, because the Ganesh |
409 // cache would consume too much memory. | 328 // cache would consume too much memory. |
410 if (base::SysInfo::IsLowEndDevice()) | 329 if (base::SysInfo::IsLowEndDevice()) |
411 settings.gpu_rasterization_enabled = false; | 330 settings.gpu_rasterization_enabled = false; |
412 settings.using_synchronous_renderer_compositor = using_synchronous_compositor; | 331 settings.using_synchronous_renderer_compositor = using_synchronous_compositor; |
413 if (using_synchronous_compositor) { | 332 if (using_synchronous_compositor) { |
414 // Android WebView uses system scrollbars, so make ours invisible. | 333 // Android WebView uses system scrollbars, so make ours invisible. |
415 settings.scrollbar_animator = cc::LayerTreeSettings::NO_ANIMATOR; | 334 settings.scrollbar_animator = cc::LayerTreeSettings::NO_ANIMATOR; |
416 settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; | 335 settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; |
417 } else { | 336 } else { |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1144 | 1063 |
1145 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); | 1064 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); |
1146 } | 1065 } |
1147 | 1066 |
1148 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1067 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
1149 float device_scale) { | 1068 float device_scale) { |
1150 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); | 1069 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); |
1151 } | 1070 } |
1152 | 1071 |
1153 } // namespace content | 1072 } // namespace content |
OLD | NEW |