| 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/scrollbar_layer.h" | 5 #include "cc/scrollbar_layer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
| 10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 gfx::Size scaledBounds = computeContentBoundsForScale(scale, scale); | 61 gfx::Size scaledBounds = computeContentBoundsForScale(scale, scale); |
| 62 if (scaledBounds.width() > maxTextureSize() || scaledBounds.height() > maxTe
xtureSize()) { | 62 if (scaledBounds.width() > maxTextureSize() || scaledBounds.height() > maxTe
xtureSize()) { |
| 63 if (scaledBounds.width() > scaledBounds.height()) | 63 if (scaledBounds.width() > scaledBounds.height()) |
| 64 return (maxTextureSize() - 1) / static_cast<float>(bounds().width()
); | 64 return (maxTextureSize() - 1) / static_cast<float>(bounds().width()
); |
| 65 else | 65 else |
| 66 return (maxTextureSize() - 1) / static_cast<float>(bounds().height(
)); | 66 return (maxTextureSize() - 1) / static_cast<float>(bounds().height(
)); |
| 67 } | 67 } |
| 68 return scale; | 68 return scale; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void ScrollbarLayer::setContentsScale(float contentsScale) { | 71 void ScrollbarLayer::calculateContentsScale( |
| 72 contentsScale = clampScaleToMaxTextureSize(contentsScale); | 72 float idealContentsScale, |
| 73 ContentsScalingLayer::setContentsScale(contentsScale); | 73 float* contentsScaleX, |
| 74 DCHECK_LE(contentBounds().width(), maxTextureSize()); | 74 float* contentsScaleY, |
| 75 DCHECK_LE(contentBounds().height(), maxTextureSize()); | 75 gfx::Size* contentBounds) |
| 76 { |
| 77 ContentsScalingLayer::calculateContentsScale( |
| 78 clampScaleToMaxTextureSize(idealContentsScale), |
| 79 contentsScaleX, |
| 80 contentsScaleY, |
| 81 contentBounds); |
| 82 DCHECK_LE(contentBounds->width(), maxTextureSize()); |
| 83 DCHECK_LE(contentBounds->height(), maxTextureSize()); |
| 76 } | 84 } |
| 77 | 85 |
| 78 void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer) | 86 void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer) |
| 79 { | 87 { |
| 80 ContentsScalingLayer::pushPropertiesTo(layer); | 88 ContentsScalingLayer::pushPropertiesTo(layer); |
| 81 | 89 |
| 82 ScrollbarLayerImpl* scrollbarLayer = static_cast<ScrollbarLayerImpl*>(layer)
; | 90 ScrollbarLayerImpl* scrollbarLayer = static_cast<ScrollbarLayerImpl*>(layer)
; |
| 83 | 91 |
| 84 if (!scrollbarLayer->scrollbarGeometry()) | 92 if (!scrollbarLayer->scrollbarGeometry()) |
| 85 scrollbarLayer->setScrollbarGeometry(ScrollbarGeometryFixedThumb::create
(make_scoped_ptr(m_geometry->clone()))); | 93 scrollbarLayer->setScrollbarGeometry(ScrollbarGeometryFixedThumb::create
(make_scoped_ptr(m_geometry->clone()))); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); | 312 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); |
| 305 | 313 |
| 306 // Consider the thumb to be at the origin when painting. | 314 // Consider the thumb to be at the origin when painting. |
| 307 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 315 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
| 308 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(0, 0,
thumbRect.width, thumbRect.height)); | 316 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(0, 0,
thumbRect.width, thumbRect.height)); |
| 309 if (!originThumbRect.IsEmpty()) | 317 if (!originThumbRect.IsEmpty()) |
| 310 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 318 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
| 311 } | 319 } |
| 312 | 320 |
| 313 } // namespace cc | 321 } // namespace cc |
| OLD | NEW |