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

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: Fix new usage of scale in FastShowPickler Created 7 years, 2 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
« no previous file with comments | « ui/base/cursor/cursors_aura.cc ('k') | ui/base/layout.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 true if |scale_factor| is supported by this platform.
72 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor);
73
74 // Returns the scale factor closest to |scale| from the full list of factors.
75 // Note that it does NOT rely on the list of supported scale factors.
76 // Finding the closest match is inefficient and shouldn't be done frequently.
77 UI_EXPORT ScaleFactor FindClosestScaleFactorUnsafe(float scale);
78
79 namespace test {
79 // Class which changes the value of GetSupportedScaleFactors() to 80 // Class which changes the value of GetSupportedScaleFactors() to
80 // |new_scale_factors| for the duration of its lifetime. 81 // |new_scale_factors| for the duration of its lifetime.
81 class UI_EXPORT ScopedSetSupportedScaleFactors { 82 class UI_EXPORT ScopedSetSupportedScaleFactors {
82 public: 83 public:
83 explicit ScopedSetSupportedScaleFactors( 84 explicit ScopedSetSupportedScaleFactors(
84 const std::vector<ui::ScaleFactor>& new_scale_factors); 85 const std::vector<ui::ScaleFactor>& new_scale_factors);
85 ~ScopedSetSupportedScaleFactors(); 86 ~ScopedSetSupportedScaleFactors();
86 87
87 private: 88 private:
88 const std::vector<ui::ScaleFactor> original_scale_factors_; 89 std::vector<ui::ScaleFactor>* original_scale_factors_;
89 90
90 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors); 91 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors);
91 }; 92 };
92 93
93 } // namespace test 94 } // namespace test
94 95
95 } // namespace ui 96 } // namespace ui
96 97
97 #endif // UI_BASE_LAYOUT_H_ 98 #endif // UI_BASE_LAYOUT_H_
OLDNEW
« no previous file with comments | « ui/base/cursor/cursors_aura.cc ('k') | ui/base/layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698