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

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: more tests fixed 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 // Figure out how to not need this.
55 // void setNative(bool native) { native_ = native; }
oshima 2016/08/02 19:44:57 looks like you already figured out?
rjkroege 2016/08/04 00:12:04 true. :-) Removed.
56
57 // Missing from ui::DisplayMode
58 float ui_scale() const { return ui_scale_; }
59 float device_scale_factor() const { return device_scale_factor_; }
60
61 private:
62 ~DisplayMode();
63 friend class base::RefCounted<DisplayMode>;
64
65 gfx::Size size_; // Physical pixel size of the display.
66 float refresh_rate_; // Refresh rate of the display, in Hz.
67 bool is_interlaced_; // True if mode is interlaced.
68 bool native_; // True if mode is native mode of the display.
69 float ui_scale_; // The UI scale factor of the mode.
70 float device_scale_factor_; // The device scale factor of the mode.
71
72 DISALLOW_COPY_AND_ASSIGN(DisplayMode);
43 }; 73 };
44 74
45 // DisplayInfo contains metadata for each display. This is used to 75 // DisplayInfo contains metadata for each display. This is used to
46 // create |display::Display| as well as to maintain extra infomation 76 // create |display::Display| as well as to maintain extra infomation
47 // to manage displays in ash environment. 77 // to manage displays in ash environment.
48 // This class is intentionally made copiable. 78 // This class is intentionally made copiable.
49 class ASH_EXPORT DisplayInfo { 79 class ASH_EXPORT DisplayInfo {
50 public: 80 public:
81 using DisplayModeList = std::vector<scoped_refptr<DisplayMode>>;
82
51 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display 83 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display
52 // whose size is 1440x800 at the location (100, 200) in host coordinates. 84 // whose size is 1440x800 at the location (100, 200) in host coordinates.
53 // The format is 85 // The format is
54 // 86 //
55 // [origin-]widthxheight[*device_scale_factor][#resolutions list] 87 // [origin-]widthxheight[*device_scale_factor][#resolutions list]
56 // [/<properties>][@ui-scale] 88 // [/<properties>][@ui-scale]
57 // 89 //
58 // where [] are optional: 90 // where [] are optional:
59 // - |origin| is given in x+y- format. 91 // - |origin| is given in x+y- format.
60 // - |device_scale_factor| is either 2 or 1 (or empty). 92 // - |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); 232 void SetOverscanInsets(const gfx::Insets& insets_in_dip);
201 gfx::Insets GetOverscanInsetsInPixel() const; 233 gfx::Insets GetOverscanInsetsInPixel() const;
202 234
203 // Sets/Gets the flag to clear overscan insets. 235 // Sets/Gets the flag to clear overscan insets.
204 bool clear_overscan_insets() const { return clear_overscan_insets_; } 236 bool clear_overscan_insets() const { return clear_overscan_insets_; }
205 void set_clear_overscan_insets(bool clear) { clear_overscan_insets_ = clear; } 237 void set_clear_overscan_insets(bool clear) { clear_overscan_insets_ = clear; }
206 238
207 void set_native(bool native) { native_ = native; } 239 void set_native(bool native) { native_ = native; }
208 bool native() const { return native_; } 240 bool native() const { return native_; }
209 241
210 const std::vector<DisplayMode>& display_modes() const { 242 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 243 // Sets the display mode list. The mode list will be sorted for the
214 // display. 244 // display.
215 void SetDisplayModes(const std::vector<DisplayMode>& display_modes); 245 void SetDisplayModes(const DisplayModeList& display_modes);
216 246
217 // Returns the native mode size. If a native mode is not present, return an 247 // Returns the native mode size. If a native mode is not present, return an
218 // empty size. 248 // empty size.
219 gfx::Size GetNativeModeSize() const; 249 gfx::Size GetNativeModeSize() const;
220 250
221 ui::ColorCalibrationProfile color_profile() const { return color_profile_; } 251 ui::ColorCalibrationProfile color_profile() const { return color_profile_; }
222 252
223 // Sets the color profile. It will ignore if the specified |profile| is not in 253 // Sets the color profile. It will ignore if the specified |profile| is not in
224 // |available_color_profiles_|. 254 // |available_color_profiles_|.
225 void SetColorProfile(ui::ColorCalibrationProfile profile); 255 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 336 // 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 337 // display is configured in a non-native mode, only parts of the display will
308 // be used such that the aspect ratio is preserved. 338 // be used such that the aspect ratio is preserved.
309 bool is_aspect_preserving_scaling_; 339 bool is_aspect_preserving_scaling_;
310 340
311 // True if the displays' overscan inset should be cleared. This is 341 // True if the displays' overscan inset should be cleared. This is
312 // to distinguish the empty overscan insets from native display info. 342 // to distinguish the empty overscan insets from native display info.
313 bool clear_overscan_insets_; 343 bool clear_overscan_insets_;
314 344
315 // The list of modes supported by this display. 345 // The list of modes supported by this display.
316 std::vector<DisplayMode> display_modes_; 346 DisplayModeList display_modes_;
317 347
318 // The current profile of the color calibration. 348 // The current profile of the color calibration.
319 ui::ColorCalibrationProfile color_profile_; 349 ui::ColorCalibrationProfile color_profile_;
320 350
321 // The list of available variations for the color calibration. 351 // The list of available variations for the color calibration.
322 std::vector<ui::ColorCalibrationProfile> available_color_profiles_; 352 std::vector<ui::ColorCalibrationProfile> available_color_profiles_;
323 353
324 // Maximum cursor size. 354 // Maximum cursor size.
325 gfx::Size maximum_cursor_size_; 355 gfx::Size maximum_cursor_size_;
326 356
327 // If you add a new member, you need to update Copy(). 357 // If you add a new member, you need to update Copy().
328 }; 358 };
329 359
330 // Resets the synthesized display id for testing. This 360 // Resets the synthesized display id for testing. This
331 // is necessary to avoid overflowing the output index. 361 // is necessary to avoid overflowing the output index.
332 ASH_EXPORT void ResetDisplayIdForTest(); 362 ASH_EXPORT void ResetDisplayIdForTest();
333 363
334 } // namespace ash 364 } // namespace ash
335 365
336 #endif // ASH_COMMON_DISPLAY_DISPLAY_INFO_H_ 366 #endif // ASH_COMMON_DISPLAY_DISPLAY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698