| 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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 void RenderWidgetCompositor::RequestNewCompositorFrameSink() { | 1035 void RenderWidgetCompositor::RequestNewCompositorFrameSink() { |
| 1036 // If the host is closing, then no more compositing is possible. This | 1036 // If the host is closing, then no more compositing is possible. This |
| 1037 // prevents shutdown races between handling the close message and | 1037 // prevents shutdown races between handling the close message and |
| 1038 // the CreateCompositorFrameSink task. | 1038 // the CreateCompositorFrameSink task. |
| 1039 if (delegate_->IsClosing()) | 1039 if (delegate_->IsClosing()) |
| 1040 return; | 1040 return; |
| 1041 | 1041 |
| 1042 bool fallback = num_failed_recreate_attempts_ >= | 1042 bool fallback = num_failed_recreate_attempts_ >= |
| 1043 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK; | 1043 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK; |
| 1044 std::unique_ptr<cc::CompositorFrameSink> surface( | 1044 std::unique_ptr<cc::CompositorFrameSink> surface( |
| 1045 delegate_->CreateCompositorFrameSink(fallback)); | 1045 delegate_->CreateCompositorFrameSink(frame_sink_id_, fallback)); |
| 1046 | 1046 |
| 1047 if (!surface) { | 1047 if (!surface) { |
| 1048 DidFailToInitializeCompositorFrameSink(); | 1048 DidFailToInitializeCompositorFrameSink(); |
| 1049 return; | 1049 return; |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 layer_tree_host_->SetCompositorFrameSink(std::move(surface)); | 1052 layer_tree_host_->SetCompositorFrameSink(std::move(surface)); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 void RenderWidgetCompositor::DidInitializeCompositorFrameSink() { | 1055 void RenderWidgetCompositor::DidInitializeCompositorFrameSink() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 const cc::proto::CompositorMessage& proto) { | 1110 const cc::proto::CompositorMessage& proto) { |
| 1111 int signed_size = proto.ByteSize(); | 1111 int signed_size = proto.ByteSize(); |
| 1112 size_t unsigned_size = base::checked_cast<size_t>(signed_size); | 1112 size_t unsigned_size = base::checked_cast<size_t>(signed_size); |
| 1113 std::vector<uint8_t> serialized(unsigned_size); | 1113 std::vector<uint8_t> serialized(unsigned_size); |
| 1114 proto.SerializeToArray(serialized.data(), signed_size); | 1114 proto.SerializeToArray(serialized.data(), signed_size); |
| 1115 delegate_->ForwardCompositorProto(serialized); | 1115 delegate_->ForwardCompositorProto(serialized); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 void RenderWidgetCompositor::SetFrameSinkId( | 1118 void RenderWidgetCompositor::SetFrameSinkId( |
| 1119 const cc::FrameSinkId& frame_sink_id) { | 1119 const cc::FrameSinkId& frame_sink_id) { |
| 1120 frame_sink_id_ = frame_sink_id; |
| 1120 layer_tree_host_->SetFrameSinkId(frame_sink_id); | 1121 layer_tree_host_->SetFrameSinkId(frame_sink_id); |
| 1121 } | 1122 } |
| 1122 | 1123 |
| 1123 void RenderWidgetCompositor::OnHandleCompositorProto( | 1124 void RenderWidgetCompositor::OnHandleCompositorProto( |
| 1124 const std::vector<uint8_t>& proto) { | 1125 const std::vector<uint8_t>& proto) { |
| 1125 DCHECK(remote_proto_channel_receiver_); | 1126 DCHECK(remote_proto_channel_receiver_); |
| 1126 | 1127 |
| 1127 std::unique_ptr<cc::proto::CompositorMessage> deserialized( | 1128 std::unique_ptr<cc::proto::CompositorMessage> deserialized( |
| 1128 new cc::proto::CompositorMessage); | 1129 new cc::proto::CompositorMessage); |
| 1129 int signed_size = base::checked_cast<int>(proto.size()); | 1130 int signed_size = base::checked_cast<int>(proto.size()); |
| 1130 if (!deserialized->ParseFromArray(proto.data(), signed_size)) { | 1131 if (!deserialized->ParseFromArray(proto.data(), signed_size)) { |
| 1131 LOG(ERROR) << "Unable to parse compositor proto."; | 1132 LOG(ERROR) << "Unable to parse compositor proto."; |
| 1132 return; | 1133 return; |
| 1133 } | 1134 } |
| 1134 | 1135 |
| 1135 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); | 1136 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); |
| 1136 } | 1137 } |
| 1137 | 1138 |
| 1138 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1139 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
| 1139 float device_scale) { | 1140 float device_scale) { |
| 1140 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1141 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
| 1141 } | 1142 } |
| 1142 | 1143 |
| 1143 void RenderWidgetCompositor::SetDeviceColorSpace( | 1144 void RenderWidgetCompositor::SetDeviceColorSpace( |
| 1144 const gfx::ColorSpace& color_space) { | 1145 const gfx::ColorSpace& color_space) { |
| 1145 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); | 1146 layer_tree_host_->GetLayerTree()->SetDeviceColorSpace(color_space); |
| 1146 } | 1147 } |
| 1147 | 1148 |
| 1148 } // namespace content | 1149 } // namespace content |
| OLD | NEW |