1 /*
2  * Cogl
3  *
4  * A Low Level GPU Graphics and Utilities API
5  *
6  * Copyright (C) 2012 Red Hat, Inc.
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation
10  * files (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use, copy,
12  * modify, merge, publish, distribute, sublicense, and/or sell copies
13  * of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  * SOFTWARE.
27  *
28  *
29  */
30 
31 #ifndef __COGL_FRAME_INFO_PRIVATE_H
32 #define __COGL_FRAME_INFO_PRIVATE_H
33 
34 #include "cogl-frame-info.h"
35 #include "cogl-object-private.h"
36 #include "cogl-context.h"
37 
38 typedef enum _CoglFrameInfoFlag
39 {
40   COGL_FRAME_INFO_FLAG_NONE = 0,
41   COGL_FRAME_INFO_FLAG_SYMBOLIC = 1 << 0,
42   /* presentation_time timestamp was provided by the hardware */
43   COGL_FRAME_INFO_FLAG_HW_CLOCK = 1 << 1,
44   /*
45    * The presentation of this frame was done zero-copy. This means the buffer
46    * from the client was given to display hardware as is, without copying it.
47    * Compositing with OpenGL counts as copying, even if textured directly from
48    * the client buffer. Possible zero-copy cases include direct scanout of a
49    * fullscreen surface and a surface on a hardware overlay.
50    */
51   COGL_FRAME_INFO_FLAG_ZERO_COPY = 1 << 2,
52   /*
53    * The presentation was synchronized to the "vertical retrace" by the display
54    * hardware such that tearing does not happen. Relying on user space
55    * scheduling is not acceptable for this flag. If presentation is done by a
56    * copy to the active frontbuffer, then it must guarantee that tearing cannot
57    * happen.
58    */
59   COGL_FRAME_INFO_FLAG_VSYNC = 1 << 3,
60 } CoglFrameInfoFlag;
61 
62 struct _CoglFrameInfo
63 {
64   CoglObject _parent;
65 
66   CoglContext *context;
67 
68   int64_t frame_counter;
69   int64_t presentation_time_us; /* CLOCK_MONOTONIC */
70   float refresh_rate;
71 
72   int64_t global_frame_counter;
73 
74   CoglFrameInfoFlag flags;
75 
76   unsigned int sequence;
77 
78   CoglTimestampQuery *timestamp_query;
79   int64_t gpu_time_before_buffer_swap_ns;
80   int64_t cpu_time_before_buffer_swap_us;
81 };
82 
83 COGL_EXPORT
84 CoglFrameInfo *cogl_frame_info_new (CoglContext *context,
85                                     int64_t      global_frame_counter);
86 
87 #endif /* __COGL_FRAME_INFO_PRIVATE_H */
88