| 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 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 23 #include "base/task_scheduler/post_task.h" | 23 #include "base/task_scheduler/post_task.h" |
| 24 #include "base/task_scheduler/task_scheduler.h" | 24 #include "base/task_scheduler/task_scheduler.h" |
| 25 #include "base/task_scheduler/task_traits.h" | 25 #include "base/task_scheduler/task_traits.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "base/values.h" | 28 #include "base/values.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "cc/animation/animation_host.h" | 30 #include "cc/animation/animation_host.h" |
| 31 #include "cc/animation/animation_timeline.h" | 31 #include "cc/animation/animation_timeline.h" |
| 32 #include "cc/base/region.h" | |
| 33 #include "cc/base/switches.h" | 32 #include "cc/base/switches.h" |
| 34 #include "cc/blink/web_layer_impl.h" | 33 #include "cc/blink/web_layer_impl.h" |
| 35 #include "cc/debug/layer_tree_debug_state.h" | 34 #include "cc/debug/layer_tree_debug_state.h" |
| 36 #include "cc/debug/micro_benchmark.h" | 35 #include "cc/debug/micro_benchmark.h" |
| 37 #include "cc/input/layer_selection_bound.h" | 36 #include "cc/input/layer_selection_bound.h" |
| 38 #include "cc/layers/layer.h" | 37 #include "cc/layers/layer.h" |
| 39 #include "cc/output/begin_frame_args.h" | 38 #include "cc/output/begin_frame_args.h" |
| 40 #include "cc/output/copy_output_request.h" | 39 #include "cc/output/copy_output_request.h" |
| 41 #include "cc/output/copy_output_result.h" | 40 #include "cc/output/copy_output_result.h" |
| 42 #include "cc/output/latency_info_swap_promise.h" | 41 #include "cc/output/latency_info_swap_promise.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 200 } |
| 202 | 201 |
| 203 RenderWidgetCompositor::RenderWidgetCompositor( | 202 RenderWidgetCompositor::RenderWidgetCompositor( |
| 204 RenderWidgetCompositorDelegate* delegate, | 203 RenderWidgetCompositorDelegate* delegate, |
| 205 CompositorDependencies* compositor_deps) | 204 CompositorDependencies* compositor_deps) |
| 206 : num_failed_recreate_attempts_(0), | 205 : num_failed_recreate_attempts_(0), |
| 207 delegate_(delegate), | 206 delegate_(delegate), |
| 208 compositor_deps_(compositor_deps), | 207 compositor_deps_(compositor_deps), |
| 209 threaded_(!!compositor_deps_->GetCompositorImplThreadTaskRunner()), | 208 threaded_(!!compositor_deps_->GetCompositorImplThreadTaskRunner()), |
| 210 never_visible_(false), | 209 never_visible_(false), |
| 211 is_for_oopif_(false), | |
| 212 layout_and_paint_async_callback_(nullptr), | 210 layout_and_paint_async_callback_(nullptr), |
| 213 weak_factory_(this) {} | 211 weak_factory_(this) {} |
| 214 | 212 |
| 215 void RenderWidgetCompositor::Initialize(float device_scale_factor, | 213 void RenderWidgetCompositor::Initialize(float device_scale_factor, |
| 216 const ScreenInfo& screen_info) { | 214 const ScreenInfo& screen_info) { |
| 217 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 215 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 218 cc::LayerTreeSettings settings = GenerateLayerTreeSettings( | 216 cc::LayerTreeSettings settings = GenerateLayerTreeSettings( |
| 219 *cmd, compositor_deps_, device_scale_factor, screen_info); | 217 *cmd, compositor_deps_, device_scale_factor, screen_info); |
| 220 | 218 |
| 221 animation_host_ = cc::AnimationHost::CreateMainInstance(); | 219 animation_host_ = cc::AnimationHost::CreateMainInstance(); |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 "EventListener and WebEventListener enums must match"); | 810 "EventListener and WebEventListener enums must match"); |
| 813 | 811 |
| 814 void RenderWidgetCompositor::setEventListenerProperties( | 812 void RenderWidgetCompositor::setEventListenerProperties( |
| 815 blink::WebEventListenerClass eventClass, | 813 blink::WebEventListenerClass eventClass, |
| 816 blink::WebEventListenerProperties properties) { | 814 blink::WebEventListenerProperties properties) { |
| 817 layer_tree_host_->GetLayerTree()->SetEventListenerProperties( | 815 layer_tree_host_->GetLayerTree()->SetEventListenerProperties( |
| 818 static_cast<cc::EventListenerClass>(eventClass), | 816 static_cast<cc::EventListenerClass>(eventClass), |
| 819 static_cast<cc::EventListenerProperties>(properties)); | 817 static_cast<cc::EventListenerProperties>(properties)); |
| 820 } | 818 } |
| 821 | 819 |
| 822 void RenderWidgetCompositor::updateTouchRectsForSubframeIfNecessary() { | |
| 823 if (!is_for_oopif_) | |
| 824 return; | |
| 825 | |
| 826 // If this is an oopif sub-frame compositor, we won't be getting TouchRects | |
| 827 // from ScrollingCoordinator, so to make sure touch events are handled | |
| 828 // properly, mark the entire root layer as a TouchRect. | |
| 829 // TODO(wjmaclean): remove this when ScrollingCoordinator is made per-frame, | |
| 830 // as opposed to per-page. | |
| 831 using blink::WebEventListenerProperties; | |
| 832 using blink::WebEventListenerClass; | |
| 833 | |
| 834 blink::WebEventListenerProperties touch_start_properties = | |
| 835 eventListenerProperties(WebEventListenerClass::TouchStartOrMove); | |
| 836 blink::WebEventListenerProperties touch_end_cancel_properties = | |
| 837 eventListenerProperties(WebEventListenerClass::TouchEndOrCancel); | |
| 838 bool has_touch_handlers = | |
| 839 touch_start_properties == WebEventListenerProperties::Blocking || | |
| 840 touch_start_properties == | |
| 841 WebEventListenerProperties::BlockingAndPassive || | |
| 842 touch_end_cancel_properties == WebEventListenerProperties::Blocking || | |
| 843 touch_end_cancel_properties == | |
| 844 WebEventListenerProperties::BlockingAndPassive; | |
| 845 | |
| 846 cc::Layer* root_layer = layer_tree_host_->GetLayerTree()->root_layer(); | |
| 847 cc::Region touch_handler_region; | |
| 848 if (has_touch_handlers) | |
| 849 touch_handler_region = gfx::Rect(gfx::Point(), root_layer->bounds()); | |
| 850 root_layer->SetTouchEventHandlerRegion(touch_handler_region); | |
| 851 } | |
| 852 | |
| 853 blink::WebEventListenerProperties | 820 blink::WebEventListenerProperties |
| 854 RenderWidgetCompositor::eventListenerProperties( | 821 RenderWidgetCompositor::eventListenerProperties( |
| 855 blink::WebEventListenerClass event_class) const { | 822 blink::WebEventListenerClass event_class) const { |
| 856 return static_cast<blink::WebEventListenerProperties>( | 823 return static_cast<blink::WebEventListenerProperties>( |
| 857 layer_tree_host_->GetLayerTree()->event_listener_properties( | 824 layer_tree_host_->GetLayerTree()->event_listener_properties( |
| 858 static_cast<cc::EventListenerClass>(event_class))); | 825 static_cast<cc::EventListenerClass>(event_class))); |
| 859 } | 826 } |
| 860 | 827 |
| 861 void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { | 828 void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { |
| 862 layer_tree_host_->GetLayerTree()->SetHaveScrollEventHandlers(has_handlers); | 829 layer_tree_host_->GetLayerTree()->SetHaveScrollEventHandlers(has_handlers); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1081 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
| 1115 float device_scale) { | 1082 float device_scale) { |
| 1116 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1083 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
| 1117 } | 1084 } |
| 1118 | 1085 |
| 1119 void RenderWidgetCompositor::SetDeviceColorSpace( | 1086 void RenderWidgetCompositor::SetDeviceColorSpace( |
| 1120 const gfx::ColorSpace& color_space) { | 1087 const gfx::ColorSpace& color_space) { |
| 1121 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); | 1088 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); |
| 1122 } | 1089 } |
| 1123 | 1090 |
| 1124 void RenderWidgetCompositor::SetIsForOopif(bool is_for_oopif) { | |
| 1125 is_for_oopif_ = is_for_oopif; | |
| 1126 } | |
| 1127 | |
| 1128 } // namespace content | 1091 } // namespace content |
| OLD | NEW |