Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 ASH_COMMON_DISPLAY_DISPLAY_INFO_H_ | 5 #ifndef UI_DISPLAY_MANAGER_MANAGED_DISPLAY_INFO_H_ |
| 6 #define ASH_COMMON_DISPLAY_DISPLAY_INFO_H_ | 6 #define UI_DISPLAY_MANAGER_MANAGED_DISPLAY_INFO_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "ash/ash_export.h" | |
| 15 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 16 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 17 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 17 #include "ui/display/display_export.h" | |
| 18 #include "ui/display/types/display_constants.h" | 18 #include "ui/display/types/display_constants.h" |
| 19 #include "ui/gfx/geometry/insets.h" | 19 #include "ui/gfx/geometry/insets.h" |
| 20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ui { |
|
kylechar
2016/08/29 16:01:33
Should this be namespace display? It seems like al
rjkroege
2016/08/29 22:21:59
Done.
| |
| 23 | 23 |
| 24 // A class that represents the display's mode info. | 24 // A class that represents the display's mode info. |
| 25 class ASH_EXPORT ManagedDisplayMode | 25 class DISPLAY_EXPORT ManagedDisplayMode |
| 26 : public base::RefCounted<ManagedDisplayMode> { | 26 : public base::RefCounted<ManagedDisplayMode> { |
| 27 public: | 27 public: |
| 28 ManagedDisplayMode(); | 28 ManagedDisplayMode(); |
| 29 | 29 |
| 30 ManagedDisplayMode(const gfx::Size& size); | 30 ManagedDisplayMode(const gfx::Size& size); |
| 31 | 31 |
| 32 ManagedDisplayMode(const gfx::Size& size, | 32 ManagedDisplayMode(const gfx::Size& size, |
| 33 float refresh_rate, | 33 float refresh_rate, |
| 34 bool is_interlaced, | 34 bool is_interlaced, |
| 35 bool native); | 35 bool native); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 63 gfx::Size size_; // Physical pixel size of the display. | 63 gfx::Size size_; // Physical pixel size of the display. |
| 64 float refresh_rate_; // Refresh rate of the display, in Hz. | 64 float refresh_rate_; // Refresh rate of the display, in Hz. |
| 65 bool is_interlaced_; // True if mode is interlaced. | 65 bool is_interlaced_; // True if mode is interlaced. |
| 66 bool native_; // True if mode is native mode of the display. | 66 bool native_; // True if mode is native mode of the display. |
| 67 float ui_scale_; // The UI scale factor of the mode. | 67 float ui_scale_; // The UI scale factor of the mode. |
| 68 float device_scale_factor_; // The device scale factor of the mode. | 68 float device_scale_factor_; // The device scale factor of the mode. |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(ManagedDisplayMode); | 70 DISALLOW_COPY_AND_ASSIGN(ManagedDisplayMode); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // DisplayInfo contains metadata for each display. This is used to | 73 // ManagedDisplayInfo contains metadata for each display. This is used to |
| 74 // create |display::Display| as well as to maintain extra infomation | 74 // create |display::Display| as well as to maintain extra infomation |
| 75 // to manage displays in ash environment. | 75 // to manage displays in ash environment. |
| 76 // This class is intentionally made copiable. | 76 // This class is intentionally made copiable. |
| 77 class ASH_EXPORT DisplayInfo { | 77 class DISPLAY_EXPORT ManagedDisplayInfo { |
| 78 public: | 78 public: |
| 79 using ManagedDisplayModeList = std::vector<scoped_refptr<ManagedDisplayMode>>; | 79 using ManagedDisplayModeList = std::vector<scoped_refptr<ManagedDisplayMode>>; |
| 80 | 80 |
| 81 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display | 81 // Creates a ManagedDisplayInfo from string spec. 100+200-1440x800 creates |
| 82 // display | |
| 82 // whose size is 1440x800 at the location (100, 200) in host coordinates. | 83 // whose size is 1440x800 at the location (100, 200) in host coordinates. |
| 83 // The format is | 84 // The format is |
| 84 // | 85 // |
| 85 // [origin-]widthxheight[*device_scale_factor][#resolutions list] | 86 // [origin-]widthxheight[*device_scale_factor][#resolutions list] |
| 86 // [/<properties>][@ui-scale] | 87 // [/<properties>][@ui-scale] |
| 87 // | 88 // |
| 88 // where [] are optional: | 89 // where [] are optional: |
| 89 // - |origin| is given in x+y- format. | 90 // - |origin| is given in x+y- format. |
| 90 // - |device_scale_factor| is either 2 or 1 (or empty). | 91 // - |device_scale_factor| is either 2 or 1 (or empty). |
| 91 // - properties can combination of 'o', which adds default overscan insets | 92 // - properties can combination of 'o', which adds default overscan insets |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 106 // "300x200/ol" | 107 // "300x200/ol" |
| 107 // 300x200 window at 0,0 origin. 1x device scale factor. | 108 // 300x200 window at 0,0 origin. 1x device scale factor. |
| 108 // with 5% overscan. rotated to left (90 degree counter clockwise). | 109 // with 5% overscan. rotated to left (90 degree counter clockwise). |
| 109 // 1.0 ui scale. | 110 // 1.0 ui scale. |
| 110 // "10+20-300x200/u@1.5" | 111 // "10+20-300x200/u@1.5" |
| 111 // 300x200 window at 10,20 origin. 1x device scale factor. | 112 // 300x200 window at 10,20 origin. 1x device scale factor. |
| 112 // no overscan. flipped upside-down (180 degree) and 1.5 ui scale. | 113 // no overscan. flipped upside-down (180 degree) and 1.5 ui scale. |
| 113 // "200x100#300x200|200x100%59.0|100x100%60" | 114 // "200x100#300x200|200x100%59.0|100x100%60" |
| 114 // 200x100 window at 0,0 origin, with 3 possible resolutions, | 115 // 200x100 window at 0,0 origin, with 3 possible resolutions, |
| 115 // 300x200, 200x100 at 59 Hz, and 100x100 at 60 Hz. | 116 // 300x200, 200x100 at 59 Hz, and 100x100 at 60 Hz. |
| 116 static DisplayInfo CreateFromSpec(const std::string& spec); | 117 static ManagedDisplayInfo CreateFromSpec(const std::string& spec); |
| 117 | 118 |
| 118 // Creates a DisplayInfo from string spec using given |id|. | 119 // Creates a ManagedDisplayInfo from string spec using given |id|. |
| 119 static DisplayInfo CreateFromSpecWithID(const std::string& spec, int64_t id); | 120 static ManagedDisplayInfo CreateFromSpecWithID(const std::string& spec, |
| 121 int64_t id); | |
| 120 | 122 |
| 121 // When this is set to true on the device whose internal display has | 123 // When this is set to true on the device whose internal display has |
| 122 // 1.25 dsf, Chrome uses 1.0f as a default scale factor, and uses | 124 // 1.25 dsf, Chrome uses 1.0f as a default scale factor, and uses |
| 123 // dsf 1.25 when UI scaling is set to 0.8f. | 125 // dsf 1.25 when UI scaling is set to 0.8f. |
| 124 static void SetUse125DSFForUIScalingForTest(bool enable); | 126 static void SetUse125DSFForUIScalingForTest(bool enable); |
| 125 | 127 |
| 126 DisplayInfo(); | 128 ManagedDisplayInfo(); |
| 127 DisplayInfo(int64_t id, const std::string& name, bool has_overscan); | 129 ManagedDisplayInfo(int64_t id, const std::string& name, bool has_overscan); |
| 128 DisplayInfo(const DisplayInfo& other); | 130 ManagedDisplayInfo(const ManagedDisplayInfo& other); |
| 129 ~DisplayInfo(); | 131 ~ManagedDisplayInfo(); |
| 130 | 132 |
| 131 int64_t id() const { return id_; } | 133 int64_t id() const { return id_; } |
| 132 | 134 |
| 133 // The name of the display. | 135 // The name of the display. |
| 134 const std::string& name() const { return name_; } | 136 const std::string& name() const { return name_; } |
| 135 | 137 |
| 136 // The path to the display device in the sysfs filesystem. | 138 // The path to the display device in the sysfs filesystem. |
| 137 void set_sys_path(const base::FilePath& sys_path) { sys_path_ = sys_path; } | 139 void set_sys_path(const base::FilePath& sys_path) { sys_path_ = sys_path; } |
| 138 const base::FilePath& sys_path() const { return sys_path_; } | 140 const base::FilePath& sys_path() const { return sys_path_; } |
| 139 | 141 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 // uses 1.0f DFS unless 0.8x UI scaling is specified. | 211 // uses 1.0f DFS unless 0.8x UI scaling is specified. |
| 210 float GetEffectiveDeviceScaleFactor() const; | 212 float GetEffectiveDeviceScaleFactor() const; |
| 211 | 213 |
| 212 // Returns the ui scale used for the device scale factor. This | 214 // Returns the ui scale used for the device scale factor. This |
| 213 // return 1.0f if the ui scale and dsf are both set to 2.0. | 215 // return 1.0f if the ui scale and dsf are both set to 2.0. |
| 214 float GetEffectiveUIScale() const; | 216 float GetEffectiveUIScale() const; |
| 215 | 217 |
| 216 // Copy the display info except for fields that can be modified by a | 218 // Copy the display info except for fields that can be modified by a |
| 217 // user (|rotation_| and |configured_ui_scale_|). |rotation_| and | 219 // user (|rotation_| and |configured_ui_scale_|). |rotation_| and |
| 218 // |configured_ui_scale_| are copied when the |another_info| isn't native one. | 220 // |configured_ui_scale_| are copied when the |another_info| isn't native one. |
| 219 void Copy(const DisplayInfo& another_info); | 221 void Copy(const ManagedDisplayInfo& another_info); |
| 220 | 222 |
| 221 // Update the |bounds_in_native_| and |size_in_pixel_| using | 223 // Update the |bounds_in_native_| and |size_in_pixel_| using |
| 222 // given |bounds_in_native|. | 224 // given |bounds_in_native|. |
| 223 void SetBounds(const gfx::Rect& bounds_in_native); | 225 void SetBounds(const gfx::Rect& bounds_in_native); |
| 224 | 226 |
| 225 // Update the |bounds_in_native| according to the current overscan | 227 // Update the |bounds_in_native| according to the current overscan |
| 226 // and rotation settings. | 228 // and rotation settings. |
| 227 void UpdateDisplaySize(); | 229 void UpdateDisplaySize(); |
| 228 | 230 |
| 229 // Sets/Clears the overscan insets. | 231 // Sets/Clears the overscan insets. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 void set_is_aspect_preserving_scaling(bool value) { | 274 void set_is_aspect_preserving_scaling(bool value) { |
| 273 is_aspect_preserving_scaling_ = value; | 275 is_aspect_preserving_scaling_ = value; |
| 274 } | 276 } |
| 275 | 277 |
| 276 // Maximum cursor size in native pixels. | 278 // Maximum cursor size in native pixels. |
| 277 const gfx::Size& maximum_cursor_size() const { return maximum_cursor_size_; } | 279 const gfx::Size& maximum_cursor_size() const { return maximum_cursor_size_; } |
| 278 void set_maximum_cursor_size(const gfx::Size& size) { | 280 void set_maximum_cursor_size(const gfx::Size& size) { |
| 279 maximum_cursor_size_ = size; | 281 maximum_cursor_size_ = size; |
| 280 } | 282 } |
| 281 | 283 |
| 282 // Returns a string representation of the DisplayInfo, excluding display | 284 // Returns a string representation of the ManagedDisplayInfo, excluding |
| 285 // display | |
| 283 // modes. | 286 // modes. |
| 284 std::string ToString() const; | 287 std::string ToString() const; |
| 285 | 288 |
| 286 // Returns a string representation of the DisplayInfo, including display | 289 // Returns a string representation of the ManagedDisplayInfo, including |
| 290 // display | |
| 287 // modes. | 291 // modes. |
| 288 std::string ToFullString() const; | 292 std::string ToFullString() const; |
| 289 | 293 |
| 290 private: | 294 private: |
| 291 // Returns true if this display should use DSF=1.25 for UI scaling; i.e. | 295 // Returns true if this display should use DSF=1.25 for UI scaling; i.e. |
| 292 // SetUse125DSFForUIScaling(true) is called and this is the internal display. | 296 // SetUse125DSFForUIScaling(true) is called and this is the internal display. |
| 293 bool Use125DSFForUIScaling() const; | 297 bool Use125DSFForUIScaling() const; |
| 294 | 298 |
| 295 int64_t id_; | 299 int64_t id_; |
| 296 std::string name_; | 300 std::string name_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 std::vector<ui::ColorCalibrationProfile> available_color_profiles_; | 354 std::vector<ui::ColorCalibrationProfile> available_color_profiles_; |
| 351 | 355 |
| 352 // Maximum cursor size. | 356 // Maximum cursor size. |
| 353 gfx::Size maximum_cursor_size_; | 357 gfx::Size maximum_cursor_size_; |
| 354 | 358 |
| 355 // If you add a new member, you need to update Copy(). | 359 // If you add a new member, you need to update Copy(). |
| 356 }; | 360 }; |
| 357 | 361 |
| 358 // Resets the synthesized display id for testing. This | 362 // Resets the synthesized display id for testing. This |
| 359 // is necessary to avoid overflowing the output index. | 363 // is necessary to avoid overflowing the output index. |
| 360 ASH_EXPORT void ResetDisplayIdForTest(); | 364 void DISPLAY_EXPORT ResetDisplayIdForTest(); |
| 361 | 365 |
| 362 } // namespace ash | 366 } // namespace ui |
| 363 | 367 |
| 364 #endif // ASH_COMMON_DISPLAY_DISPLAY_INFO_H_ | 368 #endif // UI_DISPLAY_MANAGER_MANAGED_DISPLAY_INFO_H_ |
| OLD | NEW |