[cairo-commit] glitz/src glitz_buffer.c, 1.2, 1.3 glitz_pixel.c, 1.8, 1.9

David Reveman commit at pdx.freedesktop.org
Thu Sep 16 16:56:22 PDT 2004


Committed by: davidr

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

Modified Files:
	glitz_buffer.c glitz_pixel.c 
Log Message:
A few important pixel transfer fixes

Index: glitz_buffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_buffer.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glitz_buffer.c	6 Sep 2004 22:23:29 -0000	1.2
--- glitz_buffer.c	16 Sep 2004 23:56:20 -0000	1.3
***************
*** 79,82 ****
--- 79,83 ----
        surface->backend->gl.buffer_data (buffer->target, buffer->size,
                                          data, usage);
+       surface->backend->gl.bind_buffer (buffer->target, 0);
      }
    } else
***************
*** 142,147 ****
    buffer->size = size;
    buffer->name = 0;
!   buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
! 
    if (surface->backend->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
      status = _glitz_buffer_init (buffer, surface, data, hint);
--- 143,158 ----
    buffer->size = size;
    buffer->name = 0;
!   
!   switch (hint) {
!   case GLITZ_BUFFER_HINT_STREAM_READ:
!   case GLITZ_BUFFER_HINT_STATIC_READ:
!   case GLITZ_BUFFER_HINT_DYNAMIC_READ:
!     buffer->target = GLITZ_GL_PIXEL_PACK_BUFFER;
!     break;
!   default:
!     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
!     break;
!   }
!   
    if (surface->backend->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
      status = _glitz_buffer_init (buffer, surface, data, hint);

Index: glitz_pixel.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_pixel.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glitz_pixel.c	15 Sep 2004 16:52:14 -0000	1.8
--- glitz_pixel.c	16 Sep 2004 23:56:20 -0000	1.9
***************
*** 274,278 ****
  #define GLITZ_TRANSFORM_PIXELS_MASK         (1L << 0)
  #define GLITZ_TRANSFORM_SCANLINE_ORDER_MASK (1L << 1)
! #define GLITZ_TRANSFORM_COPY_REGION_MASK    (1L << 2)
  
  typedef struct _glitz_image {
--- 274,278 ----
  #define GLITZ_TRANSFORM_PIXELS_MASK         (1L << 0)
  #define GLITZ_TRANSFORM_SCANLINE_ORDER_MASK (1L << 1)
! #define GLITZ_TRANSFORM_COPY_BOX_MASK       (1L << 2)
  
  typedef struct _glitz_image {
***************
*** 422,426 ****
    glitz_gl_pixel_format_t *gl_format = NULL;
    unsigned long transform = 0;
!   int xoffset, bytes_per_line;
  
    if (x_dst < 0 || x_dst > (dst->width - width) ||
--- 422,426 ----
    glitz_gl_pixel_format_t *gl_format = NULL;
    unsigned long transform = 0;
!   int xoffset, bytes_per_line, bpp;
  
    if (x_dst < 0 || x_dst > (dst->width - width) ||
***************
*** 458,461 ****
--- 458,463 ----
      return;
    }
+ 
+   glitz_texture_bind (gl, texture);
    
    if (transform) {
***************
*** 467,470 ****
--- 469,473 ----
      data = malloc (stride * height);
      if (!data) {
+       glitz_texture_unbind (gl, texture);
        glitz_surface_pop_current (dst);
        glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
***************
*** 495,510 ****
      xoffset = 0;
      bytes_per_line = stride;
    } else {
      xoffset = format->xoffset;
      bytes_per_line = format->bytes_per_line;
      pixels = glitz_buffer_bind (buffer, GLITZ_GL_PIXEL_UNPACK_BUFFER);
      pixels += format->skip_lines * bytes_per_line;
    }
-   
-   glitz_texture_bind (gl, texture);
- 
-   gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
-   gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_ROWS, 0);
-   gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_PIXELS, xoffset);
  
    if (bytes_per_line) {
--- 498,509 ----
      xoffset = 0;
      bytes_per_line = stride;
+     bpp = dst_image.format->masks.bpp;
    } else {
      xoffset = format->xoffset;
      bytes_per_line = format->bytes_per_line;
+     bpp = format->masks.bpp;
      pixels = glitz_buffer_bind (buffer, GLITZ_GL_PIXEL_UNPACK_BUFFER);
      pixels += format->skip_lines * bytes_per_line;
    }
  
    if (bytes_per_line) {
***************
*** 517,522 ****
      else
        gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
!   } else
      gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
  
    gl->tex_sub_image_2d (texture->target, 0,
--- 516,528 ----
      else
        gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
! 
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, bytes_per_line / (bpp / 8));
!   } else {
      gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
+     gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
+   }
+ 
+   gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_ROWS, 0);
+   gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_PIXELS, xoffset);
  
    gl->tex_sub_image_2d (texture->target, 0,
***************
*** 527,530 ****
--- 533,539 ----
                          pixels);
  
+   if (transform == 0)
+     glitz_buffer_unbind (buffer);
+ 
    if (to_drawable) {
      glitz_texture_set_tex_gen (gl, texture, x_dst, y_dst, 0); 
***************
*** 557,566 ****
  
    dst->flags |= GLITZ_SURFACE_FLAG_SOLID_DIRTY_MASK;
- 
-   if (transform == 0)
-     glitz_buffer_unbind (buffer);
    
    glitz_surface_pop_current (dst);
! 
    if (data)
      free (data);
--- 566,572 ----
  
    dst->flags |= GLITZ_SURFACE_FLAG_SOLID_DIRTY_MASK;
    
    glitz_surface_pop_current (dst);
!   
    if (data)
      free (data);
***************
*** 583,587 ****
    unsigned long transform = 0;
    int src_x = 0, src_y = 0, src_w = width, src_h = height;
!   int xoffset, bytes_per_line;
    
    if (x_src < 0 || x_src > (src->width - width) ||
--- 589,593 ----
    unsigned long transform = 0;
    int src_x = 0, src_y = 0, src_w = width, src_h = height;
!   int xoffset, bytes_per_line, bpp;
    
    if (x_src < 0 || x_src > (src->width - width) ||
***************
*** 604,608 ****
      }
  
!     transform |= GLITZ_TRANSFORM_COPY_REGION_MASK;
    }
    
--- 610,614 ----
      }
  
!     transform |= GLITZ_TRANSFORM_COPY_BOX_MASK;
    }
    
***************
*** 620,624 ****
      int stride;
      
!     if (transform & GLITZ_TRANSFORM_COPY_REGION_MASK) {
        src_w = texture->width;
        src_h = texture->height;
--- 626,630 ----
      int stride;
      
!     if (transform & GLITZ_TRANSFORM_COPY_BOX_MASK) {
        src_w = texture->width;
        src_h = texture->height;
***************
*** 637,662 ****
      xoffset = 0;
      bytes_per_line = stride;
    } else {
      xoffset = format->xoffset;
      bytes_per_line = format->bytes_per_line;
      pixels = glitz_buffer_bind (buffer, GLITZ_GL_PIXEL_PACK_BUFFER);
      pixels += format->skip_lines * bytes_per_line;
    }
    
-   gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, 0);
    gl->pixel_store_i (GLITZ_GL_PACK_SKIP_ROWS, 0);
    gl->pixel_store_i (GLITZ_GL_PACK_SKIP_PIXELS, xoffset);
! 
    if (bytes_per_line) {
      if ((bytes_per_line % 4) == 0)
!       gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 4);
      else if ((bytes_per_line % 3) == 0)
!       gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 3);
      else if ((bytes_per_line % 2) == 0)
!       gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
      else
!       gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
!   } else
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
  
    if (from_drawable) {
--- 643,673 ----
      xoffset = 0;
      bytes_per_line = stride;
+     bpp = gl_format->pixel.masks.bpp;
    } else {
      xoffset = format->xoffset;
      bytes_per_line = format->bytes_per_line;
+     bpp = format->masks.bpp;
      pixels = glitz_buffer_bind (buffer, GLITZ_GL_PIXEL_PACK_BUFFER);
      pixels += format->skip_lines * bytes_per_line;
    }
    
    gl->pixel_store_i (GLITZ_GL_PACK_SKIP_ROWS, 0);
    gl->pixel_store_i (GLITZ_GL_PACK_SKIP_PIXELS, xoffset);
!   
    if (bytes_per_line) {
      if ((bytes_per_line % 4) == 0)
!       gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 4);
      else if ((bytes_per_line % 3) == 0)
!       gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 3);
      else if ((bytes_per_line % 2) == 0)
!       gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 2);
      else
!       gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 2);
!     
!     gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, bytes_per_line / (bpp / 8));
!   } else {
!     gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 1);
!     gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, 0);
!   }
  
    if (from_drawable) {




More information about the cairo-commit mailing list