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

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

Issue 12746002: Re-implement overscan & Implement Display Rotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | « ash/display/display_controller_unittest.cc ('k') | ash/display/display_info.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) 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_DISPLAY_DISPLAY_INFO_H_ 5 #ifndef ASH_DISPLAY_DISPLAY_INFO_H_
6 #define ASH_DISPLAY_DISPLAY_INFO_H_ 6 #define ASH_DISPLAY_DISPLAY_INFO_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "ui/gfx/insets.h" 12 #include "ui/gfx/insets.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 14
15 namespace gfx { 15 namespace gfx {
16 class Display; 16 class Display;
17 } 17 }
18 18
19 namespace ash { 19 namespace ash {
20 namespace internal { 20 namespace internal {
21 21
22 // DisplayInfo contains metadata for each display. This is used to 22 // DisplayInfo contains metadata for each display. This is used to
23 // create |gfx::Display| as well as to maintain extra infomation 23 // create |gfx::Display| as well as to maintain extra infomation
24 // to manage displays in ash environment. 24 // to manage displays in ash environment.
25 // This class is intentionally made copiable. 25 // This class is intentionally made copiable.
26 class ASH_EXPORT DisplayInfo { 26 class ASH_EXPORT DisplayInfo {
27 public: 27 public:
28 // Screen Rotation in clock-wise degrees.
29 // TODO(oshima): move his to gfx::Display.
30 enum Rotation {
31 Rotate0 = 0,
sky 2013/03/11 20:52:13 Enums are all caps, eg ROTATE0 (or maybe ROTATE_0)
oshima 2013/03/11 21:45:49 Done.
32 Rotate90,
33 Rotate180,
34 Rotate270,
35 };
36
28 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display 37 // Creates a DisplayInfo from string spec. 100+200-1440x800 creates display
29 // whose size is 1440x800 at the location (100, 200) in screen's coordinates. 38 // whose size is 1440x800 at the location (100, 200) in host coordinates.
30 // The location can be omitted and be just "1440x800", which creates 39 // The location can be omitted and be just "1440x800", which creates
31 // display at the origin of the screen. An empty string creates 40 // display at the origin of the screen. An empty string creates
32 // the display with default size. 41 // the display with default size.
33 // The device scale factor can be specified by "*", like "1280x780*2", 42 // The device scale factor can be specified by "*", like "1280x780*2",
34 // or will use the value of |gfx::Display::GetForcedDeviceScaleFactor()| if 43 // or will use the value of |gfx::Display::GetForcedDeviceScaleFactor()| if
35 // --force-device-scale-factor is specified. 44 // --force-device-scale-factor is specified.
45 // Additiona properties can be specified followed by "/". 'o' adds
46 // default overscan insets (5%). 'r','l','b' rotates the display 90
47 // (to 'r'ight), 180 ('u'pside-down) and 270 degrees (to 'l'eft) respectively.
48 // For example, "1280x780*2/ob" creates a display_info whose native resolution
49 // is 1280x780 with 2.0 scale factor, with default overscan insets, and
50 // is flipped upside-down.
36 static DisplayInfo CreateFromSpec(const std::string& spec); 51 static DisplayInfo CreateFromSpec(const std::string& spec);
37 52
38 // Creates a DisplayInfo from string spec using given |id|. 53 // Creates a DisplayInfo from string spec using given |id|.
39 static DisplayInfo CreateFromSpecWithID(const std::string& spec, 54 static DisplayInfo CreateFromSpecWithID(const std::string& spec,
40 int64 id); 55 int64 id);
41 56
42 DisplayInfo(); 57 DisplayInfo();
43 DisplayInfo(int64 id, const std::string& name, bool has_overscan); 58 DisplayInfo(int64 id, const std::string& name, bool has_overscan);
44 ~DisplayInfo(); 59 ~DisplayInfo();
45 60
46 int64 id() const { return id_; } 61 int64 id() const { return id_; }
47 62
48 // The name of the display. 63 // The name of the display.
49 const std::string& name() const { return name_; } 64 const std::string& name() const { return name_; }
50 65
51 // True if the display has overscan. 66 // True if the display has overscan.
52 bool has_overscan() const { return has_overscan_; } 67 bool has_overscan() const { return has_overscan_; }
53 68
69 void set_rotation(Rotation rotation) { rotation_ = rotation; }
70 Rotation rotation() const { return rotation_; }
71
54 // Gets/Sets the device scale factor of the display. 72 // Gets/Sets the device scale factor of the display.
55 float device_scale_factor() const { return device_scale_factor_; } 73 float device_scale_factor() const { return device_scale_factor_; }
56 void set_device_scale_factor(float scale) { device_scale_factor_ = scale; } 74 void set_device_scale_factor(float scale) { device_scale_factor_ = scale; }
57 75
58 // The original bounds_in_pixel for the display. This can be different from 76 // The bounds_in_pixel for the display. The size of this can be different from
59 // the |bounds_in_pixel| in case of overscan insets. 77 // the |size_in_pixel| in case of overscan insets.
60 const gfx::Rect original_bounds_in_pixel() const { 78 const gfx::Rect bounds_in_pixel() const {
61 return original_bounds_in_pixel_; 79 return bounds_in_pixel_;
62 } 80 }
63 81
64 // The bounds for the display in pixels. 82 // The size for the display in pixels.
65 const gfx::Rect bounds_in_pixel() const { return bounds_in_pixel_; } 83 const gfx::Size& size_in_pixel() const { return size_in_pixel_; }
66 84
67 // The overscan insets for the display in DIP. The default value is 85 // The overscan insets for the display in DIP.
68 // (-1, -1, -1, -1), which indicates that no overscan should be applied.
69 const gfx::Insets& overscan_insets_in_dip() const { 86 const gfx::Insets& overscan_insets_in_dip() const {
70 return overscan_insets_in_dip_; 87 return overscan_insets_in_dip_;
71 } 88 }
72 89
73 // Copy the display info except for two fields that can be modified by a user 90 // Copy the display info except for two fields that can be modified by a user
74 // (|has_custom_overscan_insets_| and |custom_overscan_insets_in_dip_|). 91 // (|has_custom_overscan_insets_| and |custom_overscan_insets_in_dip_|).
75 void CopyFromNative(const DisplayInfo& native_info); 92 void CopyFromNative(const DisplayInfo& native_info);
76 93
77 // Set the |original_bounds_in_pixel| and |bounds_in_pixel| to 94 // Update the |bounds_in_pixel_| and |size_in_pixel_| using
78 // given |bounds|. 95 // given |bounds_in_pixel|.
79 void SetBounds(const gfx::Rect& bounds_in_pixel); 96 void SetBounds(const gfx::Rect& bounds_in_pixel);
80 97
81 // Sets the |bounds_in_pixel| and updates original bounds based on
82 // current overscan configuration.
83 void UpdateBounds(const gfx::Rect& bounds_in_pixel);
84
85 // Update the |bounds_in_pixel| according to the current overscan 98 // Update the |bounds_in_pixel| according to the current overscan
86 // settings. 99 // and rotation settings.
87 // 1) If can_overscan is false, then |bounds_in_pixel| is equal to 100 // 1) If this has custom overscan insets
88 // |original_bounds_in_pixel|.
89 // 2) If this has custom overscan insets
90 // (i.e. |has_custom_overscan_insets_| is true), it simply applies 101 // (i.e. |has_custom_overscan_insets_| is true), it simply applies
91 // the existing |overscan_insets_in_dip_|. 102 // the existing |overscan_insets_in_dip_|.
92 // 3) If this doesn't have custom overscan insets, then this updates 103 // 2) If this doesn't have custom overscan insets but the display claims
104 // that it has overscan (|has_overscan_| is true), then updates
93 // |overscan_insets_in_dip_| to default value (5% of the display size) 105 // |overscan_insets_in_dip_| to default value (5% of the display size)
94 // and apply the insets. 106 // and apply the insets.
95 void UpdateOverscanInfo(bool can_overscan); 107 // 3) Otherwise, clear the overscan insets.
108 void UpdateDisplaySize();
96 109
97 // Sets/Clears the overscan insets. 110 // Sets/Clears the overscan insets.
98 void SetOverscanInsets(bool custom, 111 void SetOverscanInsets(bool custom,
99 const gfx::Insets& insets_in_dip); 112 const gfx::Insets& insets_in_dip);
113 gfx::Insets GetOverscanInsetsInPixel() const;
100 void clear_has_custom_overscan_insets() { 114 void clear_has_custom_overscan_insets() {
101 has_custom_overscan_insets_ = false; 115 has_custom_overscan_insets_ = false;
102 } 116 }
103 117
104 // Returns a string representation of the DisplayInfo; 118 // Returns a string representation of the DisplayInfo;
105 std::string ToString() const; 119 std::string ToString() const;
106 120
107 private: 121 private:
108 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); 122 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets);
109 // Set the overscan flag. Used for test. 123 // Set the overscan flag. Used for test.
110 void set_has_overscan_for_test(bool has_overscan) { 124 void set_has_overscan_for_test(bool has_overscan) {
111 has_overscan_ = has_overscan; 125 has_overscan_ = has_overscan;
112 } 126 }
113 127
114 int64 id_; 128 int64 id_;
115 std::string name_; 129 std::string name_;
116 bool has_overscan_; 130 bool has_overscan_;
131 Rotation rotation_;
117 float device_scale_factor_; 132 float device_scale_factor_;
118 gfx::Rect original_bounds_in_pixel_;
119 gfx::Rect bounds_in_pixel_; 133 gfx::Rect bounds_in_pixel_;
134 // The size of the display in use. The size can be different from the size
135 // of |bounds_in_pixel_| if the display has overscan insets and/or rotation.
136 gfx::Size size_in_pixel_;
120 gfx::Insets overscan_insets_in_dip_; 137 gfx::Insets overscan_insets_in_dip_;
121 138
122 // True if the |overscan_insets_in_dip| is specified by a user. This 139 // True if the |overscan_insets_in_dip| is specified by a user. This
123 // is used not to override the insets by native insets. 140 // is used not to override the insets by native insets.
124 bool has_custom_overscan_insets_; 141 bool has_custom_overscan_insets_;
125 }; 142 };
126 143
127 } // namespace internal 144 } // namespace internal
128 } // namespace ash 145 } // namespace ash
129 146
130 #endif // ASH_DISPLAY_DISPLAY_INFO_H_ 147 #endif // ASH_DISPLAY_DISPLAY_INFO_H_
OLDNEW
« no previous file with comments | « ash/display/display_controller_unittest.cc ('k') | ash/display/display_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698