[cairo-commit] rendertest/src glitz.c, 1.6, 1.7 glitz_agl.c, 1.7, 1.8 glitz_common.h, 1.5, 1.6 glitz_glx.c, 1.7, 1.8 rendertest.c, 1.11, 1.12 xcb.c, 1.7, 1.8

David Reveman commit at pdx.freedesktop.org
Mon Jul 4 03:38:48 PDT 2005


Committed by: davidr

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

Modified Files:
	glitz.c glitz_agl.c glitz_common.h glitz_glx.c rendertest.c 
	xcb.c 
Log Message:
Add offscreen drawing tests

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- glitz.c	25 Jan 2005 20:33:37 -0000	1.6
+++ glitz.c	4 Jul 2005 10:38:46 -0000	1.7
@@ -328,14 +328,47 @@
 void
 _glitz_render_show (render_surface_t *surface)
 {
-  glitz_drawable_format_t *format;
+  glitz_drawable_format_t *dformat;
   glitz_drawable_t *drawable;
+  glitz_surface_t *s = (glitz_surface_t *) surface->surface;
 
-  drawable = glitz_surface_get_drawable ((glitz_surface_t *) surface->surface);
-  format = glitz_drawable_get_format (drawable);
+  drawable = glitz_surface_get_attached_drawable (s);
+  if (drawable) {
+      dformat = glitz_drawable_get_format (drawable);
+  } else {
+    glitz_format_t *format;
+    int width, height;
 
-  if (format->doublebuffer)
-    glitz_drawable_swap_buffers (drawable);
+    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);
+       }
+    }
+  }
+
+  if (dformat->doublebuffer)
+      glitz_drawable_swap_buffers (drawable);
   
   glitz_drawable_finish (drawable);
 }
@@ -519,6 +552,29 @@
 }
 
 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,
                                               int width,
                                               int height)

Index: glitz_agl.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_agl.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- glitz_agl.c	25 Jan 2005 20:33:37 -0000	1.7
+++ glitz_agl.c	4 Jul 2005 10:38:46 -0000	1.8
@@ -52,11 +52,13 @@
 typedef struct agl_options {
   int samples;
   int db;
+  int offscreen;
 } agl_options_t;
 
 static const render_option_t _glx_options[] = {
   { "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 }
 };
 
@@ -96,6 +98,7 @@
 
   options.samples = 1;
   options.db = 1;
+  options.offscreen = 0;
   
   state.pointer = &options;
 
@@ -156,10 +159,16 @@
     return 1;
   }
 
-  surface.surface =
-    _glitz_create_and_attach_surface_to_drawable (drawable,
-                                                  surface.width,
-                                                  surface.height);
+  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 (!surface.surface)
     return 1;
   

Index: glitz_common.h
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_common.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- glitz_common.h	25 Jan 2005 20:33:37 -0000	1.5
+++ glitz_common.h	4 Jul 2005 10:38:46 -0000	1.6
@@ -96,6 +96,11 @@
                                    int n_traps);
 
 glitz_surface_t *
+_glitz_create_surface_for_drawable (glitz_drawable_t *drawable,
+                                    int width,
+                                    int height);
+
+glitz_surface_t *
 _glitz_create_and_attach_surface_to_drawable (glitz_drawable_t *drawable,
                                               int width,
                                               int height);

Index: glitz_glx.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/glitz_glx.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- glitz_glx.c	25 Jan 2005 20:33:37 -0000	1.7
+++ glitz_glx.c	4 Jul 2005 10:38:46 -0000	1.8
@@ -56,6 +56,7 @@
   char *geometry;
   int samples;
   int db;
+  int offscreen;
 } glx_options_t;
 
 static const render_option_t _glx_options[] = {
@@ -63,6 +64,7 @@
   { "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 }
 };
 
@@ -84,6 +86,9 @@
   case 'p':
     options->samples = atoi (arg);
     break;
+  case 'f':
+    options->offscreen = 1;
+    break;
   default:
     return 1;
   }
@@ -113,6 +118,7 @@
   options.geometry = NULL;
   options.samples = 1;
   options.db = 1;
+  options.offscreen = 0;
   
   state.pointer = &options;
 
@@ -188,10 +194,16 @@
     return 1;
   }
 
-  surface.surface =
-    _glitz_create_and_attach_surface_to_drawable (drawable,
-                                                  surface.width,
-                                                  surface.height);
+  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 (!surface.surface)
     return 1;
   

Index: rendertest.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/rendertest.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- rendertest.c	1 Jul 2005 10:37:35 -0000	1.11
+++ rendertest.c	4 Jul 2005 10:38:46 -0000	1.12
@@ -682,7 +682,7 @@
 
   status = _render_set_background (surface, info.bg, info.logo);
   if (status) {
-    fprintf (stderr, "setting background: %s\n",
+    fprintf (stderr, "failed to set background: [%s]\n",
              _render_status_string (status));
     return RENDER_STATUS_FAILED;
   }

Index: xcb.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/xcb.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- xcb.c	25 Jan 2005 20:33:37 -0000	1.7
+++ xcb.c	4 Jul 2005 10:38:46 -0000	1.8
@@ -39,6 +39,7 @@
 typedef struct xcb_surface {
   XCBConnection *c;
   XCBDRAWABLE drawable;
+  XCBDRAWABLE pixmap;
   XCBRenderPICTURE picture;
   int render_major;
   int render_minor;
@@ -58,6 +59,9 @@
 #define XCB_RENDER_HAS_COMPONENT_ALPHA(surface) \
   XCB_RENDER_AT_LEAST ((surface), 0, 1)
 
+#define XCB_RENDER_HAS_EXTENDED_REPEAT_ATTRIBUTES(surface) \
+  XCB_RENDER_AT_LEAST ((surface), 0, 10)
+
 static int
 _xcb_operator (render_operator_t op)
 {
@@ -402,6 +406,22 @@
 {
   xcb_surface_t *s = (xcb_surface_t *) surface->surface;
 
+  if (s->pixmap.pixmap.xid) {
+    XCBGCONTEXT gc;
+
+    gc = XCBGCONTEXTNew (s->c);
+    XCBCreateGC (s->c, gc, s->drawable, 0, 0);
+  
+    XCBCopyArea (s->c,
+                 s->pixmap,
+                 s->drawable,
+                 gc,
+                 0, 0, 0, 0,
+                 surface->width,
+                 surface->height);
+
+    XCBFreeGC (s->c, gc);
+  }
   XCBSync (s->c, NULL);
 }
 
@@ -414,18 +434,24 @@
   CARD32 pa;
 
   pa = 0;
-  
+
   switch (fill) {
-  case RENDER_FILL_TRANSPARENT:
-    if (!SURFACE_TRANSFORM (surface))
+  case RENDER_FILL_NEAREST:
+    if (!XCB_RENDER_HAS_EXTENDED_REPEAT_ATTRIBUTES (s))
       return RENDER_STATUS_NOT_SUPPORTED;
+
+    pa = 2;
     break;
-  case RENDER_FILL_NEAREST:
   case RENDER_FILL_REFLECT:
-    return RENDER_STATUS_NOT_SUPPORTED;
+    if (!XCB_RENDER_HAS_EXTENDED_REPEAT_ATTRIBUTES (s))
+      return RENDER_STATUS_NOT_SUPPORTED;
+
+    pa = 3;
+    break;
   case RENDER_FILL_REPEAT:
     pa = 1;
     break;
+  case RENDER_FILL_TRANSPARENT:
   case RENDER_FILL_NONE:
   default:
     break;
@@ -599,14 +625,29 @@
   _xcb_render_set_clip_trapezoids
 };
 
+typedef struct xcb_options {
+  int offscreen;
+} xcb_options_t;
+
 static const render_option_t _xcb_options[] = {
+  { "offscreen", 'f', NULL, 0, "        use offscreen rendering" },
   { 0 }
 };
 
 static int
 _parse_option (int key, char *arg, render_arg_state_t *state)
 {
-  return 1;
+  xcb_options_t *options = state->pointer;
+
+  switch (key) {
+  case 'f':
+    options->offscreen = 1;
+    break;
+  default:
+    return 1;
+  }
+  
+  return 0;
 }
 
 int
@@ -623,8 +664,11 @@
   XCBGenericEvent *xev;
   XCBRenderPICTFORMAT format;
   XCBRenderQueryPictFormatsRep *formats_reply;
+  xcb_options_t options;
 
-  state.pointer = NULL;
+  options.offscreen = 0;
+
+  state.pointer = &options;
 
   if (render_parse_arguments (_parse_option,
                               _xcb_options,
@@ -689,8 +733,18 @@
     return 1;
   }
 
-  win.picture = XCBRenderPICTURENew (win.c);
-  XCBRenderCreatePicture (win.c, win.picture, win.drawable, format, 0, NULL);
+  win.pixmap.pixmap.xid = 0;
+  if (options.offscreen) {
+    win.pixmap.pixmap = XCBPIXMAPNew (win.c);
+    XCBCreatePixmap (win.c, root->root_depth,
+                     win.pixmap.pixmap, win.drawable,
+                     surface.width, surface.height);
+    win.picture = XCBRenderPICTURENew (win.c);
+    XCBRenderCreatePicture (win.c, win.picture, win.pixmap, format, 0, NULL);
+  } else {
+    win.picture = XCBRenderPICTURENew (win.c);
+    XCBRenderCreatePicture (win.c, win.picture, win.drawable, format, 0, NULL);
+  }
   
   XCBMapWindow (win.c, win.drawable.window);
   XCBSync (win.c, NULL);
@@ -708,6 +762,9 @@
   free (formats_reply);
   free (version_reply);
 
+  if (win.pixmap.pixmap.xid)
+      XCBFreePixmap (win.c, win.pixmap.pixmap);
+      
   XCBRenderFreePicture (win.c, win.picture);
   XCBDestroyWindow (win.c, win.drawable.window);
   XCBDisconnect (win.c);




More information about the cairo-commit mailing list