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 23 matching lines...) Expand all Loading... | |
34 } | 34 } |
35 | 35 |
36 PaintedScrollbarLayer::PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, | 36 PaintedScrollbarLayer::PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, |
37 int scroll_layer_id) | 37 int scroll_layer_id) |
38 : scrollbar_(scrollbar.Pass()), | 38 : scrollbar_(scrollbar.Pass()), |
39 scroll_layer_id_(scroll_layer_id), | 39 scroll_layer_id_(scroll_layer_id), |
40 clip_layer_id_(Layer::INVALID_ID), | 40 clip_layer_id_(Layer::INVALID_ID), |
41 thumb_thickness_(scrollbar_->ThumbThickness()), | 41 thumb_thickness_(scrollbar_->ThumbThickness()), |
42 thumb_length_(scrollbar_->ThumbLength()), | 42 thumb_length_(scrollbar_->ThumbLength()), |
43 is_overlay_(scrollbar_->IsOverlay()), | 43 is_overlay_(scrollbar_->IsOverlay()), |
44 has_thumb_(scrollbar_->HasThumb()) { | 44 has_thumb_(scrollbar_->HasThumb()), |
45 has_thumb_pre_(false) { | |
Sikugu_
2014/09/01 14:46:19
can we have some better name here like cache_thumb
| |
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 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 gfx::Size(scrollbar_->ThumbThickness(), scrollbar_->ThumbLength()); | 183 gfx::Size(scrollbar_->ThumbThickness(), scrollbar_->ThumbLength()); |
183 } | 184 } |
184 return gfx::Rect(thumb_size); | 185 return gfx::Rect(thumb_size); |
185 } | 186 } |
186 | 187 |
187 void PaintedScrollbarLayer::UpdateThumbAndTrackGeometry() { | 188 void PaintedScrollbarLayer::UpdateThumbAndTrackGeometry() { |
188 UpdateProperty(scrollbar_->TrackRect(), &track_rect_); | 189 UpdateProperty(scrollbar_->TrackRect(), &track_rect_); |
189 UpdateProperty(scrollbar_->Location(), &location_); | 190 UpdateProperty(scrollbar_->Location(), &location_); |
190 UpdateProperty(scrollbar_->IsOverlay(), &is_overlay_); | 191 UpdateProperty(scrollbar_->IsOverlay(), &is_overlay_); |
191 UpdateProperty(scrollbar_->HasThumb(), &has_thumb_); | 192 UpdateProperty(scrollbar_->HasThumb(), &has_thumb_); |
192 if (has_thumb_) { | 193 if ((has_thumb_ != has_thumb_pre_) || has_thumb_) { |
danakj
2014/09/02 16:23:06
I don't understand, when has_thumb_ became false,
MuVen
2014/09/02 16:42:04
When "Pin it" is clicked a pop-up of window height
danakj
2014/09/02 18:38:55
Ok, then how about when has_thumb is false, we alw
MuVen
2014/09/03 07:04:39
When has_thumb is false, UpdateProperty of ThumbLe
| |
193 UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); | 194 UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); |
194 UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); | 195 UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); |
196 has_thumb_pre_ = has_thumb_; | |
195 } | 197 } |
196 } | 198 } |
197 | 199 |
198 bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, | 200 bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, |
199 const OcclusionTracker<Layer>* occlusion) { | 201 const OcclusionTracker<Layer>* occlusion) { |
200 UpdateThumbAndTrackGeometry(); | 202 UpdateThumbAndTrackGeometry(); |
201 | 203 |
202 gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); | 204 gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); |
203 gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect( | 205 gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect( |
204 track_layer_rect); | 206 track_layer_rect); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 | 265 |
264 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 266 scrollbar_->PaintPart(&skcanvas, part, layer_rect); |
265 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 267 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
266 // allocation and copying. | 268 // allocation and copying. |
267 skbitmap.setImmutable(); | 269 skbitmap.setImmutable(); |
268 | 270 |
269 return UIResourceBitmap(skbitmap); | 271 return UIResourceBitmap(skbitmap); |
270 } | 272 } |
271 | 273 |
272 } // namespace cc | 274 } // namespace cc |
OLD | NEW |