149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu/*
249381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * Mesa 3-D graphics library
349381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * Version:  7.8
449381d63e61c724b156b76068058df1c01a906c2Chia-I Wu *
549381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * Copyright (C) 2009-2010 Chia-I Wu <olv@0xlab.org>
649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu *
749381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * Permission is hereby granted, free of charge, to any person obtaining a
849381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * copy of this software and associated documentation files (the "Software"),
949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * to deal in the Software without restriction, including without limitation
1049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * and/or sell copies of the Software, and to permit persons to whom the
1249381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * Software is furnished to do so, subject to the following conditions:
1349381d63e61c724b156b76068058df1c01a906c2Chia-I Wu *
1449381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * The above copyright notice and this permission notice shall be included
1549381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * in all copies or substantial portions of the Software.
1649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu *
17ba81b0743efd978509b1931d7b4b93f37e8aeb5eChia-I Wu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18ba81b0743efd978509b1931d7b4b93f37e8aeb5eChia-I Wu * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20ba81b0743efd978509b1931d7b4b93f37e8aeb5eChia-I Wu * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21ba81b0743efd978509b1931d7b4b93f37e8aeb5eChia-I Wu * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22ba81b0743efd978509b1931d7b4b93f37e8aeb5eChia-I Wu * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23ba81b0743efd978509b1931d7b4b93f37e8aeb5eChia-I Wu * DEALINGS IN THE SOFTWARE.
2449381d63e61c724b156b76068058df1c01a906c2Chia-I Wu */
2549381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
2649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#ifndef _X11_SCREEN_H_
2749381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#define _X11_SCREEN_H_
2849381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
2949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#include <X11/Xlib.h>
3049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#include <X11/Xutil.h>
3149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#include <X11/extensions/dri2tokens.h>
32f7730c0740cc8a43c3573dcdbf43e76630d957f6Chia-I Wu#include "GL/gl.h" /* for GL types needed by __GLcontextModes */
33e3c1c5377c7fcd17085bfb22fbc1cf30646751baKristian Høgsberg#include "glcore.h"  /* for __GLcontextModes */
3449381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#include "pipe/p_compiler.h"
3549381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#include "common/native.h"
3649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
3749381d63e61c724b156b76068058df1c01a906c2Chia-I Wuenum x11_screen_extension {
3849381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   X11_SCREEN_EXTENSION_XSHM,
3949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   X11_SCREEN_EXTENSION_GLX,
4049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   X11_SCREEN_EXTENSION_DRI2,
4149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu};
4249381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
4349381d63e61c724b156b76068058df1c01a906c2Chia-I Wu/* the same as DRI2Buffer */
4449381d63e61c724b156b76068058df1c01a906c2Chia-I Wustruct x11_drawable_buffer {
4549381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   unsigned int attachment;
4649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   unsigned int name;
4749381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   unsigned int pitch;
4849381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   unsigned int cpp;
4949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu   unsigned int flags;
5049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu};
5149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
5249381d63e61c724b156b76068058df1c01a906c2Chia-I Wustruct x11_screen;
5349381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
54545ac97f9b95e9b5ebd04d2960abb224b5adbe17Chia-I Wutypedef void (*x11_drawable_invalidate_buffers)(struct x11_screen *xscr,
55545ac97f9b95e9b5ebd04d2960abb224b5adbe17Chia-I Wu                                                Drawable drawable,
56545ac97f9b95e9b5ebd04d2960abb224b5adbe17Chia-I Wu                                                void *user_data);
57545ac97f9b95e9b5ebd04d2960abb224b5adbe17Chia-I Wu
5849381d63e61c724b156b76068058df1c01a906c2Chia-I Wustruct x11_screen *
5949381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_screen_create(Display *dpy, int screen);
6049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
6149381d63e61c724b156b76068058df1c01a906c2Chia-I Wuvoid
6249381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_screen_destroy(struct x11_screen *xscr);
6349381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
6449381d63e61c724b156b76068058df1c01a906c2Chia-I Wuboolean
6549381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext);
6649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
6749381d63e61c724b156b76068058df1c01a906c2Chia-I Wuconst XVisualInfo *
6849381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals);
6949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
70cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wuuint
71cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wux11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable);
72cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu
73cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu#ifdef GLX_DIRECT_RENDERING
74cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu
75cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu/* GLX */
7649381d63e61c724b156b76068058df1c01a906c2Chia-I Wuconst __GLcontextModes *
7749381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_screen_get_glx_configs(struct x11_screen *xscr);
7849381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
7949381d63e61c724b156b76068058df1c01a906c2Chia-I Wuconst __GLcontextModes *
8049381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_screen_get_glx_visuals(struct x11_screen *xscr);
8149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
8249381d63e61c724b156b76068058df1c01a906c2Chia-I Wu__GLcontextModes *
8349381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_context_modes_create(unsigned count);
8449381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
8549381d63e61c724b156b76068058df1c01a906c2Chia-I Wuvoid
8649381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_context_modes_destroy(__GLcontextModes *modes);
8749381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
8849381d63e61c724b156b76068058df1c01a906c2Chia-I Wuunsigned
8949381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_context_modes_count(const __GLcontextModes *modes);
9049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
91cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu/* DRI2 */
92cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wuconst char *
93cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wux11_screen_probe_dri2(struct x11_screen *xscr, int *major, int *minor);
94cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu
95cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wuint
96cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wux11_screen_enable_dri2(struct x11_screen *xscr,
97cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu                       x11_drawable_invalidate_buffers invalidate_buffers,
98cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu                       void *user_data);
99cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu
100184bb09ff5cf2715dfee91e25ec20cbaa2e4445cBenjamin Franzkechar *
101184bb09ff5cf2715dfee91e25ec20cbaa2e4445cBenjamin Franzkex11_screen_get_device_name(struct x11_screen *xscr);
102184bb09ff5cf2715dfee91e25ec20cbaa2e4445cBenjamin Franzke
103184bb09ff5cf2715dfee91e25ec20cbaa2e4445cBenjamin Franzkeint
104184bb09ff5cf2715dfee91e25ec20cbaa2e4445cBenjamin Franzkex11_screen_authenticate(struct x11_screen *xscr, uint32_t id);
105184bb09ff5cf2715dfee91e25ec20cbaa2e4445cBenjamin Franzke
10649381d63e61c724b156b76068058df1c01a906c2Chia-I Wuvoid
10749381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_drawable_enable_dri2(struct x11_screen *xscr,
10849381d63e61c724b156b76068058df1c01a906c2Chia-I Wu                         Drawable drawable, boolean on);
10949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
11049381d63e61c724b156b76068058df1c01a906c2Chia-I Wuvoid
111a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglundx11_drawable_copy_buffers_region(struct x11_screen *xscr, Drawable drawable,
112a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund                                 int num_rects, const int *rects,
113a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund                                 int src_buf, int dst_buf);
114a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund
115a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund/**
116a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund * Copy between buffers of the DRI2 drawable.
117a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund */
118a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglundstatic INLINE void
11949381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable,
12049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu                          int x, int y, int width, int height,
121a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund                          int src_buf, int dst_buf)
122a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund{
123a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund    int rect[4] = { x, y, width, height };
124a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund    x11_drawable_copy_buffers_region(xscr, drawable, 1, rect, src_buf, dst_buf);
125a06f58fee5dbf0054fb363e759d30cf13c4bbab9Fredrik Höglund}
12649381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
12749381d63e61c724b156b76068058df1c01a906c2Chia-I Wustruct x11_drawable_buffer *
12849381d63e61c724b156b76068058df1c01a906c2Chia-I Wux11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
12949381d63e61c724b156b76068058df1c01a906c2Chia-I Wu                         int *width, int *height, unsigned int *attachments,
13049381d63e61c724b156b76068058df1c01a906c2Chia-I Wu                         boolean with_format, int num_ins, int *num_outs);
13149381d63e61c724b156b76068058df1c01a906c2Chia-I Wu
132cf588ab3f1edb89be4cd57045a3888ff482fa817Chia-I Wu#endif /* GLX_DIRECT_RENDERING */
133f8244e294646c1b5127a2bf3e92811300b0e3b9eChia-I Wu
13449381d63e61c724b156b76068058df1c01a906c2Chia-I Wu#endif /* _X11_SCREEN_H_ */
135