Commit 8eff0dbb authored by sataya.m's avatar sataya.m Committed by Commit bot

Releasing Track & Thumb UIResources based on their Geometry

When the track rect or scaled track rect is empty, UiResources of Track
and Thumb resources are released, instead of holding in the memory.
These UIResources will be created on PaintedScrollbarLayer::Update when
the Track rect is not empty. Similary When Scrollbar doesnt have Thumb
release UIResources of Thumb.

Bug=410845

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

Cr-Commit-Position: refs/heads/master@{#295515}
parent 6d2b3cd0
......@@ -130,8 +130,12 @@ void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
if (track_resource_.get())
scrollbar_layer->set_track_ui_resource_id(track_resource_->id());
else
scrollbar_layer->set_track_ui_resource_id(0);
if (thumb_resource_.get())
scrollbar_layer->set_thumb_ui_resource_id(thumb_resource_->id());
else
scrollbar_layer->set_thumb_ui_resource_id(0);
scrollbar_layer->set_is_overlay_scrollbar(is_overlay_);
}
......@@ -206,8 +210,23 @@ bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue,
gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect(
track_layer_rect);
if (track_rect_.IsEmpty() || scaled_track_rect.IsEmpty())
return false;
bool updated = false;
if (track_rect_.IsEmpty() || scaled_track_rect.IsEmpty()) {
if (track_resource_) {
track_resource_.reset();
if (thumb_resource_)
thumb_resource_.reset();
SetNeedsPushProperties();
updated = true;
}
return updated;
}
if (!has_thumb_ && thumb_resource_) {
thumb_resource_.reset();
SetNeedsPushProperties();
}
{
base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
......@@ -216,7 +235,7 @@ bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue,
}
if (update_rect_.IsEmpty() && track_resource_)
return false;
return updated;
track_resource_ = ScopedUIResource::Create(
layer_tree_host(),
......@@ -233,7 +252,8 @@ bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue,
// UI resources changed so push properties is needed.
SetNeedsPushProperties();
return true;
updated = true;
return updated;
}
UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart(
......
This diff is collapsed.
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