[cairo-commit] glitz/src glitz.c, 1.33, 1.34 glitz.h, 1.32, 1.33 glitz_framebuffer.c, 1.1, 1.2 glitz_geometry.c, 1.5, 1.6 glitz_pixel.c, 1.19, 1.20 glitz_rect.c, 1.16, 1.17 glitz_surface.c, 1.29, 1.30 glitz_texture.c, 1.18, 1.19 glitzint.h, 1.34, 1.35

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


Committed by: davidr

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

Modified Files:
	glitz.c glitz.h glitz_framebuffer.c glitz_geometry.c 
	glitz_pixel.c glitz_rect.c glitz_surface.c glitz_texture.c 
	glitzint.h 
Log Message:
Fix GL_EXT_framebuffer_object support

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- glitz.c	6 Jun 2005 12:28:40 -0000	1.33
+++ glitz.c	4 Jul 2005 10:33:01 -0000	1.34
@@ -397,7 +397,10 @@
     status = GLITZ_STATUS_NOT_SUPPORTED;
     if (glitz_surface_push_current (dst, GLITZ_DRAWABLE_CURRENT))
     {
-        if (src->attached == dst->attached)
+        int target_height = SURFACE_DRAWABLE_HEIGHT (dst);
+        int source_height = SURFACE_DRAWABLE_HEIGHT (src);
+        
+        if (src == dst || (dst->attached && src->attached == dst->attached))
         {
             glitz_box_t box, *clip = dst->clip;
             int         n_clip = dst->n_clip;
@@ -435,16 +438,15 @@
                 {
                     glitz_set_raster_pos (gl,
                                           dst->x + box.x1,
-                                          dst->attached->height -
-                                          (dst->y + box.y2));
+                                          target_height - (dst->y + box.y2));
 
                     gl->scissor (dst->x + box.x1,
-                                 dst->attached->height - (dst->y + box.y2),
+                                 target_height - (dst->y + box.y2),
                                  box.x2 - box.x1,
                                  box.y2 - box.y1);
 
                     gl->copy_pixels (x_src + (box.x1 - x_dst),
-                                     src->attached->height -
+                                     source_height -
                                      (y_src + (box.y2 - y_dst)),
                                      box.x2 - box.x1, box.y2 - box.y1,
                                      GLITZ_GL_COLOR);
@@ -489,7 +491,7 @@
                     int           vertices = 0;
                     glitz_box_t   box, *clip = dst->clip;
                     int           n_clip = dst->n_clip;
-                    
+
                     ptr = malloc (n_clip * 8 * sizeof (glitz_float_t));
                     if (!ptr) {
                         glitz_surface_pop_current (dst);
@@ -538,8 +540,7 @@
                     if (vertices)
                     {
                         gl->scissor (bounds.x1 + dst->x,
-                                     dst->attached->height - dst->y -
-                                     bounds.y2,
+                                     (target_height - dst->y) - bounds.y2,
                                      bounds.x2 - bounds.x1,
                                      bounds.y2 - bounds.y1);
 
@@ -568,7 +569,7 @@
 
     glitz_surface_pop_current (dst);
 
-    if (status)
+    if (status && src->attached)
     {
         if (glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT))
         {

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- glitz.h	7 Jun 2005 15:44:34 -0000	1.32
+++ glitz.h	4 Jul 2005 10:33:01 -0000	1.33
@@ -38,7 +38,7 @@
 
 #define GLITZ_MAJOR    0
 #define GLITZ_MINOR    4
-#define GLITZ_REVISION 3
+#define GLITZ_REVISION 4
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {

Index: glitz_framebuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_framebuffer.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- glitz_framebuffer.c	10 Feb 2005 01:03:00 -0000	1.1
+++ glitz_framebuffer.c	4 Jul 2005 10:33:01 -0000	1.2
@@ -39,7 +39,8 @@
 glitz_framebuffer_fini (glitz_gl_proc_address_list_t *gl,
                         glitz_framebuffer_t          *framebuffer)
 {
-    gl->delete_framebuffers (1, &framebuffer->name);
+    if (framebuffer->name)
+        gl->delete_framebuffers (1, &framebuffer->name);
 }
 
 void
@@ -59,6 +60,7 @@
             glitz_texture_allocate (gl, texture);
         
         gl->gen_framebuffers (1, &framebuffer->name);
+
         gl->bind_framebuffer (GLITZ_GL_FRAMEBUFFER, framebuffer->name);
     
         gl->framebuffer_texture_2d (GLITZ_GL_FRAMEBUFFER,

Index: glitz_geometry.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_geometry.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- glitz_geometry.c	25 Jan 2005 19:50:26 -0000	1.5
+++ glitz_geometry.c	4 Jul 2005 10:33:01 -0000	1.6
@@ -360,9 +360,10 @@
                        glitz_box_t                  *bounds,
                        int                          damage)
 {
-    glitz_box_t         *clip = dst->clip;
-    int                 n_clip = dst->n_clip;
-    glitz_box_t         box;
+    glitz_box_t *clip = dst->clip;
+    int         n_clip = dst->n_clip;
+    glitz_box_t box;
+    int         target_height = SURFACE_DRAWABLE_HEIGHT (dst);
     
     while (n_clip--)
     {
@@ -382,7 +383,7 @@
         if (box.x1 < box.x2 && box.y1 < box.y2)
         {
             gl->scissor (box.x1 + dst->x,
-                         dst->attached->height - dst->y - box.y2,
+                         target_height - dst->y - box.y2,
                          box.x2 - box.x1, box.y2 - box.y1);
 
             gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);
@@ -409,6 +410,7 @@
     glitz_box_t         *clip = dst->clip;
     int                 i, n_clip = dst->n_clip;
     glitz_box_t         box;
+    int                 target_height = SURFACE_DRAWABLE_HEIGHT (dst);
     
     while (n_clip--)
     {
@@ -428,7 +430,7 @@
         if (box.x1 < box.x2 && box.y1 < box.y2)
         {
             gl->scissor (box.x1 + dst->x,
-                         dst->attached->height - dst->y - box.y2,
+                         target_height - dst->y - box.y2,
                          box.x2 - box.x1, box.y2 - box.y1);
 
             gl->push_matrix ();
@@ -532,6 +534,7 @@
     int                 byte_offset, pixel_offset = 0;
     glitz_float_t       x_off, y_off;
     glitz_box_t         box;
+    int                 target_height = SURFACE_DRAWABLE_HEIGHT (dst);
     
     if (dst->geometry.u.b.top_down)
     {
@@ -597,7 +600,7 @@
         if (box.x1 < box.x2 && box.y1 < box.y2)
         {
             gl->scissor (box.x1 + dst->x,
-                         dst->attached->height - dst->y - box.y2,
+                         target_height - dst->y - box.y2,
                          box.x2 - box.x1, box.y2 - box.y1);
 
             x_off = dst->x + dst->geometry.off.v[0];
@@ -608,8 +611,7 @@
                 x_off += array->off->v[0];
                 y_off += array->off->v[1];
 
-                glitz_set_raster_pos (gl, x_off,
-                                      dst->attached->height - y_off);
+                glitz_set_raster_pos (gl, x_off, target_height - y_off);
 
                 for (i = 0, n = array->n_arrays; n--; i++)
                 {    
@@ -633,8 +635,7 @@
             }
             else
             {
-                glitz_set_raster_pos (gl, x_off,
-                                      dst->attached->height - y_off);
+                glitz_set_raster_pos (gl, x_off, target_height - y_off);
                 
                 BITMAP_SETUP (dst,
                               dst->geometry.first,

Index: glitz_pixel.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_pixel.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- glitz_pixel.c	16 Mar 2005 18:59:41 -0000	1.19
+++ glitz_pixel.c	4 Jul 2005 10:33:01 -0000	1.20
@@ -725,7 +725,7 @@
                                               &dst->format->color,
                                               feature_mask);
     }
-  
+
     glitz_surface_push_current (dst, GLITZ_ANY_CONTEXT_CURRENT);
 
     texture = glitz_surface_get_texture (dst, 1);
@@ -973,13 +973,12 @@
     return;
   }
 
-  if (glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT)) {
-    from_drawable = 1;
-    color = &src->attached->format->color;
+  color = &src->format->color;
+  from_drawable = glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT);
+  if (from_drawable) {
+      if (src->attached)
+          color = &src->attached->format->color;
   } else {
-    from_drawable = 0;
-    color = &src->format->color;
-    
     texture = glitz_surface_get_texture (src, 0);
     if (!texture) {
       glitz_surface_pop_current (src);
@@ -1065,7 +1064,7 @@
     gl->disable (GLITZ_GL_SCISSOR_TEST);
 
     gl->read_pixels (x_src + src->x,
-                     src->attached->height - (y_src + src->y) - height,
+                     SURFACE_DRAWABLE_HEIGHT (src) - (y_src + src->y) - height,
                      width, height,
                      gl_format->format, gl_format->type,
                      pixels);

Index: glitz_rect.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_rect.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- glitz_rect.c	25 Jan 2005 19:50:26 -0000	1.16
+++ glitz_rect.c	4 Jul 2005 10:33:01 -0000	1.17
@@ -39,7 +39,7 @@
 _glitz_minimum_buffer (glitz_surface_t         *surface,
                        const glitz_rectangle_t *rects,
                        int                     n_rects,
-                       unsigned int            pixel)
+                       unsigned int            *pixel)
 {
     glitz_buffer_t *buffer;
     int            i, size = 0;
@@ -53,7 +53,10 @@
         
         rects++;
     }
-    
+
+    if (size <= 1)
+        return glitz_buffer_create_for_data (pixel);
+        
     buffer = glitz_pixel_buffer_create (surface->drawable, NULL,
                                         size * sizeof (unsigned int),
                                         GLITZ_BUFFER_HINT_STATIC_DRAW);
@@ -63,7 +66,7 @@
     data = glitz_buffer_map (buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
     
     while (size--)
-        *data++ = pixel;
+        *data++ = *pixel;
 
     glitz_buffer_unmap (buffer);
     
@@ -153,15 +156,76 @@
         };
         glitz_buffer_t *buffer = NULL;
         glitz_box_t    box;
-        glitz_bool_t   drawable;
-        
-        drawable = glitz_surface_push_current (dst, GLITZ_DRAWABLE_CURRENT);
+        glitz_bool_t   drawable = 0;
+
+        if (n_rects == 1 && rects->width <= 1 && rects->height <= 1)
+        {
+            glitz_surface_push_current (dst, GLITZ_ANY_CONTEXT_CURRENT);
+        }
+        else
+        {
+            drawable = glitz_surface_push_current (dst,
+                                                   GLITZ_DRAWABLE_CURRENT);
+        }
+
         if (drawable)
         {
+            glitz_box_t *clip;
+            int         n_clip;
+            int         target_height = SURFACE_DRAWABLE_HEIGHT (dst);
+                
             gl->clear_color (color->red   / (glitz_gl_clampf_t) 0xffff,
                              color->green / (glitz_gl_clampf_t) 0xffff,
                              color->blue  / (glitz_gl_clampf_t) 0xffff,
                              color->alpha / (glitz_gl_clampf_t) 0xffff);
+
+            while (n_rects--)
+            {
+                clip = dst->clip;
+                n_clip = dst->n_clip;
+                while (n_clip--)
+                {
+                    box.x1 = clip->x1 + dst->x_clip;
+                    box.y1 = clip->y1 + dst->y_clip;
+                    box.x2 = clip->x2 + dst->x_clip;
+                    box.y2 = clip->y2 + dst->y_clip;
+                    
+                    if (dst->box.x1 > box.x1)
+                        box.x1 = dst->box.x1;
+                    if (dst->box.y1 > box.y1)
+                        box.y1 = dst->box.y1;
+                    if (dst->box.x2 < box.x2)
+                        box.x2 = dst->box.x2;
+                    if (dst->box.y2 < box.y2)
+                        box.y2 = dst->box.y2;
+                    
+                    if (rects->x > box.x1)
+                        box.x1 = rects->x;
+                    if (rects->y > box.y1)
+                        box.y1 = rects->y;
+                    if (rects->x + rects->width < box.x2)
+                        box.x2 = rects->x + rects->width;
+                    if (rects->y + rects->height < box.y2)
+                        box.y2 = rects->y + rects->height;
+                    
+                    if (box.x1 < box.x2 && box.y1 < box.y2)
+                    {
+                        gl->scissor (box.x1,
+                                     target_height - dst->y - box.y2,
+                                     box.x2 - box.x1,
+                                     box.y2 - box.y1);
+                        
+                        gl->clear (GLITZ_GL_COLOR_BUFFER_BIT);
+                            
+                        glitz_surface_damage (dst, &box,
+                                              GLITZ_DAMAGE_TEXTURE_MASK |
+                                              GLITZ_DAMAGE_SOLID_MASK);
+                    }
+                    
+                    clip++;
+                }
+                rects++;
+            }
         }
         else
         {
@@ -170,75 +234,43 @@
                 ((((unsigned int) color->red   * 0xff) / 0xffff) << 16) |
                 ((((unsigned int) color->green * 0xff) / 0xffff) << 8) |
                 ((((unsigned int) color->blue  * 0xff) / 0xffff));
+            int x1, y1, x2, y2;
 
-            buffer = _glitz_minimum_buffer (dst, rects, n_rects, pixel);
+            buffer = _glitz_minimum_buffer (dst, rects, n_rects, &pixel);
             if (!buffer)
             {
                 glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
                 return;
             }
-        }
-      
-        while (n_rects--)
-        {
-            glitz_box_t *clip  = dst->clip;
-            int         n_clip = dst->n_clip;
 
-            while (n_clip--)
+            while (n_rects--)
             {
-                box.x1 = clip->x1 + dst->x_clip;
-                box.y1 = clip->y1 + dst->y_clip;
-                box.x2 = clip->x2 + dst->x_clip;
-                box.y2 = clip->y2 + dst->y_clip;
+                x1 = rects->x;
+                y1 = rects->y;
+                x2 = x1 + rects->width;
+                y2 = y1 + rects->height;
+            
+                if (x1 < 0)
+                    x1 = 0;
+                if (y1 < 0)
+                    y1 = 0;
+                if (x2 > dst->box.x2)
+                    x2 = dst->box.x2;
+                if (y2 > dst->box.y2)
+                    y2 = dst->box.y2;
 
-                if (dst->box.x1 > box.x1)
-                    box.x1 = dst->box.x1;
-                if (dst->box.y1 > box.y1)
-                    box.y1 = dst->box.y1;
-                if (dst->box.x2 < box.x2)
-                    box.x2 = dst->box.x2;
-                if (dst->box.y2 < box.y2)
-                    box.y2 = dst->box.y2;
-                
-                if (rects->x > box.x1)
-                    box.x1 = rects->x;
-                if (rects->y > box.y1)
-                    box.y1 = rects->y;
-                if (rects->x + rects->width < box.x2)
-                    box.x2 = rects->x + rects->width;
-                if (rects->y + rects->height < box.y2)
-                    box.y2 = rects->y + rects->height;
+                if (x1 < x2 && y1 < y2)
+                    glitz_set_pixels (dst,
+                                      x1, y1,
+                                      x2 - x1, y2 - y1,
+                                      &pf, buffer);
 
-                if (box.x1 < box.x2 && box.y1 < box.y2)
-                {
-                    if (drawable)
-                    {
-                        gl->scissor (box.x1,
-                                     dst->attached->height - dst->y - box.y2,
-                                     box.x2 - box.x1,
-                                     box.y2 - box.y1);
-                        gl->clear (GLITZ_GL_COLOR_BUFFER_BIT);
-                        
-                        glitz_surface_damage (dst, &box,
-                                              GLITZ_DAMAGE_TEXTURE_MASK |
-                                              GLITZ_DAMAGE_SOLID_MASK);
-                    }
-                    else
-                    {
-                        glitz_set_pixels (dst,
-                                          box.x1, box.y1,
-                                          box.x2 - box.x1, box.y2 - box.y1,
-                                          &pf, buffer);
-                    }
-                }
-                clip++;
+                rects++;
             }
-            rects++;
-        }
         
-        if (buffer)
-            glitz_buffer_destroy (buffer);
-
+            if (buffer)
+                glitz_buffer_destroy (buffer);
+        } 
         glitz_surface_pop_current (dst);
     }
 }

Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- glitz_surface.c	6 Jun 2005 12:28:40 -0000	1.29
+++ glitz_surface.c	4 Jul 2005 10:33:01 -0000	1.30
@@ -124,9 +124,9 @@
 
   if (surface->texture.name) {
     glitz_surface_push_current (surface, GLITZ_ANY_CONTEXT_CURRENT);
-    if (surface->framebuffer.name)
-        glitz_framebuffer_fini (&surface->drawable->backend->gl,
-                                &surface->framebuffer);
+
+    glitz_framebuffer_fini (&surface->drawable->backend->gl,
+                            &surface->framebuffer);
     glitz_texture_fini (&surface->drawable->backend->gl, &surface->texture);
   
     glitz_surface_pop_current (surface);
@@ -390,7 +390,7 @@
         if (what & GLITZ_DAMAGE_DRAWABLE_MASK)
             REGION_UNION (&surface->drawable_damage, box);
 
-        if (what & GLITZ_DAMAGE_TEXTURE_MASK)
+        if (surface->attached && (what & GLITZ_DAMAGE_TEXTURE_MASK))
             REGION_UNION (&surface->texture_damage, box);
     }
     else
@@ -401,7 +401,7 @@
             REGION_INIT (&surface->drawable_damage, &surface->box);
         }
         
-        if (what & GLITZ_DAMAGE_TEXTURE_MASK)
+        if (surface->attached && (what & GLITZ_DAMAGE_TEXTURE_MASK))
         {
             REGION_EMPTY (&surface->texture_damage);
             REGION_INIT (&surface->texture_damage, &surface->box);
@@ -594,13 +594,26 @@
 {
   glitz_surface_t *other;
   
-  if (surface->attached)
+  if (surface->attached) {
     other = surface->attached->backend->pop_current (surface->attached);
-  else
+  } else {
+    if (surface->framebuffer.name)
+        glitz_framebuffer_unbind (&surface->drawable->backend->gl);
+    
     other = surface->drawable->backend->pop_current (surface->drawable);
+  }
 
-  if (other)
+  if (other) {
+    if ((!other->attached) &&
+        (other->drawable->backend->feature_mask &
+         GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK))
+    {
+        glitz_framebuffer_complete (&other->drawable->backend->gl,
+                                    &other->framebuffer,
+                                    &other->texture);
+    }
     _glitz_surface_update_state (other);
+  }
 }
 
 void
@@ -905,5 +918,10 @@
 glitz_bool_t
 glitz_surface_valid_target (glitz_surface_t *surface)
 {
-    return glitz_surface_push_current (surface, GLITZ_DRAWABLE_CURRENT);
+    glitz_bool_t valid;
+
+    valid = glitz_surface_push_current (surface, GLITZ_DRAWABLE_CURRENT);
+    glitz_surface_pop_current (surface);
+
+    return valid;
 }

Index: glitz_texture.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_texture.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- glitz_texture.c	8 Mar 2005 07:25:08 -0000	1.18
+++ glitz_texture.c	4 Jul 2005 10:33:01 -0000	1.19
@@ -166,6 +166,15 @@
                     texture->width, texture->height, 0,
                     GLITZ_GL_ALPHA, GLITZ_GL_UNSIGNED_BYTE, data);
 
+  gl->tex_parameter_i (texture->target,
+                       GLITZ_GL_TEXTURE_MAG_FILTER,
+                       GLITZ_GL_NEAREST);
+  gl->tex_parameter_i (texture->target,
+                       GLITZ_GL_TEXTURE_MIN_FILTER,
+                       GLITZ_GL_NEAREST);
+  
+  texture->filter = GLITZ_GL_NEAREST;
+
   glitz_texture_unbind (gl, texture);
 
   if (data)

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- glitzint.h	6 Jun 2005 12:28:40 -0000	1.34
+++ glitzint.h	4 Jul 2005 10:33:01 -0000	1.35
@@ -538,6 +538,10 @@
 #define SURFACE_PROJECTIVE_TRANSFORM(surface) \
   ((surface)->flags & GLITZ_SURFACE_FLAG_PROJECTIVE_TRANSFORM_MASK)
 
+#define SURFACE_DRAWABLE_HEIGHT(surface) \
+  (((surface)->attached) ? \
+   (surface)->attached->height: surface->texture.height)
+
 typedef struct _glitz_filter_params_t glitz_filter_params_t;
 
 typedef struct _glitz_matrix {




More information about the cairo-commit mailing list