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" |
32 #include "cc/base/switches.h" | 33 #include "cc/base/switches.h" |
33 #include "cc/blink/web_layer_impl.h" | 34 #include "cc/blink/web_layer_impl.h" |
34 #include "cc/debug/layer_tree_debug_state.h" | 35 #include "cc/debug/layer_tree_debug_state.h" |
35 #include "cc/debug/micro_benchmark.h" | 36 #include "cc/debug/micro_benchmark.h" |
36 #include "cc/input/layer_selection_bound.h" | 37 #include "cc/input/layer_selection_bound.h" |
37 #include "cc/layers/layer.h" | 38 #include "cc/layers/layer.h" |
38 #include "cc/output/begin_frame_args.h" | 39 #include "cc/output/begin_frame_args.h" |
39 #include "cc/output/copy_output_request.h" | 40 #include "cc/output/copy_output_request.h" |
40 #include "cc/output/copy_output_result.h" | 41 #include "cc/output/copy_output_result.h" |
41 #include "cc/output/latency_info_swap_promise.h" | 42 #include "cc/output/latency_info_swap_promise.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 198 } |
198 | 199 |
199 RenderWidgetCompositor::RenderWidgetCompositor( | 200 RenderWidgetCompositor::RenderWidgetCompositor( |
200 RenderWidgetCompositorDelegate* delegate, | 201 RenderWidgetCompositorDelegate* delegate, |
201 CompositorDependencies* compositor_deps) | 202 CompositorDependencies* compositor_deps) |
202 : num_failed_recreate_attempts_(0), | 203 : num_failed_recreate_attempts_(0), |
203 delegate_(delegate), | 204 delegate_(delegate), |
204 compositor_deps_(compositor_deps), | 205 compositor_deps_(compositor_deps), |
205 threaded_(!!compositor_deps_->GetCompositorImplThreadTaskRunner()), | 206 threaded_(!!compositor_deps_->GetCompositorImplThreadTaskRunner()), |
206 never_visible_(false), | 207 never_visible_(false), |
| 208 is_for_oopif_(false), |
207 layout_and_paint_async_callback_(nullptr), | 209 layout_and_paint_async_callback_(nullptr), |
208 weak_factory_(this) {} | 210 weak_factory_(this) {} |
209 | 211 |
210 void RenderWidgetCompositor::Initialize( | 212 void RenderWidgetCompositor::Initialize( |
211 std::unique_ptr<cc::LayerTreeHost> layer_tree_host, | 213 std::unique_ptr<cc::LayerTreeHost> layer_tree_host, |
212 std::unique_ptr<cc::AnimationHost> animation_host) { | 214 std::unique_ptr<cc::AnimationHost> animation_host) { |
213 DCHECK(layer_tree_host); | 215 DCHECK(layer_tree_host); |
214 DCHECK(animation_host); | 216 DCHECK(animation_host); |
215 animation_host_ = std::move(animation_host); | 217 animation_host_ = std::move(animation_host); |
216 layer_tree_host_ = std::move(layer_tree_host); | 218 layer_tree_host_ = std::move(layer_tree_host); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 "EventListener and WebEventListener enums must match"); | 827 "EventListener and WebEventListener enums must match"); |
826 | 828 |
827 void RenderWidgetCompositor::setEventListenerProperties( | 829 void RenderWidgetCompositor::setEventListenerProperties( |
828 blink::WebEventListenerClass eventClass, | 830 blink::WebEventListenerClass eventClass, |
829 blink::WebEventListenerProperties properties) { | 831 blink::WebEventListenerProperties properties) { |
830 layer_tree_host_->GetLayerTree()->SetEventListenerProperties( | 832 layer_tree_host_->GetLayerTree()->SetEventListenerProperties( |
831 static_cast<cc::EventListenerClass>(eventClass), | 833 static_cast<cc::EventListenerClass>(eventClass), |
832 static_cast<cc::EventListenerProperties>(properties)); | 834 static_cast<cc::EventListenerProperties>(properties)); |
833 } | 835 } |
834 | 836 |
| 837 void RenderWidgetCompositor::updateTouchRectsForSubframeIfNecessary() { |
| 838 if (!is_for_oopif_) |
| 839 return; |
| 840 |
| 841 // If this is an oopif sub-frame compositor, we won't be getting TouchRects |
| 842 // from ScrollingCoordinator, so to make sure touch events are handled |
| 843 // properly, mark the entire root layer as a TouchRect. |
| 844 // TODO(wjmaclean): remove this when ScrollingCoordinator is made per-frame, |
| 845 // as opposed to per-page. |
| 846 using blink::WebEventListenerProperties; |
| 847 using blink::WebEventListenerClass; |
| 848 |
| 849 blink::WebEventListenerProperties touch_start_properties = |
| 850 eventListenerProperties(WebEventListenerClass::TouchStartOrMove); |
| 851 blink::WebEventListenerProperties touch_end_cancel_properties = |
| 852 eventListenerProperties(WebEventListenerClass::TouchEndOrCancel); |
| 853 bool has_touch_handlers = |
| 854 touch_start_properties == WebEventListenerProperties::Blocking || |
| 855 touch_start_properties == |
| 856 WebEventListenerProperties::BlockingAndPassive || |
| 857 touch_end_cancel_properties == WebEventListenerProperties::Blocking || |
| 858 touch_end_cancel_properties == |
| 859 WebEventListenerProperties::BlockingAndPassive; |
| 860 |
| 861 cc::Layer* root_layer = layer_tree_host_->GetLayerTree()->root_layer(); |
| 862 cc::Region touch_handler_region; |
| 863 if (has_touch_handlers) |
| 864 touch_handler_region = gfx::Rect(gfx::Point(), root_layer->bounds()); |
| 865 root_layer->SetTouchEventHandlerRegion(touch_handler_region); |
| 866 } |
| 867 |
835 blink::WebEventListenerProperties | 868 blink::WebEventListenerProperties |
836 RenderWidgetCompositor::eventListenerProperties( | 869 RenderWidgetCompositor::eventListenerProperties( |
837 blink::WebEventListenerClass event_class) const { | 870 blink::WebEventListenerClass event_class) const { |
838 return static_cast<blink::WebEventListenerProperties>( | 871 return static_cast<blink::WebEventListenerProperties>( |
839 layer_tree_host_->GetLayerTree()->event_listener_properties( | 872 layer_tree_host_->GetLayerTree()->event_listener_properties( |
840 static_cast<cc::EventListenerClass>(event_class))); | 873 static_cast<cc::EventListenerClass>(event_class))); |
841 } | 874 } |
842 | 875 |
843 void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { | 876 void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { |
844 layer_tree_host_->GetLayerTree()->SetHaveScrollEventHandlers(has_handlers); | 877 layer_tree_host_->GetLayerTree()->SetHaveScrollEventHandlers(has_handlers); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1129 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
1097 float device_scale) { | 1130 float device_scale) { |
1098 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1131 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
1099 } | 1132 } |
1100 | 1133 |
1101 void RenderWidgetCompositor::SetDeviceColorSpace( | 1134 void RenderWidgetCompositor::SetDeviceColorSpace( |
1102 const gfx::ColorSpace& color_space) { | 1135 const gfx::ColorSpace& color_space) { |
1103 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); | 1136 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); |
1104 } | 1137 } |
1105 | 1138 |
| 1139 void RenderWidgetCompositor::SetIsForOopif(bool is_for_oopif) { |
| 1140 is_for_oopif_ = is_for_oopif; |
| 1141 } |
| 1142 |
1106 } // namespace content | 1143 } // namespace content |
OLD | NEW |