| 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" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
| 18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "cc/animation/animation_host.h" | 21 #include "cc/animation/animation_host.h" |
| 22 #include "cc/animation/animation_timeline.h" | 22 #include "cc/animation/animation_timeline.h" |
| 23 #include "cc/animation/layer_tree_mutator.h" |
| 23 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
| 25 #include "cc/blink/mutation_conversions.h" |
| 24 #include "cc/blink/web_compositor_animation_timeline_impl.h" | 26 #include "cc/blink/web_compositor_animation_timeline_impl.h" |
| 25 #include "cc/blink/web_layer_impl.h" | 27 #include "cc/blink/web_layer_impl.h" |
| 28 #include "cc/blink/web_mutator_client_impl.h" |
| 26 #include "cc/debug/layer_tree_debug_state.h" | 29 #include "cc/debug/layer_tree_debug_state.h" |
| 27 #include "cc/debug/micro_benchmark.h" | 30 #include "cc/debug/micro_benchmark.h" |
| 28 #include "cc/input/layer_selection_bound.h" | 31 #include "cc/input/layer_selection_bound.h" |
| 29 #include "cc/layers/layer.h" | 32 #include "cc/layers/layer.h" |
| 30 #include "cc/output/begin_frame_args.h" | 33 #include "cc/output/begin_frame_args.h" |
| 31 #include "cc/output/copy_output_request.h" | 34 #include "cc/output/copy_output_request.h" |
| 32 #include "cc/output/copy_output_result.h" | 35 #include "cc/output/copy_output_result.h" |
| 33 #include "cc/output/latency_info_swap_promise.h" | 36 #include "cc/output/latency_info_swap_promise.h" |
| 34 #include "cc/output/swap_promise.h" | 37 #include "cc/output/swap_promise.h" |
| 35 #include "cc/proto/compositor_message.pb.h" | 38 #include "cc/proto/compositor_message.pb.h" |
| 36 #include "cc/resources/single_release_callback.h" | 39 #include "cc/resources/single_release_callback.h" |
| 37 #include "cc/scheduler/begin_frame_source.h" | 40 #include "cc/scheduler/begin_frame_source.h" |
| 38 #include "cc/trees/latency_info_swap_promise_monitor.h" | 41 #include "cc/trees/latency_info_swap_promise_monitor.h" |
| 39 #include "cc/trees/layer_tree_host.h" | 42 #include "cc/trees/layer_tree_host.h" |
| 40 #include "cc/trees/remote_proto_channel.h" | 43 #include "cc/trees/remote_proto_channel.h" |
| 41 #include "components/scheduler/renderer/renderer_scheduler.h" | 44 #include "components/scheduler/renderer/renderer_scheduler.h" |
| 42 #include "content/common/content_switches_internal.h" | 45 #include "content/common/content_switches_internal.h" |
| 43 #include "content/common/gpu/client/context_provider_command_buffer.h" | 46 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 44 #include "content/public/common/content_switches.h" | 47 #include "content/public/common/content_switches.h" |
| 45 #include "content/renderer/input/input_handler_manager.h" | 48 #include "content/renderer/input/input_handler_manager.h" |
| 46 #include "gpu/command_buffer/client/gles2_interface.h" | 49 #include "gpu/command_buffer/client/gles2_interface.h" |
| 47 #include "gpu/command_buffer/service/gpu_switches.h" | 50 #include "gpu/command_buffer/service/gpu_switches.h" |
| 48 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" | 51 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" |
| 49 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" | 52 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" |
| 53 #include "third_party/WebKit/public/platform/WebMutatorClient.h" |
| 50 #include "third_party/WebKit/public/platform/WebSize.h" | 54 #include "third_party/WebKit/public/platform/WebSize.h" |
| 51 #include "third_party/WebKit/public/web/WebKit.h" | 55 #include "third_party/WebKit/public/web/WebKit.h" |
| 52 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 56 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 53 #include "third_party/WebKit/public/web/WebSelection.h" | 57 #include "third_party/WebKit/public/web/WebSelection.h" |
| 54 #include "third_party/WebKit/public/web/WebWidget.h" | 58 #include "third_party/WebKit/public/web/WebWidget.h" |
| 55 #include "ui/gl/gl_switches.h" | 59 #include "ui/gl/gl_switches.h" |
| 56 #include "ui/native_theme/native_theme_switches.h" | 60 #include "ui/native_theme/native_theme_switches.h" |
| 57 | 61 |
| 58 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 59 #include "base/android/build_info.h" | 63 #include "base/android/build_info.h" |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 } | 829 } |
| 826 | 830 |
| 827 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { | 831 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { |
| 828 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 832 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); |
| 829 debug_state.show_touch_event_handler_rects = show; | 833 debug_state.show_touch_event_handler_rects = show; |
| 830 debug_state.show_wheel_event_handler_rects = show; | 834 debug_state.show_wheel_event_handler_rects = show; |
| 831 debug_state.show_non_fast_scrollable_rects = show; | 835 debug_state.show_non_fast_scrollable_rects = show; |
| 832 layer_tree_host_->SetDebugState(debug_state); | 836 layer_tree_host_->SetDebugState(debug_state); |
| 833 } | 837 } |
| 834 | 838 |
| 839 void RenderWidgetCompositor::setMutatorClient(blink::WebMutatorClient* client) { |
| 840 TRACE_EVENT0("compositor-worker", "RenderWidgetCompositor::setMutatorClient"); |
| 841 layer_tree_host_->SetLayerTreeMutator( |
| 842 static_cast<cc_blink::WebMutatorClientImpl*>(client)); |
| 843 } |
| 844 |
| 835 void RenderWidgetCompositor::updateTopControlsState( | 845 void RenderWidgetCompositor::updateTopControlsState( |
| 836 WebTopControlsState constraints, | 846 WebTopControlsState constraints, |
| 837 WebTopControlsState current, | 847 WebTopControlsState current, |
| 838 bool animate) { | 848 bool animate) { |
| 839 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), | 849 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), |
| 840 ConvertTopControlsState(current), | 850 ConvertTopControlsState(current), |
| 841 animate); | 851 animate); |
| 842 } | 852 } |
| 843 | 853 |
| 844 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { | 854 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 float page_scale, | 898 float page_scale, |
| 889 float top_controls_delta) { | 899 float top_controls_delta) { |
| 890 widget_->webwidget()->applyViewportDeltas( | 900 widget_->webwidget()->applyViewportDeltas( |
| 891 inner_delta, | 901 inner_delta, |
| 892 outer_delta, | 902 outer_delta, |
| 893 elastic_overscroll_delta, | 903 elastic_overscroll_delta, |
| 894 page_scale, | 904 page_scale, |
| 895 top_controls_delta); | 905 top_controls_delta); |
| 896 } | 906 } |
| 897 | 907 |
| 908 void RenderWidgetCompositor::ApplyMutations( |
| 909 const cc::LayerTreeMutationMap& mutations) { |
| 910 TRACE_EVENT0("compositor-worker", |
| 911 "RenderWidgetCompositor::ApplyMutations"); |
| 912 blink::WebMutationMap blink_mutations; |
| 913 cc_blink::convertToBlinkMutations(mutations, &blink_mutations); |
| 914 widget_->webwidget()->applyMutations(blink_mutations); |
| 915 } |
| 916 |
| 898 void RenderWidgetCompositor::RequestNewOutputSurface() { | 917 void RenderWidgetCompositor::RequestNewOutputSurface() { |
| 899 // If the host is closing, then no more compositing is possible. This | 918 // If the host is closing, then no more compositing is possible. This |
| 900 // prevents shutdown races between handling the close message and | 919 // prevents shutdown races between handling the close message and |
| 901 // the CreateOutputSurface task. | 920 // the CreateOutputSurface task. |
| 902 if (widget_->host_closing()) | 921 if (widget_->host_closing()) |
| 903 return; | 922 return; |
| 904 | 923 |
| 905 bool fallback = | 924 bool fallback = |
| 906 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; | 925 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; |
| 907 scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback)); | 926 scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 933 } | 952 } |
| 934 | 953 |
| 935 void RenderWidgetCompositor::WillCommit() { | 954 void RenderWidgetCompositor::WillCommit() { |
| 936 InvokeLayoutAndPaintCallback(); | 955 InvokeLayoutAndPaintCallback(); |
| 937 } | 956 } |
| 938 | 957 |
| 939 void RenderWidgetCompositor::DidCommit() { | 958 void RenderWidgetCompositor::DidCommit() { |
| 940 DCHECK(!temporary_copy_output_request_); | 959 DCHECK(!temporary_copy_output_request_); |
| 941 widget_->DidCommitCompositorFrame(); | 960 widget_->DidCommitCompositorFrame(); |
| 942 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); | 961 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); |
| 962 widget_->webwidget()->didCommit(); |
| 943 } | 963 } |
| 944 | 964 |
| 945 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 965 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
| 946 widget_->DidCommitAndDrawCompositorFrame(); | 966 widget_->DidCommitAndDrawCompositorFrame(); |
| 947 } | 967 } |
| 948 | 968 |
| 949 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 969 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
| 950 widget_->DidCompleteSwapBuffers(); | 970 widget_->DidCompleteSwapBuffers(); |
| 951 bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); | 971 bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); |
| 952 if (!threaded) | 972 if (!threaded) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 #endif | 1133 #endif |
| 1114 return actual; | 1134 return actual; |
| 1115 } | 1135 } |
| 1116 | 1136 |
| 1117 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1137 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
| 1118 float device_scale) { | 1138 float device_scale) { |
| 1119 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); | 1139 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); |
| 1120 } | 1140 } |
| 1121 | 1141 |
| 1122 } // namespace content | 1142 } // namespace content |
| OLD | NEW |