Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak found by Linux ASAN Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/trace_event_argument.h"
8 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
10 #include "cc/animation/animation_registrar.h" 11 #include "cc/animation/animation_registrar.h"
11 #include "cc/animation/scrollbar_animation_controller.h" 12 #include "cc/animation/scrollbar_animation_controller.h"
12 #include "cc/base/math_util.h" 13 #include "cc/base/math_util.h"
13 #include "cc/debug/debug_colors.h" 14 #include "cc/debug/debug_colors.h"
14 #include "cc/debug/layer_tree_debug_state.h" 15 #include "cc/debug/layer_tree_debug_state.h"
15 #include "cc/debug/micro_benchmark_impl.h" 16 #include "cc/debug/micro_benchmark_impl.h"
16 #include "cc/debug/traced_value.h" 17 #include "cc/debug/traced_value.h"
17 #include "cc/input/layer_scroll_offset_delegate.h" 18 #include "cc/input/layer_scroll_offset_delegate.h"
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 } 1384 }
1384 1385
1385 void LayerImpl::RemoveDependentNeedsPushProperties() { 1386 void LayerImpl::RemoveDependentNeedsPushProperties() {
1386 num_dependents_need_push_properties_--; 1387 num_dependents_need_push_properties_--;
1387 DCHECK_GE(num_dependents_need_push_properties_, 0); 1388 DCHECK_GE(num_dependents_need_push_properties_, 0);
1388 1389
1389 if (!parent_should_know_need_push_properties() && parent_) 1390 if (!parent_should_know_need_push_properties() && parent_)
1390 parent_->RemoveDependentNeedsPushProperties(); 1391 parent_->RemoveDependentNeedsPushProperties();
1391 } 1392 }
1392 1393
1393 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { 1394 void LayerImpl::AsValueInto(base::debug::TracedValue* state) const {
1394 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( 1395 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
1395 TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1396 TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1396 state, 1397 state,
1397 "cc::LayerImpl", 1398 "cc::LayerImpl",
1398 LayerTypeAsString(), 1399 LayerTypeAsString(),
1399 this); 1400 this);
1400 state->SetInteger("layer_id", id()); 1401 state->SetInteger("layer_id", id());
1401 state->Set("bounds", MathUtil::AsValue(bounds_).release()); 1402 state->BeginDictionary("bounds");
1402 state->Set("position", MathUtil::AsValue(position_).release()); 1403 MathUtil::AddToTracedValue(bounds_, state);
1404 state->EndDictionary();
1405
1406 state->BeginArray("position");
1407 MathUtil::AddToTracedValue(position_, state);
1408 state->EndArray();
1409
1403 state->SetInteger("draws_content", DrawsContent()); 1410 state->SetInteger("draws_content", DrawsContent());
1404 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); 1411 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
1405 state->Set("scroll_offset", MathUtil::AsValue(scroll_offset_).release()); 1412
1406 state->Set("transform_origin", 1413 state->BeginArray("scroll_offset");
1407 MathUtil::AsValue(transform_origin_).release()); 1414 MathUtil::AddToTracedValue(scroll_offset_, state);
1415 state->EndArray();
1416
1417 state->BeginArray("transform_origin");
1418 MathUtil::AddToTracedValue(transform_origin_, state);
1419 state->EndArray();
1408 1420
1409 bool clipped; 1421 bool clipped;
1410 gfx::QuadF layer_quad = MathUtil::MapQuad( 1422 gfx::QuadF layer_quad = MathUtil::MapQuad(
1411 screen_space_transform(), 1423 screen_space_transform(),
1412 gfx::QuadF(gfx::Rect(content_bounds())), 1424 gfx::QuadF(gfx::Rect(content_bounds())),
1413 &clipped); 1425 &clipped);
1414 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); 1426 state->BeginArray("layer_quad");
1415 1427 MathUtil::AddToTracedValue(layer_quad, state);
1428 state->EndArray();
1416 if (!touch_event_handler_region_.IsEmpty()) { 1429 if (!touch_event_handler_region_.IsEmpty()) {
1417 state->Set("touch_event_handler_region", 1430 state->BeginArray("touch_event_handler_region");
1418 touch_event_handler_region_.AsValue().release()); 1431 touch_event_handler_region_.AsValueInto(state);
1432 state->EndArray();
1419 } 1433 }
1420 if (have_wheel_event_handlers_) { 1434 if (have_wheel_event_handlers_) {
1421 gfx::Rect wheel_rect(content_bounds()); 1435 gfx::Rect wheel_rect(content_bounds());
1422 Region wheel_region(wheel_rect); 1436 Region wheel_region(wheel_rect);
1423 state->Set("wheel_event_handler_region", 1437 state->BeginArray("wheel_event_handler_region");
1424 wheel_region.AsValue().release()); 1438 wheel_region.AsValueInto(state);
1439 state->EndArray();
1425 } 1440 }
1426 if (have_scroll_event_handlers_) { 1441 if (have_scroll_event_handlers_) {
1427 gfx::Rect scroll_rect(content_bounds()); 1442 gfx::Rect scroll_rect(content_bounds());
1428 Region scroll_region(scroll_rect); 1443 Region scroll_region(scroll_rect);
1429 state->Set("scroll_event_handler_region", 1444 state->BeginArray("scroll_event_handler_region");
1430 scroll_region.AsValue().release()); 1445 scroll_region.AsValueInto(state);
1446 state->EndArray();
1431 } 1447 }
1432 if (!non_fast_scrollable_region_.IsEmpty()) { 1448 if (!non_fast_scrollable_region_.IsEmpty()) {
1433 state->Set("non_fast_scrollable_region", 1449 state->BeginArray("non_fast_scrollable_region");
1434 non_fast_scrollable_region_.AsValue().release()); 1450 non_fast_scrollable_region_.AsValueInto(state);
1451 state->EndArray();
1435 } 1452 }
1436 1453
1437 scoped_ptr<base::ListValue> children_list(new base::ListValue()); 1454 state->BeginArray("children");
1438 for (size_t i = 0; i < children_.size(); ++i) 1455 for (size_t i = 0; i < children_.size(); ++i) {
1439 children_list->Append(children_[i]->AsValue().release()); 1456 state->BeginDictionary();
1440 state->Set("children", children_list.release()); 1457 children_[i]->AsValueInto(state);
1441 if (mask_layer_) 1458 state->EndDictionary();
1442 state->Set("mask_layer", mask_layer_->AsValue().release()); 1459 }
1443 if (replica_layer_) 1460 state->EndArray();
1444 state->Set("replica_layer", replica_layer_->AsValue().release()); 1461 if (mask_layer_) {
1462 state->BeginDictionary("mask_layer");
1463 mask_layer_->AsValueInto(state);
1464 state->EndDictionary();
1465 }
1466 if (replica_layer_) {
1467 state->BeginDictionary("replica_layer");
1468 replica_layer_->AsValueInto(state);
1469 state->EndDictionary();
1470 }
1445 1471
1446 if (scroll_parent_) 1472 if (scroll_parent_)
1447 state->SetInteger("scroll_parent", scroll_parent_->id()); 1473 state->SetInteger("scroll_parent", scroll_parent_->id());
1448 1474
1449 if (clip_parent_) 1475 if (clip_parent_)
1450 state->SetInteger("clip_parent", clip_parent_->id()); 1476 state->SetInteger("clip_parent", clip_parent_->id());
1451 1477
1452 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); 1478 state->SetBoolean("can_use_lcd_text", can_use_lcd_text());
1453 state->SetBoolean("contents_opaque", contents_opaque()); 1479 state->SetBoolean("contents_opaque", contents_opaque());
1454 1480
1455 state->SetBoolean( 1481 state->SetBoolean(
1456 "has_animation_bounds", 1482 "has_animation_bounds",
1457 layer_animation_controller()->HasAnimationThatInflatesBounds()); 1483 layer_animation_controller()->HasAnimationThatInflatesBounds());
1458 1484
1459 gfx::BoxF box; 1485 gfx::BoxF box;
1460 if (LayerUtils::GetAnimationBounds(*this, &box)) 1486 if (LayerUtils::GetAnimationBounds(*this, &box)) {
1461 state->Set("animation_bounds", MathUtil::AsValue(box).release()); 1487 state->BeginArray("animation_bounds");
1488 MathUtil::AddToTracedValue(box, state);
1489 state->EndArray();
1490 }
1462 1491
1463 if (debug_info_.get()) { 1492 if (debug_info_.get()) {
1464 std::string str; 1493 std::string str;
1465 debug_info_->AppendAsTraceFormat(&str); 1494 debug_info_->AppendAsTraceFormat(&str);
1466 base::JSONReader json_reader; 1495 base::JSONReader json_reader;
1467 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); 1496 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
1468 1497
1469 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) { 1498 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
1470 base::DictionaryValue* dictionary_value = NULL; 1499 base::DictionaryValue* dictionary_value = NULL;
1471 bool converted_to_dictionary = 1500 bool converted_to_dictionary =
1472 debug_info_value->GetAsDictionary(&dictionary_value); 1501 debug_info_value->GetAsDictionary(&dictionary_value);
1473 DCHECK(converted_to_dictionary); 1502 DCHECK(converted_to_dictionary);
1474 state->MergeDictionary(dictionary_value); 1503 for (base::DictionaryValue::Iterator it(*dictionary_value); !it.IsAtEnd();
1504 it.Advance()) {
1505 state->SetValue(it.key().data(), it.value().DeepCopy());
1506 }
1475 } else { 1507 } else {
1476 NOTREACHED(); 1508 NOTREACHED();
1477 } 1509 }
1478 } 1510 }
1479 } 1511 }
1480 1512
1481 bool LayerImpl::IsDrawnRenderSurfaceLayerListMember() const { 1513 bool LayerImpl::IsDrawnRenderSurfaceLayerListMember() const {
1482 return draw_properties_.last_drawn_render_surface_layer_list_id == 1514 return draw_properties_.last_drawn_render_surface_layer_list_id ==
1483 layer_tree_impl_->current_render_surface_list_id(); 1515 layer_tree_impl_->current_render_surface_list_id();
1484 } 1516 }
1485 1517
1486 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1518 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1487 1519
1488 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1489 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1490 AsValueInto(state.get());
1491 return state.PassAs<base::Value>();
1492 }
1493
1494 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1520 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1495 benchmark->RunOnLayer(this); 1521 benchmark->RunOnLayer(this);
1496 } 1522 }
1497 1523
1498 void LayerImpl::NotifyAnimationFinished( 1524 void LayerImpl::NotifyAnimationFinished(
1499 base::TimeTicks monotonic_time, 1525 base::TimeTicks monotonic_time,
1500 Animation::TargetProperty target_property) { 1526 Animation::TargetProperty target_property) {
1501 if (target_property == Animation::ScrollOffset) 1527 if (target_property == Animation::ScrollOffset)
1502 layer_tree_impl_->InputScrollAnimationFinished(); 1528 layer_tree_impl_->InputScrollAnimationFinished();
1503 } 1529 }
1504 1530
1505 } // namespace cc 1531 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698