| 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 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 1155 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
| 1156 scoped_ptr<CopyOutputRequest> request, | 1156 scoped_ptr<CopyOutputRequest> request, |
| 1157 scoped_ptr<CopyOutputResult> result) { | 1157 scoped_ptr<CopyOutputResult> result) { |
| 1158 main_thread_task_runner->PostTask(FROM_HERE, | 1158 main_thread_task_runner->PostTask(FROM_HERE, |
| 1159 base::Bind(&RunCopyCallbackOnMainThread, | 1159 base::Bind(&RunCopyCallbackOnMainThread, |
| 1160 base::Passed(&request), | 1160 base::Passed(&request), |
| 1161 base::Passed(&result))); | 1161 base::Passed(&result))); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 void Layer::PushPropertiesTo(LayerImpl* layer) { | 1164 void Layer::PushPropertiesTo(LayerImpl* layer) { |
| 1165 TRACE_EVENT0("cc", "Layer::PushPropertiesTo"); |
| 1165 DCHECK(layer_tree_host_); | 1166 DCHECK(layer_tree_host_); |
| 1166 | 1167 |
| 1167 // If we did not SavePaintProperties() for the layer this frame, then push the | 1168 // If we did not SavePaintProperties() for the layer this frame, then push the |
| 1168 // real property values, not the paint property values. | 1169 // real property values, not the paint property values. |
| 1169 bool use_paint_properties = paint_properties_.source_frame_number == | 1170 bool use_paint_properties = paint_properties_.source_frame_number == |
| 1170 layer_tree_host_->source_frame_number(); | 1171 layer_tree_host_->source_frame_number(); |
| 1171 | 1172 |
| 1172 layer->SetTransformOrigin(transform_origin_); | 1173 layer->SetTransformOrigin(transform_origin_); |
| 1173 layer->SetBackgroundColor(background_color_); | 1174 layer->SetBackgroundColor(background_color_); |
| 1174 layer->SetBounds(use_paint_properties ? paint_properties_.bounds | 1175 layer->SetBounds(use_paint_properties ? paint_properties_.bounds |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 // When a scroll offset animation is interrupted the new scroll position on | 1278 // When a scroll offset animation is interrupted the new scroll position on |
| 1278 // the pending tree will clobber any impl-side scrolling occuring on the | 1279 // the pending tree will clobber any impl-side scrolling occuring on the |
| 1279 // active tree. To do so, avoid scrolling the pending tree along with it | 1280 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1280 // instead of trying to undo that scrolling later. | 1281 // instead of trying to undo that scrolling later. |
| 1281 if (ScrollOffsetAnimationWasInterrupted()) | 1282 if (ScrollOffsetAnimationWasInterrupted()) |
| 1282 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); | 1283 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); |
| 1283 else | 1284 else |
| 1284 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 1285 layer->PushScrollOffsetFromMainThread(scroll_offset_); |
| 1285 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 1286 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 1286 | 1287 |
| 1287 // Wrap the copy_requests_ in a PostTask to the main thread. | 1288 { |
| 1288 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; | 1289 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); |
| 1289 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | 1290 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 1290 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1291 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; |
| 1291 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1292 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { |
| 1292 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1293 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1293 const CopyOutputRequest& original_request_ref = *original_request; | 1294 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1294 scoped_ptr<CopyOutputRequest> main_thread_request = | 1295 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
| 1295 CopyOutputRequest::CreateRelayRequest( | 1296 const CopyOutputRequest& original_request_ref = *original_request; |
| 1296 original_request_ref, | 1297 scoped_ptr<CopyOutputRequest> main_thread_request = |
| 1297 base::Bind(&PostCopyCallbackToMainThread, | 1298 CopyOutputRequest::CreateRelayRequest( |
| 1298 main_thread_task_runner, | 1299 original_request_ref, |
| 1299 base::Passed(&original_request))); | 1300 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, |
| 1300 main_thread_copy_requests.push_back(std::move(main_thread_request)); | 1301 base::Passed(&original_request))); |
| 1302 main_thread_copy_requests.push_back(std::move(main_thread_request)); |
| 1303 } |
| 1304 if (!copy_requests_.empty() && layer_tree_host_) |
| 1305 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 1306 |
| 1307 copy_requests_.clear(); |
| 1308 layer->PassCopyRequests(&main_thread_copy_requests); |
| 1301 } | 1309 } |
| 1302 if (!copy_requests_.empty() && layer_tree_host_) | |
| 1303 layer_tree_host_->property_trees()->needs_rebuild = true; | |
| 1304 | |
| 1305 copy_requests_.clear(); | |
| 1306 layer->PassCopyRequests(&main_thread_copy_requests); | |
| 1307 | 1310 |
| 1308 // If the main thread commits multiple times before the impl thread actually | 1311 // If the main thread commits multiple times before the impl thread actually |
| 1309 // draws, then damage tracking will become incorrect if we simply clobber the | 1312 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1310 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1313 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1311 // union) any update changes that have occurred on the main thread. | 1314 // union) any update changes that have occurred on the main thread. |
| 1312 update_rect_.Union(layer->update_rect()); | 1315 update_rect_.Union(layer->update_rect()); |
| 1313 layer->SetUpdateRect(update_rect_); | 1316 layer->SetUpdateRect(update_rect_); |
| 1314 | 1317 |
| 1315 layer->SetStackingOrderChanged(stacking_order_changed_); | 1318 layer->SetStackingOrderChanged(stacking_order_changed_); |
| 1316 | 1319 |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 this, layer_tree_host_->property_trees()->transform_tree); | 2019 this, layer_tree_host_->property_trees()->transform_tree); |
| 2017 } | 2020 } |
| 2018 | 2021 |
| 2019 gfx::Transform Layer::screen_space_transform() const { | 2022 gfx::Transform Layer::screen_space_transform() const { |
| 2020 DCHECK_NE(transform_tree_index_, -1); | 2023 DCHECK_NE(transform_tree_index_, -1); |
| 2021 return ScreenSpaceTransformFromPropertyTrees( | 2024 return ScreenSpaceTransformFromPropertyTrees( |
| 2022 this, layer_tree_host_->property_trees()->transform_tree); | 2025 this, layer_tree_host_->property_trees()->transform_tree); |
| 2023 } | 2026 } |
| 2024 | 2027 |
| 2025 } // namespace cc | 2028 } // namespace cc |
| OLD | NEW |