Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: content/renderer/gpu/render_widget_compositor.cc

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, &params); 251 layer_tree_host_ = cc::LayerTreeHost::CreateRemoteServer(this, &params);
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, &params); 254 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
255 } else { 255 } else {
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 const gfx::Vector2dF& inner_delta, 1020 const gfx::Vector2dF& inner_delta,
1021 const gfx::Vector2dF& outer_delta, 1021 const gfx::Vector2dF& outer_delta,
1022 const gfx::Vector2dF& elastic_overscroll_delta, 1022 const gfx::Vector2dF& elastic_overscroll_delta,
1023 float page_scale, 1023 float page_scale,
1024 float top_controls_delta) { 1024 float top_controls_delta) {
1025 delegate_->ApplyViewportDeltas(inner_delta, outer_delta, 1025 delegate_->ApplyViewportDeltas(inner_delta, outer_delta,
1026 elastic_overscroll_delta, page_scale, 1026 elastic_overscroll_delta, page_scale,
1027 top_controls_delta); 1027 top_controls_delta);
1028 } 1028 }
1029 1029
1030 void RenderWidgetCompositor::RequestNewOutputSurface() { 1030 void RenderWidgetCompositor::RequestNewCompositorFrameSink() {
1031 // If the host is closing, then no more compositing is possible. This 1031 // If the host is closing, then no more compositing is possible. This
1032 // prevents shutdown races between handling the close message and 1032 // prevents shutdown races between handling the close message and
1033 // the CreateOutputSurface task. 1033 // the CreateCompositorFrameSink task.
1034 if (delegate_->IsClosing()) 1034 if (delegate_->IsClosing())
1035 return; 1035 return;
1036 1036
1037 bool fallback = 1037 bool fallback = num_failed_recreate_attempts_ >=
1038 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; 1038 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK;
1039 std::unique_ptr<cc::OutputSurface> surface( 1039 std::unique_ptr<cc::CompositorFrameSink> surface(
1040 delegate_->CreateOutputSurface(fallback)); 1040 delegate_->CreateCompositorFrameSink(fallback));
1041 1041
1042 if (!surface) { 1042 if (!surface) {
1043 DidFailToInitializeOutputSurface(); 1043 DidFailToInitializeCompositorFrameSink();
1044 return; 1044 return;
1045 } 1045 }
1046 1046
1047 DCHECK_EQ(surface->capabilities().max_frames_pending, 1); 1047 DCHECK_EQ(surface->capabilities().max_frames_pending, 1);
1048 1048
1049 layer_tree_host_->SetOutputSurface(std::move(surface)); 1049 layer_tree_host_->SetCompositorFrameSink(std::move(surface));
1050 } 1050 }
1051 1051
1052 void RenderWidgetCompositor::DidInitializeOutputSurface() { 1052 void RenderWidgetCompositor::DidInitializeCompositorFrameSink() {
1053 num_failed_recreate_attempts_ = 0; 1053 num_failed_recreate_attempts_ = 0;
1054 } 1054 }
1055 1055
1056 void RenderWidgetCompositor::DidFailToInitializeOutputSurface() { 1056 void RenderWidgetCompositor::DidFailToInitializeCompositorFrameSink() {
1057 ++num_failed_recreate_attempts_; 1057 ++num_failed_recreate_attempts_;
1058 // Tolerate a certain number of recreation failures to work around races 1058 // Tolerate a certain number of recreation failures to work around races
1059 // in the output-surface-lost machinery. 1059 // in the output-surface-lost machinery.
1060 LOG_IF(FATAL, (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)) 1060 LOG_IF(FATAL,
1061 << "Failed to create a fallback OutputSurface."; 1061 (num_failed_recreate_attempts_ >= MAX_COMPOSITOR_FRAME_SINK_RETRIES))
1062 << "Failed to create a fallback CompositorFrameSink.";
1062 1063
1063 base::ThreadTaskRunnerHandle::Get()->PostTask( 1064 base::ThreadTaskRunnerHandle::Get()->PostTask(
1064 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, 1065 FROM_HERE,
1065 weak_factory_.GetWeakPtr())); 1066 base::Bind(&RenderWidgetCompositor::RequestNewCompositorFrameSink,
1067 weak_factory_.GetWeakPtr()));
1066 } 1068 }
1067 1069
1068 void RenderWidgetCompositor::WillCommit() { 1070 void RenderWidgetCompositor::WillCommit() {
1069 InvokeLayoutAndPaintCallback(); 1071 InvokeLayoutAndPaintCallback();
1070 } 1072 }
1071 1073
1072 void RenderWidgetCompositor::DidCommit() { 1074 void RenderWidgetCompositor::DidCommit() {
1073 delegate_->DidCommitCompositorFrame(); 1075 delegate_->DidCommitCompositorFrame();
1074 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); 1076 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor();
1075 } 1077 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1133
1132 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); 1134 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized));
1133 } 1135 }
1134 1136
1135 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( 1137 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor(
1136 float device_scale) { 1138 float device_scale) {
1137 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); 1139 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale);
1138 } 1140 }
1139 1141
1140 } // namespace content 1142 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698