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