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

Side by Side Diff: cc/layers/painted_scrollbar_layer.cc

Issue 537943003: Releasing Track & Thumb UIResources based on their Geometry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Releasing Track & Thumb UIResources based on their Geometry Created 6 years, 3 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/layers/painted_scrollbar_layer.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 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/layers/painted_scrollbar_layer.h" 5 #include "cc/layers/painted_scrollbar_layer.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/layers/painted_scrollbar_layer_impl.h" 10 #include "cc/layers/painted_scrollbar_layer_impl.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 track_rect_.x() - location_.x()); 123 track_rect_.x() - location_.x());
124 scrollbar_layer->SetTrackLength(track_rect_.width()); 124 scrollbar_layer->SetTrackLength(track_rect_.width());
125 } else { 125 } else {
126 scrollbar_layer->SetTrackStart( 126 scrollbar_layer->SetTrackStart(
127 track_rect_.y() - location_.y()); 127 track_rect_.y() - location_.y());
128 scrollbar_layer->SetTrackLength(track_rect_.height()); 128 scrollbar_layer->SetTrackLength(track_rect_.height());
129 } 129 }
130 130
131 if (track_resource_.get()) 131 if (track_resource_.get())
132 scrollbar_layer->set_track_ui_resource_id(track_resource_->id()); 132 scrollbar_layer->set_track_ui_resource_id(track_resource_->id());
133 else
134 scrollbar_layer->set_track_ui_resource_id(0);
133 if (thumb_resource_.get()) 135 if (thumb_resource_.get())
134 scrollbar_layer->set_thumb_ui_resource_id(thumb_resource_->id()); 136 scrollbar_layer->set_thumb_ui_resource_id(thumb_resource_->id());
137 else
138 scrollbar_layer->set_thumb_ui_resource_id(0);
135 139
136 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_); 140 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_);
137 } 141 }
138 142
139 ScrollbarLayerInterface* PaintedScrollbarLayer::ToScrollbarLayer() { 143 ScrollbarLayerInterface* PaintedScrollbarLayer::ToScrollbarLayer() {
140 return this; 144 return this;
141 } 145 }
142 146
143 void PaintedScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl* layer) { 147 void PaintedScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl* layer) {
144 PaintedScrollbarLayerImpl* scrollbar_layer = 148 PaintedScrollbarLayerImpl* scrollbar_layer =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 UpdateProperty(scrollbar_->Location(), &location_); 193 UpdateProperty(scrollbar_->Location(), &location_);
190 UpdateProperty(scrollbar_->IsOverlay(), &is_overlay_); 194 UpdateProperty(scrollbar_->IsOverlay(), &is_overlay_);
191 UpdateProperty(scrollbar_->HasThumb(), &has_thumb_); 195 UpdateProperty(scrollbar_->HasThumb(), &has_thumb_);
192 if (has_thumb_) { 196 if (has_thumb_) {
193 UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); 197 UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_);
194 UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); 198 UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_);
195 } else { 199 } else {
196 UpdateProperty(0, &thumb_thickness_); 200 UpdateProperty(0, &thumb_thickness_);
197 UpdateProperty(0, &thumb_length_); 201 UpdateProperty(0, &thumb_length_);
198 } 202 }
203 ReleaseThumbAndTrackUIResourcesIfNecessary();
204 }
205
206 void PaintedScrollbarLayer::ReleaseThumbAndTrackUIResourcesIfNecessary() {
207 if (track_rect_.IsEmpty() && track_resource_) {
208 track_resource_.reset();
209 SetNeedsPushProperties();
210 } else if ((!has_thumb_ || track_rect_.IsEmpty()) && thumb_resource_) {
211 thumb_resource_.reset();
212 SetNeedsPushProperties();
danakj 2014/09/04 16:38:10 these need to make Update() return true also, so I
MuVen 2014/09/05 14:44:13 Done.Tests Added.
213 }
199 } 214 }
200 215
201 bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, 216 bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue,
202 const OcclusionTracker<Layer>* occlusion) { 217 const OcclusionTracker<Layer>* occlusion) {
203 UpdateThumbAndTrackGeometry(); 218 UpdateThumbAndTrackGeometry();
204 219
205 gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); 220 gfx::Rect track_layer_rect = gfx::Rect(location_, bounds());
206 gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect( 221 gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect(
207 track_layer_rect); 222 track_layer_rect);
208 223
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 281
267 scrollbar_->PaintPart(&skcanvas, part, layer_rect); 282 scrollbar_->PaintPart(&skcanvas, part, layer_rect);
268 // Make sure that the pixels are no longer mutable to unavoid unnecessary 283 // Make sure that the pixels are no longer mutable to unavoid unnecessary
269 // allocation and copying. 284 // allocation and copying.
270 skbitmap.setImmutable(); 285 skbitmap.setImmutable();
271 286
272 return UIResourceBitmap(skbitmap); 287 return UIResourceBitmap(skbitmap);
273 } 288 }
274 289
275 } // namespace cc 290 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698