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

Side by Side Diff: resolution_selector.h

Issue 6854002: Merge monitor_reconfigure into powerd. (Closed) Base URL: ssh://gitrw.chromium.org:9222/power_manager.git@master
Patch Set: . Created 9 years, 8 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 | « powerd_unittest.cc ('k') | resolution_selector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef POWER_MANAGER_RESOLUTION_SELECTOR_H_
6 #define POWER_MANAGER_RESOLUTION_SELECTOR_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12
13 namespace power_manager {
14
15 // ResolutionSelector takes the sets of resolutions supported by the
16 // built-in and external displays as input and attempts to choose a shared
17 // resolution that will work well on both devices.
18 class ResolutionSelector {
19 public:
20 // A single mode supported by a device, equivalent to the XRRModeInfo
21 // struct.
22 struct Mode {
23 Mode(int width, int height, std::string name, int id);
24 Mode();
25
26 // Mode's dimensions.
27 int width;
28 int height;
29
30 // Mode's name from XRandR. This uniquely describes the mode and can
31 // be used to set the devices's resolution later.
32 std::string name;
33
34 // The mode id, used for setting this mode.
35 unsigned id;
36 };
37
38 // Maximum screen size for the external output at which we assume that
39 // it's a projector (as opposed to a monitor) and try to find a size that
40 // will also fit on the LCD display. Above this, we just use the
41 // external output's maximum resolution, even if it doesn't fit on the
42 // LCD.
43 static const int kMaxProjectorPixels;
44
45 ResolutionSelector();
46 ~ResolutionSelector();
47
48 // Comparator used to sort Mode objects.
49 // Returns true if |mode_a| has more pixels than |mode_b| and false otherwise.
50 class ModeResolutionComparator {
51 public:
52 bool operator()(const Mode& mode_a, const Mode& mode_b) const {
53 return mode_a.width * mode_a.height > mode_b.width * mode_b.height;
54 }
55 };
56
57 // Find the "best" resolutions for various outputs.
58 // Returns the modes for both screens and the total screen resolution.
59 bool FindBestResolutions(
60 const std::vector<Mode>& lcd_modes,
61 const std::vector<Mode>& external_modes,
62 Mode* lcd_resolution,
63 Mode* external_resolution,
64 Mode* screen_resolution);
65
66 private:
67 // Find resolutions to use that are reasonably close together.
68 // |larger_device_modes| and |smaller_device_modes| should be sorted by
69 // descending resolution. We choose the highest resolution from
70 // |smaller_device_modes| and the lowest resolution from |larger_device_modes|
71 // that's at least as high as the resolution from the smaller device.
72 // |screen_resolution| gets set to |smaller_resolution| to avoid clipping.
73 bool FindNearestResolutions(
74 const std::vector<Mode>& larger_device_modes,
75 const std::vector<Mode>& smaller_device_modes,
76 Mode* larger_resolution,
77 Mode* smaller_resolution,
78 Mode* screen_resolution);
79
80 DISALLOW_COPY_AND_ASSIGN(ResolutionSelector);
81 };
82
83 } // namespace power_manager
84
85 #endif // POWER_MANAGER_RESOLUTION_SELECTOR_H_
OLDNEW
« no previous file with comments | « powerd_unittest.cc ('k') | resolution_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698