OLD | NEW |
---|---|
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 Loading... | |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 } | 203 } |
200 | 204 |
201 bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, | 205 bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, |
202 const OcclusionTracker<Layer>* occlusion) { | 206 const OcclusionTracker<Layer>* occlusion) { |
203 UpdateThumbAndTrackGeometry(); | 207 UpdateThumbAndTrackGeometry(); |
204 | 208 |
205 gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); | 209 gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); |
206 gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect( | 210 gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect( |
207 track_layer_rect); | 211 track_layer_rect); |
208 | 212 |
209 if (track_rect_.IsEmpty() || scaled_track_rect.IsEmpty()) | 213 if (track_rect_.IsEmpty() || scaled_track_rect.IsEmpty()) { |
214 if (track_resource_ && thumb_resource_) { | |
danakj
2014/09/10 16:15:03
&& seems wrong here, if the track is the only thin
MuVen
2014/09/11 14:07:21
Done.
| |
215 track_resource_.reset(); | |
216 thumb_resource_.reset(); | |
217 SetNeedsPushProperties(); | |
218 } | |
MuVen
2014/09/10 15:40:58
To make it simple i have added the reset of the UI
| |
210 return false; | 219 return false; |
220 } | |
221 | |
222 if (!has_thumb_ && thumb_resource_) { | |
223 thumb_resource_.reset(); | |
224 SetNeedsPushProperties(); | |
225 } | |
211 | 226 |
212 { | 227 { |
213 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, | 228 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, |
214 true); | 229 true); |
215 ContentsScalingLayer::Update(queue, occlusion); | 230 ContentsScalingLayer::Update(queue, occlusion); |
216 } | 231 } |
217 | 232 |
218 if (update_rect_.IsEmpty() && track_resource_) | 233 if (update_rect_.IsEmpty() && track_resource_) |
219 return false; | 234 return false; |
danakj
2014/09/10 16:15:03
if we dropped resources above, we should return tr
MuVen
2014/09/11 14:07:21
Done.
| |
220 | 235 |
221 track_resource_ = ScopedUIResource::Create( | 236 track_resource_ = ScopedUIResource::Create( |
222 layer_tree_host(), | 237 layer_tree_host(), |
223 RasterizeScrollbarPart(track_layer_rect, scaled_track_rect, TRACK)); | 238 RasterizeScrollbarPart(track_layer_rect, scaled_track_rect, TRACK)); |
224 | 239 |
225 gfx::Rect thumb_layer_rect = OriginThumbRect(); | 240 gfx::Rect thumb_layer_rect = OriginThumbRect(); |
226 gfx::Rect scaled_thumb_rect = | 241 gfx::Rect scaled_thumb_rect = |
227 ScrollbarLayerRectToContentRect(thumb_layer_rect); | 242 ScrollbarLayerRectToContentRect(thumb_layer_rect); |
228 if (has_thumb_ && !scaled_thumb_rect.IsEmpty()) { | 243 if (has_thumb_ && !scaled_thumb_rect.IsEmpty()) { |
229 thumb_resource_ = ScopedUIResource::Create( | 244 thumb_resource_ = ScopedUIResource::Create( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |