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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 cc::LayerTreeHost::InitParams params; | 235 cc::LayerTreeHost::InitParams params; |
236 params.client = this; | 236 params.client = this; |
237 params.shared_bitmap_manager = compositor_deps_->GetSharedBitmapManager(); | 237 params.shared_bitmap_manager = compositor_deps_->GetSharedBitmapManager(); |
238 params.gpu_memory_buffer_manager = | 238 params.gpu_memory_buffer_manager = |
239 compositor_deps_->GetGpuMemoryBufferManager(); | 239 compositor_deps_->GetGpuMemoryBufferManager(); |
240 params.settings = &settings; | 240 params.settings = &settings; |
241 params.task_graph_runner = compositor_deps_->GetTaskGraphRunner(); | 241 params.task_graph_runner = compositor_deps_->GetTaskGraphRunner(); |
242 params.main_task_runner = | 242 params.main_task_runner = |
243 compositor_deps_->GetCompositorMainThreadTaskRunner(); | 243 compositor_deps_->GetCompositorMainThreadTaskRunner(); |
244 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 244 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
245 DCHECK(settings.use_output_surface_begin_frame_source); | 245 DCHECK(settings.use_compositor_frame_sink_begin_frame_source); |
246 | 246 |
247 if (cmd->HasSwitch(switches::kUseRemoteCompositing)) { | 247 if (cmd->HasSwitch(switches::kUseRemoteCompositing)) { |
248 DCHECK(!threaded_); | 248 DCHECK(!threaded_); |
249 params.image_serialization_processor = | 249 params.image_serialization_processor = |
250 compositor_deps_->GetImageSerializationProcessor(); | 250 compositor_deps_->GetImageSerializationProcessor(); |
251 layer_tree_host_ = cc::LayerTreeHost::CreateRemoteServer(this, ¶ms); | 251 layer_tree_host_ = cc::LayerTreeHost::CreateRemoteServer(this, ¶ms); |
252 } else if (!threaded_) { | 252 } else if (!threaded_) { |
253 // Single-threaded layout tests. | 253 // Single-threaded layout tests. |
254 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 254 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
255 } else { | 255 } else { |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 const gfx::Vector2dF& inner_delta, | 1019 const gfx::Vector2dF& inner_delta, |
1020 const gfx::Vector2dF& outer_delta, | 1020 const gfx::Vector2dF& outer_delta, |
1021 const gfx::Vector2dF& elastic_overscroll_delta, | 1021 const gfx::Vector2dF& elastic_overscroll_delta, |
1022 float page_scale, | 1022 float page_scale, |
1023 float top_controls_delta) { | 1023 float top_controls_delta) { |
1024 delegate_->ApplyViewportDeltas(inner_delta, outer_delta, | 1024 delegate_->ApplyViewportDeltas(inner_delta, outer_delta, |
1025 elastic_overscroll_delta, page_scale, | 1025 elastic_overscroll_delta, page_scale, |
1026 top_controls_delta); | 1026 top_controls_delta); |
1027 } | 1027 } |
1028 | 1028 |
1029 void RenderWidgetCompositor::RequestNewOutputSurface() { | 1029 void RenderWidgetCompositor::RequestNewCompositorFrameSink() { |
1030 // If the host is closing, then no more compositing is possible. This | 1030 // If the host is closing, then no more compositing is possible. This |
1031 // prevents shutdown races between handling the close message and | 1031 // prevents shutdown races between handling the close message and |
1032 // the CreateOutputSurface task. | 1032 // the CreateCompositorFrameSink task. |
1033 if (delegate_->IsClosing()) | 1033 if (delegate_->IsClosing()) |
1034 return; | 1034 return; |
1035 | 1035 |
1036 bool fallback = | 1036 bool fallback = num_failed_recreate_attempts_ >= |
1037 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; | 1037 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK; |
1038 std::unique_ptr<cc::OutputSurface> surface( | 1038 std::unique_ptr<cc::CompositorFrameSink> surface( |
1039 delegate_->CreateOutputSurface(fallback)); | 1039 delegate_->CreateCompositorFrameSink(fallback)); |
1040 | 1040 |
1041 if (!surface) { | 1041 if (!surface) { |
1042 DidFailToInitializeOutputSurface(); | 1042 DidFailToInitializeCompositorFrameSink(); |
1043 return; | 1043 return; |
1044 } | 1044 } |
1045 | 1045 |
1046 DCHECK_EQ(surface->capabilities().max_frames_pending, 1); | 1046 DCHECK_EQ(surface->capabilities().max_frames_pending, 1); |
1047 | 1047 |
1048 layer_tree_host_->SetOutputSurface(std::move(surface)); | 1048 layer_tree_host_->SetCompositorFrameSink(std::move(surface)); |
1049 } | 1049 } |
1050 | 1050 |
1051 void RenderWidgetCompositor::DidInitializeOutputSurface() { | 1051 void RenderWidgetCompositor::DidInitializeCompositorFrameSink() { |
1052 num_failed_recreate_attempts_ = 0; | 1052 num_failed_recreate_attempts_ = 0; |
1053 } | 1053 } |
1054 | 1054 |
1055 void RenderWidgetCompositor::DidFailToInitializeOutputSurface() { | 1055 void RenderWidgetCompositor::DidFailToInitializeCompositorFrameSink() { |
1056 ++num_failed_recreate_attempts_; | 1056 ++num_failed_recreate_attempts_; |
1057 // Tolerate a certain number of recreation failures to work around races | 1057 // Tolerate a certain number of recreation failures to work around races |
1058 // in the output-surface-lost machinery. | 1058 // in the output-surface-lost machinery. |
1059 LOG_IF(FATAL, (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)) | 1059 LOG_IF(FATAL, |
1060 << "Failed to create a fallback OutputSurface."; | 1060 (num_failed_recreate_attempts_ >= MAX_COMPOSITOR_FRAME_SINK_RETRIES)) |
| 1061 << "Failed to create a fallback CompositorFrameSink."; |
1061 | 1062 |
1062 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1063 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1063 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, | 1064 FROM_HERE, |
1064 weak_factory_.GetWeakPtr())); | 1065 base::Bind(&RenderWidgetCompositor::RequestNewCompositorFrameSink, |
| 1066 weak_factory_.GetWeakPtr())); |
1065 } | 1067 } |
1066 | 1068 |
1067 void RenderWidgetCompositor::WillCommit() { | 1069 void RenderWidgetCompositor::WillCommit() { |
1068 InvokeLayoutAndPaintCallback(); | 1070 InvokeLayoutAndPaintCallback(); |
1069 } | 1071 } |
1070 | 1072 |
1071 void RenderWidgetCompositor::DidCommit() { | 1073 void RenderWidgetCompositor::DidCommit() { |
1072 delegate_->DidCommitCompositorFrame(); | 1074 delegate_->DidCommitCompositorFrame(); |
1073 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); | 1075 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); |
1074 } | 1076 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 float device_scale) { | 1137 float device_scale) { |
1136 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1138 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
1137 } | 1139 } |
1138 | 1140 |
1139 void RenderWidgetCompositor::SetDeviceColorSpace( | 1141 void RenderWidgetCompositor::SetDeviceColorSpace( |
1140 const gfx::ColorSpace& color_space) { | 1142 const gfx::ColorSpace& color_space) { |
1141 // TODO(ccameron): Plumb this to the cc compositor. | 1143 // TODO(ccameron): Plumb this to the cc compositor. |
1142 } | 1144 } |
1143 | 1145 |
1144 } // namespace content | 1146 } // namespace content |
OLD | NEW |