[cairo-commit] glitz/src glitz.h, 1.39, 1.40 glitz_drawable.c, 1.5, 1.6 glitz_framebuffer.c, 1.4, 1.5 glitzint.h, 1.39, 1.40

David Reveman commit at pdx.freedesktop.org
Mon Mar 13 05:42:48 PST 2006


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory kemper:/tmp/cvs-serv15574/src

Modified Files:
	glitz.h glitz_drawable.c glitz_framebuffer.c glitzint.h 
Log Message:
Add CopySubBufferMESA support

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- glitz.h	23 Feb 2006 01:21:11 -0000	1.39
+++ glitz.h	13 Mar 2006 13:42:46 -0000	1.40
@@ -129,6 +129,7 @@
 #define GLITZ_FEATURE_PACKED_PIXELS_MASK            (1L << 14)
 #define GLITZ_FEATURE_MULTI_DRAW_ARRAYS_MASK        (1L << 15)
 #define GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK       (1L << 16)
+#define GLITZ_FEATURE_COPY_SUB_BUFFER_MASK          (1L << 17)
 
 
 /* glitz_format.c */

Index: glitz_drawable.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_drawable.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- glitz_drawable.c	6 Feb 2006 22:26:04 -0000	1.5
+++ glitz_drawable.c	13 Mar 2006 13:42:46 -0000	1.6
@@ -195,125 +195,157 @@
 				   glitz_box_t      *box,
 				   int              n_box)
 {
-    if (drawable->format->d.doublebuffer && n_box)
-    {
-	glitz_box_t	rect;
-	glitz_surface_t *surface = NULL;
-	int		x_pos, y_pos;
-	int		x, y, w, h;
+    glitz_box_t	    rect;
+    glitz_surface_t *surface = NULL;
+    int		    x_pos, y_pos;
+    int		    x, y, w, h;
 
-	GLITZ_GL_DRAWABLE (drawable);
+    GLITZ_GL_DRAWABLE (drawable);
 
-	if (n_box == 1)
-	{
-	    rect.x1 = x_origin + box->x1;
-	    rect.y1 = y_origin + box->y1;
-	    rect.x2 = x_origin + box->x2;
-	    rect.y2 = y_origin + box->y2;
+    if (!drawable->format->d.doublebuffer || !n_box)
+	return;
 
-	    if (rect.x1 <= 0		   &&
-		rect.y1 <= 0		   &&
-		rect.x2 >= drawable->width &&
-		rect.x2 >= drawable->height)
+    /* try swap buffers (fastest) */
+    if (n_box == 1)
+    {
+	rect.x1 = x_origin + box->x1;
+	rect.y1 = y_origin + box->y1;
+	rect.x2 = x_origin + box->x2;
+	rect.y2 = y_origin + box->y2;
+
+	if (rect.x1 <= 0	       &&
+	    rect.y1 <= 0	       &&
+	    rect.x2 >= drawable->width &&
+	    rect.x2 >= drawable->height)
+	{
+	    if (drawable->backend->swap_buffers (drawable))
 	    {
-		if (drawable->backend->swap_buffers (drawable))
+		if (drawable->front)
 		{
-		    if (drawable->front)
-		    {
-			REGION_EMPTY (&drawable->front->drawable_damage);
-			glitz_surface_damage (drawable->front, NULL,
-					      GLITZ_DAMAGE_TEXTURE_MASK |
-					      GLITZ_DAMAGE_SOLID_MASK);
-		    }
-		    return;
+		    REGION_EMPTY (&drawable->front->drawable_damage);
+		    glitz_surface_damage (drawable->front, NULL,
+					  GLITZ_DAMAGE_TEXTURE_MASK |
+					  GLITZ_DAMAGE_SOLID_MASK);
 		}
+		return;
 	    }
 	}
+    }
 
-	if (drawable->front)
+    /* try copy sub buffer (almost as fast) */
+    while (n_box)
+    {
+	rect.x1 = x_origin + box->x1;
+	rect.y1 = y_origin + box->y1;
+	rect.x2 = x_origin + box->x2;
+	rect.y2 = y_origin + box->y2;
+
+	if (rect.x1 < rect.x2 && rect.y1 < rect.y2)
 	{
-	    if (glitz_surface_push_current (drawable->front,
-					    GLITZ_DRAWABLE_CURRENT))
-		surface = drawable->front;
+	    x = rect.x1;
+	    y = drawable->height - rect.y2;
+	    w = rect.x2 - rect.x1;
+	    h = rect.y2 - rect.y1;
+
+	    if (!drawable->backend->copy_sub_buffer (drawable, x, y, w, h))
+		break;
+
+	    if (drawable->front)
+		glitz_surface_damage (drawable->front, &rect,
+				      GLITZ_DAMAGE_TEXTURE_MASK |
+				      GLITZ_DAMAGE_SOLID_MASK);
 	}
 
-	if (!surface)
+	n_box--;
+	box++;
+    }
+
+    if (!n_box)
+	return;
+
+    /* do copy pixels (slow) */
+    if (drawable->front)
+    {
+	if (glitz_surface_push_current (drawable->front,
+					GLITZ_DRAWABLE_CURRENT))
+	    surface = drawable->front;
+    }
+    if (!surface)
+    {
+	if (drawable->backend->push_current (drawable, NULL,
+					     GLITZ_DRAWABLE_CURRENT))
 	{
-	    if (drawable->backend->push_current (drawable, NULL,
-						 GLITZ_DRAWABLE_CURRENT))
-	    {
-		drawable->update_all = 1;
+	    drawable->update_all = 1;
 
-		gl->viewport (0, 0, drawable->width, drawable->height);
-		gl->matrix_mode (GLITZ_GL_PROJECTION);
-		gl->load_identity ();
-		gl->ortho (0.0, drawable->width, 0.0,
-			   drawable->height, -1.0, 1.0);
-		gl->matrix_mode (GLITZ_GL_MODELVIEW);
-		gl->load_identity ();
-		gl->scale_f (1.0f, -1.0f, 1.0f);
-		gl->translate_f (0.0f, -drawable->height, 0.0f);
-	    }
-	    else
-	    {
-		drawable->backend->pop_current (drawable);
-		return;
-	    }
+	    gl->viewport (0, 0, drawable->width, drawable->height);
+	    gl->matrix_mode (GLITZ_GL_PROJECTION);
+	    gl->load_identity ();
+	    gl->ortho (0.0, drawable->width, 0.0,
+		       drawable->height, -1.0, 1.0);
+	    gl->matrix_mode (GLITZ_GL_MODELVIEW);
+	    gl->load_identity ();
+	    gl->scale_f (1.0f, -1.0f, 1.0f);
+	    gl->translate_f (0.0f, -drawable->height, 0.0f);
+	}
+	else
+	{
+	    drawable->backend->pop_current (drawable);
+	    return;
 	}
+    }
 
-	gl->disable (GLITZ_GL_DITHER);
+    gl->disable (GLITZ_GL_DITHER);
 
-	drawable->backend->read_buffer (drawable, GLITZ_GL_BACK);
-	drawable->backend->draw_buffer (drawable, GLITZ_GL_FRONT);
+    drawable->backend->read_buffer (drawable, GLITZ_GL_BACK);
+    drawable->backend->draw_buffer (drawable, GLITZ_GL_FRONT);
 
-	glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
+    glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
 
-	x_pos = 0;
-	y_pos = 0;
+    x_pos = 0;
+    y_pos = 0;
 
-	glitz_set_raster_pos (gl, x_pos, y_pos);
+    glitz_set_raster_pos (gl, x_pos, y_pos);
 
-	while (n_box--)
+    while (n_box--)
+    {
+	rect.x1 = x_origin + box->x1;
+	rect.y1 = y_origin + box->y1;
+	rect.x2 = x_origin + box->x2;
+	rect.y2 = y_origin + box->y2;
+
+	if (rect.x1 < rect.x2 && rect.y1 < rect.y2)
 	{
-	    rect.x1 = x_origin + box->x1;
-	    rect.y1 = y_origin + box->y1;
-	    rect.x2 = x_origin + box->x2;
-	    rect.y2 = y_origin + box->y2;
+	    x = rect.x1;
+	    y = drawable->height - rect.y2;
+	    w = rect.x2 - rect.x1;
+	    h = rect.y2 - rect.y1;
 
-	    if (rect.x1 < rect.x2 && rect.y1 < rect.y2)
+	    if (x != x_pos || y != y_pos)
 	    {
-		x = rect.x1;
-		y = drawable->height - rect.y2;
-		w = rect.x2 - rect.x1;
-		h = rect.y2 - rect.y1;
-
-		if (x != x_pos || y != y_pos)
-		{
-		    gl->bitmap (0, 0, 0, 0, x - x_pos, y - y_pos, NULL);
+		gl->bitmap (0, 0, 0, 0, x - x_pos, y - y_pos, NULL);
 
-		    x_pos = x;
-		    y_pos = y;
-		}
+		x_pos = x;
+		y_pos = y;
+	    }
 
-		gl->scissor (x, y, w, h);
-		gl->copy_pixels (x, y, w, h, GLITZ_GL_COLOR);
+	    gl->scissor (x, y, w, h);
+	    gl->copy_pixels (x, y, w, h, GLITZ_GL_COLOR);
 
-		if (surface)
-		    glitz_surface_damage (surface, &rect,
-					  GLITZ_DAMAGE_TEXTURE_MASK |
-					  GLITZ_DAMAGE_SOLID_MASK);
+	    if (surface)
+		glitz_surface_damage (surface, &rect,
+				      GLITZ_DAMAGE_TEXTURE_MASK |
+				      GLITZ_DAMAGE_SOLID_MASK);
 
-		box++;
-	    }
+	    box++;
 	}
+    }
 
-	drawable->backend->gl->flush ();
+    drawable->backend->gl->flush ();
 
-	if (surface)
-	    glitz_surface_pop_current (surface);
-	else
-	    drawable->backend->pop_current (drawable);
-    }
+    if (surface)
+	glitz_surface_pop_current (surface);
+    else
+	drawable->backend->pop_current (drawable);
 }
 
 void

Index: glitz_framebuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_framebuffer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glitz_framebuffer.c	21 Dec 2005 16:19:51 -0000	1.4
+++ glitz_framebuffer.c	13 Mar 2006 13:42:46 -0000	1.5
@@ -329,6 +329,16 @@
     return 0;
 }
 
+static glitz_bool_t
+_glitz_fbo_copy_sub_buffer (void *abstract_drawable,
+			    int  x,
+			    int  y,
+			    int  width,
+			    int  height)
+{
+    return 0;
+}
+
 static void
 _glitz_fbo_destroy (void *abstract_drawable)
 {
@@ -427,15 +437,16 @@
     backend = (glitz_backend_t *) (drawable + 1);
     *backend = *other->backend;
 
-    backend->destroy       = _glitz_fbo_destroy;
-    backend->push_current  = _glitz_fbo_push_current;
-    backend->pop_current   = _glitz_fbo_pop_current;
-    backend->attach_notify = _glitz_fbo_attach_notify;
-    backend->detach_notify = _glitz_fbo_detach_notify;
-    backend->swap_buffers  = _glitz_fbo_swap_buffers;
-    backend->make_current  = _glitz_fbo_make_current;
-    backend->draw_buffer   = _glitz_fbo_draw_buffer;
-    backend->read_buffer   = _glitz_fbo_read_buffer;
+    backend->destroy         = _glitz_fbo_destroy;
+    backend->push_current    = _glitz_fbo_push_current;
+    backend->pop_current     = _glitz_fbo_pop_current;
+    backend->attach_notify   = _glitz_fbo_attach_notify;
+    backend->detach_notify   = _glitz_fbo_detach_notify;
+    backend->swap_buffers    = _glitz_fbo_swap_buffers;
+    backend->copy_sub_buffer = _glitz_fbo_copy_sub_buffer;
+    backend->make_current    = _glitz_fbo_make_current;
+    backend->draw_buffer     = _glitz_fbo_draw_buffer;
+    backend->read_buffer     = _glitz_fbo_read_buffer;
 
     drawable->fb = 0;
 

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- glitzint.h	21 Dec 2005 16:19:51 -0000	1.39
+++ glitzint.h	13 Mar 2006 13:42:46 -0000	1.40
@@ -390,6 +390,12 @@
   glitz_bool_t
   (*swap_buffers)              (void *drawable);
 
+  glitz_bool_t
+  (*copy_sub_buffer)           (void *drawable,
+				int  x,
+				int  y,
+				int  width,
+				int  height);
 
   glitz_context_t *
   (*create_context)            (void                    *drawable,



More information about the cairo-commit mailing list