Commit bf32c2a4 authored by vmpstr's avatar vmpstr Committed by Commit bot

cc: Compute picture pile size at construction time.

We log picture size in UMA histograms every time we
prepare to draw. In order to make that code faster,
precompute the pile size when it is constructed.

R=jbroman, enne

Review URL: https://codereview.chromium.org/1127153006

Cr-Commit-Position: refs/heads/master@{#329773}
parent 078eb743
......@@ -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(
......
......@@ -124,6 +124,8 @@ class CC_EXPORT PicturePileImpl : public RasterSource {
// threads with multi-threaded Ganesh. Make this const or remove it.
bool should_attempt_to_use_distance_field_text_;
size_t picture_memory_usage_;
private:
typedef std::map<const Picture*, Region> PictureRegionMap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment