Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: ui/base/layout.h

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and vars to make image_scale more clear Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 // Returns the float scale value for |scale_factor|.
50 UI_EXPORT float GetScaleFactorScale(ScaleFactor scale_factor);
51
52 // Returns the supported ScaleFactor which most closely matches |scale|.
53 // Converting from float to ScaleFactor is inefficient and should be done as
54 // little as possible.
55 // TODO(oshima): Make ScaleFactor a class and remove this.
56 UI_EXPORT ScaleFactor GetScaleFactorFromScale(float scale);
57
58 // Returns the ScaleFactor used by |view|.
59 UI_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view);
60
61 // Returns the maximum device scale factor supported by this platform.
62 UI_EXPORT ScaleFactor GetMaxScaleFactor();
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
68 // Returns true if |scale_factor| is supported by this platform.
69 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor);
70
71 namespace test {
72
73 // Changes the value of GetSupportedScaleFactors() to |scale_factors|. 49 // Changes the value of GetSupportedScaleFactors() to |scale_factors|.
74 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the 50 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the
75 // state of other tests. 51 // state of other tests.
76 UI_EXPORT void SetSupportedScaleFactors( 52 UI_EXPORT void SetSupportedScaleFactors(
77 const std::vector<ScaleFactor>& scale_factors); 53 const std::vector<ScaleFactor>& scale_factors);
78 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
59 // Returns the float scale value for |scale_factor|.
60 UI_EXPORT float GetImageScale(ScaleFactor scale_factor);
61
62 // Returns the supported ScaleFactor which most closely matches |scale|.
63 // Converting from float to ScaleFactor is inefficient and should be done as
64 // little as possible.
65 // TODO(oshima): Make ScaleFactor a class and remove this.
66 UI_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale);
67
68 // Returns the ScaleFactor used by |view|.
69 UI_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view);
70
71 // Returns the maximum device scale factor supported by this platform.
72 UI_EXPORT ScaleFactor GetMaxSupportedScaleFactor();
73
74 // Returns true if |scale_factor| is supported by this platform.
75 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor);
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
82 namespace test {
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698