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

Side by Side Diff: cc/resources/tile.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/tile.h ('k') | cc/resources/tile_manager.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/resources/tile.h" 5 #include "cc/resources/tile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event_argument.h"
9 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
10 #include "cc/debug/traced_value.h" 11 #include "cc/debug/traced_value.h"
11 #include "cc/resources/tile_manager.h" 12 #include "cc/resources/tile_manager.h"
12 #include "third_party/khronos/GLES2/gl2.h" 13 #include "third_party/khronos/GLES2/gl2.h"
13 14
14 namespace cc { 15 namespace cc {
15 16
16 Tile::Id Tile::s_next_id_ = 0; 17 Tile::Id Tile::s_next_id_ = 0;
17 18
18 Tile::Tile(TileManager* tile_manager, 19 Tile::Tile(TileManager* tile_manager,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 55 }
55 56
56 void Tile::MarkRequiredForActivation() { 57 void Tile::MarkRequiredForActivation() {
57 if (priority_[PENDING_TREE].required_for_activation) 58 if (priority_[PENDING_TREE].required_for_activation)
58 return; 59 return;
59 60
60 priority_[PENDING_TREE].required_for_activation = true; 61 priority_[PENDING_TREE].required_for_activation = true;
61 tile_manager_->DidChangeTilePriority(this); 62 tile_manager_->DidChangeTilePriority(this);
62 } 63 }
63 64
64 scoped_ptr<base::Value> Tile::AsValue() const { 65 void Tile::AsValueInto(base::debug::TracedValue* res) const {
65 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
66 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( 66 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
67 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); 67 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res, "cc::Tile", this);
68 res->Set("picture_pile", 68 TracedValue::SetIDRef(picture_pile_.get(), res, "picture_pile");
69 TracedValue::CreateIDRef(picture_pile_.get()).release());
70 res->SetDouble("contents_scale", contents_scale_); 69 res->SetDouble("contents_scale", contents_scale_);
71 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); 70
71 res->BeginArray("content_rect");
72 MathUtil::AddToTracedValue(content_rect_, res);
73 res->EndArray();
74
72 res->SetInteger("layer_id", layer_id_); 75 res->SetInteger("layer_id", layer_id_);
73 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); 76
74 res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); 77 res->BeginDictionary("active_priority");
75 res->Set("managed_state", managed_state_.AsValue().release()); 78 priority_[ACTIVE_TREE].AsValueInto(res);
79 res->EndDictionary();
80
81 res->BeginDictionary("pending_priority");
82 priority_[PENDING_TREE].AsValueInto(res);
83 res->EndDictionary();
84
85 res->BeginDictionary("managed_state");
86 managed_state_.AsValueInto(res);
87 res->EndDictionary();
88
76 res->SetBoolean("use_picture_analysis", use_picture_analysis()); 89 res->SetBoolean("use_picture_analysis", use_picture_analysis());
77 return res.PassAs<base::Value>();
78 } 90 }
79 91
80 size_t Tile::GPUMemoryUsageInBytes() const { 92 size_t Tile::GPUMemoryUsageInBytes() const {
81 size_t total_size = 0; 93 size_t total_size = 0;
82 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) 94 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode)
83 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); 95 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes();
84 return total_size; 96 return total_size;
85 } 97 }
86 98
87 RasterMode Tile::DetermineRasterModeForTree(WhichTree tree) const { 99 RasterMode Tile::DetermineRasterModeForTree(WhichTree tree) const {
88 return DetermineRasterModeForResolution(priority(tree).resolution); 100 return DetermineRasterModeForResolution(priority(tree).resolution);
89 } 101 }
90 102
91 RasterMode Tile::DetermineOverallRasterMode() const { 103 RasterMode Tile::DetermineOverallRasterMode() const {
92 return DetermineRasterModeForResolution(managed_state_.resolution); 104 return DetermineRasterModeForResolution(managed_state_.resolution);
93 } 105 }
94 106
95 RasterMode Tile::DetermineRasterModeForResolution( 107 RasterMode Tile::DetermineRasterModeForResolution(
96 TileResolution resolution) const { 108 TileResolution resolution) const {
97 RasterMode current_mode = managed_state_.raster_mode; 109 RasterMode current_mode = managed_state_.raster_mode;
98 RasterMode raster_mode = resolution == LOW_RESOLUTION 110 RasterMode raster_mode = resolution == LOW_RESOLUTION
99 ? LOW_QUALITY_RASTER_MODE 111 ? LOW_QUALITY_RASTER_MODE
100 : HIGH_QUALITY_RASTER_MODE; 112 : HIGH_QUALITY_RASTER_MODE;
101 return std::min(raster_mode, current_mode); 113 return std::min(raster_mode, current_mode);
102 } 114 }
103 115
104 } // namespace cc 116 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile.h ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698