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

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

Issue 1263853002: Unified Desktop: Support 2xDSF display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « ash/display/display_util.h ('k') | ash/display/root_window_transformers.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/display/display_util.h" 5 #include "ash/display/display_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DisplayMode mode = native_mode; 119 DisplayMode mode = native_mode;
120 mode.ui_scale = ui_scale; 120 mode.ui_scale = ui_scale;
121 mode.native = (ui_scale == native_ui_scale); 121 mode.native = (ui_scale == native_ui_scale);
122 display_mode_list.push_back(mode); 122 display_mode_list.push_back(mode);
123 } 123 }
124 return display_mode_list; 124 return display_mode_list;
125 } 125 }
126 126
127 std::vector<DisplayMode> CreateUnifiedDisplayModeList( 127 std::vector<DisplayMode> CreateUnifiedDisplayModeList(
128 const DisplayMode& native_mode, 128 const DisplayMode& native_mode,
129 const std::set<float>& scales) { 129 const std::set<std::pair<float, float>>& dsf_scale_list) {
130 std::vector<DisplayMode> display_mode_list; 130 std::vector<DisplayMode> display_mode_list;
131 131
132 for (float ui_scale : scales) { 132 for (auto& pair : dsf_scale_list) {
133 DisplayMode mode = native_mode; 133 DisplayMode mode = native_mode;
134 mode.device_scale_factor = pair.first;
134 gfx::SizeF scaled_size(native_mode.size); 135 gfx::SizeF scaled_size(native_mode.size);
135 scaled_size.Scale(ui_scale); 136 scaled_size.Scale(pair.second);
136 mode.size = gfx::ToFlooredSize(scaled_size); 137 mode.size = gfx::ToFlooredSize(scaled_size);
137 mode.native = mode.size == native_mode.size; 138 mode.native = false;
138 display_mode_list.push_back(mode); 139 display_mode_list.push_back(mode);
139 } 140 }
141 // Sort the mode by the size in DIP.
142 std::sort(display_mode_list.begin(), display_mode_list.end(),
143 [](const DisplayMode& a, const DisplayMode& b) {
144 return a.GetSizeInDIP(false).GetArea() <
145 b.GetSizeInDIP(false).GetArea();
146 });
140 return display_mode_list; 147 return display_mode_list;
141 } 148 }
142 149
143 bool GetDisplayModeForResolution(const DisplayInfo& info, 150 bool GetDisplayModeForResolution(const DisplayInfo& info,
144 const gfx::Size& resolution, 151 const gfx::Size& resolution,
145 DisplayMode* out) { 152 DisplayMode* out) {
146 if (gfx::Display::IsInternalDisplayId(info.id())) 153 if (gfx::Display::IsInternalDisplayId(info.id()))
147 return false; 154 return false;
148 155
149 const std::vector<DisplayMode>& modes = info.display_modes(); 156 const std::vector<DisplayMode>& modes = info.display_modes();
(...skipping 24 matching lines...) Expand all
174 FindNextMode(iter, modes, up, out); 181 FindNextMode(iter, modes, up, out);
175 return true; 182 return true;
176 } 183 }
177 184
178 bool GetDisplayModeForNextResolution(const DisplayInfo& info, 185 bool GetDisplayModeForNextResolution(const DisplayInfo& info,
179 bool up, 186 bool up,
180 DisplayMode* out) { 187 DisplayMode* out) {
181 if (gfx::Display::IsInternalDisplayId(info.id())) 188 if (gfx::Display::IsInternalDisplayId(info.id()))
182 return false; 189 return false;
183 const std::vector<DisplayMode>& modes = info.display_modes(); 190 const std::vector<DisplayMode>& modes = info.display_modes();
184 const gfx::Size& resolution = info.size_in_pixel(); 191 DisplayMode tmp(info.size_in_pixel(), 0.0f, false, false);
192 tmp.device_scale_factor = info.device_scale_factor();
193 gfx::Size resolution = tmp.GetSizeInDIP(false);
185 auto iter = std::find_if(modes.begin(), modes.end(), 194 auto iter = std::find_if(modes.begin(), modes.end(),
186 [resolution](const DisplayMode& mode) { 195 [resolution](const DisplayMode& mode) {
187 return mode.size == resolution; 196 return mode.GetSizeInDIP(false) == resolution;
188 }); 197 });
189 FindNextMode(iter, modes, up, out); 198 FindNextMode(iter, modes, up, out);
190 return true; 199 return true;
191 } 200 }
192 201
193 bool SetDisplayUIScale(int64 id, float ui_scale) { 202 bool SetDisplayUIScale(int64 id, float ui_scale) {
194 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 203 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
195 const DisplayInfo& info = display_manager->GetDisplayInfo(id); 204 const DisplayInfo& info = display_manager->GetDisplayInfo(id);
196 DisplayMode mode; 205 DisplayMode mode;
197 if (!GetDisplayModeForUIScale(info, ui_scale, &mode)) 206 if (!GetDisplayModeForUIScale(info, ui_scale, &mode))
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, 332 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays,
324 const gfx::Point& point_in_screen) { 333 const gfx::Point& point_in_screen) {
325 auto iter = std::find_if(displays.begin(), displays.end(), 334 auto iter = std::find_if(displays.begin(), displays.end(),
326 [point_in_screen](const gfx::Display& display) { 335 [point_in_screen](const gfx::Display& display) {
327 return display.bounds().Contains(point_in_screen); 336 return display.bounds().Contains(point_in_screen);
328 }); 337 });
329 return iter == displays.end() ? -1 : (iter - displays.begin()); 338 return iter == displays.end() ? -1 : (iter - displays.begin());
330 } 339 }
331 340
332 } // namespace ash 341 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_util.h ('k') | ash/display/root_window_transformers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698