Tizen 2.0 Release
[framework/uifw/xorg/lib/libdri2.git] / src / dri2.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  * Copyright © 2007,2008 Red Hat, Inc.
4  *
5  * Contact: Sangjin Lee <lsj119@samsung.com>, SooChan Lim <sc1.lim@samsung.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Soft-
9  * ware"), to deal in the Software without restriction, including without
10  * limitation the rights to use, copy, modify, merge, publish, distribute,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, provided that the above copyright
13  * notice(s) and this permission notice appear in all copies of the Soft-
14  * ware and that both the above copyright notice(s) and this permission
15  * notice appear in supporting documentation.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
19  * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
20  * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
21  * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
22  * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
23  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
25  * MANCE OF THIS SOFTWARE.
26  *
27  * Except as contained in this notice, the name of a copyright holder shall
28  * not be used in advertising or otherwise to promote the sale, use or
29  * other dealings in this Software without prior written authorization of
30  * the copyright holder.
31  *
32  * Origin Authors:
33  *   Kristian Høgsberg (krh@redhat.com)
34  */
35
36 #ifndef _DRI2_H_
37 #define _DRI2_H_
38
39 #include <X11/extensions/Xfixes.h>
40 #include <X11/extensions/dri2tokens.h>
41
42 /* events */
43 #define DRI2BufferSwapCompleteNotify 0
44 #define DRI2InvalidateBuffersNotify     1
45
46 typedef struct
47 {
48    unsigned int attachment;
49    unsigned int name;
50    unsigned int pitch;
51    unsigned int cpp;
52    unsigned int flags;
53 } DRI2Buffer;
54
55 extern Bool
56 DRI2QueryExtension(Display * display, int *eventBase, int *errorBase);
57
58 extern Bool
59 DRI2QueryVersion(Display * display, int *major, int *minor);
60
61 extern Bool
62 DRI2Connect(Display * display, XID window,
63             char **driverName, char **deviceName);
64
65 extern Bool
66 DRI2Authenticate(Display * display, XID window, unsigned int magic);
67
68 extern void
69 DRI2CreateDrawable(Display * display, XID drawable);
70
71 extern void
72 DRI2DestroyDrawable(Display * display, XID handle);
73
74 extern DRI2Buffer*
75 DRI2GetBuffers(Display * dpy, XID drawable,
76                int *width, int *height,
77                unsigned int *attachments, int count,
78                int *outCount);
79
80 /**
81  * \note
82  * This function is only supported with DRI2 version 1.1 or later.
83  */
84 extern DRI2Buffer*
85 DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
86                          int *width, int *height,
87                          unsigned int *attachments,
88                          int count, int *outCount);
89
90 extern void
91 DRI2CopyRegion(Display * dpy, XID drawable,
92                XserverRegion region,
93                CARD32 dest, CARD32 src);
94
95 extern void
96 DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
97                 CARD64 remainder, CARD64 *count);
98
99 extern Bool
100 DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
101
102 extern Bool
103 DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
104             CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
105
106 extern Bool
107 DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
108             CARD64 *msc, CARD64 *sbc);
109
110 extern void
111 DRI2SwapInterval(Display *dpy, XID drawable, int interval);
112
113 typedef struct {
114     int type;
115     unsigned long serial;       /* # of last request processed by server */
116     Bool send_event;            /* true if this came from a SendEvent request */
117     Display *display;           /* Display the event was read from */
118     Drawable drawable;  /* drawable on which event was requested in event mask */
119     int event_type;
120     int64_t ust;
121     int64_t msc;
122     int64_t sbc;
123 } DRI2BufferSwapComplete;
124
125 typedef struct {
126     int type;
127     unsigned long serial;       /* # of last request processed by server */
128     Bool send_event;            /* true if this came from a SendEvent request */
129     Display *display;           /* Display the event was read from */
130     Drawable drawable;  /* drawable on which event was requested in event mask */
131     int event_type;
132 } DRI2BufferInvalidate;
133
134 extern void
135 DRI2SwapBuffersWithRegion(Display *dpy, XID drawable, XserverRegion region,
136                 CARD64  *count);
137 #endif