Chromium Code Reviews| 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 <utility> | 10 #include <utility> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 effect_tree_index_(-1), | 87 effect_tree_index_(-1), |
| 88 clip_tree_index_(-1), | 88 clip_tree_index_(-1), |
| 89 scroll_tree_index_(-1), | 89 scroll_tree_index_(-1), |
| 90 draw_depth_(0.f), | 90 draw_depth_(0.f), |
| 91 needs_push_properties_(false), | 91 needs_push_properties_(false), |
| 92 num_dependents_need_push_properties_(0), | 92 num_dependents_need_push_properties_(0), |
| 93 sorting_context_id_(0), | 93 sorting_context_id_(0), |
| 94 current_draw_mode_(DRAW_MODE_NONE), | 94 current_draw_mode_(DRAW_MODE_NONE), |
| 95 element_id_(0), | 95 element_id_(0), |
| 96 mutable_properties_(MutableProperty::kNone), | 96 mutable_properties_(MutableProperty::kNone), |
| 97 debug_info_(nullptr), | |
| 97 force_render_surface_(false), | 98 force_render_surface_(false), |
| 98 frame_timing_requests_dirty_(false), | 99 frame_timing_requests_dirty_(false), |
| 99 visited_(false), | 100 visited_(false), |
| 100 layer_or_descendant_is_drawn_(false), | 101 layer_or_descendant_is_drawn_(false), |
| 101 layer_or_descendant_has_touch_handler_(false), | 102 layer_or_descendant_has_touch_handler_(false), |
| 102 sorted_for_recursion_(false) { | 103 sorted_for_recursion_(false) { |
| 103 DCHECK_GT(layer_id_, 0); | 104 DCHECK_GT(layer_id_, 0); |
| 104 DCHECK(layer_tree_impl_); | 105 DCHECK(layer_tree_impl_); |
| 105 layer_tree_impl_->RegisterLayer(this); | 106 layer_tree_impl_->RegisterLayer(this); |
| 106 | 107 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 return; | 197 return; |
| 197 | 198 |
| 198 if (parent) | 199 if (parent) |
| 199 DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent); | 200 DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent); |
| 200 | 201 |
| 201 scroll_parent_ = parent; | 202 scroll_parent_ = parent; |
| 202 SetNeedsPushProperties(); | 203 SetNeedsPushProperties(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 void LayerImpl::SetDebugInfo( | 206 void LayerImpl::SetDebugInfo( |
| 206 scoped_refptr<base::trace_event::ConvertableToTraceFormat> other) { | 207 scoped_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { |
| 207 debug_info_ = other; | 208 owned_debug_info_ = std::move(debug_info); |
| 209 debug_info_ = owned_debug_info_.get(); | |
| 208 SetNeedsPushProperties(); | 210 SetNeedsPushProperties(); |
| 209 } | 211 } |
| 210 | 212 |
| 211 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { | 213 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { |
| 212 if (scroll_children_.get() == children) | 214 if (scroll_children_.get() == children) |
| 213 return; | 215 return; |
| 214 scroll_children_.reset(children); | 216 scroll_children_.reset(children); |
| 215 SetNeedsPushProperties(); | 217 SetNeedsPushProperties(); |
| 216 } | 218 } |
| 217 | 219 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 | 604 |
| 603 layer->PassCopyRequests(©_requests_); | 605 layer->PassCopyRequests(©_requests_); |
| 604 | 606 |
| 605 // If the main thread commits multiple times before the impl thread actually | 607 // If the main thread commits multiple times before the impl thread actually |
| 606 // draws, then damage tracking will become incorrect if we simply clobber the | 608 // draws, then damage tracking will become incorrect if we simply clobber the |
| 607 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 609 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 608 // union) any update changes that have occurred on the main thread. | 610 // union) any update changes that have occurred on the main thread. |
| 609 update_rect_.Union(layer->update_rect()); | 611 update_rect_.Union(layer->update_rect()); |
| 610 layer->SetUpdateRect(update_rect_); | 612 layer->SetUpdateRect(update_rect_); |
| 611 | 613 |
| 612 layer->SetDebugInfo(debug_info_); | 614 if (owned_debug_info_) |
|
danakj
2016/02/29 18:19:18
For my own understand, was it failing without this
Primiano Tucci (use gerrit)
2016/02/29 18:32:38
Yes precisely. It was not crashing but failing the
danakj
2016/02/29 19:19:07
There's only A & B. But I guess it means that we S
| |
| 615 layer->SetDebugInfo(std::move(owned_debug_info_)); | |
| 613 | 616 |
| 614 if (frame_timing_requests_dirty_) { | 617 if (frame_timing_requests_dirty_) { |
| 615 layer->SetFrameTimingRequests(frame_timing_requests_); | 618 layer->SetFrameTimingRequests(frame_timing_requests_); |
| 616 frame_timing_requests_dirty_ = false; | 619 frame_timing_requests_dirty_ = false; |
| 617 } | 620 } |
| 618 | 621 |
| 619 // Reset any state that should be cleared for the next update. | 622 // Reset any state that should be cleared for the next update. |
| 620 layer_property_changed_ = false; | 623 layer_property_changed_ = false; |
| 621 update_rect_ = gfx::Rect(); | 624 update_rect_ = gfx::Rect(); |
| 622 needs_push_properties_ = false; | 625 needs_push_properties_ = false; |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1637 state->SetBoolean( | 1640 state->SetBoolean( |
| 1638 "has_animation_bounds", | 1641 "has_animation_bounds", |
| 1639 layer_animation_controller_ | 1642 layer_animation_controller_ |
| 1640 ? layer_animation_controller_->HasAnimationThatInflatesBounds() | 1643 ? layer_animation_controller_->HasAnimationThatInflatesBounds() |
| 1641 : layer_tree_impl_->HasAnimationThatInflatesBounds(this)); | 1644 : layer_tree_impl_->HasAnimationThatInflatesBounds(this)); |
| 1642 | 1645 |
| 1643 gfx::BoxF box; | 1646 gfx::BoxF box; |
| 1644 if (LayerUtils::GetAnimationBounds(*this, &box)) | 1647 if (LayerUtils::GetAnimationBounds(*this, &box)) |
| 1645 MathUtil::AddToTracedValue("animation_bounds", box, state); | 1648 MathUtil::AddToTracedValue("animation_bounds", box, state); |
| 1646 | 1649 |
| 1647 if (debug_info_.get()) { | 1650 if (debug_info_) { |
| 1648 std::string str; | 1651 std::string str; |
| 1649 debug_info_->AppendAsTraceFormat(&str); | 1652 debug_info_->AppendAsTraceFormat(&str); |
| 1650 base::JSONReader json_reader; | 1653 base::JSONReader json_reader; |
| 1651 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); | 1654 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); |
| 1652 | 1655 |
| 1653 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) { | 1656 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) { |
| 1654 base::DictionaryValue* dictionary_value = nullptr; | 1657 base::DictionaryValue* dictionary_value = nullptr; |
| 1655 bool converted_to_dictionary = | 1658 bool converted_to_dictionary = |
| 1656 debug_info_value->GetAsDictionary(&dictionary_value); | 1659 debug_info_value->GetAsDictionary(&dictionary_value); |
| 1657 DCHECK(converted_to_dictionary); | 1660 DCHECK(converted_to_dictionary); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1778 .layer_transforms_should_scale_layer_contents) { | 1781 .layer_transforms_should_scale_layer_contents) { |
| 1779 return default_scale; | 1782 return default_scale; |
| 1780 } | 1783 } |
| 1781 | 1784 |
| 1782 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1785 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1783 DrawTransform(), default_scale); | 1786 DrawTransform(), default_scale); |
| 1784 return std::max(transform_scales.x(), transform_scales.y()); | 1787 return std::max(transform_scales.x(), transform_scales.y()); |
| 1785 } | 1788 } |
| 1786 | 1789 |
| 1787 } // namespace cc | 1790 } // namespace cc |
| OLD | NEW |