tizen 2.3.1 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 _XFUNCPROTOBEGIN
56
57 extern Bool
58 DRI2QueryExtension(Display * display, int *eventBase, int *errorBase);
59
60 extern Bool
61 DRI2QueryVersion(Display * display, int *major, int *minor);
62
63 extern Bool
64 DRI2QeuryExtensionAndCheckVersion(Display * dpy, int *eventBase, int *errorBase, int *major, int *minor, int check_major, int check_minor);
65
66 extern Bool
67 DRI2Connect(Display * display, XID window,
68             char **driverName, char **deviceName);
69
70 extern Bool
71 DRI2Authenticate(Display * display, XID window, unsigned int magic);
72
73 extern void
74 DRI2CreateDrawable(Display * display, XID drawable);
75
76 extern void
77 DRI2DestroyDrawable(Display * display, XID handle);
78
79 extern DRI2Buffer*
80 DRI2GetBuffers(Display * dpy, XID drawable,
81                int *width, int *height,
82                unsigned int *attachments, int count,
83                int *outCount);
84
85 /**
86  * \note
87  * This function is only supported with DRI2 version 1.1 or later.
88  */
89 extern DRI2Buffer*
90 DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
91                          int *width, int *height,
92                          unsigned int *attachments,
93                          int count, int *outCount);
94
95 extern void
96 DRI2CopyRegion(Display * dpy, XID drawable,
97                XserverRegion region,
98                CARD32 dest, CARD32 src);
99
100 extern void
101 DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
102                 CARD64 remainder, CARD64 *count);
103
104 extern Bool
105 DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
106
107 extern Bool
108 DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
109             CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
110
111 extern Bool
112 DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
113             CARD64 *msc, CARD64 *sbc);
114
115 extern void
116 DRI2SwapInterval(Display *dpy, XID drawable, int interval);
117
118 typedef struct {
119     int type;
120     unsigned long serial;       /* # of last request processed by server */
121     Bool send_event;            /* true if this came from a SendEvent request */
122     Display *display;           /* Display the event was read from */
123     Drawable drawable;  /* drawable on which event was requested in event mask */
124     int event_type;
125     int64_t ust;
126     int64_t msc;
127     int64_t sbc;
128 } DRI2BufferSwapComplete;
129
130 typedef struct {
131     int type;
132     unsigned long serial;       /* # of last request processed by server */
133     Bool send_event;            /* true if this came from a SendEvent request */
134     Display *display;           /* Display the event was read from */
135     Drawable drawable;  /* drawable on which event was requested in event mask */
136     int event_type;
137 } DRI2BufferInvalidate;
138
139 extern void
140 DRI2SwapBuffersWithRegion(Display *dpy, XID drawable, XserverRegion region,
141                 CARD64  *count);
142
143 _XFUNCPROTOEND
144
145 #endif