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

Side by Side Diff: components/exo/display.h

Issue 2396883003: exo: Fix dragging edge cases (Closed)
Patch Set: Fix presubmit errors Created 4 years, 2 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 | « no previous file | components/exo/display.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_EXO_DISPLAY_H_ 5 #ifndef COMPONENTS_EXO_DISPLAY_H_
6 #define COMPONENTS_EXO_DISPLAY_H_ 6 #define COMPONENTS_EXO_DISPLAY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/shared_memory_handle.h" 14 #include "base/memory/shared_memory_handle.h"
15 #include "ui/gfx/geometry/point.h"
15 16
16 #if defined(USE_OZONE) 17 #if defined(USE_OZONE)
17 #include "base/files/scoped_file.h" 18 #include "base/files/scoped_file.h"
18 #include "ui/gfx/buffer_types.h" 19 #include "ui/gfx/buffer_types.h"
19 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
20 #include "ui/gfx/native_pixmap_handle.h" 21 #include "ui/gfx/native_pixmap_handle.h"
21 #endif 22 #endif
22 23
23 namespace gfx {
24 class Point;
25 }
26
27 namespace exo { 24 namespace exo {
28 class NotificationSurface; 25 class NotificationSurface;
29 class NotificationSurfaceManager; 26 class NotificationSurfaceManager;
30 class SharedMemory; 27 class SharedMemory;
31 class ShellSurface; 28 class ShellSurface;
32 class SubSurface; 29 class SubSurface;
33 class Surface; 30 class Surface;
34 31
35 #if defined(USE_OZONE) 32 #if defined(USE_OZONE)
36 class Buffer; 33 class Buffer;
37 #endif 34 #endif
38 35
39 // The core display class. This class provides functions for creating surfaces 36 // The core display class. This class provides functions for creating surfaces
40 // and is in charge of combining the contents of multiple surfaces into one 37 // and is in charge of combining the contents of multiple surfaces into one
41 // displayable output. 38 // displayable output.
39 //
40 // This class is also responsible for conversion between server-side screen
41 // coordinates and client-side virtual coordinates. This mapping enables
42 // support for multiple displays when the client is limited to a single
43 // display. In that case, the client uses a virtual display computed as
44 // the bounding box of the physical displays, and the server translates
45 // positions based on the display layout. For example, P is the client's
46 // origin in virtual coordinates, and Q is the server's origin in screen
47 // coordinates.
48 //
49 // P Q
50 // +-----+ /
51 // | |/
52 // | 2 +-----------+
53 // | | |
54 // +-----+ 1 |
55 // | |
56 // +-----------+
57 //
42 class Display { 58 class Display {
43 public: 59 public:
44 Display(); 60 Display();
45 explicit Display(NotificationSurfaceManager* notification_surface_manager); 61 explicit Display(NotificationSurfaceManager* notification_surface_manager);
46 ~Display(); 62 ~Display();
47 63
64 void set_virtual_origin(const gfx::Point& virtual_origin) {
65 virtual_origin_ = virtual_origin;
66 }
67
68 template <typename Point>
reveman 2016/10/16 23:16:02 why the template argument? what are the different
Dominik Laskowski 2016/10/18 21:22:56 gfx::Point and gfx::Rect. Would overloads be prefe
69 void ConvertFromVirtualToScreen(Point* point) const {
70 *point += virtual_origin_.OffsetFromOrigin();
71 }
72
73 template <typename Point>
74 void ConvertFromScreenToVirtual(Point* point) const {
75 *point -= virtual_origin_.OffsetFromOrigin();
76 }
77
48 // Creates a new surface. 78 // Creates a new surface.
49 std::unique_ptr<Surface> CreateSurface(); 79 std::unique_ptr<Surface> CreateSurface();
50 80
51 // Creates a shared memory segment from |handle| of |size| with the 81 // Creates a shared memory segment from |handle| of |size| with the
52 // given |id|. This function takes ownership of |handle|. 82 // given |id|. This function takes ownership of |handle|.
53 std::unique_ptr<SharedMemory> CreateSharedMemory( 83 std::unique_ptr<SharedMemory> CreateSharedMemory(
54 const base::SharedMemoryHandle& handle, 84 const base::SharedMemoryHandle& handle,
55 size_t size); 85 size_t size);
56 86
57 #if defined(USE_OZONE) 87 #if defined(USE_OZONE)
(...skipping 23 matching lines...) Expand all
81 // a child of |parent|. 111 // a child of |parent|.
82 std::unique_ptr<SubSurface> CreateSubSurface(Surface* surface, 112 std::unique_ptr<SubSurface> CreateSubSurface(Surface* surface,
83 Surface* parent); 113 Surface* parent);
84 114
85 // Creates a notification surface for a surface and notification id. 115 // Creates a notification surface for a surface and notification id.
86 std::unique_ptr<NotificationSurface> CreateNotificationSurface( 116 std::unique_ptr<NotificationSurface> CreateNotificationSurface(
87 Surface* surface, 117 Surface* surface,
88 const std::string& notification_id); 118 const std::string& notification_id);
89 119
90 private: 120 private:
121 // Origin of the virtual screen relative to the primary display.
122 gfx::Point virtual_origin_;
123
91 NotificationSurfaceManager* const notification_surface_manager_; 124 NotificationSurfaceManager* const notification_surface_manager_;
92 125
93 DISALLOW_COPY_AND_ASSIGN(Display); 126 DISALLOW_COPY_AND_ASSIGN(Display);
94 }; 127 };
95 128
96 } // namespace exo 129 } // namespace exo
97 130
98 #endif // COMPONENTS_EXO_DISPLAY_H_ 131 #endif // COMPONENTS_EXO_DISPLAY_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698