summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reveman <davidr@novell.com>2005-04-12 14:54:56 +0000
committerDavid Reveman <davidr@novell.com>2005-04-12 14:54:56 +0000
commit368c6bfbebfa47bf88fe4fdeba69cba8fef8fd04 (patch)
tree4ba840cb68999977b94a9afa3ee38aa40461558f
parente3647299e2fab280c49b6248be7da2eb8ce4599d (diff)
Add glitz_context_t interface
-rw-r--r--ChangeLog25
-rw-r--r--src/Makefile.am1
-rw-r--r--src/agl/glitz_agl_context.c154
-rw-r--r--src/agl/glitz_agl_drawable.c6
-rw-r--r--src/agl/glitz_agl_info.c3
-rw-r--r--src/agl/glitz_aglint.h5
-rw-r--r--src/glitz.c11
-rw-r--r--src/glitz.h55
-rw-r--r--src/glitz_surface.c17
-rw-r--r--src/glitz_util.c1
-rw-r--r--src/glitzint.h56
-rw-r--r--src/glx/glitz_glx_context.c147
-rw-r--r--src/glx/glitz_glx_drawable.c10
-rw-r--r--src/glx/glitz_glx_info.c3
-rw-r--r--src/glx/glitz_glxint.h6
15 files changed, 437 insertions, 63 deletions
diff --git a/ChangeLog b/ChangeLog
index 54b264e..48091b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2005-04-12 David Reveman <davidr@novell.com>
+
+ * src/glx/glitz_glx_context.c (_glitz_glx_context_make_current):
+ * src/agl/glitz_agl_context.c:
+ (_glitz_agl_context_make_current): Call glFinish before switching
+ context.
+
+ * src/Makefile.am (libglitz_la_SOURCES):
+ * src/agl/glitz_glx_info.c:
+ * src/agl/glitz_agl_info.c:
+ * src/glx/glitz_glx_context.c:
+ * src/agl/glitz_agl_context.c:
+ * src/glitzint.h:
+ * src/glitz.h: Added glitz_context_t interface.
+
+ * src/agl/glitz_glxint.h:
+ * src/agl/glitz_aglint.h:
+ * src/agl/glitz_glx_info.c:
+ * src/agl/glitz_agl_info.c:
+ * src/agl/glitz_glx_drawable.c:
+ * src/agl/glitz_agl_drawable.c:
+ * src/glitzint.h:
+ * src/glitz_surface.c:
+ * src/glitz.c (glitz_copy_area): Removed use of "make current read".
+
2005-03-16 David Reveman <davidr@novell.com>
* src/glitz_pixel.c (glitz_get_pixels): Fix y-offset when returning
diff --git a/src/Makefile.am b/src/Makefile.am
index 7f0a0be..ffa75d7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,6 +23,7 @@ libglitz_la_SOURCES = \
glitz_pixel.c \
glitz_trap.c \
glitz_framebuffer.c \
+ glitz_context.c \
glitz_trapimp.h \
glitz_gl.h \
glitzint.h
diff --git a/src/agl/glitz_agl_context.c b/src/agl/glitz_agl_context.c
index 4c473a8..34cd199 100644
--- a/src/agl/glitz_agl_context.c
+++ b/src/agl/glitz_agl_context.c
@@ -102,6 +102,137 @@ _glitz_agl_get_proc_address (const char *name, void *closure)
return address;
}
+static glitz_context_t *
+_glitz_agl_create_context (void *abstract_drawable,
+ glitz_drawable_format_t *format)
+{
+ glitz_agl_drawable_t *drawable = (glitz_agl_drawable_t *) abstract_drawable;
+ glitz_agl_thread_info_t *thread_info = drawable->thread_info;
+ glitz_agl_context_t *context;
+
+ context = malloc (sizeof (glitz_agl_context_t));
+ if (!context)
+ return NULL;
+
+ context->context =
+ aglCreateContext (thread_info->pixel_formats[format->id],
+ thread_info->root_context);
+
+ _glitz_context_init (&context->base, &drawable->base);
+
+ context->pbuffer = 0;
+
+ return (glitz_context_t *) context;
+}
+
+static void
+_glitz_agl_context_destroy (void *abstract_context)
+{
+ glitz_agl_context_t *context = (glitz_agl_context_t *) abstract_context;
+ glitz_agl_drawable_t *drawable = (glitz_agl_drawable_t *)
+ context->base.drawable;
+
+ if (drawable->thread_info->cctx == &context->base)
+ {
+ aglSetCurrentContext (NULL);
+
+ drawable->thread_info->cctx = NULL;
+ }
+
+ aglDestroyContext (context->context);
+
+ _glitz_context_fini (&context->base);
+
+ free (context);
+}
+
+static void
+_glitz_agl_copy_context (void *abstract_src,
+ void *abstract_dst,
+ unsigned long mask)
+{
+ glitz_agl_context_t *src = (glitz_agl_context_t *) abstract_src;
+ glitz_agl_context_t *dst = (glitz_agl_context_t *) abstract_dst;
+
+ aglCopyContext (src->context, dst->context, mask);
+}
+
+static void
+_glitz_agl_make_current (void *abstract_context,
+ void *abstract_drawable)
+{
+ glitz_agl_context_t *context = (glitz_agl_context_t *) abstract_context;
+ glitz_agl_drawable_t *drawable = (glitz_agl_drawable_t *) abstract_drawable;
+ int update = 0;
+
+ if (aglGetCurrentContext () != context->context)
+ {
+ update = 1;
+ }
+ else
+ {
+ if (drawable->pbuffer)
+ {
+ AGLPbuffer pbuffer;
+ GLuint unused;
+
+ aglGetPBuffer (context->context, &pbuffer,
+ &unused, &unused, &unused);
+
+ if (pbuffer != drawable->pbuffer)
+ update = 1;
+
+ }
+ else if (drawable->drawable)
+ {
+ if (aglGetDrawable (context->context) != drawable->drawable)
+ update = 1;
+ }
+ }
+
+ if (update)
+ {
+ if (drawable->pbuffer) {
+ aglSetPBuffer (context->context, drawable->pbuffer, 0, 0,
+ aglGetVirtualScreen (context->context));
+ context->pbuffer = 1;
+ }
+ else
+ {
+ if (context->pbuffer) {
+ aglSetDrawable (context->context, NULL);
+ context->pbuffer = 0;
+ }
+ aglSetDrawable (context->context, drawable->drawable);
+ }
+
+ aglSetCurrentContext (context->context);
+ }
+
+ drawable->thread_info->cctx = &context->base;
+}
+
+static glitz_function_pointer_t
+_glitz_agl_context_get_proc_address (void *abstract_context,
+ const char *name)
+{
+ glitz_agl_context_t *context = (glitz_agl_context_t *) abstract_context;
+ glitz_agl_drawable_t *drawable = (glitz_agl_drawable_t *)
+ context->base.drawable;
+ glitz_function_pointer_t func;
+ CFBundleRef bundle;
+
+ _glitz_agl_make_current (context, drawable);
+
+ bundle = _glitz_agl_get_bundle ("OpenGL.framework");
+
+ func = _glitz_agl_get_proc_address (name, (void *) bundle);
+
+ _glitz_agl_release_bundle (bundle);
+
+ return func;
+}
+
glitz_agl_context_t *
glitz_agl_context_get (glitz_agl_thread_info_t *thread_info,
glitz_drawable_format_t *format)
@@ -151,8 +282,13 @@ glitz_agl_context_get (glitz_agl_thread_info_t *thread_info,
context->backend.push_current = glitz_agl_push_current;
context->backend.pop_current = glitz_agl_pop_current;
context->backend.swap_buffers = glitz_agl_swap_buffers;
- context->backend.make_current_read = glitz_agl_make_current_read;
+ context->backend.create_context = _glitz_agl_create_context;
+ context->backend.destroy_context = _glitz_agl_context_destroy;
+ context->backend.copy_context = _glitz_agl_copy_context;
+ context->backend.make_current = _glitz_agl_make_current;
+ context->backend.get_proc_address = _glitz_agl_context_get_proc_address;
+
context->backend.drawable_formats = thread_info->formats;
context->backend.n_drawable_formats = thread_info->n_formats;
@@ -207,10 +343,20 @@ _glitz_agl_context_initialize (glitz_agl_thread_info_t *thread_info,
static void
_glitz_agl_context_make_current (glitz_agl_drawable_t *drawable,
- glitz_bool_t flush)
+ glitz_bool_t finish)
{
- if (flush)
- glFlush ();
+ if (finish)
+ glFinish ();
+
+ if (drawable->thread_info->cctx)
+ {
+ glitz_context_t *ctx = drawable->thread_info->cctx;
+
+ if (ctx->lose_current)
+ ctx->lose_current (ctx->closure);
+
+ drawable->thread_info->cctx = NULL;
+ }
if (drawable->pbuffer) {
aglSetPBuffer (drawable->context->context, drawable->pbuffer, 0, 0,
diff --git a/src/agl/glitz_agl_drawable.c b/src/agl/glitz_agl_drawable.c
index 97cf804..ada714a 100644
--- a/src/agl/glitz_agl_drawable.c
+++ b/src/agl/glitz_agl_drawable.c
@@ -29,12 +29,6 @@
#include "glitz_aglint.h"
-glitz_status_t
-glitz_agl_make_current_read (void *abstract_surface)
-{
- return GLITZ_STATUS_NOT_SUPPORTED;
-}
-
static glitz_agl_drawable_t *
_glitz_agl_create_drawable (glitz_agl_thread_info_t *thread_info,
glitz_agl_context_t *context,
diff --git a/src/agl/glitz_agl_info.c b/src/agl/glitz_agl_info.c
index 50ac828..d921c57 100644
--- a/src/agl/glitz_agl_info.c
+++ b/src/agl/glitz_agl_info.c
@@ -187,6 +187,7 @@ static glitz_agl_thread_info_t _thread_info = {
0,
NULL,
0,
+ NULL,
{ 0 }
};
@@ -225,6 +226,8 @@ glitz_agl_thread_info_init (glitz_agl_thread_info_t *thread_info)
thread_info->agl_feature_mask = 0;
+ thread_info->cctx = NULL;
+
glitz_program_map_init (&thread_info->program_map);
if (!glitz_agl_query_extensions (thread_info))
diff --git a/src/agl/glitz_aglint.h b/src/agl/glitz_aglint.h
index ea1a64c..d8d5d7c 100644
--- a/src/agl/glitz_aglint.h
+++ b/src/agl/glitz_aglint.h
@@ -49,6 +49,7 @@ typedef struct _glitz_agl_context_info_t {
} glitz_agl_context_info_t;
typedef struct _glitz_agl_context_t {
+ glitz_context_t base;
AGLContext context;
glitz_format_id_t id;
AGLPixelFormat pixel_format;
@@ -71,6 +72,7 @@ typedef struct _glitz_agl_thread_info_t {
int context_stack_size;
AGLContext root_context;
unsigned long agl_feature_mask;
+ glitz_context_t *cctx;
glitz_program_map_t program_map;
} glitz_agl_thread_info_t;
@@ -123,9 +125,6 @@ glitz_agl_push_current (void *abstract_drawable,
extern glitz_surface_t __internal_linkage *
glitz_agl_pop_current (void *abstract_drawable);
-extern glitz_status_t __internal_linkage
-glitz_agl_make_current_read (void *abstract_surface);
-
extern void __internal_linkage
glitz_agl_destroy (void *abstract_drawable);
diff --git a/src/glitz.c b/src/glitz.c
index 2ea92a3..ae78d73 100644
--- a/src/glitz.c
+++ b/src/glitz.c
@@ -399,19 +399,14 @@ glitz_copy_area (glitz_surface_t *src,
{
if (src->attached == dst->attached)
{
+ glitz_box_t box, *clip = dst->clip;
+ int n_clip = dst->n_clip;
+
if (REGION_NOTEMPTY (&src->drawable_damage))
{
glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT);
glitz_surface_pop_current (src);
}
- status = GLITZ_STATUS_SUCCESS;
- } else
- status = glitz_surface_make_current_read (src);
-
- if (!status)
- {
- glitz_box_t box, *clip = dst->clip;
- int n_clip = dst->n_clip;
gl->read_buffer (src->buffer);
gl->draw_buffer (dst->buffer);
diff --git a/src/glitz.h b/src/glitz.h
index b57fa04..8039885 100644
--- a/src/glitz.h
+++ b/src/glitz.h
@@ -374,6 +374,61 @@ glitz_surface_set_clip_region (glitz_surface_t *surface,
glitz_bool_t
glitz_surface_valid_target (glitz_surface_t *surface);
+
+/* glitz_context.c */
+
+typedef struct _glitz_context glitz_context_t;
+
+glitz_context_t *
+glitz_context_create (glitz_drawable_t *drawable,
+ glitz_drawable_format_t *format);
+void
+glitz_context_destroy (glitz_context_t *context);
+
+void
+glitz_context_reference (glitz_context_t *context);
+
+void
+glitz_context_copy (glitz_context_t *src,
+ glitz_context_t *dst,
+ unsigned long mask);
+
+typedef void (*glitz_lose_current_function_t) (void *closure);
+
+void
+glitz_context_set_user_data (glitz_context_t *context,
+ void *closure,
+ glitz_lose_current_function_t lose_current);
+
+typedef void (*glitz_function_pointer_t) (void);
+
+glitz_function_pointer_t
+glitz_context_get_proc_address (glitz_context_t *context,
+ const char *name);
+
+void
+glitz_context_make_current (glitz_context_t *context);
+
+/* XXX: The following context functions are part of a temporary solution and
+ will be removed soon. It should not be possible to attach a surface to a
+ context. Only drawables can be used with contexts. */
+void
+glitz_context_set_surface (glitz_context_t *context,
+ glitz_surface_t *surface);
+
+void
+glitz_context_set_viewport (glitz_context_t *context,
+ int x,
+ int y,
+ int width,
+ int height);
+void
+glitz_context_set_scissor (glitz_context_t *context,
+ int x,
+ int y,
+ int width,
+ int height);
+
/* glitz_rect.c */
diff --git a/src/glitz_surface.c b/src/glitz_surface.c
index 4e2fad9..f0f86d5 100644
--- a/src/glitz_surface.c
+++ b/src/glitz_surface.c
@@ -236,8 +236,8 @@ _glitz_surface_sync_texture (glitz_surface_t *surface)
}
}
-static void
-_glitz_surface_sync_drawable (glitz_surface_t *surface)
+void
+glitz_surface_sync_drawable (glitz_surface_t *surface)
{
if (REGION_NOTEMPTY (&surface->drawable_damage))
{
@@ -440,7 +440,7 @@ _glitz_surface_update_state (glitz_surface_t *surface)
height = surface->texture.height;
}
- if (drawable->update_all ||
+ if (drawable->update_all ||
drawable->viewport.x != surface->x ||
drawable->viewport.y != surface->y ||
drawable->viewport.width != surface->box.x2 ||
@@ -560,7 +560,7 @@ glitz_surface_push_current (glitz_surface_t *surface,
glitz_framebuffer_unbind (&surface->attached->backend->gl);
_glitz_surface_update_state (surface);
- _glitz_surface_sync_drawable (surface);
+ glitz_surface_sync_drawable (surface);
}
}
else
@@ -603,15 +603,6 @@ glitz_surface_pop_current (glitz_surface_t *surface)
_glitz_surface_update_state (other);
}
-glitz_status_t
-glitz_surface_make_current_read (glitz_surface_t *surface)
-{
- if (surface->attached)
- return surface->attached->backend->make_current_read (surface->attached);
- else
- return surface->drawable->backend->make_current_read (surface->drawable);
-}
-
void
glitz_surface_set_transform (glitz_surface_t *surface,
glitz_transform_t *transform)
diff --git a/src/glitz_util.c b/src/glitz_util.c
index 8486a10..369dbe9 100644
--- a/src/glitz_util.c
+++ b/src/glitz_util.c
@@ -351,7 +351,6 @@ glitz_clamp_value (glitz_float_t *value,
void
glitz_initiate_state (glitz_gl_proc_address_list_t *gl)
{
- gl->disable (GLITZ_GL_DEPTH_TEST);
gl->hint (GLITZ_GL_PERSPECTIVE_CORRECTION_HINT, GLITZ_GL_FASTEST);
gl->disable (GLITZ_GL_CULL_FACE);
gl->depth_mask (GLITZ_GL_FALSE);
diff --git a/src/glitzint.h b/src/glitzint.h
index f7d404f..fd128cc 100644
--- a/src/glitzint.h
+++ b/src/glitzint.h
@@ -87,8 +87,6 @@
#define GLITZ_CONTEXT_STACK_SIZE 16
-typedef void (*glitz_function_pointer_t) (void);
-
typedef struct _glitz_gl_proc_address_list_t {
/* core */
@@ -332,8 +330,25 @@ typedef struct glitz_backend {
void
(*swap_buffers) (void *drawable);
- glitz_status_t
- (*make_current_read) (void *drawable);
+ glitz_context_t *
+ (*create_context) (void *drawable,
+ glitz_drawable_format_t *format);
+
+ void
+ (*destroy_context) (void *context);
+
+ void
+ (*copy_context) (void *src,
+ void *dst,
+ unsigned long mask);
+
+ void
+ (*make_current) (void *context,
+ void *drawable);
+
+ glitz_function_pointer_t
+ (*get_proc_address) (void *context,
+ const char *name);
glitz_gl_proc_address_list_t gl;
@@ -574,6 +589,16 @@ struct _glitz_surface {
#define GLITZ_GL_SURFACE(surface) \
glitz_gl_proc_address_list_t *gl = &(surface)->drawable->backend->gl;
+struct _glitz_context {
+ glitz_drawable_t *drawable;
+ glitz_surface_t *surface;
+ int ref_count;
+ void *closure;
+ glitz_lose_current_function_t lose_current;
+ glitz_box_t scissor;
+ glitz_box_t viewport;
+};
+
typedef struct _glitz_composite_op_t glitz_composite_op_t;
typedef void (*glitz_combine_function_t) (glitz_composite_op_t *);
@@ -726,15 +751,15 @@ glitz_surface_push_current (glitz_surface_t *surface,
extern void __internal_linkage
glitz_surface_pop_current (glitz_surface_t *surface);
-extern glitz_status_t __internal_linkage
-glitz_surface_make_current_read (glitz_surface_t *surface);
-
extern void __internal_linkage
glitz_surface_damage (glitz_surface_t *surface,
glitz_box_t *box,
int what);
extern void __internal_linkage
+glitz_surface_sync_drawable (glitz_surface_t *surface);
+
+extern void __internal_linkage
glitz_surface_status_add (glitz_surface_t *surface,
int flags);
@@ -833,6 +858,13 @@ glitz_framebuffer_complete (glitz_gl_proc_address_list_t *gl,
glitz_framebuffer_t *framebuffer,
glitz_texture_t *texture);
+void
+_glitz_context_init (glitz_context_t *context,
+ glitz_drawable_t *drawable);
+
+void
+_glitz_context_fini (glitz_context_t *context);
+
#define MAXSHORT SHRT_MAX
#define MINSHORT SHRT_MIN
@@ -944,5 +976,15 @@ slim_hidden_proto(glitz_multi_array_reset)
slim_hidden_proto(glitz_set_multi_array)
slim_hidden_proto(glitz_buffer_set_data)
slim_hidden_proto(glitz_buffer_get_data)
+slim_hidden_proto(glitz_context_create)
+slim_hidden_proto(glitz_context_destroy)
+slim_hidden_proto(glitz_context_reference)
+slim_hidden_proto(glitz_context_copy)
+slim_hidden_proto(glitz_context_set_user_data)
+slim_hidden_proto(glitz_context_get_proc_address)
+slim_hidden_proto(glitz_context_make_current)
+slim_hidden_proto(glitz_context_set_surface)
+slim_hidden_proto(glitz_context_set_viewport)
+slim_hidden_proto(glitz_context_set_scissor)
#endif /* GLITZINT_H_INCLUDED */
diff --git a/src/glx/glitz_glx_context.c b/src/glx/glitz_glx_context.c
index 99a13e2..e6cf48b 100644
--- a/src/glx/glitz_glx_context.c
+++ b/src/glx/glitz_glx_context.c
@@ -104,6 +104,101 @@ _glitz_glx_context_create_using_fbconfig (glitz_glx_screen_info_t *screen_info,
XFree (fbconfigs);
}
+static glitz_context_t *
+_glitz_glx_create_context (void *abstract_drawable,
+ glitz_drawable_format_t *format)
+{
+ glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
+ glitz_glx_screen_info_t *screen_info = drawable->screen_info;
+ int format_id = screen_info->format_ids[format->id];
+ glitz_glx_context_t *context;
+
+ context = malloc (sizeof (glitz_glx_context_t));
+ if (!context)
+ return NULL;
+
+ _glitz_context_init (&context->base, &drawable->base);
+
+ if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
+ _glitz_glx_context_create_using_fbconfig (screen_info,
+ format_id,
+ screen_info->root_context,
+ context);
+ else
+ _glitz_glx_context_create (screen_info,
+ format_id,
+ screen_info->root_context,
+ context);
+
+ return (glitz_context_t *) context;
+}
+
+static void
+_glitz_glx_context_destroy (void *abstract_context)
+{
+ glitz_glx_context_t *context = (glitz_glx_context_t *) abstract_context;
+ glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+ context->base.drawable;
+
+ if (drawable->screen_info->display_info->thread_info->cctx == &context->base)
+ {
+ glXMakeCurrent (drawable->screen_info->display_info->display,
+ None, NULL);
+
+ drawable->screen_info->display_info->thread_info->cctx = NULL;
+ }
+
+ glXDestroyContext (drawable->screen_info->display_info->display,
+ context->context);
+
+ _glitz_context_fini (&context->base);
+
+ free (context);
+}
+
+static void
+_glitz_glx_copy_context (void *abstract_src,
+ void *abstract_dst,
+ unsigned long mask)
+{
+ glitz_glx_context_t *src = (glitz_glx_context_t *) abstract_src;
+ glitz_glx_context_t *dst = (glitz_glx_context_t *) abstract_dst;
+ glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+ src->base.drawable;
+
+ glXCopyContext (drawable->screen_info->display_info->display,
+ src->context, dst->context, mask);
+}
+
+static void
+_glitz_glx_make_current (void *abstract_context,
+ void *abstract_drawable)
+{
+ glitz_glx_context_t *context = (glitz_glx_context_t *) abstract_context;
+ glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
+ glitz_glx_display_info_t *display_info = drawable->screen_info->display_info;
+
+ if ((glXGetCurrentContext () != context->context) ||
+ (glXGetCurrentDrawable () != drawable->drawable))
+ glXMakeCurrent (display_info->display, drawable->drawable,
+ context->context);
+
+ display_info->thread_info->cctx = &context->base;
+}
+
+static glitz_function_pointer_t
+_glitz_glx_context_get_proc_address (void *abstract_context,
+ const char *name)
+{
+ glitz_glx_context_t *context = (glitz_glx_context_t *) abstract_context;
+ glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+ context->base.drawable;
+
+ _glitz_glx_make_current (context, drawable);
+
+ return glitz_glx_get_proc_address (name, drawable->screen_info);
+}
+
glitz_glx_context_t *
glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
glitz_drawable_format_t *format)
@@ -143,7 +238,7 @@ glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
format_id,
screen_info->root_context,
context);
-
+
if (!screen_info->root_context)
screen_info->root_context = context->context;
@@ -156,8 +251,13 @@ glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
context->backend.push_current = glitz_glx_push_current;
context->backend.pop_current = glitz_glx_pop_current;
context->backend.swap_buffers = glitz_glx_swap_buffers;
- context->backend.make_current_read = glitz_glx_make_current_read;
-
+
+ context->backend.create_context = _glitz_glx_create_context;
+ context->backend.destroy_context = _glitz_glx_context_destroy;
+ context->backend.copy_context = _glitz_glx_copy_context;
+ context->backend.make_current = _glitz_glx_make_current;
+ context->backend.get_proc_address = _glitz_glx_context_get_proc_address;
+
context->backend.drawable_formats = screen_info->formats;
context->backend.n_drawable_formats = screen_info->n_formats;
@@ -203,7 +303,7 @@ _glitz_glx_context_initialize (glitz_glx_screen_info_t *screen_info,
glitz_initiate_state (&_glitz_glx_gl_proc_address);
- version = context->backend.gl.get_string (GLITZ_GL_VERSION);
+ version = (const char *) context->backend.gl.get_string (GLITZ_GL_VERSION);
if (version)
{
/* Having trouble with TexSubImage2D to NPOT GL_TEXTURE_2D textures when
@@ -223,15 +323,27 @@ _glitz_glx_context_initialize (glitz_glx_screen_info_t *screen_info,
static void
_glitz_glx_context_make_current (glitz_glx_drawable_t *drawable,
- glitz_bool_t flush)
+ glitz_bool_t finish)
{
- if (flush)
- glFlush ();
+ glitz_glx_display_info_t *display_info = drawable->screen_info->display_info;
+
+ if (finish)
+ glFinish ();
+
+ if (display_info->thread_info->cctx)
+ {
+ glitz_context_t *ctx = display_info->thread_info->cctx;
+
+ if (ctx->lose_current)
+ ctx->lose_current (ctx->closure);
- glXMakeCurrent (drawable->screen_info->display_info->display,
+ display_info->thread_info->cctx = NULL;
+ }
+
+ glXMakeCurrent (display_info->display,
drawable->drawable,
drawable->context->context);
-
+
drawable->base.update_all = 1;
if (!drawable->context->initialized)
@@ -247,11 +359,20 @@ _glitz_glx_context_update (glitz_glx_drawable_t *drawable,
switch (constraint) {
case GLITZ_NONE:
break;
- case GLITZ_ANY_CONTEXT_CURRENT:
- context = glXGetCurrentContext ();
- if (context == (GLXContext) 0)
+ case GLITZ_ANY_CONTEXT_CURRENT: {
+ glitz_glx_display_info_t *dinfo = drawable->screen_info->display_info;
+
+ if (dinfo->thread_info->cctx)
+ {
_glitz_glx_context_make_current (drawable, 0);
- break;
+ }
+ else
+ {
+ context = glXGetCurrentContext ();
+ if (context == (GLXContext) 0)
+ _glitz_glx_context_make_current (drawable, 0);
+ }
+ } break;
case GLITZ_CONTEXT_CURRENT:
context = glXGetCurrentContext ();
if (context != drawable->context->context)
diff --git a/src/glx/glitz_glx_drawable.c b/src/glx/glitz_glx_drawable.c
index e6c2232..f770476 100644
--- a/src/glx/glitz_glx_drawable.c
+++ b/src/glx/glitz_glx_drawable.c
@@ -29,12 +29,6 @@
#include "glitz_glxint.h"
-glitz_status_t
-glitz_glx_make_current_read (void *abstract_surface)
-{
- return GLITZ_STATUS_NOT_SUPPORTED;
-}
-
static glitz_glx_drawable_t *
_glitz_glx_create_drawable (glitz_glx_screen_info_t *screen_info,
glitz_glx_context_t *context,
@@ -73,7 +67,7 @@ _glitz_glx_create_drawable (glitz_glx_screen_info_t *screen_info,
free (drawable);
return NULL;
}
-
+
screen_info->drawables++;
return drawable;
@@ -139,7 +133,7 @@ glitz_glx_create_drawable_for_window (Display *display,
screen_info = glitz_glx_screen_info_get (display, screen);
if (!screen_info)
return NULL;
-
+
context = glitz_glx_context_get (screen_info, format);
if (!context)
return NULL;
diff --git a/src/glx/glitz_glx_info.c b/src/glx/glitz_glx_info.c
index c8e60d1..def1de7 100644
--- a/src/glx/glitz_glx_info.c
+++ b/src/glx/glitz_glx_info.c
@@ -277,6 +277,8 @@ _glitz_glx_thread_info_fini (glitz_glx_thread_info_t *thread_info)
dlclose (thread_info->dlhand);
thread_info->dlhand = NULL;
}
+
+ thread_info->cctx = NULL;
}
#ifdef XTHREADS
@@ -295,6 +297,7 @@ _glitz_glx_thread_info_init (glitz_glx_thread_info_t *thread_info)
thread_info->n_displays = 0;
thread_info->gl_library = NULL;
thread_info->dlhand = NULL;
+ thread_info->cctx = NULL;
}
static void
diff --git a/src/glx/glitz_glxint.h b/src/glx/glitz_glxint.h
index 27190cc..fda6d9f 100644
--- a/src/glx/glitz_glxint.h
+++ b/src/glx/glitz_glxint.h
@@ -64,6 +64,7 @@ typedef struct _glitz_glx_thread_info_t {
int n_displays;
char *gl_library;
void *dlhand;
+ glitz_context_t *cctx;
} glitz_glx_thread_info_t;
struct _glitz_glx_display_info_t {
@@ -80,6 +81,7 @@ typedef struct _glitz_glx_context_info_t {
} glitz_glx_context_info_t;
typedef struct _glitz_glx_context_t {
+ glitz_context_t base;
GLXContext context;
glitz_format_id_t id;
GLXFBConfig fbconfig;
@@ -164,6 +166,10 @@ glitz_glx_push_current (void *abstract_drawable,
extern glitz_surface_t __internal_linkage *
glitz_glx_pop_current (void *abstract_drawable);
+void
+glitz_glx_make_current (void *abstract_drawable,
+ glitz_constraint_t constraint);
+
extern glitz_status_t __internal_linkage
glitz_glx_make_current_read (void *abstract_surface);