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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/json/json_reader.h" |
8 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
9 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
10 #include "cc/animation/scrollbar_animation_controller.h" | 11 #include "cc/animation/scrollbar_animation_controller.h" |
11 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 12 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
12 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 13 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
13 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
14 #include "cc/debug/debug_colors.h" | 15 #include "cc/debug/debug_colors.h" |
15 #include "cc/debug/layer_tree_debug_state.h" | 16 #include "cc/debug/layer_tree_debug_state.h" |
16 #include "cc/debug/micro_benchmark_impl.h" | 17 #include "cc/debug/micro_benchmark_impl.h" |
17 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 149 |
149 // Having both a scroll parent and a scroll offset delegate is unsupported. | 150 // Having both a scroll parent and a scroll offset delegate is unsupported. |
150 DCHECK(!scroll_offset_delegate_); | 151 DCHECK(!scroll_offset_delegate_); |
151 | 152 |
152 if (scroll_parent_) | 153 if (scroll_parent_) |
153 scroll_parent_->RemoveScrollChild(this); | 154 scroll_parent_->RemoveScrollChild(this); |
154 | 155 |
155 scroll_parent_ = parent; | 156 scroll_parent_ = parent; |
156 } | 157 } |
157 | 158 |
| 159 void LayerImpl::SetDebugInfo( |
| 160 scoped_refptr<base::debug::ConvertableToTraceFormat> other) { |
| 161 debug_info_ = other; |
| 162 } |
| 163 |
158 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { | 164 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { |
159 if (scroll_children_.get() == children) | 165 if (scroll_children_.get() == children) |
160 return; | 166 return; |
161 scroll_children_.reset(children); | 167 scroll_children_.reset(children); |
162 } | 168 } |
163 | 169 |
164 void LayerImpl::RemoveScrollChild(LayerImpl* child) { | 170 void LayerImpl::RemoveScrollChild(LayerImpl* child) { |
165 DCHECK(scroll_children_); | 171 DCHECK(scroll_children_); |
166 scroll_children_->erase(child); | 172 scroll_children_->erase(child); |
167 if (scroll_children_->empty()) | 173 if (scroll_children_->empty()) |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // 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. |
584 // union) any update changes that have occurred on the main thread. | 590 // union) any update changes that have occurred on the main thread. |
585 update_rect_.Union(layer->update_rect()); | 591 update_rect_.Union(layer->update_rect()); |
586 layer->set_update_rect(update_rect_); | 592 layer->set_update_rect(update_rect_); |
587 | 593 |
588 layer->SetStackingOrderChanged(stacking_order_changed_); | 594 layer->SetStackingOrderChanged(stacking_order_changed_); |
589 | 595 |
590 // Reset any state that should be cleared for the next update. | 596 // Reset any state that should be cleared for the next update. |
591 stacking_order_changed_ = false; | 597 stacking_order_changed_ = false; |
592 update_rect_ = gfx::RectF(); | 598 update_rect_ = gfx::RectF(); |
| 599 |
| 600 layer->SetDebugInfo(debug_info_); |
593 } | 601 } |
594 | 602 |
595 base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { | 603 base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { |
596 base::DictionaryValue* result = new base::DictionaryValue; | 604 base::DictionaryValue* result = new base::DictionaryValue; |
597 result->SetString("LayerType", LayerTypeAsString()); | 605 result->SetString("LayerType", LayerTypeAsString()); |
598 | 606 |
599 base::ListValue* list = new base::ListValue; | 607 base::ListValue* list = new base::ListValue; |
600 list->AppendInteger(bounds().width()); | 608 list->AppendInteger(bounds().width()); |
601 list->AppendInteger(bounds().height()); | 609 list->AppendInteger(bounds().height()); |
602 result->Set("Bounds", list); | 610 result->Set("Bounds", list); |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); | 1365 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); |
1358 state->SetBoolean("contents_opaque", contents_opaque()); | 1366 state->SetBoolean("contents_opaque", contents_opaque()); |
1359 | 1367 |
1360 if (layer_animation_controller_->IsAnimatingProperty(Animation::Transform) || | 1368 if (layer_animation_controller_->IsAnimatingProperty(Animation::Transform) || |
1361 layer_animation_controller_->IsAnimatingProperty(Animation::Filter)) { | 1369 layer_animation_controller_->IsAnimatingProperty(Animation::Filter)) { |
1362 gfx::BoxF box(bounds().width(), bounds().height(), 0.f); | 1370 gfx::BoxF box(bounds().width(), bounds().height(), 0.f); |
1363 gfx::BoxF inflated; | 1371 gfx::BoxF inflated; |
1364 if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated)) | 1372 if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated)) |
1365 state->Set("animated_bounds", MathUtil::AsValue(inflated).release()); | 1373 state->Set("animated_bounds", MathUtil::AsValue(inflated).release()); |
1366 } | 1374 } |
| 1375 |
| 1376 if (debug_info_.get()) { |
| 1377 std::string str; |
| 1378 debug_info_->AppendAsTraceFormat(&str); |
| 1379 base::JSONReader json_reader; |
| 1380 // Parsing the JSON and re-encoding it is not very efficient, |
| 1381 // but it's the simplest way to achieve the desired effect, which |
| 1382 // is to output: |
| 1383 // {..., layout_rects: [{geometry_rect: ...}, ...], ...} |
| 1384 // rather than: |
| 1385 // {layout_rects: "[{geometry_rect: ...}, ...]", ...} |
| 1386 state->Set("layout_rects", json_reader.ReadToValue(str)); |
| 1387 } |
1367 } | 1388 } |
1368 | 1389 |
1369 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1390 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
1370 | 1391 |
1371 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1392 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1372 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1393 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1373 AsValueInto(state.get()); | 1394 AsValueInto(state.get()); |
1374 return state.PassAs<base::Value>(); | 1395 return state.PassAs<base::Value>(); |
1375 } | 1396 } |
1376 | 1397 |
1377 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1398 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1378 benchmark->RunOnLayer(this); | 1399 benchmark->RunOnLayer(this); |
1379 } | 1400 } |
1380 | 1401 |
1381 } // namespace cc | 1402 } // namespace cc |
OLD | NEW |