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

Side by Side Diff: ui/display/manager/display_manager_utilities.h

Issue 2286523002: Relocate reuseable portions of ash/display/display_util.* (Closed)
Patch Set: fixed ozone build Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium 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 UI_DISPLAY_MANAGER_DISPLAY_MANAGER_UTILITIES_H_
6 #define UI_DISPLAY_MANAGER_DISPLAY_MANAGER_UTILITIES_H_
7
8 #include <set>
9
10 #include "ui/display/display.h"
11 #include "ui/display/display_export.h"
12 #include "ui/display/manager/display_layout.h"
13 #include "ui/display/manager/managed_display_info.h"
14
15 namespace gfx {
16 class Point;
17 class Rect;
18 class Size;
19 }
20
21 namespace display {
22 class ManagedDisplayInfo;
23 class ManagedDisplayMode;
24
25 // Creates the display mode list for internal display
26 // based on |native_mode|.
27 DISPLAY_EXPORT ManagedDisplayInfo::ManagedDisplayModeList
28 CreateInternalManagedDisplayModeList(
29 const scoped_refptr<display::ManagedDisplayMode>& native_mode);
30
31 // Creates the display mode list for unified display
32 // based on |native_mode| and |scales|.
33 DISPLAY_EXPORT ManagedDisplayInfo::ManagedDisplayModeList
34 CreateUnifiedManagedDisplayModeList(
35 const scoped_refptr<display::ManagedDisplayMode>& native_mode,
36 const std::set<std::pair<float, float>>& dsf_scale_list);
37
38 // Gets the display mode for |resolution|. Returns false if no display
39 // mode matches the resolution, or the display is an internal display.
40 DISPLAY_EXPORT scoped_refptr<ManagedDisplayMode> GetDisplayModeForResolution(
41 const ManagedDisplayInfo& info,
42 const gfx::Size& resolution);
43
44 // Gets the display mode for the next valid UI scale. Returns false
45 // if the display is not an internal display.
46 DISPLAY_EXPORT scoped_refptr<ManagedDisplayMode> GetDisplayModeForNextUIScale(
47 const ManagedDisplayInfo& info,
48 bool up);
49
50 // Gets the display mode for the next valid resolution. Returns false
51 // if the display is an internal display.
52 DISPLAY_EXPORT scoped_refptr<ManagedDisplayMode>
53 GetDisplayModeForNextResolution(const ManagedDisplayInfo& info, bool up);
54
55 // Tests if the |info| has display mode that matches |ui_scale|.
56 bool HasDisplayModeForUIScale(const display::ManagedDisplayInfo& info,
57 float ui_scale);
58
59 // Computes the bounds that defines the bounds between two displays.
60 // Returns false if two displays do not intersect.
61 DISPLAY_EXPORT bool ComputeBoundary(const display::Display& primary_display,
62 const display::Display& secondary_display,
63 gfx::Rect* primary_edge_in_screen,
64 gfx::Rect* secondary_edge_in_screen);
65
66 // Returns the index in the displays whose bounds contains |point_in_screen|.
67 // Returns -1 if no such display exist.
68 DISPLAY_EXPORT int FindDisplayIndexContainingPoint(
69 const std::vector<display::Display>& displays,
70 const gfx::Point& point_in_screen);
71
72 // Sorts id list using |CompareDisplayIds| below.
73 DISPLAY_EXPORT void SortDisplayIdList(display::DisplayIdList* list);
74
75 // Default id generator.
76 class DefaultDisplayIdGenerator {
77 public:
78 int64_t operator()(int64_t id) { return id; }
79 };
80
81 // Generate sorted display::DisplayIdList from iterators.
82 template <class ForwardIterator, class Generator = DefaultDisplayIdGenerator>
83 display::DisplayIdList GenerateDisplayIdList(
84 ForwardIterator first,
85 ForwardIterator last,
86 Generator generator = Generator()) {
87 display::DisplayIdList list;
88 while (first != last) {
89 list.push_back(generator(*first));
90 ++first;
91 }
92 SortDisplayIdList(&list);
93 return list;
94 }
95
96 // Creates sorted display::DisplayIdList.
97 DISPLAY_EXPORT display::DisplayIdList CreateDisplayIdList(
98 const display::DisplayList& list);
99
100 DISPLAY_EXPORT std::string DisplayIdListToString(
101 const display::DisplayIdList& list);
102
103 // Returns true if one of following conditions is met.
104 // 1) id1 is internal.
105 // 2) output index of id1 < output index of id2 and id2 isn't internal.
106 DISPLAY_EXPORT bool CompareDisplayIds(int64_t id1, int64_t id2);
107
108 } // namespace display
109
110 #endif // UI_DISPLAY_MANAGER_DISPLAY_MANAGER_UTILITIES_H_
OLDNEW
« no previous file with comments | « ui/display/manager/display_layout_store.cc ('k') | ui/display/manager/display_manager_utilities.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698