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::updateContentsScale(float ideal_contents_scale) { |
danakj
2012/12/14 20:37:23
What do you think of making this method just retur
enne (OOO)
2012/12/14 22:06:05
Done.
| |
22 return computeContentBoundsForScale(contentsScaleX(), contentsScaleY()); | 21 m_drawProperties.contents_scale_x = ideal_contents_scale; |
22 m_drawProperties.contents_scale_y = ideal_contents_scale; | |
23 m_drawProperties.content_bounds = computeContentBoundsForScale( | |
24 contentsScaleX(), | |
25 contentsScaleY()); | |
23 } | 26 } |
24 | 27 |
25 float ContentsScalingLayer::contentsScaleX() const { | 28 void ContentsScalingLayer::didUpdateBounds() { |
26 return m_contentsScale; | 29 m_drawProperties.content_bounds = computeContentBoundsForScale( |
27 } | 30 contentsScaleX(), |
28 | 31 contentsScaleY()); |
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(); | |
38 } | 32 } |
39 | 33 |
40 } // namespace cc | 34 } // namespace cc |
OLD | NEW |