| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_impl.h" | 5 #include "cc/layers/layer_impl.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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 effect_tree_index_(-1), | 84 effect_tree_index_(-1), |
| 85 clip_tree_index_(-1), | 85 clip_tree_index_(-1), |
| 86 scroll_tree_index_(-1), | 86 scroll_tree_index_(-1), |
| 87 draw_depth_(0.f), | 87 draw_depth_(0.f), |
| 88 sorting_context_id_(0), | 88 sorting_context_id_(0), |
| 89 current_draw_mode_(DRAW_MODE_NONE), | 89 current_draw_mode_(DRAW_MODE_NONE), |
| 90 element_id_(0), | 90 element_id_(0), |
| 91 mutable_properties_(MutableProperty::kNone), | 91 mutable_properties_(MutableProperty::kNone), |
| 92 debug_info_(nullptr), | 92 debug_info_(nullptr), |
| 93 force_render_surface_(false), | 93 force_render_surface_(false), |
| 94 frame_timing_requests_dirty_(false), | |
| 95 scrolls_drawn_descendant_(false), | 94 scrolls_drawn_descendant_(false), |
| 96 layer_or_descendant_has_touch_handler_(false) { | 95 layer_or_descendant_has_touch_handler_(false) { |
| 97 DCHECK_GT(layer_id_, 0); | 96 DCHECK_GT(layer_id_, 0); |
| 98 | 97 |
| 99 DCHECK(layer_tree_impl_); | 98 DCHECK(layer_tree_impl_); |
| 100 layer_tree_impl_->RegisterLayer(this); | 99 layer_tree_impl_->RegisterLayer(this); |
| 101 layer_tree_impl_->AddToElementMap(this); | 100 layer_tree_impl_->AddToElementMap(this); |
| 102 | 101 |
| 103 SetNeedsPushProperties(); | 102 SetNeedsPushProperties(); |
| 104 } | 103 } |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // If the main thread commits multiple times before the impl thread actually | 587 // If the main thread commits multiple times before the impl thread actually |
| 589 // draws, then damage tracking will become incorrect if we simply clobber the | 588 // draws, then damage tracking will become incorrect if we simply clobber the |
| 590 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 589 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 591 // union) any update changes that have occurred on the main thread. | 590 // union) any update changes that have occurred on the main thread. |
| 592 update_rect_.Union(layer->update_rect()); | 591 update_rect_.Union(layer->update_rect()); |
| 593 layer->SetUpdateRect(update_rect_); | 592 layer->SetUpdateRect(update_rect_); |
| 594 | 593 |
| 595 if (owned_debug_info_) | 594 if (owned_debug_info_) |
| 596 layer->SetDebugInfo(std::move(owned_debug_info_)); | 595 layer->SetDebugInfo(std::move(owned_debug_info_)); |
| 597 | 596 |
| 598 if (frame_timing_requests_dirty_) { | |
| 599 layer->SetFrameTimingRequests(frame_timing_requests_); | |
| 600 frame_timing_requests_dirty_ = false; | |
| 601 } | |
| 602 | |
| 603 // Reset any state that should be cleared for the next update. | 597 // Reset any state that should be cleared for the next update. |
| 604 layer_property_changed_ = false; | 598 layer_property_changed_ = false; |
| 605 update_rect_ = gfx::Rect(); | 599 update_rect_ = gfx::Rect(); |
| 606 layer_tree_impl()->RemoveLayerShouldPushProperties(this); | 600 layer_tree_impl()->RemoveLayerShouldPushProperties(this); |
| 607 } | 601 } |
| 608 | 602 |
| 609 bool LayerImpl::IsAffectedByPageScale() const { | 603 bool LayerImpl::IsAffectedByPageScale() const { |
| 610 TransformTree& transform_tree = | 604 TransformTree& transform_tree = |
| 611 layer_tree_impl()->property_trees()->transform_tree; | 605 layer_tree_impl()->property_trees()->transform_tree; |
| 612 return transform_tree.Node(transform_tree_index()) | 606 return transform_tree.Node(transform_tree_index()) |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 | 1201 |
| 1208 should_flatten_transform_ = flatten; | 1202 should_flatten_transform_ = flatten; |
| 1209 } | 1203 } |
| 1210 | 1204 |
| 1211 void LayerImpl::Set3dSortingContextId(int id) { | 1205 void LayerImpl::Set3dSortingContextId(int id) { |
| 1212 if (id == sorting_context_id_) | 1206 if (id == sorting_context_id_) |
| 1213 return; | 1207 return; |
| 1214 sorting_context_id_ = id; | 1208 sorting_context_id_ = id; |
| 1215 } | 1209 } |
| 1216 | 1210 |
| 1217 void LayerImpl::SetFrameTimingRequests( | |
| 1218 const std::vector<FrameTimingRequest>& requests) { | |
| 1219 frame_timing_requests_ = requests; | |
| 1220 frame_timing_requests_dirty_ = true; | |
| 1221 SetNeedsPushProperties(); | |
| 1222 } | |
| 1223 | |
| 1224 void LayerImpl::GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids) { | |
| 1225 for (const auto& request : frame_timing_requests_) | |
| 1226 request_ids->push_back(request.id()); | |
| 1227 } | |
| 1228 | |
| 1229 void LayerImpl::SetTransform(const gfx::Transform& transform) { | 1211 void LayerImpl::SetTransform(const gfx::Transform& transform) { |
| 1230 if (transform_ == transform) | 1212 if (transform_ == transform) |
| 1231 return; | 1213 return; |
| 1232 | 1214 |
| 1233 transform_ = transform; | 1215 transform_ = transform; |
| 1234 transform_is_invertible_ = transform_.IsInvertible(); | 1216 transform_is_invertible_ = transform_.IsInvertible(); |
| 1235 } | 1217 } |
| 1236 | 1218 |
| 1237 void LayerImpl::SetTransformAndInvertibility(const gfx::Transform& transform, | 1219 void LayerImpl::SetTransformAndInvertibility(const gfx::Transform& transform, |
| 1238 bool transform_is_invertible) { | 1220 bool transform_is_invertible) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 debug_info_value->GetAsDictionary(&dictionary_value); | 1462 debug_info_value->GetAsDictionary(&dictionary_value); |
| 1481 DCHECK(converted_to_dictionary); | 1463 DCHECK(converted_to_dictionary); |
| 1482 for (base::DictionaryValue::Iterator it(*dictionary_value); !it.IsAtEnd(); | 1464 for (base::DictionaryValue::Iterator it(*dictionary_value); !it.IsAtEnd(); |
| 1483 it.Advance()) { | 1465 it.Advance()) { |
| 1484 state->SetValue(it.key().data(), it.value().CreateDeepCopy()); | 1466 state->SetValue(it.key().data(), it.value().CreateDeepCopy()); |
| 1485 } | 1467 } |
| 1486 } else { | 1468 } else { |
| 1487 NOTREACHED(); | 1469 NOTREACHED(); |
| 1488 } | 1470 } |
| 1489 } | 1471 } |
| 1490 | |
| 1491 if (!frame_timing_requests_.empty()) { | |
| 1492 state->BeginArray("frame_timing_requests"); | |
| 1493 for (const auto& request : frame_timing_requests_) { | |
| 1494 state->BeginDictionary(); | |
| 1495 state->SetInteger("request_id", request.id()); | |
| 1496 MathUtil::AddToTracedValue("request_rect", request.rect(), state); | |
| 1497 state->EndDictionary(); | |
| 1498 } | |
| 1499 state->EndArray(); | |
| 1500 } | |
| 1501 } | 1472 } |
| 1502 | 1473 |
| 1503 bool LayerImpl::IsDrawnRenderSurfaceLayerListMember() const { | 1474 bool LayerImpl::IsDrawnRenderSurfaceLayerListMember() const { |
| 1504 return draw_properties_.last_drawn_render_surface_layer_list_id == | 1475 return draw_properties_.last_drawn_render_surface_layer_list_id == |
| 1505 layer_tree_impl_->current_render_surface_list_id(); | 1476 layer_tree_impl_->current_render_surface_list_id(); |
| 1506 } | 1477 } |
| 1507 | 1478 |
| 1508 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1479 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
| 1509 | 1480 |
| 1510 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1481 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 .layer_transforms_should_scale_layer_contents) { | 1604 .layer_transforms_should_scale_layer_contents) { |
| 1634 return default_scale; | 1605 return default_scale; |
| 1635 } | 1606 } |
| 1636 | 1607 |
| 1637 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1608 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1638 DrawTransform(), default_scale); | 1609 DrawTransform(), default_scale); |
| 1639 return std::max(transform_scales.x(), transform_scales.y()); | 1610 return std::max(transform_scales.x(), transform_scales.y()); |
| 1640 } | 1611 } |
| 1641 | 1612 |
| 1642 } // namespace cc | 1613 } // namespace cc |
| OLD | NEW |