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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 PaintedScrollbarLayer::PaintedScrollbarLayer(const LayerSettings& settings, | 42 PaintedScrollbarLayer::PaintedScrollbarLayer(const LayerSettings& settings, |
43 scoped_ptr<Scrollbar> scrollbar, | 43 scoped_ptr<Scrollbar> scrollbar, |
44 int scroll_layer_id) | 44 int scroll_layer_id) |
45 : Layer(settings), | 45 : Layer(settings), |
46 scrollbar_(std::move(scrollbar)), | 46 scrollbar_(std::move(scrollbar)), |
47 scroll_layer_id_(scroll_layer_id), | 47 scroll_layer_id_(scroll_layer_id), |
48 internal_contents_scale_(1.f), | 48 internal_contents_scale_(1.f), |
49 thumb_thickness_(scrollbar_->ThumbThickness()), | 49 thumb_thickness_(scrollbar_->ThumbThickness()), |
50 thumb_length_(scrollbar_->ThumbLength()), | 50 thumb_length_(scrollbar_->ThumbLength()), |
51 is_overlay_(scrollbar_->IsOverlay()), | 51 is_overlay_(scrollbar_->IsOverlay()), |
52 has_thumb_(scrollbar_->HasThumb()) { | 52 has_thumb_(scrollbar_->HasThumb()), |
| 53 thumb_opacity_(scrollbar_->ThumbOpacity()) { |
53 if (!scrollbar_->IsOverlay()) | 54 if (!scrollbar_->IsOverlay()) |
54 SetShouldScrollOnMainThread(true); | 55 SetShouldScrollOnMainThread(true); |
55 } | 56 } |
56 | 57 |
57 PaintedScrollbarLayer::~PaintedScrollbarLayer() {} | 58 PaintedScrollbarLayer::~PaintedScrollbarLayer() {} |
58 | 59 |
59 int PaintedScrollbarLayer::ScrollLayerId() const { | 60 int PaintedScrollbarLayer::ScrollLayerId() const { |
60 return scroll_layer_id_; | 61 return scroll_layer_id_; |
61 } | 62 } |
62 | 63 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 238 |
238 if (!has_thumb_ && thumb_resource_) { | 239 if (!has_thumb_ && thumb_resource_) { |
239 thumb_resource_ = nullptr; | 240 thumb_resource_ = nullptr; |
240 SetNeedsPushProperties(); | 241 SetNeedsPushProperties(); |
241 updated = true; | 242 updated = true; |
242 } | 243 } |
243 | 244 |
244 if (update_rect_.IsEmpty() && track_resource_) | 245 if (update_rect_.IsEmpty() && track_resource_) |
245 return updated; | 246 return updated; |
246 | 247 |
247 track_resource_ = ScopedUIResource::Create( | 248 if (!track_resource_ || scrollbar_->NeedsPaintPart(TRACK)) { |
248 layer_tree_host(), | 249 track_resource_ = ScopedUIResource::Create( |
249 RasterizeScrollbarPart(track_layer_rect, scaled_track_rect, TRACK)); | 250 layer_tree_host(), |
| 251 RasterizeScrollbarPart(track_layer_rect, scaled_track_rect, TRACK)); |
| 252 } |
250 | 253 |
251 gfx::Rect thumb_layer_rect = OriginThumbRect(); | 254 gfx::Rect thumb_layer_rect = OriginThumbRect(); |
252 gfx::Rect scaled_thumb_rect = | 255 gfx::Rect scaled_thumb_rect = |
253 ScrollbarLayerRectToContentRect(thumb_layer_rect); | 256 ScrollbarLayerRectToContentRect(thumb_layer_rect); |
254 if (has_thumb_ && !scaled_thumb_rect.IsEmpty()) { | 257 if (has_thumb_ && !scaled_thumb_rect.IsEmpty()) { |
255 thumb_resource_ = ScopedUIResource::Create( | 258 if (!thumb_resource_ || scrollbar_->NeedsPaintPart(THUMB)) { |
256 layer_tree_host(), | 259 thumb_resource_ = ScopedUIResource::Create( |
257 RasterizeScrollbarPart(thumb_layer_rect, scaled_thumb_rect, THUMB)); | 260 layer_tree_host(), |
| 261 RasterizeScrollbarPart(thumb_layer_rect, scaled_thumb_rect, THUMB)); |
| 262 } |
| 263 thumb_opacity_ = scrollbar_->ThumbOpacity(); |
258 } | 264 } |
259 | 265 |
260 // UI resources changed so push properties is needed. | 266 // UI resources changed so push properties is needed. |
261 SetNeedsPushProperties(); | 267 SetNeedsPushProperties(); |
262 updated = true; | 268 updated = true; |
263 return updated; | 269 return updated; |
264 } | 270 } |
265 | 271 |
266 UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart( | 272 UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart( |
267 const gfx::Rect& layer_rect, | 273 const gfx::Rect& layer_rect, |
(...skipping 25 matching lines...) Expand all Loading... |
293 | 299 |
294 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 300 scrollbar_->PaintPart(&skcanvas, part, layer_rect); |
295 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 301 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
296 // allocation and copying. | 302 // allocation and copying. |
297 skbitmap.setImmutable(); | 303 skbitmap.setImmutable(); |
298 | 304 |
299 return UIResourceBitmap(skbitmap); | 305 return UIResourceBitmap(skbitmap); |
300 } | 306 } |
301 | 307 |
302 } // namespace cc | 308 } // namespace cc |
OLD | NEW |