summaryrefslogtreecommitdiff
path: root/cogl/cogl-output.h
blob: 1f275a3f2576d3981eba3de6016ed5c5d98d1041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/*
 * Cogl
 *
 * An object oriented GL/GLES Abstraction/Utility Layer
 *
 * Copyright (C) 2012 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 *
 *
 * Authors:
 *   Owen Taylor <otaylor@redhat.com>
 */
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif

#ifndef __COGL_OUTPUT_H
#define __COGL_OUTPUT_H

/* We forward declare the CoglOutput type here to avoid some circular
 * dependency issues with the following headers.
 */
typedef struct _CoglOutput CoglOutput;

#include <cogl/cogl-types.h>
#include <cogl/cogl-overlay.h>
#include <cogl/cogl-mode.h>

COGL_BEGIN_DECLS

/**
 * SECTION:cogl-output
 * @short_description: information about an output device
 *
 * The #CoglOutput object holds information about an output device
 * such as a monitor or laptop display. It can be queried to find
 * out the position of the output with respect to the screen
 * coordinate system and other information such as the resolution
 * and refresh rate of the device.
 *
 * There can be any number of outputs which may overlap: the
 * same area of the screen may be displayed by multiple output
 * devices.
 *
 * XXX: though it's possible to query the position of the output
 * with respect to screen coordinates, there is currently no way
 * of finding out the position of a #CoglOnscreen in screen
 * coordinates, at least without using windowing-system specific
 * API's, so it's not easy to get the output positions relative
 * to the #CoglOnscreen.
 */

#define COGL_OUTPUT(X) ((CoglOutput *)(X))

/**
 * CoglSubpixelOrder:
 * @COGL_SUBPIXEL_ORDER_UNKNOWN: the layout of subpixel
 *   components for the device is unknown.
 * @COGL_SUBPIXEL_ORDER_NONE: the device displays colors
 *   without geometrically-separated subpixel components,
 *   or the positioning or colors of the components do not
 *   match any of the values in the enumeration.
 * @COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB: the device has
 *   horizontally arranged components in the order
 *   red-green-blue from left to right.
 * @COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR: the device has
 *   horizontally arranged  components in the order
 *   blue-green-red from left to right.
 * @COGL_SUBPIXEL_ORDER_VERTICAL_RGB: the device has
 *   vertically arranged components in the order
 *   red-green-blue from top to bottom.
 * @COGL_SUBPIXEL_ORDER_VERTICAL_BGR: the device has
 *   vertically arranged components in the order
 *   blue-green-red from top to bottom.
 *
 * Some output devices (such as LCD panels) display colors
 * by making each pixel consist of smaller "subpixels"
 * that each have a particular color. By using knowledge
 * of the layout of this subpixel components, it is possible
 * to create image content with higher resolution than the
 * pixel grid.
 *
 * Since: 1.14
 * Stability: unstable
 */
typedef enum {
  COGL_SUBPIXEL_ORDER_UNKNOWN,
  COGL_SUBPIXEL_ORDER_NONE,
  COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB,
  COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR,
  COGL_SUBPIXEL_ORDER_VERTICAL_RGB,
  COGL_SUBPIXEL_ORDER_VERTICAL_BGR
} CoglSubpixelOrder;

/**
 * cogl_is_output:
 * @object: A #CoglObject pointer
 *
 * Gets whether the given object references a #CoglOutput.
 *
 * Return value: %TRUE if the object references a #CoglOutput
 *   and %FALSE otherwise.
 * Since: 1.14
 * Stability: unstable
 */
CoglBool
cogl_is_output (void *object);

/**
 * cogl_output_get_x:
 * @output: a #CoglOutput
 *
 * Gets the X position of the output with respect to the coordinate
 * system of the screen.
 *
 * Return value: the X position of the output as a pixel offset
 *  from the left side of the screen coordinate space
 * Since: 1.14
 * Stability: unstable
 */
int
cogl_output_get_x (CoglOutput *output);

/**
 * cogl_output_get_y:
 * @output: a #CoglOutput
 *
 * Gets the Y position of the output with respect to the coordinate
 * system of the screen.
 *
 * Return value: the Y position of the output as a pixel offset
 *  from the top side of the screen coordinate space
 * Since: 1.14
 * Stability: unstable
 */
int
cogl_output_get_y (CoglOutput *output);

/**
 * cogl_output_get_width:
 * @output: a #CoglOutput
 *
 * Gets the width of the output in pixels.
 *
 * Return value: the width of the output in pixels
 * Since: 1.14
 * Stability: unstable
 */
int
cogl_output_get_width (CoglOutput *output);

/**
 * cogl_output_get_height:
 * @output: a #CoglOutput
 *
 * Gets the height of the output in pixels.
 *
 * Return value: the height of the output in pixels
 * Since: 1.14
 * Stability: unstable
 */
int
cogl_output_get_height (CoglOutput *output);

/**
 * cogl_output_get_mm_width:
 * @output: a #CoglOutput
 *
 * Gets the physical width of the output. In some cases (such as
 * as a projector), the value returned here might correspond to
 * nominal resolution rather than the actual physical size of the
 * output device.
 *
 * Return value: the height of the output in millimeters. A value
 *  of 0 indicates the width is unknown
 * Since: 1.14
 * Stability: unstable
 */
int
cogl_output_get_mm_width (CoglOutput *output);

/**
 * cogl_output_get_mm_height:
 * @output: a #CoglOutput
 *
 * Gets the physical height of the output. In some cases (such as
 * as a projector), the value returned here might correspond to
 * nominal resolution rather than the actual physical size of the
 * output device.
 *
 * Return value: the height of the output in millimeters. A value
 *  of 0 indicates that the height is unknown
 * Since: 1.14
 * Stability: unstable
 */
int
cogl_output_get_mm_height (CoglOutput *output);

/**
 * cogl_output_get_subpixel_order:
 * @output: a #CoglOutput
 *
 * For an output device where each pixel is made up of smaller components
 * with different colors, returns the layout of the subpixel
 * components.
 *
 * Return value: the order of subpixel components for the output device
 * Since: 1.14
 * Stability: unstable
 */
CoglSubpixelOrder
cogl_output_get_subpixel_order (CoglOutput *output);

/**
 * cogl_output_get_refresh_rate:
 * @output: a #CoglOutput
 *
 * Gets the number of times per second that the output device refreshes
 * the display contents.
 *
 * Return value: the refresh rate of the output device. A value of zero
 *  indicates that the refresh rate is unknown.
 * Since: 1.14
 * Stability: unstable
 */
float
cogl_output_get_refresh_rate (CoglOutput *output);

/**
 * cogl_output_get_overlay0:
 * @output: a #CoglOutput
 *
 * Queries the first, base overlay associated with the given @output.
 *
 * Return value: A pointer to the first #CoglOverlay associated with
 *               @output.
 * Since: 1.16
 * Stability: unstable
 */
CoglOverlay *
cogl_output_get_overlay0 (CoglOutput *output);

/**
 * cogl_output_append_overlay:
 * @output: a #CoglOutput
 * @overlay: A #CoglOverlay to add
 *
 * Stacks @overlay above all the other overlays currently associated
 * with the given @output.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_append_overlay (CoglOutput *output,
                            CoglOverlay *overlay);

/**
 * cogl_output_put_overlay_above:
 * @output: a #CoglOutput
 * @overlay: A #CoglOverlay to position
 * @sibling: A #CoglOverlay to position @overlay above or %NULL
 *
 * Stacks @overlay above @sibling. If @sibling is %NULL then @overlay
 * is stacked at the lowest position.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_put_overlay_above (CoglOutput *output,
                               CoglOverlay *overlay,
                               CoglOverlay *sibling);

/**
 * cogl_output_put_overlay_below:
 * @output: a #CoglOutput
 * @overlay: A #CoglOverlay to position
 * @sibling: A #CoglOverlay to position @overlay below or %NULL
 *
 * Stacks @overlay below @sibling. If @sibling is %NULL then @overlay
 * is stacked at the highest position.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_put_overlay_below (CoglOutput *output,
                               CoglOverlay *overlay,
                               CoglOverlay *sibling);

/**
 * cogl_output_remove_overlay:
 * @output: a #CoglOutput
 * @overlay: A #CoglOverlay to remove
 *
 * Removes @overlay from the given @output.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_remove_overlay (CoglOutput *output,
                            CoglOverlay *overlay);

/**
 * CoglOutputModeCallback:
 * @overlay: The current overlay being iterated
 * @user_data: The private data passed to
 *             cogl_output_foreach_mode()
 *
 * A callback type for use with cogl_output_foreach_mode()
 *
 * Since: 1.16
 * Stability: unstable
 */
typedef void (*CoglOutputModeCallback) (CoglMode *mode,
                                        void *user_data);

/**
 * cogl_output_foreach_mode:
 * @output: a #CoglOutput
 * @callback: A #CoglOutputModeCallback to call for each mode.
 * @user_data: A private pointer to pass to @callback
 *
 * Iterates through the possible #CoglMode<!-- -->'s usable with @output.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_foreach_mode (CoglOutput *output,
                          CoglOutputModeCallback callback,
                          void *user_data);

/**
 * cogl_output_set_mode:
 * @output: a #CoglOutput
 * @mode: A #CoglMode
 *
 * Requests to set the given @mode on the given @output the next
 * time output configurations are comitted via
 * cogl_renderer_commit_outputs().
 *
 * <note>@mode should be a mode that was found via
 * cogl_output_foreach_mode()</note>
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_set_mode (CoglOutput *output,
                      CoglMode *mode);

/**
 * cogl_output_get_mode:
 * @output: a #CoglOutput
 *
 * Queries the mode that's currently set on the given @output.
 *
 * <note>If the mode is set via cogl_output_set_mode() but
 * cogl_renderer_commit_outputs() hasn't since been called then this
 * will return the last set mode, which might not correspond to the
 * outputs actual mode.</note>
 *
 * Since: 1.16
 * Stability: unstable
 */
CoglMode *
cogl_output_get_mode (CoglOutput *output);

/**
 * CoglDpmsMode:
 * @COGL_DPMS_MODE_ON: Set when the display is use
 * @COGL_DPMS_MODE_STANDBY: Uses less than 80% of the power compared
 *                          to @COGL_DPMS_MODE_ON. Recovery time about
 *                          1 second.
 * @COGL_DPMS_MODE_SUSPEND: Uses less the 30W. Recovery time may be
 *                          about 5 seconds.
 * @COGL_DPMS_MODE_OFF: Uses less than 8W. Recovery time may be about
 *                      20 seconds.
 *
 * Standard VESA Display Power Management modes that can be controlled
 * for each #CoglOutput via cogl_output_set_dpms_mode().
 *
 * Since: 1.16
 * Stability: unstable
 */
typedef enum _CoglDpmsMode
{
  COGL_DPMS_MODE_ON,
  COGL_DPMS_MODE_STANDBY,
  COGL_DPMS_MODE_SUSPEND,
  COGL_DPMS_MODE_OFF,
} CoglDpmsMode;

/**
 * cogl_output_set_dpms_mode:
 * @output: a #CoglOutput
 * @dpms_mode: A #CoglDpmsMode
 *
 * Requests to set the given @dpms_mode on the given @output the next
 * time that cogl_renderer_commit_outputs() is called.
 *
 * This can be used to save power when a display is not in active
 * use.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_set_dpms_mode (CoglOutput *output,
                           CoglDpmsMode dpms_mode);

/**
 * cogl_output_get_dpms_mode:
 * @output: a #CoglOutput
 *
 * Queries the dpms mode last set on @output.
 *
 * <note>If the dpms mode has been set with
 * cogl_output_set_dpms_mode() but cogl_renderer_commit_outputs()
 * hasn't since been called then this will return the last set
 * dpms mode that might not correspond to the actual state of
 * @output.<note.
 *
 * Return value: The dpms mode set on @output.
 *
 * Since: 1.16
 * Stability: unstable
 */
CoglDpmsMode
cogl_output_get_dpms_mode (CoglOutput *output);

/**
 * CoglOutputOverlayCallback:
 * @overlay: The current overlay being iterated
 * @user_data: The private data passed to
 *             cogl_output_foreach_overlay()
 *
 * A callback type for use with cogl_output_foreach_overlay()
 *
 * Since: 1.16
 * Stability: unstable
 */
typedef void (*CoglOutputOverlayCallback) (CoglOverlay *overlay,
                                           void *user_data);

/**
 * cogl_output_foreach_overlay:
 * @output: a #CoglOutput
 * @callback: A #CoglOutputOverlayCallback to call for each overlay.
 * @user_data: A private pointer to pass to @callback
 *
 * Iterates through the current @output overlays, starting from
 * overlay 0.
 *
 * Since: 1.16
 * Stability: unstable
 */
void
cogl_output_foreach_overlay (CoglOutput *output,
                             CoglOutputOverlayCallback callback,
                             void *user_data);

COGL_END_DECLS

#endif /* __COGL_OUTPUT_H */