| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 | 1200 |
| 1201 // When a scroll offset animation is interrupted the new scroll position on | 1201 // When a scroll offset animation is interrupted the new scroll position on |
| 1202 // the pending tree will clobber any impl-side scrolling occuring on the | 1202 // the pending tree will clobber any impl-side scrolling occuring on the |
| 1203 // active tree. To do so, avoid scrolling the pending tree along with it | 1203 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1204 // instead of trying to undo that scrolling later. | 1204 // instead of trying to undo that scrolling later. |
| 1205 if (ScrollOffsetAnimationWasInterrupted()) | 1205 if (ScrollOffsetAnimationWasInterrupted()) |
| 1206 layer_tree_host() | 1206 layer_tree_host() |
| 1207 ->property_trees() | 1207 ->property_trees() |
| 1208 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); | 1208 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); |
| 1209 | 1209 |
| 1210 { | |
| 1211 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); | |
| 1212 // Wrap the copy_requests_ in a PostTask to the main thread. | |
| 1213 std::vector<std::unique_ptr<CopyOutputRequest>> main_thread_copy_requests; | |
| 1214 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | |
| 1215 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | |
| 1216 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | |
| 1217 std::unique_ptr<CopyOutputRequest> original_request = std::move(*it); | |
| 1218 const CopyOutputRequest& original_request_ref = *original_request; | |
| 1219 std::unique_ptr<CopyOutputRequest> main_thread_request = | |
| 1220 CopyOutputRequest::CreateRelayRequest( | |
| 1221 original_request_ref, | |
| 1222 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, | |
| 1223 base::Passed(&original_request))); | |
| 1224 main_thread_copy_requests.push_back(std::move(main_thread_request)); | |
| 1225 } | |
| 1226 if (!copy_requests_.empty() && layer_tree_host_) | |
| 1227 layer_tree_host_->property_trees()->needs_rebuild = true; | |
| 1228 | |
| 1229 copy_requests_.clear(); | |
| 1230 layer->PassCopyRequests(&main_thread_copy_requests); | |
| 1231 } | |
| 1232 | |
| 1233 // If the main thread commits multiple times before the impl thread actually | 1210 // If the main thread commits multiple times before the impl thread actually |
| 1234 // draws, then damage tracking will become incorrect if we simply clobber the | 1211 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1235 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1212 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1236 // union) any update changes that have occurred on the main thread. | 1213 // union) any update changes that have occurred on the main thread. |
| 1237 update_rect_.Union(layer->update_rect()); | 1214 update_rect_.Union(layer->update_rect()); |
| 1238 layer->SetUpdateRect(update_rect_); | 1215 layer->SetUpdateRect(update_rect_); |
| 1239 | 1216 |
| 1240 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); | 1217 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1241 | 1218 |
| 1242 // Reset any state that should be cleared for the next update. | 1219 // Reset any state that should be cleared for the next update. |
| 1243 subtree_property_changed_ = false; | 1220 subtree_property_changed_ = false; |
| 1244 update_rect_ = gfx::Rect(); | 1221 update_rect_ = gfx::Rect(); |
| 1245 | 1222 |
| 1246 layer_tree_host()->RemoveLayerShouldPushProperties(this); | 1223 layer_tree_host()->RemoveLayerShouldPushProperties(this); |
| 1247 } | 1224 } |
| 1248 | 1225 |
| 1226 void Layer::TakeCopyRequests( |
| 1227 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { |
| 1228 for (auto& it : copy_requests_) { |
| 1229 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1230 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1231 std::unique_ptr<CopyOutputRequest> original_request = std::move(it); |
| 1232 const CopyOutputRequest& original_request_ref = *original_request; |
| 1233 std::unique_ptr<CopyOutputRequest> main_thread_request = |
| 1234 CopyOutputRequest::CreateRelayRequest( |
| 1235 original_request_ref, |
| 1236 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, |
| 1237 base::Passed(&original_request))); |
| 1238 if (main_thread_request->has_area()) { |
| 1239 main_thread_request->set_area(gfx::IntersectRects( |
| 1240 main_thread_request->area(), gfx::Rect(bounds()))); |
| 1241 } |
| 1242 requests->push_back(std::move(main_thread_request)); |
| 1243 } |
| 1244 |
| 1245 copy_requests_.clear(); |
| 1246 } |
| 1247 |
| 1249 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 1248 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
| 1250 proto->set_type(proto::LayerNode::LAYER); | 1249 proto->set_type(proto::LayerNode::LAYER); |
| 1251 } | 1250 } |
| 1252 | 1251 |
| 1253 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const { | 1252 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const { |
| 1254 proto->set_id(layer_id_); | 1253 proto->set_id(layer_id_); |
| 1255 SetTypeForProtoSerialization(proto); | 1254 SetTypeForProtoSerialization(proto); |
| 1256 | 1255 |
| 1257 if (parent_) | 1256 if (parent_) |
| 1258 proto->set_parent_id(parent_->id()); | 1257 proto->set_parent_id(parent_->id()); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 ->data.num_copy_requests_in_subtree; | 1829 ->data.num_copy_requests_in_subtree; |
| 1831 } | 1830 } |
| 1832 | 1831 |
| 1833 gfx::Transform Layer::screen_space_transform() const { | 1832 gfx::Transform Layer::screen_space_transform() const { |
| 1834 DCHECK_NE(transform_tree_index_, -1); | 1833 DCHECK_NE(transform_tree_index_, -1); |
| 1835 return draw_property_utils::ScreenSpaceTransform( | 1834 return draw_property_utils::ScreenSpaceTransform( |
| 1836 this, layer_tree_host_->property_trees()->transform_tree); | 1835 this, layer_tree_host_->property_trees()->transform_tree); |
| 1837 } | 1836 } |
| 1838 | 1837 |
| 1839 } // namespace cc | 1838 } // namespace cc |
| OLD | NEW |