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

Side by Side Diff: cc/resources/managed_tile_state.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/resources/managed_tile_state.h ('k') | cc/resources/picture.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/managed_tile_state.h" 5 #include "cc/resources/managed_tile_state.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string>
8 9
10 #include "base/debug/trace_event_argument.h"
9 #include "cc/base/math_util.h" 11 #include "cc/base/math_util.h"
10 12
11 namespace cc { 13 namespace cc {
12 14
13 scoped_ptr<base::Value> ManagedTileBinAsValue(ManagedTileBin bin) { 15 std::string ManagedTileBinToString(ManagedTileBin bin) {
14 switch (bin) { 16 switch (bin) {
15 case NOW_AND_READY_TO_DRAW_BIN: 17 case NOW_AND_READY_TO_DRAW_BIN:
16 return scoped_ptr<base::Value>( 18 return "NOW_AND_READY_TO_DRAW_BIN";
17 new base::StringValue("NOW_AND_READY_TO_DRAW_BIN"));
18 case NOW_BIN: 19 case NOW_BIN:
19 return scoped_ptr<base::Value>(new base::StringValue("NOW_BIN")); 20 return "NOW_BIN";
20 case SOON_BIN: 21 case SOON_BIN:
21 return scoped_ptr<base::Value>( 22 return "SOON_BIN";
22 new base::StringValue("SOON_BIN"));
23 case EVENTUALLY_AND_ACTIVE_BIN: 23 case EVENTUALLY_AND_ACTIVE_BIN:
24 return scoped_ptr<base::Value>( 24 return "EVENTUALLY_AND_ACTIVE_BIN";
25 new base::StringValue("EVENTUALLY_AND_ACTIVE_BIN"));
26 case EVENTUALLY_BIN: 25 case EVENTUALLY_BIN:
27 return scoped_ptr<base::Value>( 26 return "EVENTUALLY_BIN";
28 new base::StringValue("EVENTUALLY_BIN"));
29 case AT_LAST_AND_ACTIVE_BIN: 27 case AT_LAST_AND_ACTIVE_BIN:
30 return scoped_ptr<base::Value>( 28 return "AT_LAST_AND_ACTIVE_BIN";
31 new base::StringValue("AT_LAST_AND_ACTIVE_BIN"));
32 case AT_LAST_BIN: 29 case AT_LAST_BIN:
33 return scoped_ptr<base::Value>( 30 return "AT_LAST_BIN";
34 new base::StringValue("AT_LAST_BIN"));
35 case NEVER_BIN: 31 case NEVER_BIN:
36 return scoped_ptr<base::Value>( 32 return "NEVER_BIN";
37 new base::StringValue("NEVER_BIN"));
38 case NUM_BINS: 33 case NUM_BINS:
39 NOTREACHED(); 34 NOTREACHED();
40 return scoped_ptr<base::Value>( 35 return "Invalid Bin (NUM_BINS)";
41 new base::StringValue("Invalid Bin (NUM_BINS)"));
42 } 36 }
43 return scoped_ptr<base::Value>( 37 return "Invalid Bin (UNKNOWN)";
44 new base::StringValue("Invalid Bin (UNKNOWN)"));
45 } 38 }
46 39
47 ManagedTileState::ManagedTileState() 40 ManagedTileState::ManagedTileState()
48 : raster_mode(LOW_QUALITY_RASTER_MODE), 41 : raster_mode(LOW_QUALITY_RASTER_MODE),
49 bin(NEVER_BIN), 42 bin(NEVER_BIN),
50 resolution(NON_IDEAL_RESOLUTION), 43 resolution(NON_IDEAL_RESOLUTION),
51 required_for_activation(false), 44 required_for_activation(false),
52 priority_bin(TilePriority::EVENTUALLY), 45 priority_bin(TilePriority::EVENTUALLY),
53 distance_to_visible(std::numeric_limits<float>::infinity()), 46 distance_to_visible(std::numeric_limits<float>::infinity()),
54 visible_and_ready_to_draw(false), 47 visible_and_ready_to_draw(false),
(...skipping 18 matching lines...) Expand all
73 } 66 }
74 67
75 size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const { 68 size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const {
76 if (!resource_) 69 if (!resource_)
77 return 0; 70 return 0;
78 return resource_->bytes(); 71 return resource_->bytes();
79 } 72 }
80 73
81 ManagedTileState::~ManagedTileState() {} 74 ManagedTileState::~ManagedTileState() {}
82 75
83 scoped_ptr<base::Value> ManagedTileState::AsValue() const { 76 void ManagedTileState::AsValueInto(base::debug::TracedValue* state) const {
84 bool has_resource = false; 77 bool has_resource = false;
85 bool has_active_task = false; 78 bool has_active_task = false;
86 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { 79 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) {
87 has_resource |= (tile_versions[mode].resource_.get() != 0); 80 has_resource |= (tile_versions[mode].resource_.get() != 0);
88 has_active_task |= (tile_versions[mode].raster_task_.get() != 0); 81 has_active_task |= (tile_versions[mode].raster_task_.get() != 0);
89 } 82 }
90 83
91 bool is_using_gpu_memory = has_resource || has_active_task; 84 bool is_using_gpu_memory = has_resource || has_active_task;
92 85
93 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
94 state->SetBoolean("has_resource", has_resource); 86 state->SetBoolean("has_resource", has_resource);
95 state->SetBoolean("is_using_gpu_memory", is_using_gpu_memory); 87 state->SetBoolean("is_using_gpu_memory", is_using_gpu_memory);
96 state->Set("bin", ManagedTileBinAsValue(bin).release()); 88 state->SetString("bin", ManagedTileBinToString(bin));
97 state->Set("resolution", TileResolutionAsValue(resolution).release()); 89 state->SetString("resolution", TileResolutionToString(resolution));
98 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); 90 state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
99 state->Set("distance_to_visible", 91 state->SetDouble("distance_to_visible",
100 MathUtil::AsValueSafely(distance_to_visible).release()); 92 MathUtil::AsFloatSafely(distance_to_visible));
101 state->SetBoolean("required_for_activation", required_for_activation); 93 state->SetBoolean("required_for_activation", required_for_activation);
102 state->SetBoolean( 94 state->SetBoolean(
103 "is_solid_color", 95 "is_solid_color",
104 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE); 96 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE);
105 state->SetBoolean( 97 state->SetBoolean(
106 "is_transparent", 98 "is_transparent",
107 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE && 99 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE &&
108 !SkColorGetA(tile_versions[raster_mode].solid_color_)); 100 !SkColorGetA(tile_versions[raster_mode].solid_color_));
109 state->SetInteger("scheduled_priority", scheduled_priority); 101 state->SetInteger("scheduled_priority", scheduled_priority);
110 return state.PassAs<base::Value>();
111 } 102 }
112 103
113 } // namespace cc 104 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/managed_tile_state.h ('k') | cc/resources/picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698