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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture_pile_impl.cc
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index d1fba063af1dd62900ea0ee963e4a3e79be413ed..1626657a56106263e8ff43c383e3b54955fd4787 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -34,7 +34,8 @@ PicturePileImpl::PicturePileImpl()
clear_canvas_with_debug_color_(false),
min_contents_scale_(0.f),
slow_down_raster_scale_factor_for_debug_(0),
- should_attempt_to_use_distance_field_text_(false) {
+ should_attempt_to_use_distance_field_text_(false),
+ picture_memory_usage_(0) {
}
PicturePileImpl::PicturePileImpl(const PicturePile* other,
@@ -52,7 +53,15 @@ PicturePileImpl::PicturePileImpl(const PicturePile* other,
min_contents_scale_(other->min_contents_scale_),
slow_down_raster_scale_factor_for_debug_(
other->slow_down_raster_scale_factor_for_debug_),
- should_attempt_to_use_distance_field_text_(false) {
+ should_attempt_to_use_distance_field_text_(false),
+ picture_memory_usage_(0) {
+ // Figure out the picture size upon construction.
+ base::hash_set<const Picture*> pictures_seen;
+ for (const auto& map_value : picture_map_) {
+ const Picture* picture = map_value.second.get();
+ if (pictures_seen.insert(picture).second)
+ picture_memory_usage_ += picture->ApproximateMemoryUsage();
+ }
}
PicturePileImpl::PicturePileImpl(const PicturePileImpl* other,
@@ -71,7 +80,8 @@ PicturePileImpl::PicturePileImpl(const PicturePileImpl* other,
slow_down_raster_scale_factor_for_debug_(
other->slow_down_raster_scale_factor_for_debug_),
should_attempt_to_use_distance_field_text_(
- other->should_attempt_to_use_distance_field_text_) {
+ other->should_attempt_to_use_distance_field_text_),
+ picture_memory_usage_(other->picture_memory_usage_) {
}
PicturePileImpl::~PicturePileImpl() {
@@ -264,16 +274,7 @@ skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() {
}
size_t PicturePileImpl::GetPictureMemoryUsage() const {
- // Place all pictures in a set to de-dupe.
- size_t total_size = 0;
- std::set<const Picture*> pictures_seen;
- for (const auto& map_value : picture_map_) {
- const Picture* picture = map_value.second.get();
- if (pictures_seen.insert(picture).second)
- total_size += picture->ApproximateMemoryUsage();
- }
-
- return total_size;
+ return picture_memory_usage_;
}
void PicturePileImpl::PerformSolidColorAnalysis(
« 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