| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_overlay_scrollbar_layer.h" | 5 #include "cc/layers/painted_overlay_scrollbar_layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 updated |= UpdateProperty(scrollbar_->TrackRect(), &track_rect_); | 131 updated |= UpdateProperty(scrollbar_->TrackRect(), &track_rect_); |
| 132 updated |= UpdateProperty(scrollbar_->Location(), &location_); | 132 updated |= UpdateProperty(scrollbar_->Location(), &location_); |
| 133 updated |= UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); | 133 updated |= UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); |
| 134 updated |= UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); | 134 updated |= UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); |
| 135 updated |= PaintThumbIfNeeded(); | 135 updated |= PaintThumbIfNeeded(); |
| 136 | 136 |
| 137 return updated; | 137 return updated; |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool PaintedOverlayScrollbarLayer::PaintThumbIfNeeded() { | 140 bool PaintedOverlayScrollbarLayer::PaintThumbIfNeeded() { |
| 141 if (!scrollbar_->NeedsPaintPart(THUMB)) | 141 if (!scrollbar_->NeedsPaintPart(THUMB) && thumb_resource_) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 gfx::Rect paint_rect = OriginThumbRectForPainting(); | 144 gfx::Rect paint_rect = OriginThumbRectForPainting(); |
| 145 aperture_ = scrollbar_->NinePatchThumbAperture(); | 145 aperture_ = scrollbar_->NinePatchThumbAperture(); |
| 146 | 146 |
| 147 DCHECK(!paint_rect.size().IsEmpty()); | 147 DCHECK(!paint_rect.size().IsEmpty()); |
| 148 DCHECK(paint_rect.origin().IsOrigin()); | 148 DCHECK(paint_rect.origin().IsOrigin()); |
| 149 | 149 |
| 150 SkBitmap skbitmap; | 150 SkBitmap skbitmap; |
| 151 skbitmap.allocN32Pixels(paint_rect.width(), paint_rect.height()); | 151 skbitmap.allocN32Pixels(paint_rect.width(), paint_rect.height()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 165 | 165 |
| 166 thumb_resource_ = ScopedUIResource::Create( | 166 thumb_resource_ = ScopedUIResource::Create( |
| 167 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); | 167 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); |
| 168 | 168 |
| 169 SetNeedsPushProperties(); | 169 SetNeedsPushProperties(); |
| 170 | 170 |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace cc | 174 } // namespace cc |
| OLD | NEW |