[cairo-commit] glitz/src/agl glitz_agl_context.c, 1.2,
1.3 glitz_agl_drawable.c, 1.2, 1.3 glitz_agl_info.c, 1.2,
1.3 glitz_aglint.h, 1.2, 1.3
David Reveman
commit at pdx.freedesktop.org
Tue Apr 12 07:54:59 PDT 2005
- Previous message: [cairo-commit] glitz/src/glx glitz_glx_context.c, 1.3,
1.4 glitz_glx_drawable.c, 1.2, 1.3 glitz_glx_info.c, 1.3,
1.4 glitz_glxint.h, 1.2, 1.3
- Next message: [cairo-commit] glitz/src Makefile.am, 1.10, 1.11 glitz.c, 1.31,
1.32 glitz.h, 1.28, 1.29 glitz_surface.c, 1.27,
1.28 glitz_util.c, 1.13, 1.14 glitzint.h, 1.32, 1.33
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: davidr
Update of /cvs/cairo/glitz/src/agl
In directory gabe:/tmp/cvs-serv20487/src/agl
Modified Files:
glitz_agl_context.c glitz_agl_drawable.c glitz_agl_info.c
glitz_aglint.h
Log Message:
Add glitz_context_t interface
Index: glitz_agl_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_agl_context.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_agl_context.c 25 Jan 2005 19:50:26 -0000 1.2
+++ glitz_agl_context.c 12 Apr 2005 14:54:56 -0000 1.3
@@ -102,6 +102,137 @@
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 @@
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 @@
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,
Index: glitz_agl_drawable.c
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_agl_drawable.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_agl_drawable.c 25 Jan 2005 19:50:26 -0000 1.2
+++ glitz_agl_drawable.c 12 Apr 2005 14:54:56 -0000 1.3
@@ -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,
Index: glitz_agl_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_agl_info.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_agl_info.c 25 Jan 2005 19:50:26 -0000 1.2
+++ glitz_agl_info.c 12 Apr 2005 14:54:56 -0000 1.3
@@ -187,6 +187,7 @@
0,
NULL,
0,
+ NULL,
{ 0 }
};
@@ -225,6 +226,8 @@
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))
Index: glitz_aglint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_aglint.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_aglint.h 25 Jan 2005 19:50:26 -0000 1.2
+++ glitz_aglint.h 12 Apr 2005 14:54:56 -0000 1.3
@@ -49,6 +49,7 @@
} 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 @@
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 @@
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);
- Previous message: [cairo-commit] glitz/src/glx glitz_glx_context.c, 1.3,
1.4 glitz_glx_drawable.c, 1.2, 1.3 glitz_glx_info.c, 1.3,
1.4 glitz_glxint.h, 1.2, 1.3
- Next message: [cairo-commit] glitz/src Makefile.am, 1.10, 1.11 glitz.c, 1.31,
1.32 glitz.h, 1.28, 1.29 glitz_surface.c, 1.27,
1.28 glitz_util.c, 1.13, 1.14 glitzint.h, 1.32, 1.33
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list