| 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 28 matching lines...) Expand all Loading... |
| 39 SCALE_FACTOR_125P, | 39 SCALE_FACTOR_125P, |
| 40 SCALE_FACTOR_133P, | 40 SCALE_FACTOR_133P, |
| 41 SCALE_FACTOR_140P, | 41 SCALE_FACTOR_140P, |
| 42 SCALE_FACTOR_150P, | 42 SCALE_FACTOR_150P, |
| 43 SCALE_FACTOR_180P, | 43 SCALE_FACTOR_180P, |
| 44 SCALE_FACTOR_200P, | 44 SCALE_FACTOR_200P, |
| 45 | 45 |
| 46 NUM_SCALE_FACTORS // This always appears last. | 46 NUM_SCALE_FACTORS // This always appears last. |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // Changes the value of GetSupportedScaleFactors() to |scale_factors|. |
| 50 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the |
| 51 // state of other tests. |
| 52 UI_EXPORT void SetSupportedScaleFactors( |
| 53 const std::vector<ScaleFactor>& scale_factors); |
| 54 |
| 55 // Returns a vector with the scale factors which are supported by this |
| 56 // platform, in ascending order. |
| 57 UI_EXPORT const std::vector<ScaleFactor>& GetSupportedScaleFactors(); |
| 58 |
| 49 // Returns the float scale value for |scale_factor|. | 59 // Returns the float scale value for |scale_factor|. |
| 50 UI_EXPORT float GetScaleFactorScale(ScaleFactor scale_factor); | 60 UI_EXPORT float GetScaleFactorScale(ScaleFactor scale_factor); |
| 51 | 61 |
| 52 // Returns the supported ScaleFactor which most closely matches |scale|. | 62 // Returns the supported ScaleFactor which most closely matches |scale|. |
| 53 // Converting from float to ScaleFactor is inefficient and should be done as | 63 // Converting from float to ScaleFactor is inefficient and should be done as |
| 54 // little as possible. | 64 // little as possible. |
| 55 // TODO(oshima): Make ScaleFactor a class and remove this. | 65 // TODO(oshima): Make ScaleFactor a class and remove this. |
| 56 UI_EXPORT ScaleFactor GetScaleFactorFromScale(float scale); | 66 UI_EXPORT ScaleFactor GetScaleFactorFromScale(float scale); |
| 57 | 67 |
| 58 // Returns the ScaleFactor used by |view|. | 68 // Returns the ScaleFactor used by |view|. |
| 59 UI_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view); | 69 UI_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view); |
| 60 | 70 |
| 61 // Returns the maximum device scale factor supported by this platform. | 71 // Returns the maximum device scale factor supported by this platform. |
| 62 UI_EXPORT ScaleFactor GetMaxScaleFactor(); | 72 UI_EXPORT ScaleFactor GetMaxSupportedScaleFactor(); |
| 63 | |
| 64 // Returns a vector with the scale factors which are supported by this | |
| 65 // platform, in ascending order. | |
| 66 UI_EXPORT std::vector<ScaleFactor> GetSupportedScaleFactors(); | |
| 67 | 73 |
| 68 // Returns true if |scale_factor| is supported by this platform. | 74 // Returns true if |scale_factor| is supported by this platform. |
| 69 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor); | 75 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor); |
| 70 | 76 |
| 77 // Returns the scale factor closest to |scale| from the full list of factors. |
| 78 // Note that it does NOT rely on the list of supported scale factors. |
| 79 // Finding the closest match is inefficient and shouldn't be done frequently. |
| 80 UI_EXPORT ScaleFactor FindClosestScaleFactorUnsafe(float scale); |
| 81 |
| 71 namespace test { | 82 namespace test { |
| 72 | |
| 73 // Changes the value of GetSupportedScaleFactors() to |scale_factors|. | |
| 74 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the | |
| 75 // state of other tests. | |
| 76 UI_EXPORT void SetSupportedScaleFactors( | |
| 77 const std::vector<ScaleFactor>& scale_factors); | |
| 78 | |
| 79 // Class which changes the value of GetSupportedScaleFactors() to | 83 // Class which changes the value of GetSupportedScaleFactors() to |
| 80 // |new_scale_factors| for the duration of its lifetime. | 84 // |new_scale_factors| for the duration of its lifetime. |
| 81 class UI_EXPORT ScopedSetSupportedScaleFactors { | 85 class UI_EXPORT ScopedSetSupportedScaleFactors { |
| 82 public: | 86 public: |
| 83 explicit ScopedSetSupportedScaleFactors( | 87 explicit ScopedSetSupportedScaleFactors( |
| 84 const std::vector<ui::ScaleFactor>& new_scale_factors); | 88 const std::vector<ui::ScaleFactor>& new_scale_factors); |
| 85 ~ScopedSetSupportedScaleFactors(); | 89 ~ScopedSetSupportedScaleFactors(); |
| 86 | 90 |
| 87 private: | 91 private: |
| 88 const std::vector<ui::ScaleFactor> original_scale_factors_; | 92 const std::vector<ui::ScaleFactor> original_scale_factors_; |
| 89 | 93 |
| 90 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors); | 94 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors); |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 } // namespace test | 97 } // namespace test |
| 94 | 98 |
| 95 } // namespace ui | 99 } // namespace ui |
| 96 | 100 |
| 97 #endif // UI_BASE_LAYOUT_H_ | 101 #endif // UI_BASE_LAYOUT_H_ |
| OLD | NEW |