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 "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); | 163 UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_); |
164 UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); | 164 UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_); |
165 } else { | 165 } else { |
166 UpdateProperty(0, &thumb_thickness_); | 166 UpdateProperty(0, &thumb_thickness_); |
167 UpdateProperty(0, &thumb_length_); | 167 UpdateProperty(0, &thumb_length_); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 void PaintedScrollbarLayer::UpdateInternalContentScale() { | 171 void PaintedScrollbarLayer::UpdateInternalContentScale() { |
172 float scale = GetLayerTree()->device_scale_factor(); | 172 float scale = GetLayerTree()->device_scale_factor(); |
173 if (GetLayerTree() | 173 if (layer_tree_host() |
174 ->GetSettings() | 174 ->GetSettings() |
175 .layer_transforms_should_scale_layer_contents) { | 175 .layer_transforms_should_scale_layer_contents) { |
176 gfx::Transform transform; | 176 gfx::Transform transform; |
177 transform = draw_property_utils::ScreenSpaceTransform( | 177 transform = draw_property_utils::ScreenSpaceTransform( |
178 this, GetLayerTree()->property_trees()->transform_tree); | 178 this, GetLayerTree()->property_trees()->transform_tree); |
179 | 179 |
180 gfx::Vector2dF transform_scales = | 180 gfx::Vector2dF transform_scales = |
181 MathUtil::ComputeTransform2dScaleComponents(transform, scale); | 181 MathUtil::ComputeTransform2dScaleComponents(transform, scale); |
182 scale = std::max(transform_scales.x(), transform_scales.y()); | 182 scale = std::max(transform_scales.x(), transform_scales.y()); |
183 } | 183 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 thumb_resource_ = nullptr; | 222 thumb_resource_ = nullptr; |
223 SetNeedsPushProperties(); | 223 SetNeedsPushProperties(); |
224 updated = true; | 224 updated = true; |
225 } | 225 } |
226 | 226 |
227 if (update_rect().IsEmpty() && track_resource_) | 227 if (update_rect().IsEmpty() && track_resource_) |
228 return updated; | 228 return updated; |
229 | 229 |
230 if (!track_resource_ || scrollbar_->NeedsPaintPart(TRACK)) { | 230 if (!track_resource_ || scrollbar_->NeedsPaintPart(TRACK)) { |
231 track_resource_ = ScopedUIResource::Create( | 231 track_resource_ = ScopedUIResource::Create( |
232 GetLayerTree()->GetUIResourceManager(), | 232 layer_tree_host()->GetUIResourceManager(), |
233 RasterizeScrollbarPart(track_layer_rect, scaled_track_rect, TRACK)); | 233 RasterizeScrollbarPart(track_layer_rect, scaled_track_rect, TRACK)); |
234 } | 234 } |
235 | 235 |
236 gfx::Rect thumb_layer_rect = OriginThumbRect(); | 236 gfx::Rect thumb_layer_rect = OriginThumbRect(); |
237 gfx::Rect scaled_thumb_rect = | 237 gfx::Rect scaled_thumb_rect = |
238 ScrollbarLayerRectToContentRect(thumb_layer_rect); | 238 ScrollbarLayerRectToContentRect(thumb_layer_rect); |
239 if (has_thumb_ && !scaled_thumb_rect.IsEmpty()) { | 239 if (has_thumb_ && !scaled_thumb_rect.IsEmpty()) { |
240 if (!thumb_resource_ || scrollbar_->NeedsPaintPart(THUMB) || | 240 if (!thumb_resource_ || scrollbar_->NeedsPaintPart(THUMB) || |
241 scaled_thumb_rect.size() != | 241 scaled_thumb_rect.size() != |
242 thumb_resource_->GetBitmap(0, false).GetSize()) { | 242 thumb_resource_->GetBitmap(0, false).GetSize()) { |
243 thumb_resource_ = ScopedUIResource::Create( | 243 thumb_resource_ = ScopedUIResource::Create( |
244 GetLayerTree()->GetUIResourceManager(), | 244 layer_tree_host()->GetUIResourceManager(), |
245 RasterizeScrollbarPart(thumb_layer_rect, scaled_thumb_rect, THUMB)); | 245 RasterizeScrollbarPart(thumb_layer_rect, scaled_thumb_rect, THUMB)); |
246 } | 246 } |
247 thumb_opacity_ = scrollbar_->ThumbOpacity(); | 247 thumb_opacity_ = scrollbar_->ThumbOpacity(); |
248 } | 248 } |
249 | 249 |
250 // UI resources changed so push properties is needed. | 250 // UI resources changed so push properties is needed. |
251 SetNeedsPushProperties(); | 251 SetNeedsPushProperties(); |
252 updated = true; | 252 updated = true; |
253 return updated; | 253 return updated; |
254 } | 254 } |
(...skipping 28 matching lines...) Expand all Loading... |
283 | 283 |
284 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 284 scrollbar_->PaintPart(&skcanvas, part, layer_rect); |
285 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 285 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
286 // allocation and copying. | 286 // allocation and copying. |
287 skbitmap.setImmutable(); | 287 skbitmap.setImmutable(); |
288 | 288 |
289 return UIResourceBitmap(skbitmap); | 289 return UIResourceBitmap(skbitmap); |
290 } | 290 } |
291 | 291 |
292 } // namespace cc | 292 } // namespace cc |
OLD | NEW |