| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/scrollbar_layer_impl.h" | 5 #include "cc/layers/scrollbar_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/animation/scrollbar_animation_controller.h" | 9 #include "cc/animation/scrollbar_animation_controller.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 return ScrollbarLayerImpl::Create(tree_impl, | 56 return ScrollbarLayerImpl::Create(tree_impl, |
| 57 id(), | 57 id(), |
| 58 orientation_).PassAs<LayerImpl>(); | 58 orientation_).PassAs<LayerImpl>(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ScrollbarLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 61 void ScrollbarLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 62 LayerImpl::PushPropertiesTo(layer); | 62 LayerImpl::PushPropertiesTo(layer); |
| 63 | 63 |
| 64 ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); | 64 ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer); |
| 65 | 65 |
| 66 scrollbar_layer->set_thumb_thickness(thumb_thickness_); | 66 scrollbar_layer->SetThumbThickness(thumb_thickness_); |
| 67 scrollbar_layer->set_thumb_length(thumb_length_); | 67 scrollbar_layer->SetThumbLength(thumb_length_); |
| 68 scrollbar_layer->set_track_start(track_start_); | 68 scrollbar_layer->SetTrackStart(track_start_); |
| 69 scrollbar_layer->set_track_length(track_length_); | 69 scrollbar_layer->SetTrackLength(track_length_); |
| 70 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_scrollbar_); | 70 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_scrollbar_); |
| 71 | 71 |
| 72 scrollbar_layer->set_track_resource_id(track_resource_id_); | 72 scrollbar_layer->set_track_resource_id(track_resource_id_); |
| 73 scrollbar_layer->set_thumb_resource_id(thumb_resource_id_); | 73 scrollbar_layer->set_thumb_resource_id(thumb_resource_id_); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool ScrollbarLayerImpl::WillDraw(DrawMode draw_mode, | 76 bool ScrollbarLayerImpl::WillDraw(DrawMode draw_mode, |
| 77 ResourceProvider* resource_provider) { | 77 ResourceProvider* resource_provider) { |
| 78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE && | 78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE && |
| 79 !layer_tree_impl()->settings().solid_color_scrollbars) | 79 !layer_tree_impl()->settings().solid_color_scrollbars) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 gfx::Rect ScrollbarLayerImpl::ScrollbarLayerRectToContentRect( | 163 gfx::Rect ScrollbarLayerImpl::ScrollbarLayerRectToContentRect( |
| 164 gfx::RectF layer_rect) const { | 164 gfx::RectF layer_rect) const { |
| 165 // Don't intersect with the bounds as in layerRectToContentRect() because | 165 // Don't intersect with the bounds as in layerRectToContentRect() because |
| 166 // layer_rect here might be in coordinates of the containing layer. | 166 // layer_rect here might be in coordinates of the containing layer. |
| 167 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, | 167 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, |
| 168 contents_scale_x(), | 168 contents_scale_x(), |
| 169 contents_scale_y()); | 169 contents_scale_y()); |
| 170 return gfx::ToEnclosingRect(content_rect); | 170 return gfx::ToEnclosingRect(content_rect); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ScrollbarLayerImpl::SetThumbThickness(int thumb_thickness) { |
| 174 if (thumb_thickness_ == thumb_thickness) |
| 175 return; |
| 176 thumb_thickness_ = thumb_thickness; |
| 177 NoteLayerPropertyChanged(); |
| 178 } |
| 179 |
| 180 void ScrollbarLayerImpl::SetThumbLength(int thumb_length) { |
| 181 if (thumb_length_ == thumb_length) |
| 182 return; |
| 183 thumb_length_ = thumb_length; |
| 184 NoteLayerPropertyChanged(); |
| 185 } |
| 186 void ScrollbarLayerImpl::SetTrackStart(int track_start) { |
| 187 if (track_start_ == track_start) |
| 188 return; |
| 189 track_start_ = track_start; |
| 190 NoteLayerPropertyChanged(); |
| 191 } |
| 192 |
| 193 void ScrollbarLayerImpl::SetTrackLength(int track_length) { |
| 194 if (track_length_ == track_length) |
| 195 return; |
| 196 track_length_ = track_length; |
| 197 NoteLayerPropertyChanged(); |
| 198 } |
| 199 |
| 200 void ScrollbarLayerImpl::SetVerticalAdjust(float vertical_adjust) { |
| 201 if (vertical_adjust_ == vertical_adjust) |
| 202 return; |
| 203 vertical_adjust_ = vertical_adjust; |
| 204 NoteLayerPropertyChanged(); |
| 205 } |
| 206 |
| 207 void ScrollbarLayerImpl::SetVisibleToTotalLengthRatio(float ratio) { |
| 208 if (visible_to_total_length_ratio_ == ratio) |
| 209 return; |
| 210 visible_to_total_length_ratio_ = ratio; |
| 211 NoteLayerPropertyChanged(); |
| 212 } |
| 213 |
| 173 void ScrollbarLayerImpl::SetCurrentPos(float current_pos) { | 214 void ScrollbarLayerImpl::SetCurrentPos(float current_pos) { |
| 215 if (current_pos_ == current_pos) |
| 216 return; |
| 174 current_pos_ = current_pos; | 217 current_pos_ = current_pos; |
| 175 NoteLayerPropertyChanged(); | 218 NoteLayerPropertyChanged(); |
| 176 } | 219 } |
| 177 | 220 |
| 178 void ScrollbarLayerImpl::SetMaximum(int maximum) { | 221 void ScrollbarLayerImpl::SetMaximum(int maximum) { |
| 222 if (maximum_ == maximum) |
| 223 return; |
| 179 maximum_ = maximum; | 224 maximum_ = maximum; |
| 180 NoteLayerPropertyChanged(); | 225 NoteLayerPropertyChanged(); |
| 181 } | 226 } |
| 182 | 227 |
| 183 gfx::Rect ScrollbarLayerImpl::ComputeThumbQuadRect() const { | 228 gfx::Rect ScrollbarLayerImpl::ComputeThumbQuadRect() const { |
| 184 // Thumb extent is the length of the thumb in the scrolling direction, thumb | 229 // Thumb extent is the length of the thumb in the scrolling direction, thumb |
| 185 // thickness is in the perpendicular direction. Here's an example of a | 230 // thickness is in the perpendicular direction. Here's an example of a |
| 186 // horizontal scrollbar - inputs are above the scrollbar, computed values | 231 // horizontal scrollbar - inputs are above the scrollbar, computed values |
| 187 // below: | 232 // below: |
| 188 // | 233 // |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void ScrollbarLayerImpl::DidLoseOutputSurface() { | 319 void ScrollbarLayerImpl::DidLoseOutputSurface() { |
| 275 track_resource_id_ = 0; | 320 track_resource_id_ = 0; |
| 276 thumb_resource_id_ = 0; | 321 thumb_resource_id_ = 0; |
| 277 } | 322 } |
| 278 | 323 |
| 279 const char* ScrollbarLayerImpl::LayerTypeAsString() const { | 324 const char* ScrollbarLayerImpl::LayerTypeAsString() const { |
| 280 return "cc::ScrollbarLayerImpl"; | 325 return "cc::ScrollbarLayerImpl"; |
| 281 } | 326 } |
| 282 | 327 |
| 283 } // namespace cc | 328 } // namespace cc |
| OLD | NEW |