diff options
author | David Reveman <davidr@novell.com> | 2005-11-09 12:22:04 +0000 |
---|---|---|
committer | David Reveman <davidr@novell.com> | 2005-11-09 12:22:04 +0000 |
commit | 4eb06d14799ec475789756feedb09feefb476adb (patch) | |
tree | 72f9e67377617bdfb9433e09a0c350c4190998e5 | |
parent | 5c13cb3ce423a6085da906e6356e312eeebb47a1 (diff) |
AGL backend updates (Vladimir Vukicevic)
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/agl/glitz-agl.h | 10 | ||||
-rw-r--r-- | src/agl/glitz_agl_context.c | 30 | ||||
-rw-r--r-- | src/agl/glitz_agl_drawable.c | 23 | ||||
-rw-r--r-- | src/agl/glitz_agl_format.c | 137 | ||||
-rw-r--r-- | src/agl/glitz_aglint.h | 6 |
6 files changed, 126 insertions, 84 deletions
@@ -1,3 +1,7 @@ +2005-11-09 David Reveman <davidr@novell.com> + + * src/agl/glitz_aglint.h: AGL backend updates (Vladimir Vukicevic) + 2005-09-02 David Reveman <davidr@novell.com> * src/glitz.h (GLITZ_REVISION): Bump version to 0.5.0. diff --git a/src/agl/glitz-agl.h b/src/agl/glitz-agl.h index afbdf41..173a005 100644 --- a/src/agl/glitz-agl.h +++ b/src/agl/glitz-agl.h @@ -47,10 +47,14 @@ glitz_agl_fini (void); /* glitz_agl_format.c */ glitz_drawable_format_t * -glitz_agl_find_drawable_format (unsigned long mask, - const glitz_drawable_format_t *templ, - int count); +glitz_agl_find_window_format (unsigned long mask, + const glitz_drawable_format_t *templ, + int count); +glitz_drawable_format_t * +glitz_agl_find_pbuffer_format (unsigned long mask, + const glitz_drawable_format_t *templ, + int count); /* glitz_agl_drawable.c */ diff --git a/src/agl/glitz_agl_context.c b/src/agl/glitz_agl_context.c index f6491d6..130654c 100644 --- a/src/agl/glitz_agl_context.c +++ b/src/agl/glitz_agl_context.c @@ -36,7 +36,7 @@ _glitz_agl_get_bundle (const char *name) { CFBundleRef bundle = 0; FSRefParam ref_param; - unsigned char framework_name[256]; + char framework_name[256]; framework_name[0] = strlen (name); strcpy (&framework_name[1], name); @@ -52,7 +52,7 @@ _glitz_agl_get_bundle (const char *name) memset (&ref, 0, sizeof (ref)); - ref_param.ioNamePtr = framework_name; + ref_param.ioNamePtr = (unsigned char *) framework_name; ref_param.newRef = &ref; if (PBMakeFSRefSync (&ref_param) == noErr) { @@ -173,9 +173,9 @@ _glitz_agl_make_current (void *abstract_drawable, if (drawable->base.width != drawable->width || drawable->base.height != drawable->height) - _glitz_agl_drawable_update_size (drawable, - drawable->base.width, - drawable->base.height); + glitz_agl_drawable_update_size (drawable, + drawable->base.width, + drawable->base.height); if (aglGetCurrentContext () != context->context) { @@ -186,7 +186,7 @@ _glitz_agl_make_current (void *abstract_drawable, if (drawable->pbuffer) { AGLPbuffer pbuffer; - GLuint unused; + GLint unused; aglGetPBuffer (context->context, &pbuffer, &unused, &unused, &unused); @@ -242,7 +242,7 @@ _glitz_agl_context_get_proc_address (void *abstract_context, glitz_function_pointer_t func; CFBundleRef bundle; - _glitz_agl_make_current (drawable, context, NULL); + _glitz_agl_make_current (drawable, context); bundle = _glitz_agl_get_bundle ("OpenGL.framework"); @@ -312,17 +312,17 @@ glitz_agl_context_get (glitz_agl_thread_info_t *thread_info, context->backend.drawable_formats = NULL; context->backend.n_drawable_formats = 0; - if (screen_info->n_formats) + if (thread_info->n_formats) { int size; - size = sizeof (glitz_int_drawable_format_t) * screen_info->n_formats; + size = sizeof (glitz_int_drawable_format_t) * thread_info->n_formats; context->backend.drawable_formats = malloc (size); if (context->backend.drawable_formats) { - memcpy (context->backend.drawable_formats, screen_info->formats, + memcpy (context->backend.drawable_formats, thread_info->formats, size); - context->backend.n_drawable_formats = screen_info->n_formats; + context->backend.n_drawable_formats = thread_info->n_formats; } } @@ -436,9 +436,9 @@ _glitz_agl_context_update (glitz_agl_drawable_t *drawable, case GLITZ_DRAWABLE_CURRENT: if (drawable->base.width != drawable->width || drawable->base.height != drawable->height) - _glitz_agl_drawable_update_size (drawable, - drawable->base.width, - drawable->base.height); + glitz_agl_drawable_update_size (drawable, + drawable->base.width, + drawable->base.height); context = aglGetCurrentContext (); if (context != drawable->context->context) { @@ -446,7 +446,7 @@ _glitz_agl_context_update (glitz_agl_drawable_t *drawable, } else { if (drawable->pbuffer) { AGLPbuffer pbuffer; - GLuint unused; + GLint unused; aglGetPBuffer (drawable->context->context, &pbuffer, &unused, &unused, &unused); diff --git a/src/agl/glitz_agl_drawable.c b/src/agl/glitz_agl_drawable.c index d2fe826..991efae 100644 --- a/src/agl/glitz_agl_drawable.c +++ b/src/agl/glitz_agl_drawable.c @@ -52,7 +52,7 @@ _glitz_agl_create_drawable (glitz_agl_thread_info_t *thread_info, drawable->height = height; _glitz_drawable_init (&drawable->base, - format, + &thread_info->formats[format->id], &context->backend, width, height); @@ -73,16 +73,15 @@ _glitz_agl_create_drawable (glitz_agl_thread_info_t *thread_info, } glitz_bool_t -_glitz_agl_drawable_update_size (glitz_agl_drawable_t *drawable, - int width, - int height) +glitz_agl_drawable_update_size (glitz_agl_drawable_t *drawable, + int width, + int height) { if (drawable->pbuffer) { - glitz_agl_pbuffer_destroy (drawable->thread_info, drawable->pbuffer); + glitz_agl_pbuffer_destroy (drawable->pbuffer); drawable->pbuffer = glitz_agl_pbuffer_create (drawable->thread_info, - drawable->context->fbconfig, (int) width, (int) height); if (!drawable->pbuffer) return 0; @@ -104,9 +103,6 @@ _glitz_agl_create_pbuffer_drawable (glitz_agl_thread_info_t *thread_info, glitz_agl_context_t *context; AGLPbuffer pbuffer; - if (!format->types.pbuffer) - return NULL; - context = glitz_agl_context_get (thread_info, format); if (!context) return NULL; @@ -158,7 +154,7 @@ glitz_agl_create_drawable_for_window (glitz_drawable_format_t *format, if (!thread_info) return NULL; - if (format->id >= screen_info->n_formats) + if (format->id >= thread_info->n_formats) return NULL; context = glitz_agl_context_get (thread_info, format); @@ -186,7 +182,7 @@ glitz_agl_create_pbuffer_drawable (glitz_drawable_format_t *format, if (!thread_info) return NULL; - if (format->id >= screen_info->n_formats) + if (format->id >= thread_info->n_formats) return NULL; return _glitz_agl_create_pbuffer_drawable (thread_info, format, @@ -208,8 +204,9 @@ glitz_agl_destroy (void *abstract_drawable) */ glitz_agl_push_current (abstract_drawable, NULL, GLITZ_CONTEXT_CURRENT); - glitz_program_map_fini (&drawable->base.backend->gl, + glitz_program_map_fini (drawable->base.backend->gl, &drawable->thread_info->program_map); + glitz_program_map_init (&drawable->thread_info->program_map); glitz_agl_pop_current (abstract_drawable); } @@ -219,7 +216,7 @@ glitz_agl_destroy (void *abstract_drawable) if (context == drawable->context->context) { if (drawable->pbuffer) { AGLPbuffer pbuffer; - GLuint unused; + GLint unused; aglGetPBuffer (context, &pbuffer, &unused, &unused, &unused); diff --git a/src/agl/glitz_agl_format.c b/src/agl/glitz_agl_format.c index e66c8fb..29bd101 100644 --- a/src/agl/glitz_agl_format.c +++ b/src/agl/glitz_agl_format.c @@ -153,41 +153,44 @@ _glitz_agl_format_compare (const void *elem1, i = score[0] = score[1] = 0; for (; i < 2; i++) { - if (format[i]->color.red_size) { - if (format[i]->color.red_size == 8) + if (format[i]->d.color.red_size) { + if (format[i]->d.color.red_size == 8) score[i] += 5; score[i] += 10; } - if (format[i]->color.green_size) { - if (format[i]->color.green_size == 8) + if (format[i]->d.color.green_size) { + if (format[i]->d.color.green_size == 8) score[i] += 5; score[i] += 10; } - if (format[i]->color.alpha_size) { - if (format[i]->color.alpha_size == 8) + if (format[i]->d.color.alpha_size) { + if (format[i]->d.color.alpha_size == 8) score[i] += 5; score[i] += 10; } - if (format[i]->stencil_size) + if (format[i]->d.stencil_size) score[i] += 5; - if (format[i]->depth_size) + if (format[i]->d.depth_size) score[i] += 5; - if (format[i]->doublebuffer) + if (format[i]->d.doublebuffer) score[i] += 10; - if (format[i]->types.window) + if (format[i]->d.samples > 1) + score[i] -= (20 - format[i]->samples); + + if (format[i]->types & GLITZ_DRAWABLE_TYPE_WINDOW_MASK) score[i] += 10; - if (format[i]->types.pbuffer) + if (format[i]->types & GLITZ_DRAWABLE_TYPE_PBUFFER_MASK) score[i] += 10; - if (format[i]->samples > 1) - score[i] -= (20 - format[i]->samples); + if (format[i]->caveat) + score[i] -= 1000; } return score[1] - score[0]; @@ -206,14 +209,14 @@ _glitz_add_format (glitz_agl_thread_info_t *thread_info, thread_info->formats = realloc (thread_info->formats, - sizeof (glitz_drawable_format_t) * (n + 1)); + sizeof (glitz_int_drawable_format_t) * (n + 1)); thread_info->pixel_formats = realloc (thread_info->pixel_formats, sizeof (AGLPixelFormat) * (n + 1)); if (thread_info->formats && thread_info->pixel_formats) { - thread_info->formats[n] = *format; - thread_info->formats[n].id = n; + thread_info->formats[n] = *(glitz_int_drawable_format_t*)format; + thread_info->formats[n].d.id = n; thread_info->pixel_formats[n] = pixel_format; thread_info->n_formats++; } @@ -223,12 +226,12 @@ _glitz_add_format (glitz_agl_thread_info_t *thread_info, void glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) { - glitz_drawable_format_t format; + glitz_int_drawable_format_t format; AGLPixelFormat pixel_format, *new_pfs; int n_attribs_list, i; - format.types.window = 1; - format.id = 0; + format.types = GLITZ_DRAWABLE_TYPE_WINDOW_MASK; + format.d.id = 0 n_attribs_list = sizeof (_attribs_list) / sizeof (GLint *); @@ -245,20 +248,20 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) } aglDescribePixelFormat (pixel_format, AGL_DOUBLEBUFFER, &value); - format.doublebuffer = (value)? 1: 0; + format.d.doublebuffer = (value)? 1: 0; aglDescribePixelFormat (pixel_format, AGL_RED_SIZE, &value); - format.color.red_size = (unsigned short) value; + format.d.color.red_size = (unsigned short) value; aglDescribePixelFormat (pixel_format, AGL_GREEN_SIZE, &value); - format.color.green_size = (unsigned short) value; + format.d.color.green_size = (unsigned short) value; aglDescribePixelFormat (pixel_format, AGL_BLUE_SIZE, &value); - format.color.blue_size = (unsigned short) value; + format.d.color.blue_size = (unsigned short) value; aglDescribePixelFormat (pixel_format, AGL_ALPHA_SIZE, &value); - format.color.alpha_size = (unsigned short) value; + format.d.color.alpha_size = (unsigned short) value; aglDescribePixelFormat (pixel_format, AGL_DEPTH_SIZE, &value); - format.depth_size = (unsigned short) value; + format.d.depth_size = (unsigned short) value; aglDescribePixelFormat (pixel_format, AGL_STENCIL_SIZE, &value); - format.stencil_size = (unsigned short) value; + format.d.stencil_size = (unsigned short) value; if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_MULTISAMPLE_MASK) { @@ -266,42 +269,42 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) &value); if (value) { aglDescribePixelFormat (pixel_format, AGL_SAMPLES_ARB, &value); - format.samples = (unsigned short) (value > 1)? value: 1; + format.d.samples = (unsigned short) (value > 1)? value: 1; } else - format.samples = 1; + format.d.samples = 1; } else - format.samples = 1; + format.d.samples = 1; if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_PBUFFER_MASK) { - if (format.color.red_size && format.color.green_size && - format.color.blue_size && format.color.alpha_size && - format.doublebuffer == 0 && format.stencil_size == 0 && - format.depth_size == 0) { + if (format.d.color.red_size && format.d.color.green_size && + format.d.color.blue_size && format.d.color.alpha_size && + format.d.doublebuffer == 0 && format.d.stencil_size == 0 && + format.d.depth_size == 0) { if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK) - format.types.pbuffer = 1; - else if (format.samples == 1) - format.types.pbuffer = 1; + format.types |= GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; + else if (format.d.samples == 1) + format.types |= GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; else - format.types.pbuffer = 0; + format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; } else - format.types.pbuffer = 0; + format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; } else - format.types.pbuffer = 0; + format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; - if (format.color.red_size || - format.color.green_size || - format.color.blue_size || - format.color.alpha_size) - _glitz_add_format (thread_info, &format, pixel_format); + if (format.d.color.red_size || + format.d.color.green_size || + format.d.color.blue_size || + format.d.color.alpha_size) + _glitz_agl_add_format (thread_info, &format, pixel_format); } if (!thread_info->n_formats) return; qsort (thread_info->formats, thread_info->n_formats, - sizeof (glitz_drawable_format_t), _glitz_agl_format_compare); + sizeof (glitz_int_drawable_format_t), _glitz_agl_format_compare); /* * Update AGLPixelFormat list so that it matches the sorted format list. @@ -313,8 +316,8 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) } for (i = 0; i < thread_info->n_formats; i++) { - new_pfs[i] = thread_info->pixel_formats[thread_info->formats[i].id]; - thread_info->formats[i].id = i; + new_pfs[i] = thread_info->pixel_formats[thread_info->formats[i].d.id]; + thread_info->formats[i].d.id = i; } free (thread_info->pixel_formats); @@ -322,14 +325,42 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) } glitz_drawable_format_t * -glitz_agl_find_drawable_format (unsigned long mask, - const glitz_drawable_format_t *templ, - int count) +glitz_agl_find_window_format (unsigned long mask, + const glitz_drawable_format_t *templ, + int count) { - glitz_agl_thread_info_t *thread_info = glitz_agl_thread_info_get (); + glitz_int_drawable_format_t itempl; + glitz_agl_thread_info_t *thread_info = + glitz_agl_thread_info_get (); + + glitz_drawable_format_copy (templ, &itempl.d, mask); + + itempl.types = GLITZ_DRAWABLE_TYPE_WINDOW_MASK; + mask |= GLITZ_INT_FORMAT_WINDOW_MASK; + + return glitz_drawable_format_find (thread_info->formats, + thread_info->n_formats, + mask, &itempl, count); +} +slim_hidden_def(glitz_agl_find_window_format); + + +glitz_drawable_format_t * +glitz_agl_find_pbuffer_format (unsigned long mask, + const glitz_drawable_format_t *templ, + int count) +{ + glitz_int_drawable_format_t itempl; + glitz_agl_thread_info_t *thread_info = + glitz_agl_thread_info_get (); + + glitz_drawable_format_copy (templ, &itempl.d, mask); + + itempl.types = GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; + mask |= GLITZ_INT_FORMAT_PBUFFER_MASK; return glitz_drawable_format_find (thread_info->formats, thread_info->n_formats, - mask, templ, count); + mask, &itempl, count); } -slim_hidden_def(glitz_agl_find_drawable_format); +slim_hidden_def(glitz_agl_find_pbuffer_format); diff --git a/src/agl/glitz_aglint.h b/src/agl/glitz_aglint.h index 0060319..1a058b0 100644 --- a/src/agl/glitz_aglint.h +++ b/src/agl/glitz_aglint.h @@ -130,6 +130,11 @@ glitz_agl_destroy (void *abstract_drawable); extern glitz_bool_t __internal_linkage glitz_agl_swap_buffers (void *abstract_drawable); +extern glitz_bool_t __internal_linkage +glitz_agl_drawable_update_size (glitz_agl_drawable_t *drawable, + int width, + int height); + /* Avoid unnecessary PLT entries. */ slim_hidden_proto(glitz_agl_init) @@ -137,5 +142,6 @@ slim_hidden_proto(glitz_agl_fini) slim_hidden_proto(glitz_agl_find_drawable_format) slim_hidden_proto(glitz_agl_create_drawable_for_window) slim_hidden_proto(glitz_agl_create_pbuffer_drawable) +slim_hidden_proto(glitz_agl_drawable_update_size) #endif /* GLITZ_GLXINT_H_INCLUDED */ |