Chromium Code Reviews| Index: components/exo/display.h |
| diff --git a/components/exo/display.h b/components/exo/display.h |
| index d4f3b3d08065b522f902612fe7fabe6c23a806de..6b653592f95f344907deb02c4fd61a661c826c21 100644 |
| --- a/components/exo/display.h |
| +++ b/components/exo/display.h |
| @@ -12,6 +12,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/shared_memory_handle.h" |
| +#include "ui/gfx/geometry/point.h" |
| #if defined(USE_OZONE) |
| #include "base/files/scoped_file.h" |
| @@ -20,10 +21,6 @@ |
| #include "ui/gfx/native_pixmap_handle.h" |
| #endif |
| -namespace gfx { |
| -class Point; |
| -} |
| - |
| namespace exo { |
| class NotificationSurface; |
| class NotificationSurfaceManager; |
| @@ -39,12 +36,45 @@ class Buffer; |
| // The core display class. This class provides functions for creating surfaces |
| // and is in charge of combining the contents of multiple surfaces into one |
| // displayable output. |
| +// |
| +// This class is also responsible for conversion between server-side screen |
| +// coordinates and client-side virtual coordinates. This mapping enables |
| +// support for multiple displays when the client is limited to a single |
| +// display. In that case, the client uses a virtual display computed as |
| +// the bounding box of the physical displays, and the server translates |
| +// positions based on the display layout. For example, P is the client's |
| +// origin in virtual coordinates, and Q is the server's origin in screen |
| +// coordinates. |
| +// |
| +// P Q |
| +// +-----+ / |
| +// | |/ |
| +// | 2 +-----------+ |
| +// | | | |
| +// +-----+ 1 | |
| +// | | |
| +// +-----------+ |
| +// |
| class Display { |
| public: |
| Display(); |
| explicit Display(NotificationSurfaceManager* notification_surface_manager); |
| ~Display(); |
| + void set_virtual_origin(const gfx::Point& virtual_origin) { |
| + virtual_origin_ = virtual_origin; |
| + } |
| + |
| + 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
|
| + void ConvertFromVirtualToScreen(Point* point) const { |
| + *point += virtual_origin_.OffsetFromOrigin(); |
| + } |
| + |
| + template <typename Point> |
| + void ConvertFromScreenToVirtual(Point* point) const { |
| + *point -= virtual_origin_.OffsetFromOrigin(); |
| + } |
| + |
| // Creates a new surface. |
| std::unique_ptr<Surface> CreateSurface(); |
| @@ -88,6 +118,9 @@ class Display { |
| const std::string& notification_id); |
| private: |
| + // Origin of the virtual screen relative to the primary display. |
| + gfx::Point virtual_origin_; |
| + |
| NotificationSurfaceManager* const notification_surface_manager_; |
| DISALLOW_COPY_AND_ASSIGN(Display); |