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

Side by Side Diff: cc/resources/picture_pile_impl.cc

Issue 1127153006: cc: Compute picture pile size at construction time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | no next file » | 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 <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 #include <set> 7 #include <set>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/region.h" 10 #include "cc/base/region.h"
(...skipping 16 matching lines...) Expand all
27 PicturePileImpl::PicturePileImpl() 27 PicturePileImpl::PicturePileImpl()
28 : background_color_(SK_ColorTRANSPARENT), 28 : background_color_(SK_ColorTRANSPARENT),
29 requires_clear_(true), 29 requires_clear_(true),
30 can_use_lcd_text_(true), 30 can_use_lcd_text_(true),
31 is_solid_color_(false), 31 is_solid_color_(false),
32 solid_color_(SK_ColorTRANSPARENT), 32 solid_color_(SK_ColorTRANSPARENT),
33 has_any_recordings_(false), 33 has_any_recordings_(false),
34 clear_canvas_with_debug_color_(false), 34 clear_canvas_with_debug_color_(false),
35 min_contents_scale_(0.f), 35 min_contents_scale_(0.f),
36 slow_down_raster_scale_factor_for_debug_(0), 36 slow_down_raster_scale_factor_for_debug_(0),
37 should_attempt_to_use_distance_field_text_(false) { 37 should_attempt_to_use_distance_field_text_(false),
38 picture_memory_usage_(0) {
38 } 39 }
39 40
40 PicturePileImpl::PicturePileImpl(const PicturePile* other, 41 PicturePileImpl::PicturePileImpl(const PicturePile* other,
41 bool can_use_lcd_text) 42 bool can_use_lcd_text)
42 : picture_map_(other->picture_map_), 43 : picture_map_(other->picture_map_),
43 tiling_(other->tiling_), 44 tiling_(other->tiling_),
44 background_color_(other->background_color_), 45 background_color_(other->background_color_),
45 requires_clear_(other->requires_clear_), 46 requires_clear_(other->requires_clear_),
46 can_use_lcd_text_(can_use_lcd_text), 47 can_use_lcd_text_(can_use_lcd_text),
47 is_solid_color_(other->is_solid_color_), 48 is_solid_color_(other->is_solid_color_),
48 solid_color_(other->solid_color_), 49 solid_color_(other->solid_color_),
49 recorded_viewport_(other->recorded_viewport_), 50 recorded_viewport_(other->recorded_viewport_),
50 has_any_recordings_(other->has_any_recordings_), 51 has_any_recordings_(other->has_any_recordings_),
51 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 52 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
52 min_contents_scale_(other->min_contents_scale_), 53 min_contents_scale_(other->min_contents_scale_),
53 slow_down_raster_scale_factor_for_debug_( 54 slow_down_raster_scale_factor_for_debug_(
54 other->slow_down_raster_scale_factor_for_debug_), 55 other->slow_down_raster_scale_factor_for_debug_),
55 should_attempt_to_use_distance_field_text_(false) { 56 should_attempt_to_use_distance_field_text_(false),
57 picture_memory_usage_(0) {
58 // Figure out the picture size upon construction.
59 base::hash_set<const Picture*> pictures_seen;
60 for (const auto& map_value : picture_map_) {
61 const Picture* picture = map_value.second.get();
62 if (pictures_seen.insert(picture).second)
63 picture_memory_usage_ += picture->ApproximateMemoryUsage();
64 }
56 } 65 }
57 66
58 PicturePileImpl::PicturePileImpl(const PicturePileImpl* other, 67 PicturePileImpl::PicturePileImpl(const PicturePileImpl* other,
59 bool can_use_lcd_text) 68 bool can_use_lcd_text)
60 : picture_map_(other->picture_map_), 69 : picture_map_(other->picture_map_),
61 tiling_(other->tiling_), 70 tiling_(other->tiling_),
62 background_color_(other->background_color_), 71 background_color_(other->background_color_),
63 requires_clear_(other->requires_clear_), 72 requires_clear_(other->requires_clear_),
64 can_use_lcd_text_(can_use_lcd_text), 73 can_use_lcd_text_(can_use_lcd_text),
65 is_solid_color_(other->is_solid_color_), 74 is_solid_color_(other->is_solid_color_),
66 solid_color_(other->solid_color_), 75 solid_color_(other->solid_color_),
67 recorded_viewport_(other->recorded_viewport_), 76 recorded_viewport_(other->recorded_viewport_),
68 has_any_recordings_(other->has_any_recordings_), 77 has_any_recordings_(other->has_any_recordings_),
69 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 78 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
70 min_contents_scale_(other->min_contents_scale_), 79 min_contents_scale_(other->min_contents_scale_),
71 slow_down_raster_scale_factor_for_debug_( 80 slow_down_raster_scale_factor_for_debug_(
72 other->slow_down_raster_scale_factor_for_debug_), 81 other->slow_down_raster_scale_factor_for_debug_),
73 should_attempt_to_use_distance_field_text_( 82 should_attempt_to_use_distance_field_text_(
74 other->should_attempt_to_use_distance_field_text_) { 83 other->should_attempt_to_use_distance_field_text_),
84 picture_memory_usage_(other->picture_memory_usage_) {
75 } 85 }
76 86
77 PicturePileImpl::~PicturePileImpl() { 87 PicturePileImpl::~PicturePileImpl() {
78 } 88 }
79 89
80 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas, 90 void PicturePileImpl::PlaybackToSharedCanvas(SkCanvas* canvas,
81 const gfx::Rect& canvas_rect, 91 const gfx::Rect& canvas_rect,
82 float contents_scale) const { 92 float contents_scale) const {
83 RasterCommon(canvas, NULL, canvas_rect, contents_scale); 93 RasterCommon(canvas, NULL, canvas_rect, contents_scale);
84 } 94 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 recorder.beginRecording(tiling_rect.width(), tiling_rect.height()); 267 recorder.beginRecording(tiling_rect.width(), tiling_rect.height());
258 if (!tiling_rect.IsEmpty()) 268 if (!tiling_rect.IsEmpty())
259 PlaybackToCanvas(canvas, tiling_rect, 1.0); 269 PlaybackToCanvas(canvas, tiling_rect, 1.0);
260 skia::RefPtr<SkPicture> picture = 270 skia::RefPtr<SkPicture> picture =
261 skia::AdoptRef(recorder.endRecordingAsPicture()); 271 skia::AdoptRef(recorder.endRecordingAsPicture());
262 272
263 return picture; 273 return picture;
264 } 274 }
265 275
266 size_t PicturePileImpl::GetPictureMemoryUsage() const { 276 size_t PicturePileImpl::GetPictureMemoryUsage() const {
267 // Place all pictures in a set to de-dupe. 277 return picture_memory_usage_;
268 size_t total_size = 0;
269 std::set<const Picture*> pictures_seen;
270 for (const auto& map_value : picture_map_) {
271 const Picture* picture = map_value.second.get();
272 if (pictures_seen.insert(picture).second)
273 total_size += picture->ApproximateMemoryUsage();
274 }
275
276 return total_size;
277 } 278 }
278 279
279 void PicturePileImpl::PerformSolidColorAnalysis( 280 void PicturePileImpl::PerformSolidColorAnalysis(
280 const gfx::Rect& content_rect, 281 const gfx::Rect& content_rect,
281 float contents_scale, 282 float contents_scale,
282 RasterSource::SolidColorAnalysis* analysis) const { 283 RasterSource::SolidColorAnalysis* analysis) const {
283 DCHECK(analysis); 284 DCHECK(analysis);
284 TRACE_EVENT0("cc", "PicturePileImpl::PerformSolidColorAnalysis"); 285 TRACE_EVENT0("cc", "PicturePileImpl::PerformSolidColorAnalysis");
285 286
286 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( 287 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 for (const auto& map_pair : picture_map_) { 454 for (const auto& map_pair : picture_map_) {
454 const Picture* picture = map_pair.second.get(); 455 const Picture* picture = map_pair.second.get();
455 if (processed_pictures.count(picture) == 0) { 456 if (processed_pictures.count(picture) == 0) {
456 picture->EmitTraceSnapshot(); 457 picture->EmitTraceSnapshot();
457 processed_pictures.insert(picture); 458 processed_pictures.insert(picture);
458 } 459 }
459 } 460 }
460 } 461 }
461 462
462 } // namespace cc 463 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698