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

Side by Side Diff: ash/display/display_util.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
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/display_util.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 #ifndef ASH_DISPLAY_DISPLAY_UTIL_H_ 5 #ifndef ASH_DISPLAY_DISPLAY_UTIL_H_
6 #define ASH_DISPLAY_DISPLAY_UTIL_H_ 6 #define ASH_DISPLAY_DISPLAY_UTIL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 12 matching lines...) Expand all
23 namespace gfx { 23 namespace gfx {
24 class Point; 24 class Point;
25 class Rect; 25 class Rect;
26 class Size; 26 class Size;
27 } 27 }
28 28
29 namespace ui {} 29 namespace ui {}
30 30
31 namespace ash { 31 namespace ash {
32 class AshWindowTreeHost; 32 class AshWindowTreeHost;
33 class ManagedDisplayMode;
34 33
35 // Creates the display mode list for internal display 34 // TODO(rjkroege): Move this into display_manager.h
36 // based on |native_mode|.
37 ASH_EXPORT display::ManagedDisplayInfo::ManagedDisplayModeList
38 CreateInternalManagedDisplayModeList(
39 const scoped_refptr<display::ManagedDisplayMode>& native_mode);
40
41 // Creates the display mode list for unified display
42 // based on |native_mode| and |scales|.
43 ASH_EXPORT display::ManagedDisplayInfo::ManagedDisplayModeList
44 CreateUnifiedManagedDisplayModeList(
45 const scoped_refptr<display::ManagedDisplayMode>& native_mode,
46 const std::set<std::pair<float, float>>& dsf_scale_list);
47
48 // Gets the display mode for |resolution|. Returns false if no display
49 // mode matches the resolution, or the display is an internal display.
50 ASH_EXPORT scoped_refptr<display::ManagedDisplayMode>
51 GetDisplayModeForResolution(const display::ManagedDisplayInfo& info,
52 const gfx::Size& resolution);
53
54 // Gets the display mode for the next valid UI scale. Returns false
55 // if the display is not an internal display.
56 ASH_EXPORT scoped_refptr<display::ManagedDisplayMode>
57 GetDisplayModeForNextUIScale(const display::ManagedDisplayInfo& info, bool up);
58
59 // Gets the display mode for the next valid resolution. Returns false
60 // if the display is an internal display.
61 ASH_EXPORT scoped_refptr<display::ManagedDisplayMode>
62 GetDisplayModeForNextResolution(const display::ManagedDisplayInfo& info,
63 bool up);
64
65 // Sets the UI scale for the |display_id|. Returns false if the 35 // Sets the UI scale for the |display_id|. Returns false if the
66 // display_id is not an internal display. 36 // display_id is not an internal display.
67 ASH_EXPORT bool SetDisplayUIScale(int64_t display_id, float scale); 37 ASH_EXPORT bool SetDisplayUIScale(int64_t display_id, float scale);
68 38
69 // Tests if the |info| has display mode that matches |ui_scale|.
70 bool HasDisplayModeForUIScale(const display::ManagedDisplayInfo& info,
71 float ui_scale);
72
73 // Computes the bounds that defines the bounds between two displays.
74 // Returns false if two displays do not intersect.
75 bool ComputeBoundary(const display::Display& primary_display,
76 const display::Display& secondary_display,
77 gfx::Rect* primary_edge_in_screen,
78 gfx::Rect* secondary_edge_in_screen);
79
80 // Creates edge bounds from |bounds_in_screen| that fits the edge 39 // Creates edge bounds from |bounds_in_screen| that fits the edge
81 // of the native window for |ash_host|. 40 // of the native window for |ash_host|.
82 ASH_EXPORT gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host, 41 ASH_EXPORT gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host,
83 const gfx::Rect& bounds_in_screen); 42 const gfx::Rect& bounds_in_screen);
84 43
85 // Moves the cursor to the point inside the |ash_host| that is closest to 44 // Moves the cursor to the point inside the |ash_host| that is closest to
86 // the point_in_screen, which may be outside of the root window. 45 // the point_in_screen, which may be outside of the root window.
87 // |update_last_loation_now| is used for the test to update the mouse 46 // |update_last_loation_now| is used for the test to update the mouse
88 // location synchronously. 47 // location synchronously.
89 void MoveCursorTo(AshWindowTreeHost* ash_host, 48 void MoveCursorTo(AshWindowTreeHost* ash_host,
90 const gfx::Point& point_in_screen, 49 const gfx::Point& point_in_screen,
91 bool update_last_location_now); 50 bool update_last_location_now);
92 51
93 // Returns the index in the displays whose bounds contains |point_in_screen|.
94 // Returns -1 if no such display exist.
95 ASH_EXPORT int FindDisplayIndexContainingPoint(
96 const std::vector<display::Display>& displays,
97 const gfx::Point& point_in_screen);
98
99 // Sorts id list using |CompareDisplayIds| below.
100 ASH_EXPORT void SortDisplayIdList(display::DisplayIdList* list);
101
102 // Default id generator.
103 class DefaultDisplayIdGenerator {
104 public:
105 int64_t operator()(int64_t id) { return id; }
106 };
107
108 // Generate sorted display::DisplayIdList from iterators.
109 template <class ForwardIterator, class Generator = DefaultDisplayIdGenerator>
110 display::DisplayIdList GenerateDisplayIdList(
111 ForwardIterator first,
112 ForwardIterator last,
113 Generator generator = Generator()) {
114 display::DisplayIdList list;
115 while (first != last) {
116 list.push_back(generator(*first));
117 ++first;
118 }
119 SortDisplayIdList(&list);
120 return list;
121 }
122
123 // Creates sorted display::DisplayIdList.
124 ASH_EXPORT display::DisplayIdList CreateDisplayIdList(
125 const display::DisplayList& list);
126
127 ASH_EXPORT std::string DisplayIdListToString(
128 const display::DisplayIdList& list);
129
130 // Returns true if one of following conditinos is met.
131 // 1) id1 is internal.
132 // 2) output index of id1 < output index of id2 and id2 isn't internal.
133 ASH_EXPORT bool CompareDisplayIds(int64_t id1, int64_t id2);
134
135 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
136 // Shows the notification message for display related issues. 53 // Shows the notification message for display related issues.
137 void ShowDisplayErrorNotification(int message_id); 54 void ShowDisplayErrorNotification(int message_id);
138 #endif 55 #endif
139 56
140 ASH_EXPORT base::string16 GetDisplayErrorNotificationMessageForTest(); 57 ASH_EXPORT base::string16 GetDisplayErrorNotificationMessageForTest();
141 58
142 } // namespace ash 59 } // namespace ash
143 60
144 #endif // ASH_DISPLAY_DISPLAY_UTIL_H_ 61 #endif // ASH_DISPLAY_DISPLAY_UTIL_H_
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/display_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698