[cairo-commit] rendertest/src glitz.c, 1.7, 1.8 glitz_agl.c, 1.8, 1.9 glitz_common.h, 1.6, 1.7 glitz_egl.c, 1.1, 1.2 glitz_glx.c, 1.8, 1.9

David Reveman commit at pdx.freedesktop.org
Wed Sep 14 09:02:27 PDT 2005


Committed by: davidr

Update of /cvs/cairo/rendertest/src
In directory gabe:/tmp/cvs-serv7420/src

Modified Files:
	glitz.c glitz_agl.c glitz_common.h glitz_egl.c glitz_glx.c 
Log Message:
Track changes to glitz

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- glitz.c	4 Jul 2005 10:38:46 -0000	1.7
+++ glitz.c	14 Sep 2005 16:02:25 -0000	1.8
@@ -328,49 +328,49 @@
 void
 _glitz_render_show (render_surface_t *surface)
 {
-  glitz_drawable_format_t *dformat;
-  glitz_drawable_t *drawable;
-  glitz_surface_t *s = (glitz_surface_t *) surface->surface;
-
-  drawable = glitz_surface_get_attached_drawable (s);
-  if (drawable) {
-      dformat = glitz_drawable_get_format (drawable);
-  } else {
-    glitz_format_t *format;
+    glitz_drawable_t *drawable, *attached;
+    glitz_surface_t *s = (glitz_surface_t *) surface->surface;
+    glitz_drawable_format_t *dformat;
     int width, height;
 
-    width  = glitz_surface_get_width (s);
-    height = glitz_surface_get_height (s);         
-      
     drawable = glitz_surface_get_drawable (s);
-    dformat = glitz_drawable_get_format (drawable);
-    format = glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32);
-    if (format) {
-       glitz_surface_t *dst;
-    
-       dst = glitz_surface_create (drawable, format, width, height, 0, NULL);
-       if (dst) {
-         if (dformat->doublebuffer)
-           glitz_surface_attach (dst, drawable,
-                                 GLITZ_DRAWABLE_BUFFER_BACK_COLOR,
-                                 0, 0);
-         else
-           glitz_surface_attach (dst, drawable,
-                                 GLITZ_DRAWABLE_BUFFER_FRONT_COLOR,
-                                 0, 0);
-           
-         glitz_copy_area (s, dst, 0, 0, width, height, 0, 0);
-         
-         glitz_surface_flush (dst);
-         glitz_surface_destroy (dst);
-       }
+    attached = glitz_surface_get_attached_drawable (s);
+    dformat  = glitz_drawable_get_format (drawable);
+
+    width  = glitz_surface_get_width (s);
+    height = glitz_surface_get_height (s);
+
+    if (attached != drawable)
+    {
+	glitz_format_t *format;
+
+	format = glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32);
+	if (format) {
+	    glitz_surface_t *dst;
+
+	    dst = glitz_surface_create (drawable, format,
+					width, height, 0, NULL);
+	    if (dst)
+	    {
+		if (dformat->doublebuffer)
+		    glitz_surface_attach (dst, drawable,
+					  GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
+		else
+		    glitz_surface_attach (dst, drawable,
+					  GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+
+		glitz_copy_area (s, dst, 0, 0, width, height, 0, 0);
+
+		glitz_surface_flush (dst);
+		glitz_surface_destroy (dst);
+	    }
+	}
     }
-  }
 
-  if (dformat->doublebuffer)
-      glitz_drawable_swap_buffers (drawable);
-  
-  glitz_drawable_finish (drawable);
+    if (dformat->doublebuffer)
+	glitz_drawable_swap_buffers (drawable);
+    else
+	glitz_drawable_finish (drawable);
 }
 
 render_status_t
@@ -552,41 +552,30 @@
 }
 
 glitz_surface_t *
-_glitz_create_surface_for_drawable (glitz_drawable_t *drawable,
-                                    int width,
-                                    int height)
-{
-  glitz_format_t *format;
-  glitz_surface_t *surface;
-    
-  format = glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32);
-  if (!format) {
-    fprintf (stderr, "Error: couldn't find ARGB surface format\n");
-    return NULL;
-  }
-
-  surface = glitz_surface_create (drawable, format, width, height, 0, NULL);
-  if (!surface) {
-    fprintf (stderr, "Error: couldn't create glitz surface\n");
-    return NULL;
-  }
-
-  return surface;
-}
-
-glitz_surface_t *
 _glitz_create_and_attach_surface_to_drawable (glitz_drawable_t *drawable,
+                                              glitz_drawable_t *attach,
                                               int width,
                                               int height)
 {
   glitz_drawable_format_t *dformat;
-  glitz_format_t *format;
+  glitz_format_t *format, templ;
   glitz_surface_t *surface;
   glitz_drawable_buffer_t buffer;
     
-  format = glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32);
+  dformat = glitz_drawable_get_format (attach);
+
+  templ.type = GLITZ_FORMAT_TYPE_COLOR;
+  templ.color = dformat->color;
+  format = glitz_find_format (drawable, 
+                              GLITZ_FORMAT_TYPE_MASK       |
+                              GLITZ_FORMAT_RED_SIZE_MASK   |
+                              GLITZ_FORMAT_GREEN_SIZE_MASK |
+                              GLITZ_FORMAT_BLUE_SIZE_MASK  |
+                              GLITZ_FORMAT_ALPHA_SIZE_MASK,
+                              &templ,
+                              0);
   if (!format) {
-    fprintf (stderr, "Error: couldn't find ARGB surface format\n");
+    fprintf (stderr, "Error: couldn't find surface format\n");
     return NULL;
   }
 
@@ -596,13 +585,12 @@
     return NULL;
   }
 
-  dformat = glitz_drawable_get_format (drawable);
   if (dformat->doublebuffer)
     buffer = GLITZ_DRAWABLE_BUFFER_BACK_COLOR;
   else
     buffer = GLITZ_DRAWABLE_BUFFER_FRONT_COLOR;
 
-  glitz_surface_attach (surface, drawable, buffer, 0, 0);
+  glitz_surface_attach (surface, attach, buffer);
 
   return surface;
 }

Index: glitz_agl.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_agl.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- glitz_agl.c	4 Jul 2005 10:38:46 -0000	1.8
+++ glitz_agl.c	14 Sep 2005 16:02:25 -0000	1.9
@@ -74,6 +74,9 @@
   case 'p':
     options->samples = atoi (arg);
     break;
+  case 'f':
+    options->offscreen = 1;
+    break;
   default:
     return 1;
   }
@@ -89,7 +92,7 @@
   glitz_drawable_format_t templ;
   unsigned long mask;
   glitz_drawable_format_t *dformat;
-  glitz_drawable_t *drawable;
+  glitz_drawable_t *drawable, *offscreen = 0;
   render_arg_state_t state;
   agl_options_t options;
   WindowRef win;
@@ -132,11 +135,8 @@
 	
   SelectWindow (win);
   
-  templ.types.window = 1;
-  mask = GLITZ_FORMAT_WINDOW_MASK;
-
   templ.samples = options.samples;
-  mask |= GLITZ_FORMAT_SAMPLES_MASK;
+  mask = GLITZ_FORMAT_SAMPLES_MASK;
 
   if (options.db)
     templ.doublebuffer = 1;
@@ -145,7 +145,7 @@
 
   mask |= GLITZ_FORMAT_DOUBLEBUFFER_MASK;
 
-  dformat = glitz_agl_find_drawable_format (mask, &templ, 0);
+  dformat = glitz_agl_find_window_format (mask, &templ, 0);
   if (!dformat) {
     fprintf (stderr, "Error: couldn't find window format\n");
     return 1;
@@ -159,16 +159,38 @@
     return 1;
   }
 
-  if (options.offscreen) {
-    surface.surface = _glitz_create_surface_for_drawable (drawable,
-                                                          surface.width,
-                                                          surface.height);
-  } else {
+  if (options.offscreen)
+  {
+      dformat = glitz_find_drawable_format (drawable, 0, 0, 0);
+      if (!dformat)
+      {
+	  fprintf (stderr, "Error: couldn't find offscreen format\n");
+	  return 1;
+      }
+
+      offscreen = glitz_create_drawable (drawable, dformat,
+					 surface.width, surface.height);
+      if (!offscreen)
+      {
+	  fprintf (stderr, "Error: couldn't create offscreen drawable\n");
+	  return 1;
+      }
+
+      surface.surface =
+	  _glitz_create_and_attach_surface_to_drawable (drawable,
+							offscreen,
+							surface.width,
+							surface.height);
+  }
+  else
+  {
     surface.surface =
       _glitz_create_and_attach_surface_to_drawable (drawable,
-                                                    surface.width,
-                                                    surface.height);
+						    drawable,
+						    surface.width,
+						    surface.height);
   }
+
   if (!surface.surface)
     return 1;
   
@@ -177,6 +199,10 @@
   status = render_run (&surface, &state.settings);
 
   glitz_surface_destroy ((glitz_surface_t *) surface.surface);
+
+  if (offscreen)
+      glitz_drawable_destroy (offscreen);
+
   glitz_drawable_destroy (drawable);
 
   glitz_agl_fini ();

Index: glitz_common.h
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_common.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- glitz_common.h	4 Jul 2005 10:38:46 -0000	1.6
+++ glitz_common.h	14 Sep 2005 16:02:25 -0000	1.7
@@ -102,5 +102,6 @@
 
 glitz_surface_t *
 _glitz_create_and_attach_surface_to_drawable (glitz_drawable_t *drawable,
+                                              glitz_drawable_t *attach,
                                               int width,
                                               int height);

Index: glitz_egl.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_egl.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- glitz_egl.c	20 May 2005 01:26:11 -0000	1.1
+++ glitz_egl.c	14 Sep 2005 16:02:25 -0000	1.2
@@ -38,6 +38,9 @@
 
 #include <glitz-egl.h>
 
+#define EGL_DEFAULT_DST_WIDTH  1024
+#define EGL_DEFAULT_DST_HEIGHT  768
+
 static const render_backend_t _glitz_egl_render_backend = {
   _glitz_render_create_similar,
   _glitz_render_destroy,
@@ -53,17 +56,15 @@
 };
 
 typedef struct egl_options {
-  char *display;
-  char *geometry;
   int samples;
   int db;
+  int offscreen;
 } egl_options_t;
 
 static const render_option_t _egl_options[] = {
-  { "display", 'd', "DISPLAY", 0, "   X display to use" },
-  { "geometry", 'g', "GEOMETRY", 0, " X geometry specification" },
   { "single-buffer", 'l', NULL, 0, "    use single buffered format" },
   { "samples", 'p', "SAMPLES", 0, "   use this hardware multi-sample format" },
+  { "offscreen", 'f', NULL, 0, "        use offscreen rendering" },
   { 0 }
 };
 
@@ -73,18 +74,15 @@
   egl_options_t *options = state->pointer;
   
   switch (key) {
-  case 'd':
-    options->display = arg;
-    break;
-  case 'g':
-    options->geometry = arg;
-    break;
   case 'l':
     options->db = 0;
     break;
   case 'p':
     options->samples = atoi (arg);
     break;
+  case 'f':
+    options->offscreen = 1;
+    break;
   default:
     return 1;
   }
@@ -104,7 +102,7 @@
   glitz_drawable_format_t templ;
   unsigned long mask;
   glitz_drawable_format_t *dformat;
-  glitz_drawable_t *drawable;
+  glitz_drawable_t *drawable, *offscreen = 0;
   render_arg_state_t state;
   egl_options_t options;
   int maj, min, count;
@@ -114,11 +112,10 @@
     EGL_NONE
   };
 
-  options.display = NULL;
-  options.geometry = NULL;
   options.samples = 1;
   options.db = 1;
-  
+  options.offscreen = 0;
+
   state.pointer = &options;
 
   if (render_parse_arguments (_parse_option,
@@ -130,35 +127,23 @@
   surface.backend = &_glitz_egl_render_backend;
   surface.flags = 0;
 
-  if (options.geometry) {
-    unsigned int width, height;
-    
-    surface.width = width;
-    surface.height = height;
-  } else {
-    x = y = 50;
-    surface.width = RENDER_DEFAULT_DST_WIDTH;
-    surface.height = RENDER_DEFAULT_DST_HEIGHT;
-  }
- surface.width = 1024;
- surface.height = 768;
+  x = y = 50;
+  surface.width = EGL_DEFAULT_DST_WIDTH;
+  surface.height = EGL_DEFAULT_DST_HEIGHT;
 
-  egl_display = eglGetDisplay("!fb_dri");
+  egl_display = eglGetDisplay (":0");
   assert(egl_display);
   
   if (!eglInitialize(egl_display, &maj, &min)) {
-    printf("demo: eglInitialize failed\n");
-    exit(1);
+    fprintf (stderr, "Error: eglInitialize failed\n");
+    return 1;
   }
   
   eglGetScreensMESA(egl_display, &egl_screen, 1, &count);
   eglGetModesMESA(egl_display, egl_screen, &egl_mode, 1, &count);
 
-  templ.types.window = 1;
-  mask = GLITZ_FORMAT_WINDOW_MASK;
-
   templ.samples = options.samples;
-  mask |= GLITZ_FORMAT_SAMPLES_MASK;
+  mask = GLITZ_FORMAT_SAMPLES_MASK;
 
   if (options.db)
     templ.doublebuffer = 1;
@@ -167,7 +152,8 @@
 
   mask |= GLITZ_FORMAT_DOUBLEBUFFER_MASK;
   
-  dformat = glitz_egl_find_config (egl_display, egl_screen, mask, &templ, 0);
+  dformat = glitz_egl_find_window_config (egl_display, egl_screen, 
+                                          mask, &templ, 0);
   if (!dformat) {
     fprintf (stderr, "Error: couldn't find window format\n");
     return 1;
@@ -175,7 +161,7 @@
 
   egl_surface = eglCreateScreenSurfaceMESA(egl_display, dformat->id, screenAttribs);
   if (egl_surface == EGL_NO_SURFACE) {
-    printf("failed to create screen surface\n");
+    fprintf (stderr, "Error: failed to create screen surface\n");
     return 0;
   }
    
@@ -189,16 +175,48 @@
     return 1;
   }
 
-  surface.surface =
-    _glitz_create_and_attach_surface_to_drawable (drawable,
-                                                  surface.width,
-                                                  surface.height);
+  if (options.offscreen)
+  {
+      dformat = glitz_find_drawable_format (drawable, 0, 0, 0);
+      if (!dformat)
+      {
+	  fprintf (stderr, "Error: couldn't find offscreen format\n");
+	  return 1;
+      }
+
+      offscreen = glitz_create_drawable (drawable, dformat,
+					 surface.width, surface.height);
+      if (!offscreen)
+      {
+	  fprintf (stderr, "Error: couldn't create offscreen drawable\n");
+	  return 1;
+      }
+
+      surface.surface =
+	  _glitz_create_and_attach_surface_to_drawable (drawable,
+							offscreen,
+							surface.width,
+							surface.height);
+  }
+  else
+  {
+    surface.surface =
+      _glitz_create_and_attach_surface_to_drawable (drawable,
+						    drawable,
+						    surface.width,
+						    surface.height);
+  }
+
   if (!surface.surface)
     return 1;
   
   status = render_run (&surface, &state.settings);
 
   glitz_surface_destroy ((glitz_surface_t *) surface.surface);
+
+  if (offscreen)
+      glitz_drawable_destroy (offscreen);
+
   glitz_drawable_destroy (drawable);
 
   glitz_egl_fini ();

Index: glitz_glx.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_glx.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- glitz_glx.c	4 Jul 2005 10:38:46 -0000	1.8
+++ glitz_glx.c	14 Sep 2005 16:02:25 -0000	1.9
@@ -109,7 +109,7 @@
   glitz_drawable_format_t templ;
   unsigned long mask;
   glitz_drawable_format_t *dformat;
-  glitz_drawable_t *drawable;
+  glitz_drawable_t *drawable, *offscreen = 0;
   render_arg_state_t state;
   glx_options_t options;
   XEvent event;
@@ -151,20 +151,15 @@
 
   screen = DefaultScreen (display);
 
-  templ.types.window = 1;
-  mask = GLITZ_FORMAT_WINDOW_MASK;
-
   templ.samples = options.samples;
-  mask |= GLITZ_FORMAT_SAMPLES_MASK;
+  mask = GLITZ_FORMAT_SAMPLES_MASK;
 
   if (options.db)
     templ.doublebuffer = 1;
   else
     templ.doublebuffer = 0;
 
-  mask |= GLITZ_FORMAT_DOUBLEBUFFER_MASK;
-  
-  dformat = glitz_glx_find_drawable_format (display, screen, mask, &templ, 0);
+  dformat = glitz_glx_find_window_format (display, screen, mask, &templ, 0);
   if (!dformat) {
     fprintf (stderr, "Error: couldn't find window format\n");
     return 1;
@@ -194,16 +189,38 @@
     return 1;
   }
 
-  if (options.offscreen) {
-    surface.surface = _glitz_create_surface_for_drawable (drawable,
-                                                          surface.width,
-                                                          surface.height);
-  } else {
-    surface.surface =
-      _glitz_create_and_attach_surface_to_drawable (drawable,
-                                                    surface.width,
-                                                    surface.height);
+  if (options.offscreen)
+  {
+      dformat = glitz_find_drawable_format (drawable, 0, 0, 0);
+      if (!dformat)
+      {
+	  fprintf (stderr, "Error: couldn't find offscreen format\n");
+	  return 1;
+      }
+
+      offscreen = glitz_create_drawable (drawable, dformat,
+					 surface.width, surface.height);
+      if (!offscreen)
+      {
+	  fprintf (stderr, "Error: couldn't create offscreen drawable\n");
+	  return 1;
+      }
+
+      surface.surface =
+	  _glitz_create_and_attach_surface_to_drawable (drawable,
+							offscreen,
+							surface.width,
+							surface.height);
   }
+  else
+  {
+      surface.surface =
+	  _glitz_create_and_attach_surface_to_drawable (drawable,
+							drawable,
+							surface.width,
+							surface.height);
+  }
+
   if (!surface.surface)
     return 1;
   
@@ -220,6 +237,10 @@
   status = render_run (&surface, &state.settings);
 
   glitz_surface_destroy ((glitz_surface_t *) surface.surface);
+
+  if (offscreen)
+      glitz_drawable_destroy (offscreen);
+
   glitz_drawable_destroy (drawable);
 
   glitz_glx_fini ();



More information about the cairo-commit mailing list