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

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

Issue 21297003: Add ability to set resolution on external display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 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 | Annotate | Revision Log
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 #include <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "ui/gfx/display.h" 14 #include "ui/gfx/display.h"
15 #include "ui/gfx/size_conversions.h" 15 #include "ui/gfx/size_conversions.h"
16 #include "ui/gfx/size_f.h" 16 #include "ui/gfx/size_f.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 #include "ui/aura/root_window_host.h" 19 #include "ui/aura/root_window_host.h"
20 #endif 20 #endif
21 21
22 namespace ash { 22 namespace ash {
23 namespace internal { 23 namespace internal {
24 24
25 Resolution::Resolution(const gfx::Size& size, bool interlaced)
26 : size(size),
27 interlaced(interlaced) {
28 }
29
25 // satic 30 // satic
26 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { 31 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) {
27 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); 32 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID);
28 } 33 }
29 34
30 // static 35 // static
31 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, 36 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
32 int64 id) { 37 int64 id) {
33 // Default bounds for a display. 38 // Default bounds for a display.
34 const int kDefaultHostWindowX = 200; 39 const int kDefaultHostWindowX = 200;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 &device_scale_factor) >= 4) { 96 &device_scale_factor) >= 4) {
92 bounds_in_pixel.SetRect(x, y, width, height); 97 bounds_in_pixel.SetRect(x, y, width, height);
93 } 98 }
94 if (id == gfx::Display::kInvalidDisplayID) 99 if (id == gfx::Display::kInvalidDisplayID)
95 id = synthesized_display_id++; 100 id = synthesized_display_id++;
96 DisplayInfo display_info( 101 DisplayInfo display_info(
97 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); 102 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan);
98 display_info.set_device_scale_factor(device_scale_factor); 103 display_info.set_device_scale_factor(device_scale_factor);
99 display_info.set_rotation(rotation); 104 display_info.set_rotation(rotation);
100 display_info.set_ui_scale(ui_scale); 105 display_info.set_ui_scale(ui_scale);
101 display_info.SetBounds(bounds_in_pixel); 106 display_info.SetBounds(bounds_in_pixel);
Jun Mukai 2013/07/31 23:10:00 should we add the specified display's size to |res
oshima 2013/07/31 23:29:26 I didn't add it because it's not necessary, and in
102 107
103 // To test the overscan, it creates the default 5% overscan. 108 // To test the overscan, it creates the default 5% overscan.
104 if (has_overscan) { 109 if (has_overscan) {
105 int width = bounds_in_pixel.width() / device_scale_factor / 40; 110 int width = bounds_in_pixel.width() / device_scale_factor / 40;
106 int height = bounds_in_pixel.height() / device_scale_factor / 40; 111 int height = bounds_in_pixel.height() / device_scale_factor / 40;
107 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); 112 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width));
108 display_info.UpdateDisplaySize(); 113 display_info.UpdateDisplaySize();
109 } 114 }
110 115
111 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() 116 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString()
(...skipping 29 matching lines...) Expand all
141 146
142 void DisplayInfo::Copy(const DisplayInfo& native_info) { 147 void DisplayInfo::Copy(const DisplayInfo& native_info) {
143 DCHECK(id_ == native_info.id_); 148 DCHECK(id_ == native_info.id_);
144 name_ = native_info.name_; 149 name_ = native_info.name_;
145 has_overscan_ = native_info.has_overscan_; 150 has_overscan_ = native_info.has_overscan_;
146 151
147 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); 152 DCHECK(!native_info.bounds_in_pixel_.IsEmpty());
148 bounds_in_pixel_ = native_info.bounds_in_pixel_; 153 bounds_in_pixel_ = native_info.bounds_in_pixel_;
149 size_in_pixel_ = native_info.size_in_pixel_; 154 size_in_pixel_ = native_info.size_in_pixel_;
150 device_scale_factor_ = native_info.device_scale_factor_; 155 device_scale_factor_ = native_info.device_scale_factor_;
156 resolutions_ = native_info.resolutions_;
151 157
152 // Copy overscan_insets_in_dip_ if it's not empty. This is for test 158 // Copy overscan_insets_in_dip_ if it's not empty. This is for test
153 // cases which use "/o" annotation which sets the overscan inset 159 // cases which use "/o" annotation which sets the overscan inset
154 // to native, and that overscan has to be propagated. This does not 160 // to native, and that overscan has to be propagated. This does not
155 // happen on the real environment. 161 // happen on the real environment.
156 if (!native_info.overscan_insets_in_dip_.empty()) 162 if (!native_info.overscan_insets_in_dip_.empty())
157 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; 163 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_;
158 164
159 // Rotation_ and ui_scale_ are given by preference, or unit 165 // Rotation_ and ui_scale_ are given by preference, or unit
160 // tests. Don't copy if this native_info came from 166 // tests. Don't copy if this native_info came from
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 "overscan=%s, rotation=%d, ui-scale=%f", 213 "overscan=%s, rotation=%d, ui-scale=%f",
208 static_cast<long long int>(id_), 214 static_cast<long long int>(id_),
209 bounds_in_pixel_.ToString().c_str(), 215 bounds_in_pixel_.ToString().c_str(),
210 size_in_pixel_.ToString().c_str(), 216 size_in_pixel_.ToString().c_str(),
211 device_scale_factor_, 217 device_scale_factor_,
212 overscan_insets_in_dip_.ToString().c_str(), 218 overscan_insets_in_dip_.ToString().c_str(),
213 rotation_degree, 219 rotation_degree,
214 ui_scale_); 220 ui_scale_);
215 } 221 }
216 222
223 std::string DisplayInfo::ToFullString() const {
224 std::string resolutions_str;
225 std::vector<Resolution>::const_iterator iter = resolutions_.begin();
226 for (; iter != resolutions_.end(); ++iter) {
227 if (resolutions_str.empty())
Daniel Erat 2013/07/31 22:10:17 the other way, right? you should only append the c
oshima 2013/07/31 23:29:26 oops, you're right. done.
228 resolutions_str += ",";
229 resolutions_str += iter->size.ToString();
230 if (iter->interlaced)
231 resolutions_str += "(i)";
232 }
233 return ToString() + ", resolutions=" + resolutions_str;
234 }
235
217 } // namespace internal 236 } // namespace internal
218 } // namespace ash 237 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698