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

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

Issue 22662005: Don't remember best resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « ash/display/display_info.h ('k') | ash/display/display_info_unittest.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 #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"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 int x = 0, y = 0, width, height; 91 int x = 0, y = 0, width, height;
92 float device_scale_factor = 1.0f; 92 float device_scale_factor = 1.0f;
93 if (sscanf(main_spec.c_str(), "%dx%d*%f", 93 if (sscanf(main_spec.c_str(), "%dx%d*%f",
94 &width, &height, &device_scale_factor) >= 2 || 94 &width, &height, &device_scale_factor) >= 2 ||
95 sscanf(main_spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, 95 sscanf(main_spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
96 &device_scale_factor) >= 4) { 96 &device_scale_factor) >= 4) {
97 bounds_in_pixel.SetRect(x, y, width, height); 97 bounds_in_pixel.SetRect(x, y, width, height);
98 } 98 }
99
100 std::vector<Resolution> resolutions;
101 if (Tokenize(main_spec, "#", &parts) == 2) {
102 main_spec = parts[0];
103 std::string resolution_list = parts[1];
104 count = Tokenize(resolution_list, "|", &parts);
105 for (size_t i = 0; i < count; ++i) {
106 std::string resolution = parts[i];
107 int width, height;
108 if (sscanf(resolution.c_str(), "%dx%d", &width, &height) == 2)
109 resolutions.push_back(Resolution(gfx::Size(width, height), false));
110 }
111 }
112
99 if (id == gfx::Display::kInvalidDisplayID) 113 if (id == gfx::Display::kInvalidDisplayID)
100 id = synthesized_display_id++; 114 id = synthesized_display_id++;
101 DisplayInfo display_info( 115 DisplayInfo display_info(
102 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); 116 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan);
103 display_info.set_device_scale_factor(device_scale_factor); 117 display_info.set_device_scale_factor(device_scale_factor);
104 display_info.set_rotation(rotation); 118 display_info.set_rotation(rotation);
105 display_info.set_ui_scale(ui_scale); 119 display_info.set_ui_scale(ui_scale);
106 display_info.SetBounds(bounds_in_pixel); 120 display_info.SetBounds(bounds_in_pixel);
121 display_info.set_resolutions(resolutions);
107 122
108 // To test the overscan, it creates the default 5% overscan. 123 // To test the overscan, it creates the default 5% overscan.
109 if (has_overscan) { 124 if (has_overscan) {
110 int width = bounds_in_pixel.width() / device_scale_factor / 40; 125 int width = bounds_in_pixel.width() / device_scale_factor / 40;
111 int height = bounds_in_pixel.height() / device_scale_factor / 40; 126 int height = bounds_in_pixel.height() / device_scale_factor / 40;
112 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); 127 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width));
113 display_info.UpdateDisplaySize(); 128 display_info.UpdateDisplaySize();
114 } 129 }
115 130
116 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() 131 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString()
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 resolutions_str += ","; 243 resolutions_str += ",";
229 resolutions_str += iter->size.ToString(); 244 resolutions_str += iter->size.ToString();
230 if (iter->interlaced) 245 if (iter->interlaced)
231 resolutions_str += "(i)"; 246 resolutions_str += "(i)";
232 } 247 }
233 return ToString() + ", resolutions=" + resolutions_str; 248 return ToString() + ", resolutions=" + resolutions_str;
234 } 249 }
235 250
236 } // namespace internal 251 } // namespace internal
237 } // namespace ash 252 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_info.h ('k') | ash/display/display_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698