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 10 matching lines...) Expand all Loading... |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 scoped_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl( | 23 scoped_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl( |
24 LayerTreeImpl* tree_impl) { | 24 LayerTreeImpl* tree_impl) { |
25 return PaintedScrollbarLayerImpl::Create( | 25 return PaintedScrollbarLayerImpl::Create( |
26 tree_impl, id(), scrollbar_->Orientation()).PassAs<LayerImpl>(); | 26 tree_impl, id(), scrollbar_->Orientation()).PassAs<LayerImpl>(); |
27 } | 27 } |
28 | 28 |
29 scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create( | 29 scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create( |
30 scoped_ptr<Scrollbar> scrollbar, | 30 scoped_ptr<Scrollbar> scrollbar, |
31 int scroll_layer_id) { | 31 Layer* scroll_layer) { |
32 return make_scoped_refptr( | 32 return make_scoped_refptr( |
33 new PaintedScrollbarLayer(scrollbar.Pass(), scroll_layer_id)); | 33 new PaintedScrollbarLayer(scrollbar.Pass(), scroll_layer)); |
34 } | 34 } |
35 | 35 |
36 PaintedScrollbarLayer::PaintedScrollbarLayer( | 36 PaintedScrollbarLayer::PaintedScrollbarLayer( |
37 scoped_ptr<Scrollbar> scrollbar, | 37 scoped_ptr<Scrollbar> scrollbar, |
38 int scroll_layer_id) | 38 Layer* scroll_layer) |
39 : scrollbar_(scrollbar.Pass()), | 39 : scrollbar_(scrollbar.Pass()), |
40 scroll_layer_id_(scroll_layer_id), | 40 scroll_layer_(scroll_layer), |
| 41 clip_layer_(NULL), |
41 thumb_thickness_(scrollbar_->ThumbThickness()), | 42 thumb_thickness_(scrollbar_->ThumbThickness()), |
42 thumb_length_(scrollbar_->ThumbLength()), | 43 thumb_length_(scrollbar_->ThumbLength()), |
43 is_overlay_(scrollbar_->IsOverlay()), | 44 is_overlay_(scrollbar_->IsOverlay()), |
44 has_thumb_(scrollbar_->HasThumb()) { | 45 has_thumb_(scrollbar_->HasThumb()) { |
45 if (!scrollbar_->IsOverlay()) | 46 if (!scrollbar_->IsOverlay()) |
46 SetShouldScrollOnMainThread(true); | 47 SetShouldScrollOnMainThread(true); |
47 } | 48 } |
48 | 49 |
49 PaintedScrollbarLayer::~PaintedScrollbarLayer() {} | 50 PaintedScrollbarLayer::~PaintedScrollbarLayer() {} |
50 | 51 |
51 int PaintedScrollbarLayer::ScrollLayerId() const { | 52 int PaintedScrollbarLayer::ScrollLayerId() const { |
52 return scroll_layer_id_; | 53 return scroll_layer_->id(); |
53 } | 54 } |
54 | 55 |
55 void PaintedScrollbarLayer::SetScrollLayerId(int id) { | 56 void PaintedScrollbarLayer::SetScrollLayer(scoped_refptr<Layer> layer) { |
56 if (id == scroll_layer_id_) | 57 if (layer == scroll_layer_) |
57 return; | 58 return; |
58 | 59 |
59 scroll_layer_id_ = id; | 60 scroll_layer_ = layer; |
60 SetNeedsFullTreeSync(); | 61 SetNeedsFullTreeSync(); |
61 } | 62 } |
62 | 63 |
| 64 void PaintedScrollbarLayer::SetClipLayer(scoped_refptr<Layer> layer) { |
| 65 if (layer == clip_layer_) |
| 66 return; |
| 67 |
| 68 clip_layer_ = layer; |
| 69 SetNeedsFullTreeSync(); |
| 70 } |
| 71 |
63 bool PaintedScrollbarLayer::OpacityCanAnimateOnImplThread() const { | 72 bool PaintedScrollbarLayer::OpacityCanAnimateOnImplThread() const { |
64 return scrollbar_->IsOverlay(); | 73 return scrollbar_->IsOverlay(); |
65 } | 74 } |
66 | 75 |
67 ScrollbarOrientation PaintedScrollbarLayer::orientation() const { | 76 ScrollbarOrientation PaintedScrollbarLayer::orientation() const { |
68 return scrollbar_->Orientation(); | 77 return scrollbar_->Orientation(); |
69 } | 78 } |
70 | 79 |
71 int PaintedScrollbarLayer::MaxTextureSize() { | 80 int PaintedScrollbarLayer::MaxTextureSize() { |
72 DCHECK(layer_tree_host()); | 81 DCHECK(layer_tree_host()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 contents_scale_y, | 114 contents_scale_y, |
106 content_bounds); | 115 content_bounds); |
107 } | 116 } |
108 | 117 |
109 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { | 118 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
110 ContentsScalingLayer::PushPropertiesTo(layer); | 119 ContentsScalingLayer::PushPropertiesTo(layer); |
111 | 120 |
112 PaintedScrollbarLayerImpl* scrollbar_layer = | 121 PaintedScrollbarLayerImpl* scrollbar_layer = |
113 static_cast<PaintedScrollbarLayerImpl*>(layer); | 122 static_cast<PaintedScrollbarLayerImpl*>(layer); |
114 | 123 |
| 124 scrollbar_layer->SetScrollLayerById(scroll_layer_ ? scroll_layer_->id() |
| 125 : Layer::INVALID_ID); |
| 126 scrollbar_layer->SetClipLayerById(clip_layer_ ? clip_layer_->id() |
| 127 : Layer::INVALID_ID); |
| 128 |
115 scrollbar_layer->SetThumbThickness(thumb_thickness_); | 129 scrollbar_layer->SetThumbThickness(thumb_thickness_); |
116 scrollbar_layer->SetThumbLength(thumb_length_); | 130 scrollbar_layer->SetThumbLength(thumb_length_); |
117 if (orientation() == HORIZONTAL) { | 131 if (orientation() == HORIZONTAL) { |
118 scrollbar_layer->SetTrackStart( | 132 scrollbar_layer->SetTrackStart( |
119 track_rect_.x() - location_.x()); | 133 track_rect_.x() - location_.x()); |
120 scrollbar_layer->SetTrackLength(track_rect_.width()); | 134 scrollbar_layer->SetTrackLength(track_rect_.width()); |
121 } else { | 135 } else { |
122 scrollbar_layer->SetTrackStart( | 136 scrollbar_layer->SetTrackStart( |
123 track_rect_.y() - location_.y()); | 137 track_rect_.y() - location_.y()); |
124 scrollbar_layer->SetTrackLength(track_rect_.height()); | 138 scrollbar_layer->SetTrackLength(track_rect_.height()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 255 |
242 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 256 scrollbar_->PaintPart(&skcanvas, part, layer_rect); |
243 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 257 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
244 // allocation and copying. | 258 // allocation and copying. |
245 skbitmap.setImmutable(); | 259 skbitmap.setImmutable(); |
246 | 260 |
247 return UIResourceBitmap(skbitmap); | 261 return UIResourceBitmap(skbitmap); |
248 } | 262 } |
249 | 263 |
250 } // namespace cc | 264 } // namespace cc |
OLD | NEW |