Chromium Code Reviews| 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()) { |
| 210 return false; | 214 if (track_resource_) { |
| 215 track_resource_.reset(); | |
| 216 if (thumb_resource_) | |
| 217 thumb_resource_.reset(); | |
| 218 SetNeedsPushProperties(); | |
| 219 } | |
| 220 return true; | |
|
danakj
2014/09/11 17:22:01
but this should return false if you didn't SetNeed
MuVen
2014/09/11 18:44:41
Done.
| |
| 221 } | |
| 222 | |
| 223 if (!has_thumb_ && thumb_resource_) { | |
| 224 thumb_resource_.reset(); | |
| 225 SetNeedsPushProperties(); | |
| 226 } | |
| 211 | 227 |
| 212 { | 228 { |
| 213 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, | 229 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, |
| 214 true); | 230 true); |
| 215 ContentsScalingLayer::Update(queue, occlusion); | 231 ContentsScalingLayer::Update(queue, occlusion); |
| 216 } | 232 } |
| 217 | 233 |
| 218 if (update_rect_.IsEmpty() && track_resource_) | 234 if (update_rect_.IsEmpty() && track_resource_) |
| 219 return false; | 235 return false; |
| 220 | 236 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 | 282 |
| 267 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 283 scrollbar_->PaintPart(&skcanvas, part, layer_rect); |
| 268 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 284 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
| 269 // allocation and copying. | 285 // allocation and copying. |
| 270 skbitmap.setImmutable(); | 286 skbitmap.setImmutable(); |
| 271 | 287 |
| 272 return UIResourceBitmap(skbitmap); | 288 return UIResourceBitmap(skbitmap); |
| 273 } | 289 } |
| 274 | 290 |
| 275 } // namespace cc | 291 } // namespace cc |
| OLD | NEW |