OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef UI_BASE_LAYOUT_H_ | 5 #ifndef UI_BASE_LAYOUT_H_ |
6 #define UI_BASE_LAYOUT_H_ | 6 #define UI_BASE_LAYOUT_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Changes the value of GetSupportedScaleFactors() to |scale_factors|. | 50 // Changes the value of GetSupportedScaleFactors() to |scale_factors|. |
51 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the | 51 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the |
52 // state of other tests. | 52 // state of other tests. |
53 UI_BASE_EXPORT void SetSupportedScaleFactors( | 53 UI_BASE_EXPORT void SetSupportedScaleFactors( |
54 const std::vector<ScaleFactor>& scale_factors); | 54 const std::vector<ScaleFactor>& scale_factors); |
55 | 55 |
56 // Returns a vector with the scale factors which are supported by this | 56 // Returns a vector with the scale factors which are supported by this |
57 // platform, in ascending order. | 57 // platform, in ascending order. |
58 UI_BASE_EXPORT const std::vector<ScaleFactor>& GetSupportedScaleFactors(); | 58 UI_BASE_EXPORT const std::vector<ScaleFactor>& GetSupportedScaleFactors(); |
59 | 59 |
60 // Returns the float scale value for |scale_factor|. | 60 // Returns the actual image scale to be used for the scale factor passed in. |
| 61 // On Windows high dpi, this returns the dpi scale for the display. |
61 UI_BASE_EXPORT float GetImageScale(ScaleFactor scale_factor); | 62 UI_BASE_EXPORT float GetImageScale(ScaleFactor scale_factor); |
62 | 63 |
63 // Returns the supported ScaleFactor which most closely matches |scale|. | 64 // Returns the supported ScaleFactor which most closely matches |scale|. |
64 // Converting from float to ScaleFactor is inefficient and should be done as | 65 // Converting from float to ScaleFactor is inefficient and should be done as |
65 // little as possible. | 66 // little as possible. |
66 // TODO(oshima): Make ScaleFactor a class and remove this. | 67 // TODO(oshima): Make ScaleFactor a class and remove this. |
67 UI_BASE_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale); | 68 UI_BASE_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale); |
68 | 69 |
69 // Returns the ScaleFactor used by |view|. | 70 // Returns the ScaleFactor used by |view|. |
70 UI_BASE_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view); | 71 UI_BASE_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view); |
71 | 72 |
72 // Returns true if |scale_factor| is supported by this platform. | 73 // Returns true if |scale_factor| is supported by this platform. |
73 UI_BASE_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor); | 74 UI_BASE_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor); |
74 | 75 |
75 // Returns the scale factor closest to |scale| from the full list of factors. | 76 // Returns the scale factor closest to |scale| from the full list of factors. |
76 // Note that it does NOT rely on the list of supported scale factors. | 77 // Note that it does NOT rely on the list of supported scale factors. |
77 // Finding the closest match is inefficient and shouldn't be done frequently. | 78 // Finding the closest match is inefficient and shouldn't be done frequently. |
78 UI_BASE_EXPORT ScaleFactor FindClosestScaleFactorUnsafe(float scale); | 79 UI_BASE_EXPORT ScaleFactor FindClosestScaleFactorUnsafe(float scale); |
79 | 80 |
| 81 // Returns the image scale for the scale factor passed in. |
| 82 UI_BASE_EXPORT float GetScaleForScaleFactor(ScaleFactor scale_factor); |
| 83 |
80 namespace test { | 84 namespace test { |
81 // Class which changes the value of GetSupportedScaleFactors() to | 85 // Class which changes the value of GetSupportedScaleFactors() to |
82 // |new_scale_factors| for the duration of its lifetime. | 86 // |new_scale_factors| for the duration of its lifetime. |
83 class UI_BASE_EXPORT ScopedSetSupportedScaleFactors { | 87 class UI_BASE_EXPORT ScopedSetSupportedScaleFactors { |
84 public: | 88 public: |
85 explicit ScopedSetSupportedScaleFactors( | 89 explicit ScopedSetSupportedScaleFactors( |
86 const std::vector<ui::ScaleFactor>& new_scale_factors); | 90 const std::vector<ui::ScaleFactor>& new_scale_factors); |
87 ~ScopedSetSupportedScaleFactors(); | 91 ~ScopedSetSupportedScaleFactors(); |
88 | 92 |
89 private: | 93 private: |
90 std::vector<ui::ScaleFactor>* original_scale_factors_; | 94 std::vector<ui::ScaleFactor>* original_scale_factors_; |
91 | 95 |
92 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors); | 96 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors); |
93 }; | 97 }; |
94 | 98 |
95 } // namespace test | 99 } // namespace test |
96 | 100 |
97 } // namespace ui | 101 } // namespace ui |
98 | 102 |
99 #endif // UI_BASE_LAYOUT_H_ | 103 #endif // UI_BASE_LAYOUT_H_ |
OLD | NEW |