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/contents_scaling_layer.h" | 5 #include "cc/contents_scaling_layer.h" |
6 #include "ui/gfx/size_conversions.h" | 6 #include "ui/gfx/size_conversions.h" |
7 | 7 |
8 namespace cc { | 8 namespace cc { |
9 | 9 |
10 gfx::Size ContentsScalingLayer::computeContentBoundsForScale(float scaleX, float
scaleY) const { | 10 gfx::Size ContentsScalingLayer::computeContentBoundsForScale(float scaleX, float
scaleY) const { |
11 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX, scaleY)); | 11 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX, scaleY)); |
12 } | 12 } |
13 | 13 |
14 ContentsScalingLayer::ContentsScalingLayer() | 14 ContentsScalingLayer::ContentsScalingLayer() { |
15 : m_contentsScale(1.0) { | |
16 } | 15 } |
17 | 16 |
18 ContentsScalingLayer::~ContentsScalingLayer() { | 17 ContentsScalingLayer::~ContentsScalingLayer() { |
19 } | 18 } |
20 | 19 |
21 gfx::Size ContentsScalingLayer::contentBounds() const { | 20 void ContentsScalingLayer::setIdealContentsScale( |
22 return computeContentBoundsForScale(contentsScaleX(), contentsScaleY()); | 21 float ideal_contents_scale) { |
23 } | 22 if (m_drawProperties.ideal_contents_scale == ideal_contents_scale) |
| 23 return; |
24 | 24 |
25 float ContentsScalingLayer::contentsScaleX() const { | 25 m_drawProperties.ideal_contents_scale = ideal_contents_scale; |
26 return m_contentsScale; | 26 m_drawProperties.contents_scale_x = ideal_contents_scale; |
27 } | 27 m_drawProperties.contents_scale_y = ideal_contents_scale; |
28 | 28 didUpdateBounds(); |
29 float ContentsScalingLayer::contentsScaleY() const { | |
30 return m_contentsScale; | |
31 } | |
32 | |
33 void ContentsScalingLayer::setContentsScale(float contentsScale) { | |
34 if (m_contentsScale == contentsScale) | |
35 return; | |
36 m_contentsScale = contentsScale; | |
37 setNeedsDisplay(); | 29 setNeedsDisplay(); |
38 } | 30 } |
39 | 31 |
| 32 void ContentsScalingLayer::didUpdateBounds() { |
| 33 m_drawProperties.content_bounds = computeContentBoundsForScale( |
| 34 m_drawProperties.ideal_contents_scale, |
| 35 m_drawProperties.ideal_contents_scale); |
| 36 } |
| 37 |
40 } // namespace cc | 38 } // namespace cc |
OLD | NEW |