Merge commit 'origin/gallium-master-merge'
[mesa.git] / src / driclient / include / driclient.h
1 #ifndef driclient_h
2 #define driclient_h
3
4 #include <stdint.h>
5 #include <X11/Xlib.h>
6 #include <drm_sarea.h>
7 #include "xf86dri.h"
8
9 /* TODO: Bring in DRI XML options */
10
11 typedef struct dri_version
12 {
13 int major;
14 int minor;
15 int patch;
16 } dri_version_t;
17
18 typedef struct dri_screen
19 {
20 Display *display;
21 unsigned int num;
22 dri_version_t ddx, dri, drm;
23 int draw_lock_id;
24 int fd;
25 drm_sarea_t *sarea;
26 void *drawable_hash;
27 void *private;
28 } dri_screen_t;
29
30 struct dri_context;
31
32 typedef struct dri_drawable
33 {
34 drm_drawable_t drm_drawable;
35 Drawable x_drawable;
36 unsigned int sarea_index;
37 unsigned int *sarea_stamp;
38 unsigned int last_sarea_stamp;
39 int x, y, w, h;
40 int back_x, back_y;
41 int num_cliprects, num_back_cliprects;
42 drm_clip_rect_t *cliprects, *back_cliprects;
43 dri_screen_t *dri_screen;
44 unsigned int refcount;
45 void *private;
46 } dri_drawable_t;
47
48 typedef struct dri_context
49 {
50 XID id;
51 drm_context_t drm_context;
52 dri_screen_t *dri_screen;
53 void *private;
54 } dri_context_t;
55
56 typedef struct dri_framebuffer
57 {
58 drm_handle_t drm_handle;
59 int base, size, stride;
60 int private_size;
61 void *private;
62 } dri_framebuffer_t;
63
64 int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf);
65 int driDestroyScreen(dri_screen_t *dri_screen);
66 int driCreateDrawable(dri_screen_t *dri_screen, Drawable drawable, dri_drawable_t **dri_drawable);
67 int driUpdateDrawableInfo(dri_drawable_t *dri_drawable);
68 int driDestroyDrawable(dri_drawable_t *dri_drawable);
69 int driCreateContext(dri_screen_t *dri_screen, Visual *visual, dri_context_t **dri_context);
70 int driDestroyContext(dri_context_t *dri_context);
71
72 #define DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable) \
73 do \
74 { \
75 if (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp) \
76 driUpdateDrawableInfo(dri_drawable); \
77 } while (0)
78
79 #define DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable) \
80 do \
81 { \
82 while (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp) \
83 { \
84 register unsigned int hwContext = dri_screen->sarea->lock.lock & \
85 ~(DRM_LOCK_HELD | DRM_LOCK_CONT); \
86 DRM_UNLOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext); \
87 \
88 DRM_SPINLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id); \
89 DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable); \
90 DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id); \
91 \
92 DRM_LIGHT_LOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext); \
93 } \
94 } while (0)
95
96 #endif
97