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

Side by Side Diff: cc/resources/picture_pile_base.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/picture_pile_base.h ('k') | cc/resources/pixel_buffer_raster_worker_pool.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 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/picture_pile_base.h" 5 #include "cc/resources/picture_pile_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/debug/trace_event_argument.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
14 #include "cc/debug/traced_value.h" 15 #include "cc/debug/traced_value.h"
15 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/gfx/rect_conversions.h" 17 #include "ui/gfx/rect_conversions.h"
17 18
18 namespace { 19 namespace {
19 // Dimensions of the tiles in this picture pile as well as the dimensions of 20 // Dimensions of the tiles in this picture pile as well as the dimensions of
20 // the base picture in each tile. 21 // the base picture in each tile.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return PadRect(tile); 192 return PadRect(tile);
192 } 193 }
193 194
194 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { 195 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) {
195 gfx::Rect padded_rect = rect; 196 gfx::Rect padded_rect = rect;
196 padded_rect.Inset( 197 padded_rect.Inset(
197 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); 198 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels());
198 return padded_rect; 199 return padded_rect;
199 } 200 }
200 201
201 scoped_ptr<base::Value> PicturePileBase::AsValue() const { 202 void PicturePileBase::AsValueInto(base::debug::TracedValue* pictures) const {
202 scoped_ptr<base::ListValue> pictures(new base::ListValue());
203 gfx::Rect tiling_rect(tiling_.tiling_size()); 203 gfx::Rect tiling_rect(tiling_.tiling_size());
204 std::set<void*> appended_pictures; 204 std::set<void*> appended_pictures;
205 bool include_borders = true; 205 bool include_borders = true;
206 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); 206 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders);
207 tile_iter; 207 tile_iter;
208 ++tile_iter) { 208 ++tile_iter) {
209 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); 209 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
210 if (map_iter == picture_map_.end()) 210 if (map_iter == picture_map_.end())
211 continue; 211 continue;
212 212
213 Picture* picture = map_iter->second.GetPicture(); 213 Picture* picture = map_iter->second.GetPicture();
214 if (picture && (appended_pictures.count(picture) == 0)) { 214 if (picture && (appended_pictures.count(picture) == 0)) {
215 appended_pictures.insert(picture); 215 appended_pictures.insert(picture);
216 pictures->Append(TracedValue::CreateIDRef(picture).release()); 216 TracedValue::AppendIDRef(picture, pictures);
217 } 217 }
218 } 218 }
219 return pictures.PassAs<base::Value>();
220 } 219 }
221 220
222 PicturePileBase::PictureInfo::PictureInfo() : last_frame_number_(0) {} 221 PicturePileBase::PictureInfo::PictureInfo() : last_frame_number_(0) {}
223 222
224 PicturePileBase::PictureInfo::~PictureInfo() {} 223 PicturePileBase::PictureInfo::~PictureInfo() {}
225 224
226 void PicturePileBase::PictureInfo::AdvanceInvalidationHistory( 225 void PicturePileBase::PictureInfo::AdvanceInvalidationHistory(
227 int frame_number) { 226 int frame_number) {
228 DCHECK_GE(frame_number, last_frame_number_); 227 DCHECK_GE(frame_number, last_frame_number_);
229 if (frame_number == last_frame_number_) 228 if (frame_number == last_frame_number_)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); 269 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index);
271 return info; 270 return info;
272 } 271 }
273 272
274 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { 273 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const {
275 return invalidation_history_.count() / 274 return invalidation_history_.count() /
276 static_cast<float>(INVALIDATION_FRAMES_TRACKED); 275 static_cast<float>(INVALIDATION_FRAMES_TRACKED);
277 } 276 }
278 277
279 } // namespace cc 278 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile_base.h ('k') | cc/resources/pixel_buffer_raster_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698