1 /**************************************************************************
2 *
3 * Copyright (C) 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27 /*
28 * Author: Keith Whitwell <[email protected]>
29 * Author: Jakob Bornecrantz <[email protected]>
30 */
31
32 #ifndef DRI_CONTEXT_H
33 #define DRI_CONTEXT_H
34
35 #include "dri_util.h"
36 #include "util/compiler.h"
37 #include "hud/hud_context.h"
38
39 struct pipe_context;
40 struct pipe_fence;
41 struct st_context;
42 struct dri_drawable;
43 struct dri_screen;
44
45 struct dri_context
46 {
47 /* dri */
48 struct dri_screen *screen;
49
50 /**
51 * Pointer to drawable currently bound to this context for drawing.
52 */
53 struct dri_drawable *draw;
54
55 /**
56 * Pointer to drawable currently bound to this context for reading.
57 */
58 struct dri_drawable *read;
59
60 /**
61 * True if the dri_drawable's current __DRIimageBufferMask is
62 * __DRI_IMAGE_BUFFER_SHARED.
63 */
64 bool is_shared_buffer_bound;
65
66 /**
67 * The loaders's private context data. This structure is opaque.
68 */
69 void *loaderPrivate;
70
71 struct {
72 int draw_stamp;
73 int read_stamp;
74 } dri2;
75
76 /* gallium */
77 struct st_context *st;
78 struct pp_queue_t *pp;
79 struct hud_context *hud;
80 };
81
82 static inline struct dri_context *
dri_context(__DRIcontext * driContextPriv)83 dri_context(__DRIcontext *driContextPriv)
84 {
85 return (struct dri_context *)driContextPriv;
86 }
87
88 static inline __DRIcontext *
opaque_dri_context(struct dri_context * ctx)89 opaque_dri_context(struct dri_context *ctx)
90 {
91 return (__DRIcontext *)ctx;
92 }
93
94 /***********************************************************************
95 * dri_context.c
96 */
97 void dri_destroy_context(struct dri_context *ctx);
98
99 bool
100 dri_unbind_context(struct dri_context *ctx);
101
102 bool
103 dri_make_current(struct dri_context *ctx,
104 struct dri_drawable *draw,
105 struct dri_drawable *read);
106
107 struct dri_context *
108 dri_get_current(void);
109
110 struct dri_context *
111 dri_create_context(struct dri_screen *screen,
112 gl_api api, const struct gl_config *visual,
113 const struct __DriverContextConfig *ctx_config,
114 unsigned *error,
115 struct dri_context *sharedContextPrivate,
116 void *loaderPrivate);
117
118 #endif
119
120 /* vim: set sw=3 ts=8 sts=3 expandtab: */
121