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

Side by Side Diff: ash/common/display/display_info.h

Issue 2196923002: Make ash::DisplayMode more like ui::DisplayMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 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
OLDNEW
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 ASH_COMMON_DISPLAY_DISPLAY_INFO_H_
6 #define ASH_COMMON_DISPLAY_DISPLAY_INFO_H_ 6 #define ASH_COMMON_DISPLAY_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" 14 #include "ash/ash_export.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/memory/ref_counted.h"
16 #include "ui/display/display.h" 17 #include "ui/display/display.h"
17 #include "ui/display/types/display_constants.h" 18 #include "ui/display/types/display_constants.h"
18 #include "ui/gfx/geometry/insets.h" 19 #include "ui/gfx/geometry/insets.h"
19 #include "ui/gfx/geometry/rect.h" 20 #include "ui/gfx/geometry/rect.h"
20 21
21 namespace ash { 22 namespace ash {
22 23
23 // A struct that represents the display's mode info. 24 // A class that represents the display's mode info.
24 struct ASH_EXPORT DisplayMode { 25 class ASH_EXPORT DisplayMode : public base::RefCounted<DisplayMode> {
26 public:
25 DisplayMode(); 27 DisplayMode();
28
29 DisplayMode(const gfx::Size& size);
30
26 DisplayMode(const gfx::Size& size, 31 DisplayMode(const gfx::Size& size,
27 float refresh_rate, 32 float refresh_rate,
28 bool interlaced, 33 bool is_interlaced,
29 bool native); 34 bool native);
30 35
36 DisplayMode(const gfx::Size& size,
37 float refresh_rate,
38 bool is_interlaced,
39 bool native,
40 float ui_scale,
41 float device_scale_factor);
31 // Returns the size in DIP which is visible to the user. 42 // Returns the size in DIP which is visible to the user.
32 gfx::Size GetSizeInDIP(bool is_internal) const; 43 gfx::Size GetSizeInDIP(bool is_internal) const;
33 44
34 // Returns true if |other| has same size and scale factors. 45 // Returns true if |other| has same size and scale factors.
35 bool IsEquivalent(const DisplayMode& other) const; 46 bool IsEquivalent(const scoped_refptr<DisplayMode>& other) const;
36 47
37 gfx::Size size; // Physical pixel size of the display. 48 const gfx::Size& size() const { return size_; }
38 float refresh_rate; // Refresh rate of the display, in Hz. 49 bool is_interlaced() const { return is_interlaced_; }
39 bool interlaced; // True if mode is interlaced. 50 float refresh_rate() const { return refresh_rate_; }
40 bool native; // True if mode is native mode of the display. 51
41 float ui_scale; // The UI scale factor of the mode. 52 bool native() const { return native_; }
42 float device_scale_factor; // The device scale factor of the mode. 53
54 // Missing from ui::DisplayMode
55 float ui_scale() const { return ui_scale_; }
56 float device_scale_factor() const { return device_scale_factor_; }
57
58 private:
59 ~DisplayMode();
60 friend class base::RefCounted<DisplayMode>;
61
62 gfx::Size size_; // Physical pixel size of the display.
63 float refresh_rate_; // Refresh rate of the display, in Hz.
64 bool is_interlaced_; // True if mode is interlaced.
65 bool native_; // True if mode is native mode of the display.
66 float ui_scale_; // The UI scale factor of the mode.
67 float device_scale_factor_; // The device scale factor of the mode.
68
69 DISALLOW_COPY_AND_ASSIGN(DisplayMode);
43 }; 70 };
44 71
45 // DisplayInfo contains metadata for each display. This is used to 72 // DisplayInfo contains metadata for each display. This is used to
46 // create |display::Display| as well as to maintain extra infomation 73 // create |display::Display| as well as to maintain extra infomation
47 // to manage displays in ash environment. 74 // to manage displays in ash environment.
48 // This class is intentionally made copiable. 75 // This class is intentionally made copiable.
49 class ASH_EXPORT DisplayInfo { 76 class ASH_EXPORT DisplayInfo {
50 public: 77 public:
78 using DisplayModeList = std::vector<scoped_refptr<DisplayMode>>;
79
51 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display 80 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display
52 // whose size is 1440x800 at the location (100, 200) in host coordinates. 81 // whose size is 1440x800 at the location (100, 200) in host coordinates.
53 // The format is 82 // The format is
54 // 83 //
55 // [origin-]widthxheight[*device_scale_factor][#resolutions list] 84 // [origin-]widthxheight[*device_scale_factor][#resolutions list]
56 // [/<properties>][@ui-scale] 85 // [/<properties>][@ui-scale]
57 // 86 //
58 // where [] are optional: 87 // where [] are optional:
59 // - |origin| is given in x+y- format. 88 // - |origin| is given in x+y- format.
60 // - |device_scale_factor| is either 2 or 1 (or empty). 89 // - |device_scale_factor| is either 2 or 1 (or empty).
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void SetOverscanInsets(const gfx::Insets& insets_in_dip); 229 void SetOverscanInsets(const gfx::Insets& insets_in_dip);
201 gfx::Insets GetOverscanInsetsInPixel() const; 230 gfx::Insets GetOverscanInsetsInPixel() const;
202 231
203 // Sets/Gets the flag to clear overscan insets. 232 // Sets/Gets the flag to clear overscan insets.
204 bool clear_overscan_insets() const { return clear_overscan_insets_; } 233 bool clear_overscan_insets() const { return clear_overscan_insets_; }
205 void set_clear_overscan_insets(bool clear) { clear_overscan_insets_ = clear; } 234 void set_clear_overscan_insets(bool clear) { clear_overscan_insets_ = clear; }
206 235
207 void set_native(bool native) { native_ = native; } 236 void set_native(bool native) { native_ = native; }
208 bool native() const { return native_; } 237 bool native() const { return native_; }
209 238
210 const std::vector<DisplayMode>& display_modes() const { 239 const DisplayModeList& display_modes() const { return display_modes_; }
211 return display_modes_;
212 }
213 // Sets the display mode list. The mode list will be sorted for the 240 // Sets the display mode list. The mode list will be sorted for the
214 // display. 241 // display.
215 void SetDisplayModes(const std::vector<DisplayMode>& display_modes); 242 void SetDisplayModes(const DisplayModeList& display_modes);
216 243
217 // Returns the native mode size. If a native mode is not present, return an 244 // Returns the native mode size. If a native mode is not present, return an
218 // empty size. 245 // empty size.
219 gfx::Size GetNativeModeSize() const; 246 gfx::Size GetNativeModeSize() const;
220 247
221 ui::ColorCalibrationProfile color_profile() const { return color_profile_; } 248 ui::ColorCalibrationProfile color_profile() const { return color_profile_; }
222 249
223 // Sets the color profile. It will ignore if the specified |profile| is not in 250 // Sets the color profile. It will ignore if the specified |profile| is not in
224 // |available_color_profiles_|. 251 // |available_color_profiles_|.
225 void SetColorProfile(ui::ColorCalibrationProfile profile); 252 void SetColorProfile(ui::ColorCalibrationProfile profile);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // True if the display is configured to preserve the aspect ratio. When the 333 // True if the display is configured to preserve the aspect ratio. When the
307 // display is configured in a non-native mode, only parts of the display will 334 // display is configured in a non-native mode, only parts of the display will
308 // be used such that the aspect ratio is preserved. 335 // be used such that the aspect ratio is preserved.
309 bool is_aspect_preserving_scaling_; 336 bool is_aspect_preserving_scaling_;
310 337
311 // True if the displays' overscan inset should be cleared. This is 338 // True if the displays' overscan inset should be cleared. This is
312 // to distinguish the empty overscan insets from native display info. 339 // to distinguish the empty overscan insets from native display info.
313 bool clear_overscan_insets_; 340 bool clear_overscan_insets_;
314 341
315 // The list of modes supported by this display. 342 // The list of modes supported by this display.
316 std::vector<DisplayMode> display_modes_; 343 DisplayModeList display_modes_;
317 344
318 // The current profile of the color calibration. 345 // The current profile of the color calibration.
319 ui::ColorCalibrationProfile color_profile_; 346 ui::ColorCalibrationProfile color_profile_;
320 347
321 // The list of available variations for the color calibration. 348 // The list of available variations for the color calibration.
322 std::vector<ui::ColorCalibrationProfile> available_color_profiles_; 349 std::vector<ui::ColorCalibrationProfile> available_color_profiles_;
323 350
324 // Maximum cursor size. 351 // Maximum cursor size.
325 gfx::Size maximum_cursor_size_; 352 gfx::Size maximum_cursor_size_;
326 353
327 // If you add a new member, you need to update Copy(). 354 // If you add a new member, you need to update Copy().
328 }; 355 };
329 356
330 // Resets the synthesized display id for testing. This 357 // Resets the synthesized display id for testing. This
331 // is necessary to avoid overflowing the output index. 358 // is necessary to avoid overflowing the output index.
332 ASH_EXPORT void ResetDisplayIdForTest(); 359 ASH_EXPORT void ResetDisplayIdForTest();
333 360
334 } // namespace ash 361 } // namespace ash
335 362
336 #endif // ASH_COMMON_DISPLAY_DISPLAY_INFO_H_ 363 #endif // ASH_COMMON_DISPLAY_DISPLAY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698