[cosmetic] cleanup copyright headers
[vuplus_xbmc] / xbmc / windowing / egl / wayland / Output.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2011-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22 #include <vector>
23
24 #include <boost/noncopyable.hpp>
25
26 #include <wayland-client.h>
27
28 class IDllWaylandClient;
29
30 namespace xbmc
31 {
32 namespace wayland
33 {
34 struct Output :
35   boost::noncopyable
36 {
37 public:
38
39   Output(IDllWaylandClient &,
40          struct wl_output *);
41   ~Output();
42
43   struct ModeGeometry
44   {
45     int32_t width;
46     int32_t height;
47     int32_t refresh;
48   };
49
50   struct PhysicalGeometry
51   {
52     int32_t x;
53     int32_t y;
54     int32_t physicalWidth;
55     int32_t physicalHeight;
56     enum wl_output_subpixel subpixelArrangement;
57     enum wl_output_transform outputTransformation;
58   };
59
60   struct wl_output * GetWlOutput();
61
62   /* It is a precondition violation to use the following four
63    * functions when the first modes have not yet been received.
64    * 
65    * Use a synchronization point after creating this object
66    * (eg, WaitForSynchronize() to ensure that the initial modes
67    * are available */
68   
69   /* The "current" mode is the mode that the display is currently
70    * using */
71   const ModeGeometry & CurrentMode();
72   
73   /* The "preferred" mode is the mode most optimal to this output.
74    * 
75    * This is usually the maximum possible mode that this output
76    * supports. All fullscreen windows should generally have a buffer
77    * of this size in order to avoid scaling. */
78   const ModeGeometry & PreferredMode();
79
80   const std::vector <ModeGeometry> & AllModes();
81
82   /* The geometry represents the physical geometry of this monitor */
83   const PhysicalGeometry & Geometry();
84   
85   /* The scale factor of this output is an integer value representing
86    * the number of output pixels per hardware pixel. For instance,
87    * if UI elements were scaled up to 1680x1050 and the monitor was
88    * displaying at a native resolution of 3360x2100 when this would be
89    * "2". This is useful for supporting HiDPI display modes where,
90    * for instance we allocate a 3360x2100 buffer but display our UI
91    * elements at 1680x1050 */
92   uint32_t ScaleFactor();
93
94   static void GeometryCallback(void *,
95                                struct wl_output *,
96                                int32_t,
97                                int32_t,
98                                int32_t,
99                                int32_t,
100                                int32_t,
101                                const char *,
102                                const char *,
103                                int32_t);
104   static void ModeCallback(void *,
105                            struct wl_output *,
106                            uint32_t,
107                            int32_t,
108                            int32_t,
109                            int32_t);
110   static void ScaleCallback(void *,
111                             struct wl_output *,
112                             int32_t);
113   static void DoneCallback(void *,
114                            struct wl_output *);
115
116 private:
117
118   static const wl_output_listener m_listener;
119
120   void Geometry(int32_t x,
121                 int32_t y,
122                 int32_t physicalWidth,
123                 int32_t physicalHeight,
124                 int32_t subpixel,
125                 const char *make,
126                 const char *model,
127                 int32_t transform);
128   void Mode(uint32_t flags,
129             int32_t width,
130             int32_t height,
131             int32_t refresh);
132   void Scale(int32_t);
133   void Done();
134
135   IDllWaylandClient &m_clientLibrary;
136
137   struct wl_output *m_output;
138
139   PhysicalGeometry m_geometry;
140   std::vector<ModeGeometry> m_modes;
141
142   uint32_t m_scaleFactor;
143
144   /* Only one mode at a time can have the current or preferred
145    * flags set, so only one pointer is set here */
146   ModeGeometry *m_current;
147   ModeGeometry *m_preferred;
148 };
149 }
150 }