Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ui / base / layout.h
blobdf9f6cc5e7a1a417c32ec71bef500ce5aa98e2ef
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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_LAYOUT_H_
6 #define UI_BASE_LAYOUT_H_
8 #include <vector>
10 #include "build/build_config.h"
11 #include "ui/base/ui_base_export.h"
12 #include "ui/gfx/native_widget_types.h"
14 namespace ui {
16 // Supported UI scale factors for the platform. This is used as an index
17 // into the array |kScaleFactorScales| which maps the enum value to a float.
18 // SCALE_FACTOR_NONE is used for density independent resources such as
19 // string, html/js files or an image that can be used for any scale factors
20 // (such as wallpapers).
21 enum ScaleFactor {
22 SCALE_FACTOR_NONE = 0,
23 SCALE_FACTOR_100P,
24 SCALE_FACTOR_125P,
25 SCALE_FACTOR_133P,
26 SCALE_FACTOR_140P,
27 SCALE_FACTOR_150P,
28 SCALE_FACTOR_180P,
29 SCALE_FACTOR_200P,
30 SCALE_FACTOR_300P,
32 NUM_SCALE_FACTORS // This always appears last.
35 // Changes the value of GetSupportedScaleFactors() to |scale_factors|.
36 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the
37 // state of other tests.
38 UI_BASE_EXPORT void SetSupportedScaleFactors(
39 const std::vector<ScaleFactor>& scale_factors);
41 // Returns a vector with the scale factors which are supported by this
42 // platform, in ascending order.
43 UI_BASE_EXPORT const std::vector<ScaleFactor>& GetSupportedScaleFactors();
45 // Returns the actual image scale to be used for the scale factor passed in.
46 // On Windows high dpi, this returns the dpi scale for the display.
47 UI_BASE_EXPORT float GetImageScale(ScaleFactor scale_factor);
49 // Returns the supported ScaleFactor which most closely matches |scale|.
50 // Converting from float to ScaleFactor is inefficient and should be done as
51 // little as possible.
52 // TODO(oshima): Make ScaleFactor a class and remove this.
53 UI_BASE_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale);
55 // Returns the ScaleFactor used by |view|.
56 UI_BASE_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view);
58 // Returns true if |scale_factor| is supported by this platform.
59 UI_BASE_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor);
61 // Returns the scale factor closest to |scale| from the full list of factors.
62 // Note that it does NOT rely on the list of supported scale factors.
63 // Finding the closest match is inefficient and shouldn't be done frequently.
64 UI_BASE_EXPORT ScaleFactor FindClosestScaleFactorUnsafe(float scale);
66 // Returns the image scale for the scale factor passed in.
67 UI_BASE_EXPORT float GetScaleForScaleFactor(ScaleFactor scale_factor);
69 namespace test {
70 // Class which changes the value of GetSupportedScaleFactors() to
71 // |new_scale_factors| for the duration of its lifetime.
72 class UI_BASE_EXPORT ScopedSetSupportedScaleFactors {
73 public:
74 explicit ScopedSetSupportedScaleFactors(
75 const std::vector<ui::ScaleFactor>& new_scale_factors);
76 ~ScopedSetSupportedScaleFactors();
78 private:
79 std::vector<ui::ScaleFactor>* original_scale_factors_;
81 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors);
84 } // namespace test
86 } // namespace ui
88 #endif // UI_BASE_LAYOUT_H_