| 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> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| 20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "cc/animation/animation_host.h" | 24 #include "cc/animation/animation_host.h" |
| 25 #include "cc/animation/animation_timeline.h" | 25 #include "cc/animation/animation_timeline.h" |
| 26 #include "cc/animation/layer_tree_mutator.h" |
| 26 #include "cc/base/switches.h" | 27 #include "cc/base/switches.h" |
| 27 #include "cc/blink/web_compositor_animation_timeline_impl.h" | 28 #include "cc/blink/web_compositor_animation_timeline_impl.h" |
| 28 #include "cc/blink/web_layer_impl.h" | 29 #include "cc/blink/web_layer_impl.h" |
| 29 #include "cc/debug/layer_tree_debug_state.h" | 30 #include "cc/debug/layer_tree_debug_state.h" |
| 30 #include "cc/debug/micro_benchmark.h" | 31 #include "cc/debug/micro_benchmark.h" |
| 31 #include "cc/input/layer_selection_bound.h" | 32 #include "cc/input/layer_selection_bound.h" |
| 32 #include "cc/layers/layer.h" | 33 #include "cc/layers/layer.h" |
| 33 #include "cc/output/begin_frame_args.h" | 34 #include "cc/output/begin_frame_args.h" |
| 34 #include "cc/output/copy_output_request.h" | 35 #include "cc/output/copy_output_request.h" |
| 35 #include "cc/output/copy_output_result.h" | 36 #include "cc/output/copy_output_result.h" |
| 36 #include "cc/output/latency_info_swap_promise.h" | 37 #include "cc/output/latency_info_swap_promise.h" |
| 37 #include "cc/output/swap_promise.h" | 38 #include "cc/output/swap_promise.h" |
| 38 #include "cc/proto/compositor_message.pb.h" | 39 #include "cc/proto/compositor_message.pb.h" |
| 39 #include "cc/resources/single_release_callback.h" | 40 #include "cc/resources/single_release_callback.h" |
| 40 #include "cc/scheduler/begin_frame_source.h" | 41 #include "cc/scheduler/begin_frame_source.h" |
| 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_switches.h" | 48 #include "content/public/common/content_switches.h" |
| 48 #include "content/renderer/input/input_handler_manager.h" | 49 #include "content/renderer/input/input_handler_manager.h" |
| 49 #include "gpu/command_buffer/client/gles2_interface.h" | 50 #include "gpu/command_buffer/client/gles2_interface.h" |
| 50 #include "gpu/command_buffer/service/gpu_switches.h" | 51 #include "gpu/command_buffer/service/gpu_switches.h" |
| 52 #include "third_party/WebKit/public/platform/WebCompositorMutations.h" |
| 53 #include "third_party/WebKit/public/platform/WebCompositorMutatorClient.h" |
| 51 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" | 54 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" |
| 52 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" | 55 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" |
| 53 #include "third_party/WebKit/public/platform/WebSize.h" | 56 #include "third_party/WebKit/public/platform/WebSize.h" |
| 54 #include "third_party/WebKit/public/web/WebKit.h" | 57 #include "third_party/WebKit/public/web/WebKit.h" |
| 55 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 58 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 56 #include "third_party/WebKit/public/web/WebSelection.h" | 59 #include "third_party/WebKit/public/web/WebSelection.h" |
| 57 #include "third_party/WebKit/public/web/WebWidget.h" | 60 #include "third_party/WebKit/public/web/WebWidget.h" |
| 58 #include "ui/gl/gl_switches.h" | 61 #include "ui/gl/gl_switches.h" |
| 59 #include "ui/native_theme/native_theme_switches.h" | 62 #include "ui/native_theme/native_theme_switches.h" |
| 60 | 63 |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 } | 843 } |
| 841 | 844 |
| 842 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { | 845 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { |
| 843 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 846 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); |
| 844 debug_state.show_touch_event_handler_rects = show; | 847 debug_state.show_touch_event_handler_rects = show; |
| 845 debug_state.show_wheel_event_handler_rects = show; | 848 debug_state.show_wheel_event_handler_rects = show; |
| 846 debug_state.show_non_fast_scrollable_rects = show; | 849 debug_state.show_non_fast_scrollable_rects = show; |
| 847 layer_tree_host_->SetDebugState(debug_state); | 850 layer_tree_host_->SetDebugState(debug_state); |
| 848 } | 851 } |
| 849 | 852 |
| 853 void RenderWidgetCompositor::setMutatorClient( |
| 854 blink::WebCompositorMutatorClient* client) { |
| 855 TRACE_EVENT0("compositor-worker", "RenderWidgetCompositor::setMutatorClient"); |
| 856 layer_tree_host_->SetLayerTreeMutator(client); |
| 857 } |
| 858 |
| 850 void RenderWidgetCompositor::updateTopControlsState( | 859 void RenderWidgetCompositor::updateTopControlsState( |
| 851 WebTopControlsState constraints, | 860 WebTopControlsState constraints, |
| 852 WebTopControlsState current, | 861 WebTopControlsState current, |
| 853 bool animate) { | 862 bool animate) { |
| 854 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), | 863 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), |
| 855 ConvertTopControlsState(current), | 864 ConvertTopControlsState(current), |
| 856 animate); | 865 animate); |
| 857 } | 866 } |
| 858 | 867 |
| 859 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { | 868 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 float page_scale, | 913 float page_scale, |
| 905 float top_controls_delta) { | 914 float top_controls_delta) { |
| 906 widget_->webwidget()->applyViewportDeltas( | 915 widget_->webwidget()->applyViewportDeltas( |
| 907 inner_delta, | 916 inner_delta, |
| 908 outer_delta, | 917 outer_delta, |
| 909 elastic_overscroll_delta, | 918 elastic_overscroll_delta, |
| 910 page_scale, | 919 page_scale, |
| 911 top_controls_delta); | 920 top_controls_delta); |
| 912 } | 921 } |
| 913 | 922 |
| 923 void RenderWidgetCompositor::ApplyMutations( |
| 924 const cc::LayerTreeMutations& mutations) { |
| 925 TRACE_EVENT0("compositor-worker", |
| 926 "RenderWidgetCompositor::ApplyMutations"); |
| 927 widget_->webwidget()->applyMutations( |
| 928 static_cast<const blink::WebCompositorMutations&>(mutations)); |
| 929 } |
| 930 |
| 914 void RenderWidgetCompositor::RequestNewOutputSurface() { | 931 void RenderWidgetCompositor::RequestNewOutputSurface() { |
| 915 // If the host is closing, then no more compositing is possible. This | 932 // If the host is closing, then no more compositing is possible. This |
| 916 // prevents shutdown races between handling the close message and | 933 // prevents shutdown races between handling the close message and |
| 917 // the CreateOutputSurface task. | 934 // the CreateOutputSurface task. |
| 918 if (widget_->host_closing()) | 935 if (widget_->host_closing()) |
| 919 return; | 936 return; |
| 920 | 937 |
| 921 bool fallback = | 938 bool fallback = |
| 922 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; | 939 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; |
| 923 scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback)); | 940 scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 949 } | 966 } |
| 950 | 967 |
| 951 void RenderWidgetCompositor::WillCommit() { | 968 void RenderWidgetCompositor::WillCommit() { |
| 952 InvokeLayoutAndPaintCallback(); | 969 InvokeLayoutAndPaintCallback(); |
| 953 } | 970 } |
| 954 | 971 |
| 955 void RenderWidgetCompositor::DidCommit() { | 972 void RenderWidgetCompositor::DidCommit() { |
| 956 DCHECK(!temporary_copy_output_request_); | 973 DCHECK(!temporary_copy_output_request_); |
| 957 widget_->DidCommitCompositorFrame(); | 974 widget_->DidCommitCompositorFrame(); |
| 958 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); | 975 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); |
| 976 widget_->webwidget()->didCommit(); |
| 959 } | 977 } |
| 960 | 978 |
| 961 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 979 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
| 962 widget_->DidCommitAndDrawCompositorFrame(); | 980 widget_->DidCommitAndDrawCompositorFrame(); |
| 963 } | 981 } |
| 964 | 982 |
| 965 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 983 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
| 966 widget_->DidCompleteSwapBuffers(); | 984 widget_->DidCompleteSwapBuffers(); |
| 967 bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); | 985 bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); |
| 968 if (!threaded) | 986 if (!threaded) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 #endif | 1147 #endif |
| 1130 return actual; | 1148 return actual; |
| 1131 } | 1149 } |
| 1132 | 1150 |
| 1133 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1151 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
| 1134 float device_scale) { | 1152 float device_scale) { |
| 1135 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); | 1153 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); |
| 1136 } | 1154 } |
| 1137 | 1155 |
| 1138 } // namespace content | 1156 } // namespace content |
| OLD | NEW |