[cairo-commit] glitz/src/agl glitz-agl.h, 1.3, 1.4 glitz_agl_context.c, 1.5, 1.6 glitz_agl_drawable.c, 1.4, 1.5 glitz_agl_format.c, 1.3, 1.4 glitz_aglint.h, 1.4, 1.5

David Reveman commit at pdx.freedesktop.org
Wed Nov 9 04:22:07 PST 2005


Committed by: davidr

Update of /cvs/cairo/glitz/src/agl
In directory gabe:/tmp/cvs-serv22454/src/agl

Modified Files:
	glitz-agl.h glitz_agl_context.c glitz_agl_drawable.c 
	glitz_agl_format.c glitz_aglint.h 
Log Message:
AGL backend updates (Vladimir Vukicevic)

Index: glitz-agl.h
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz-agl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz-agl.h	14 Sep 2005 15:57:16 -0000	1.3
+++ glitz-agl.h	9 Nov 2005 12:22:04 -0000	1.4
@@ -47,10 +47,14 @@
 /* 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 */
 

Index: glitz_agl_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_agl_context.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- glitz_agl_context.c	14 Sep 2005 15:57:16 -0000	1.5
+++ glitz_agl_context.c	9 Nov 2005 12:22:04 -0000	1.6
@@ -36,7 +36,7 @@
 {
     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 @@
 
 	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 @@
 
     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 @@
 	if (drawable->pbuffer)
 	{
 	    AGLPbuffer pbuffer;
-	    GLuint unused;
+	    GLint unused;
 
 	    aglGetPBuffer (context->context, &pbuffer,
 			   &unused, &unused, &unused);
@@ -242,7 +242,7 @@
     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 @@
     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 @@
     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 @@
 	} else {
 	    if (drawable->pbuffer) {
 		AGLPbuffer pbuffer;
-		GLuint unused;
+		GLint unused;
 
 		aglGetPBuffer (drawable->context->context, &pbuffer,
 			       &unused, &unused, &unused);

Index: glitz_agl_drawable.c
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_agl_drawable.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glitz_agl_drawable.c	14 Sep 2005 15:57:16 -0000	1.4
+++ glitz_agl_drawable.c	9 Nov 2005 12:22:04 -0000	1.5
@@ -52,7 +52,7 @@
     drawable->height = height;
 
     _glitz_drawable_init (&drawable->base,
-			  format,
+			  &thread_info->formats[format->id],
 			  &context->backend,
 			  width, height);
 
@@ -73,16 +73,15 @@
 }
 
 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_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 @@
     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 @@
     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_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 @@
 	if (context == drawable->context->context) {
 	    if (drawable->pbuffer) {
 		AGLPbuffer pbuffer;
-		GLuint unused;
+		GLint unused;
 
 		aglGetPBuffer (context, &pbuffer, &unused, &unused, &unused);
 

Index: glitz_agl_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_agl_format.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_agl_format.c	14 Sep 2005 15:57:16 -0000	1.3
+++ glitz_agl_format.c	9 Nov 2005 12:22:04 -0000	1.4
@@ -153,41 +153,44 @@
     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 @@
 
 	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 @@
 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 @@
 	}
 
 	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 @@
 				    &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 @@
     }
 
     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_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, templ, count);
+				       mask, &itempl, count);
 }
-slim_hidden_def(glitz_agl_find_drawable_format);
+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, &itempl, count);
+}
+slim_hidden_def(glitz_agl_find_pbuffer_format);

Index: glitz_aglint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/agl/glitz_aglint.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glitz_aglint.h	14 Sep 2005 15:57:16 -0000	1.4
+++ glitz_aglint.h	9 Nov 2005 12:22:04 -0000	1.5
@@ -130,6 +130,11 @@
 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_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 */



More information about the cairo-commit mailing list