[cairo-commit] libglc/src glc_matrix.c,NONE,1.1 Makefile.am,1.1.1.1,1.2 glc.c,1.3,1.4 glc_glx_format.c,1.1.1.1,1.2 glc_glx_surface.c,1.1.1.1,1.2 glc_rect.c,1.2,1.3 glc_surface.c,1.2,1.3 glc_trap.c,1.2,1.3 glc_tri.c,1.2,1.3 glc_util.c,1.1.1.1,1.2 glcint.h,1.2,1.3

David Reveman commit at pdx.freedesktop.org
Wed Dec 3 08:55:52 PST 2003


Committed by: davidr

Update of /cvs/cairo/libglc/src
In directory pdx:/tmp/cvs-serv9248/src

Modified Files:
	Makefile.am glc.c glc_glx_format.c glc_glx_surface.c 
	glc_rect.c glc_surface.c glc_trap.c glc_tri.c glc_util.c 
	glcint.h 
Added Files:
	glc_matrix.c 
Log Message:
New transformation model

--- NEW FILE: glc_matrix.c ---
(This appears to be a binary file; contents omitted.)

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/libglc/src/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Makefile.am	27 Nov 2003 11:47:05 -0000	1.1.1.1
--- Makefile.am	3 Dec 2003 16:55:50 -0000	1.2
***************
*** 14,17 ****
--- 14,18 ----
  	glc_tri.c \
  	glc_status.c \
+ 	glc_matrix.c \
  	glc_util.c \
  	glc-glx.h \

Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc.c	1 Dec 2003 12:38:25 -0000	1.3
--- glc.c	3 Dec 2003 16:55:50 -0000	1.4
***************
*** 96,112 ****
  {
    glc_surface_t *intermediate = NULL, *mask_intermediate = NULL;
!   GLuint texture = 0;
    double width_factor, height_factor;
    double tx1, tx2, ty1, ty2;
!   int vx1, vx2, vy1, vy2;
    glc_region_box_t ibounds;
    int x_draw_offset = 0, y_draw_offset = 0;
  
    if (mask) {
-     /* XXX: I don't think transformations are handled correctly when
-        compositing with mask. */
      glc_surface_t *mask_surface;
      glc_region_box_t mask_bounds;
!     
      if (mask->type != GLC_SURFACE_PBUFFER_TYPE) {
        glc_region_box_t bounds;
--- 96,110 ----
  {
    glc_surface_t *intermediate = NULL, *mask_intermediate = NULL;
!   GLuint src_texture, texture = 0;
    double width_factor, height_factor;
    double tx1, tx2, ty1, ty2;
!   glc_point_t tl, bl, br, tr;
    glc_region_box_t ibounds;
    int x_draw_offset = 0, y_draw_offset = 0;
  
    if (mask) {
      glc_surface_t *mask_surface;
      glc_region_box_t mask_bounds;
! 
      if (mask->type != GLC_SURFACE_PBUFFER_TYPE) {
        glc_region_box_t bounds;
***************
*** 119,122 ****
--- 117,124 ----
        glc_mask_bounds (src, mask, dst, x_src, y_src, x_mask, y_mask,
                         &bounds, &mask_bounds);
+ 
+       if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
+           mask_bounds.y2 - mask_bounds.y1 <= 0)
+         return;
        
        mask_surface = mask_intermediate =
***************
*** 142,151 ****
      height = mask_surface->height;
  
-     glc_surface_disable_transform (src);
      glc_composite (GLC_OPERATOR_MASK,
                     src, NULL, mask_surface,
                     x_src, y_src, 0, 0, 0, 0,
                     mask_surface->width, mask_surface->height);
-     glc_surface_enable_transform (src);
      
      src = mask_surface;
--- 144,151 ----
***************
*** 164,167 ****
--- 164,170 ----
                               &x_draw_offset, &y_draw_offset);
  
+     if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
+       return;
+ 
      intermediate =
        glc_surface_create_intermediate (dst,
***************
*** 175,178 ****
--- 178,182 ----
      }
  
+     glc_surface_disable_transform (dst);
      glc_composite (GLC_OPERATOR_SRC,
                     dst,
***************
*** 183,186 ****
--- 187,192 ----
                     0, 0,
                     intermediate->width, intermediate->height);
+     glc_surface_enable_transform (dst);
+     src_texture = dst->texture;
      dst = intermediate;
    }
***************
*** 242,250 ****
      glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      
!     vx1 = x_dst;
!     vy1 = y_dst;
!     vx2 = x_dst + width;
!     vy2 = y_dst + height;
!     
      tx1i = x_src % src->width;
      ty1i = src->real_height - (height % src->real_height) -
--- 248,256 ----
      glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      
!     bl.x = tl.x = x_dst;
!     tr.y = tl.y = y_dst;
!     tr.x = br.x = x_dst + width;
!     bl.y = br.y = y_dst + height;
! 
      tx1i = x_src % src->width;
      ty1i = src->real_height - (height % src->real_height) -
***************
*** 265,281 ****
      glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  
!     /* Calulate texture and vertex coordinates. Y is flipped in
         texture coordinates. */
!     vx1 = x_dst;
!     vy1 = y_dst;
  
!     tx1i = x_src;
!     ty2i = src->real_height - y_src;
  
      tx2i = src->width;
      ty1i = src->real_height - src->height;
  
!     vx2 = vx1 + (tx2i - tx1i);
!     vy2 = vy1 + (ty2i - ty1i);
  
      /* Normalizing texture coordinates */
--- 271,322 ----
      glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  
!     /* Calculate texture and vertex coordinates. Y is flipped in
         texture coordinates. */
!     bl.x = tl.x = 0;
!     tr.y = tl.y = 0;
  
!     tx1i = 0;
!     ty2i = src->real_height;
  
      tx2i = src->width;
      ty1i = src->real_height - src->height;
  
!     tr.x = br.x = tx2i - tx1i;
!     bl.y = br.y = ty2i - ty1i;
! 
!     if (src->transform && (!src->disable_transform)) {
!       glc_matrix_transform_point (src->transform, &tl);
!       glc_matrix_transform_point (src->transform, &bl);
!       glc_matrix_transform_point (src->transform, &tr);
!       glc_matrix_transform_point (src->transform, &br);
!     }
!     
!     /* Shift all coordinates with destination offset */
!     if (x_dst) {
!       tl.x += x_dst;
!       bl.x += x_dst;
!       tr.x += x_dst;
!       br.x += x_dst;
!     }
!     if (y_dst) {
!       tl.y += y_dst;
!       bl.y += y_dst;
!       tr.y += y_dst;
!       br.y += y_dst;
!     }
! 
!     /* Shift all coordinates with source offset */
!     if (x_src) {
!       tl.x -= x_src;
!       bl.x -= x_src;
!       tr.x -= x_src;
!       br.x -= x_src;
!     }
!     if (y_src) {
!       tl.y -= y_src;
!       bl.y -= y_src;
!       tr.y -= y_src;
!       br.y -= y_src;
!     }
  
      /* Normalizing texture coordinates */
***************
*** 292,303 ****
    }
  
-   if (src->transform && (!src->disable_transform)) {
-     glMatrixMode (GL_MODELVIEW);
-     glPushMatrix ();
-     glTranslated (x_dst, y_dst, 0.0);
-     glMultMatrixd (src->transform);
-     glTranslated (-x_dst, -y_dst, 0.0);
-   }
- 
    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
--- 333,336 ----
***************
*** 306,333 ****
    glScissor (x_dst, dst->height - (y_dst + height), width, height);
  
    glBegin (GL_QUADS);
    glTexCoord2d (tx1, ty2);
!   glVertex2i (x_draw_offset + vx1, y_draw_offset + vy1);
    glTexCoord2d (tx2, ty2);
!   glVertex2i (x_draw_offset + vx2, y_draw_offset + vy1);
    glTexCoord2d (tx2, ty1);
!   glVertex2i (x_draw_offset + vx2, y_draw_offset + vy2);
    glTexCoord2d (tx1, ty1);
!   glVertex2i (x_draw_offset + vx1, y_draw_offset + vy2);
    glEnd ();
  
    glDisable (GL_TEXTURE_2D);
  
-   if (src->transform && (!src->disable_transform))
-     glPopMatrix ();
- 
    if (texture)
      glc_texture_destroy (texture);
    
    if (intermediate) { 
!     glBindTexture (GL_TEXTURE_2D, dst->texture);
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_width - (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);
--- 339,366 ----
    glScissor (x_dst, dst->height - (y_dst + height), width, height);
  
+   glColorMask (src->red, src->green, src->blue, src->alpha);
+ 
    glBegin (GL_QUADS);
    glTexCoord2d (tx1, ty2);
!   glVertex2d (x_draw_offset + tl.x, y_draw_offset + tl.y);
    glTexCoord2d (tx2, ty2);
!   glVertex2d (x_draw_offset + tr.x, y_draw_offset + tr.y);
    glTexCoord2d (tx2, ty1);
!   glVertex2d (x_draw_offset + br.x, y_draw_offset + br.y);
    glTexCoord2d (tx1, ty1);
!   glVertex2d (x_draw_offset + bl.x, y_draw_offset + bl.y);
    glEnd ();
  
    glDisable (GL_TEXTURE_2D);
  
    if (texture)
      glc_texture_destroy (texture);
    
    if (intermediate) { 
!     glBindTexture (GL_TEXTURE_2D, src_texture);
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_height -
!                          (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);

Index: glc_glx_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_format.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** glc_glx_format.c	27 Nov 2003 11:47:05 -0000	1.1.1.1
--- glc_glx_format.c	3 Dec 2003 16:55:50 -0000	1.2
***************
*** 127,130 ****
--- 127,139 ----
      if (vinfo) {
        format.fbconfigid = _glc_get_fbconfigid (screen_info, vinfo);
+       format.direct.red = 0;
+       format.direct.green = 0;
+       format.direct.blue = 0;
+       format.direct.alpha = 8;
+       format.id = id++;
+       format.visualid = vinfo->visualid;
+       
+       _glc_add_format (screen_info, &format);
+ 
        format.direct.red = 8;
        format.direct.green = 8;
***************
*** 132,136 ****
        format.direct.alpha = 0;
        format.id = id++;
!       format.visualid = vinfo->visualid;
        
        _glc_add_format (screen_info, &format);
--- 141,152 ----
        format.direct.alpha = 0;
        format.id = id++;
! 
!       _glc_add_format (screen_info, &format);
!         
!       format.direct.red = 8;
!       format.direct.green = 8;
!       format.direct.blue = 8;
!       format.direct.alpha = 8;
!       format.id = id++;
        
        _glc_add_format (screen_info, &format);

Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** glc_glx_surface.c	27 Nov 2003 11:46:15 -0000	1.1.1.1
--- glc_glx_surface.c	3 Dec 2003 16:55:50 -0000	1.2
***************
*** 34,39 ****
  static glc_surface_t *
  _glc_glx_surface_create_intermediate (void *abstract_templ,
!                                        int width,
!                                        int height);
  
  static void
--- 34,39 ----
  static glc_surface_t *
  _glc_glx_surface_create_intermediate (void *abstract_templ,
!                                       int width,
!                                       int height);
  
  static void
***************
*** 49,54 ****
    else
      glc_glx_context_push_current (surface->context,
!                                    surface,
!                                    surface->drawable);
    
    glc_surface_setup_environment (&surface->base);
--- 49,54 ----
    else
      glc_glx_context_push_current (surface->context,
!                                   surface,
!                                   surface->drawable);
    
    glc_surface_setup_environment (&surface->base);
***************
*** 75,81 ****
  static glc_bool_t
  _glc_glx_surface_realize (Display *display,
!                            Window drawable,
!                            int *width,
!                            int *height)
  {
    unsigned int uwidth, uheight, bwidth_ignore, depth_ignore;
--- 75,81 ----
  static glc_bool_t
  _glc_glx_surface_realize (Display *display,
!                           Window drawable,
!                           int *width,
!                           int *height)
  {
    unsigned int uwidth, uheight, bwidth_ignore, depth_ignore;
***************
*** 95,102 ****
  glc_surface_t *
  glc_glx_surface_create_offscreen (Display *display,
!                                    int screen,
!                                    glc_glx_format_t *format,
!                                    int width,
!                                    int height)
  {
    glc_glx_surface_t *surface;
--- 95,102 ----
  glc_surface_t *
  glc_glx_surface_create_offscreen (Display *display,
!                                   int screen,
!                                   glc_glx_format_t *format,
!                                   int width,
!                                   int height)
  {
    glc_glx_surface_t *surface;
***************
*** 118,121 ****
--- 118,132 ----
    surface->screen_info = screen_info;
    surface->format = format;
+   
+   if (format->type == GLC_GLX_FORMAT_TYPE_DIRECT) {
+     surface->base.red = format->direct.red;
+     surface->base.green = format->direct.green;
+     surface->base.blue = format->direct.blue;
+     surface->base.alpha = format->direct.alpha;
+   } else {
+     surface->base.red = surface->base.green = surface->base.blue = 1;
+     surface->base.alpha = 0;
+   }
+   
    surface->base.width = width;
    surface->base.height = height;
***************
*** 126,132 ****
    surface->base.texture =
      glc_texture_create (surface->base.width,
!                          surface->base.height,
!                          &surface->base.real_width,
!                          &surface->base.real_height);
    
    glc_surface_pop_current (&surface->base);
--- 137,143 ----
    surface->base.texture =
      glc_texture_create (surface->base.width,
!                         surface->base.height,
!                         &surface->base.real_width,
!                         &surface->base.real_height);
    
    glc_surface_pop_current (&surface->base);
***************
*** 142,148 ****
  static glc_glx_surface_t *
  _glc_glx_surface_create_for_drawable (Display *display,
!                                        int screen,
!                                        Drawable drawable,
!                                        glc_glx_format_t *format)
  {
    glc_glx_surface_t *surface;
--- 153,159 ----
  static glc_glx_surface_t *
  _glc_glx_surface_create_for_drawable (Display *display,
!                                       int screen,
!                                       Drawable drawable,
!                                       glc_glx_format_t *format)
  {
    glc_glx_surface_t *surface;
***************
*** 168,171 ****
--- 179,193 ----
    surface->context = context;
    surface->format = format;
+ 
+   if (format->type == GLC_GLX_FORMAT_TYPE_DIRECT) {
+     surface->base.red = format->direct.red;
+     surface->base.green = format->direct.green;
+     surface->base.blue = format->direct.blue;
+     surface->base.alpha = format->direct.alpha;
+   } else {
+     surface->base.red = surface->base.green = surface->base.blue = 1;
+     surface->base.alpha = 0;
+   }
+   
    surface->base.width = surface->base.real_width = width;
    surface->base.height = surface->base.real_height = height;
***************
*** 177,188 ****
  glc_surface_t *
  glc_glx_surface_create_for_window (Display *display,
!                                     int screen,
!                                     Window window,
!                                     glc_glx_format_t *format)
  {
    glc_glx_surface_t *surface;
    
    surface = _glc_glx_surface_create_for_drawable (display, screen, window,
!                                                    format);
  
    if (surface) {
--- 199,210 ----
  glc_surface_t *
  glc_glx_surface_create_for_window (Display *display,
!                                    int screen,
!                                    Window window,
!                                    glc_glx_format_t *format)
  {
    glc_glx_surface_t *surface;
    
    surface = _glc_glx_surface_create_for_drawable (display, screen, window,
!                                                   format);
  
    if (surface) {
***************
*** 200,206 ****
  static int
  _glc_get_pbuffer_valid_fbconfig (Display *display,
!                                   int screen,
!                                   glc_glx_format_t *format,
!                                   GLXFBConfig **fbconfig)
  {
    int nelements, value;
--- 222,228 ----
  static int
  _glc_get_pbuffer_valid_fbconfig (Display *display,
!                                  int screen,
!                                  glc_glx_format_t *format,
!                                  GLXFBConfig **fbconfig)
  {
    int nelements, value;
***************
*** 228,235 ****
  static glc_surface_t *
  _glc_glx_surface_create_pbuffer (glc_glx_surface_t *templ,
!                                   GLXFBConfig fbconfig,
!                                   glc_glx_format_t *format,
!                                   int width,
!                                   int height)
  {
    glc_glx_surface_t *surface;
--- 250,257 ----
  static glc_surface_t *
  _glc_glx_surface_create_pbuffer (glc_glx_surface_t *templ,
!                                  GLXFBConfig fbconfig,
!                                  glc_glx_format_t *format,
!                                  int width,
!                                  int height)
  {
    glc_glx_surface_t *surface;
***************
*** 250,253 ****
--- 272,286 ----
    surface->context = context;
    surface->format = format;
+   
+   if (format->type == GLC_GLX_FORMAT_TYPE_DIRECT) {
+     surface->base.red = format->direct.red;
+     surface->base.green = format->direct.green;
+     surface->base.blue = format->direct.blue;
+     surface->base.alpha = format->direct.alpha;
+   } else {
+     surface->base.red = surface->base.green = surface->base.blue = 1;
+     surface->base.alpha = 0;
+   }
+   
    surface->base.width = surface->base.real_width = width;
    surface->base.height = surface->base.real_height = height;
***************
*** 256,260 ****
    surface->drawable =
      glc_glx_pbuffer_create (screen_info->display_info->display, fbconfig,
!                              surface->base.width, surface->base.height);
    
    if (surface->drawable)
--- 289,293 ----
    surface->drawable =
      glc_glx_pbuffer_create (screen_info->display_info->display, fbconfig,
!                             surface->base.width, surface->base.height);
    
    if (surface->drawable)
***************
*** 268,273 ****
  static glc_surface_t *
  _glc_glx_surface_create_intermediate (void *abstract_templ,
!                                        int width,
!                                        int height)
  {
    glc_glx_surface_t *templ = abstract_templ;
--- 301,306 ----
  static glc_surface_t *
  _glc_glx_surface_create_intermediate (void *abstract_templ,
!                                       int width,
!                                       int height)
  {
    glc_glx_surface_t *templ = abstract_templ;
***************
*** 283,289 ****
    if ((screen_info->feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) &&
        _glc_get_pbuffer_valid_fbconfig (display, screen, templ->format,
!                                         &fbconfig)) {
      surface = _glc_glx_surface_create_pbuffer (templ, *fbconfig,
!                                                 templ->format, width, height);
      
      XFree (fbconfig);
--- 316,322 ----
    if ((screen_info->feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) &&
        _glc_get_pbuffer_valid_fbconfig (display, screen, templ->format,
!                                        &fbconfig)) {
      surface = _glc_glx_surface_create_pbuffer (templ, *fbconfig,
!                                                templ->format, width, height);
      
      XFree (fbconfig);
***************
*** 308,312 ****
      if (surface->drawable)
        glc_glx_pbuffer_destroy (surface->screen_info->display_info->display,
!                                 surface->drawable);
      break;
    case GLC_SURFACE_WINDOW_TYPE:
--- 341,345 ----
      if (surface->drawable)
        glc_glx_pbuffer_destroy (surface->screen_info->display_info->display,
!                                surface->drawable);
      break;
    case GLC_SURFACE_WINDOW_TYPE:
***************
*** 329,335 ****
    if (glx_surface->base.type == GLC_SURFACE_WINDOW_TYPE)
      _glc_glx_surface_realize (glx_surface->screen_info->display_info->display,
!                                glx_surface->drawable,
!                                &glx_surface->base.width,
!                                &glx_surface->base.height);
  }
  
--- 362,368 ----
    if (glx_surface->base.type == GLC_SURFACE_WINDOW_TYPE)
      _glc_glx_surface_realize (glx_surface->screen_info->display_info->display,
!                               glx_surface->drawable,
!                               &glx_surface->base.width,
!                               &glx_surface->base.height);
  }
  
***************
*** 343,347 ****
    
    glc_glx_context_push_current (glx_surface->context, glx_surface,
!                              glx_surface->drawable);
    glXSwapBuffers (glx_surface->screen_info->display_info->display,
                    glx_surface->drawable);
--- 376,380 ----
    
    glc_glx_context_push_current (glx_surface->context, glx_surface,
!                                 glx_surface->drawable);
    glXSwapBuffers (glx_surface->screen_info->display_info->display,
                    glx_surface->drawable);
***************
*** 390,398 ****
  void
  glc_glx_surface_read_pixels (glc_surface_t *surface,
!                               int x,
!                               int y,
!                               unsigned int width,
!                               unsigned int height,
!                               char *pixels)
  {
    unsigned char *row_buf;
--- 423,431 ----
  void
  glc_glx_surface_read_pixels (glc_surface_t *surface,
!                              int x,
!                              int y,
!                              unsigned int width,
!                              unsigned int height,
!                              char *pixels)
  {
    unsigned char *row_buf;
***************
*** 410,414 ****
    if (surface->type == GLC_SURFACE_TEXTURE_TYPE) {
      intermediate = _glc_glx_surface_create_intermediate (surface,
!                                                           width, height);
      if (!intermediate) {
        glc_surface_status_add (surface, GLC_STATUS_NOT_SUPPORTED_MASK);
--- 443,447 ----
    if (surface->type == GLC_SURFACE_TEXTURE_TYPE) {
      intermediate = _glc_glx_surface_create_intermediate (surface,
!                                                          width, height);
      if (!intermediate) {
        glc_surface_status_add (surface, GLC_STATUS_NOT_SUPPORTED_MASK);
***************
*** 417,428 ****
      
      glc_composite (GLC_OPERATOR_SRC,
!                     surface,
!                     NULL,
!                     intermediate,
!                     x, y,
!                     0, 0,
!                     0, 0,
!                     width,
!                     height);
      
      surface = intermediate;
--- 450,461 ----
      
      glc_composite (GLC_OPERATOR_SRC,
!                    surface,
!                    NULL,
!                    intermediate,
!                    x, y,
!                    0, 0,
!                    0, 0,
!                    width,
!                    height);
      
      surface = intermediate;
***************
*** 445,449 ****
       Needs some changes to texture handling, as images will become upside
       down without it.
!      */
    for (i = 0; i < ((int) height - i); i++) {
      memcpy (row_buf, &pixels[(height - i - 1) * rowstride], rowstride);
--- 478,482 ----
       Needs some changes to texture handling, as images will become upside
       down without it.
!   */
    for (i = 0; i < ((int) height - i); i++) {
      memcpy (row_buf, &pixels[(height - i - 1) * rowstride], rowstride);
***************
*** 462,470 ****
  void
  glc_glx_surface_draw_pixels (glc_surface_t *surface,
!                           int x,
!                           int y,
!                           unsigned int width,
!                           unsigned int height,
!                           char *pixels)
  {
    unsigned char *pixel_buf;
--- 495,503 ----
  void
  glc_glx_surface_draw_pixels (glc_surface_t *surface,
!                              int x,
!                              int y,
!                              unsigned int width,
!                              unsigned int height,
!                              char *pixels)
  {
    unsigned char *pixel_buf;
***************
*** 489,493 ****
       Needs some changes to texture handling, as images will become upside
       down without it.
!      */
    pixel_buf = (unsigned char *) malloc (rowstride * height);
    for (i = 0; i < (int) height; i++)
--- 522,526 ----
       Needs some changes to texture handling, as images will become upside
       down without it.
!   */
    pixel_buf = (unsigned char *) malloc (rowstride * height);
    for (i = 0; i < (int) height; i++)
***************
*** 501,507 ****
      
      offscreen = glc_glx_surface_create_offscreen (display, screen,
!                                                    glx_surface->format,
!                                                    glx_surface->base.width,
!                                                    glx_surface->base.height);
      
      glc_surface_push_current (offscreen);
--- 534,540 ----
      
      offscreen = glc_glx_surface_create_offscreen (display, screen,
!                                                   glx_surface->format,
!                                                   glx_surface->base.width,
!                                                   glx_surface->base.height);
      
      glc_surface_push_current (offscreen);
***************
*** 512,518 ****
    glEnable (GL_TEXTURE_2D);
    glBindTexture (GL_TEXTURE_2D, dst->texture);
!   
    glTexSubImage2D (GL_TEXTURE_2D, 0,
!                    x, (glx_surface->base.real_height - (y)) - height,
                     width, height,
                     format,
--- 545,551 ----
    glEnable (GL_TEXTURE_2D);
    glBindTexture (GL_TEXTURE_2D, dst->texture);
! 
    glTexSubImage2D (GL_TEXTURE_2D, 0,
!                    x, (dst->real_height - y) - height,
                     width, height,
                     format,
***************
*** 524,535 ****
    if (offscreen) {
      glc_composite (GLC_OPERATOR_SRC,
!                     offscreen,
!                     NULL,
!                     surface,
!                     0, 0,
!                     0, 0,
!                     x, y,
!                     width,
!                     height);
  
      glc_surface_pop_current (surface);
--- 557,568 ----
    if (offscreen) {
      glc_composite (GLC_OPERATOR_SRC,
!                    offscreen,
!                    NULL,
!                    surface,
!                    0, 0,
!                    0, 0,
!                    x, y,
!                    width,
!                    height);
  
      glc_surface_pop_current (surface);

Index: glc_rect.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_rect.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_rect.c	1 Dec 2003 12:21:10 -0000	1.2
--- glc_rect.c	3 Dec 2003 16:55:50 -0000	1.3
***************
*** 83,86 ****
--- 83,89 ----
      glc_intermediate_bounds (dst, &bounds, &ibounds,
                               &x_draw_offset, &y_draw_offset);
+ 
+     if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
+       return;
      
      intermediate = surface =
***************
*** 142,146 ****
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_width - (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);
--- 145,150 ----
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_height -
!                          (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);
***************
*** 172,175 ****
--- 176,182 ----
      glc_intermediate_bounds (dst, &bounds, &ibounds,
                               &x_draw_offset, &y_draw_offset);
+ 
+     if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
+       return;
      
      intermediate = surface =
***************
*** 192,196 ****
                     0, 0,
                     intermediate->width, intermediate->height);
!     glc_surface_disable_transform (dst);
    } else
      surface = dst;
--- 199,203 ----
                     0, 0,
                     intermediate->width, intermediate->height);
!     glc_surface_enable_transform (dst);
    } else
      surface = dst;
***************
*** 222,226 ****
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_width - (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);
--- 229,234 ----
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_height -
!                          (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);

Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_surface.c	1 Dec 2003 12:21:10 -0000	1.2
--- glc_surface.c	3 Dec 2003 16:55:50 -0000	1.3
***************
*** 100,130 ****
    };
  
-   static const double gl_identity[] = {
-     1.0, 0.0, 0.0, 0.0,
-     0.0, 1.0, 0.0, 0.0,
-     0.0, 0.0, 1.0, 0.0,
-     0.0, 0.0, 0.0, 1.0
-   };
- 
    if (transform && memcmp (transform, &identity,
                             sizeof (glc_transform_t)) == 0)
!     transform = 0;
! 
    if (transform) {
      if (!surface->transform) {
!       surface->transform = (double *) malloc (sizeof (double) * 16);
        if (!surface->transform)
!         return;
!       memcpy (surface->transform, gl_identity, sizeof (gl_identity));
!     }
  
!     surface->transform[0] = XFIXED_TO_DOUBLE (transform->matrix[0][0]);
!     surface->transform[1] = XFIXED_TO_DOUBLE (transform->matrix[1][0]);
!     
!     surface->transform[4] = XFIXED_TO_DOUBLE (transform->matrix[0][1]);
!     surface->transform[5] = XFIXED_TO_DOUBLE (transform->matrix[1][1]);
!     
!     surface->transform[12] = XFIXED_TO_DOUBLE (transform->matrix[0][2]);
!     surface->transform[13] = XFIXED_TO_DOUBLE (transform->matrix[1][2]);
  
      if (glc_matrix_invert (surface->transform)) {
--- 100,121 ----
    };
  
    if (transform && memcmp (transform, &identity,
                             sizeof (glc_transform_t)) == 0)
!     transform = NULL;
!   
    if (transform) {
      if (!surface->transform) {
!       surface->transform = malloc (sizeof (glc_matrix_t));
        if (!surface->transform)
! 		return;
! 	}
  
!     surface->transform->m[0][0] = XFIXED_TO_DOUBLE (transform->matrix[0][0]);
!     surface->transform->m[1][0] = XFIXED_TO_DOUBLE (transform->matrix[0][1]);
!     surface->transform->m[2][0] = XFIXED_TO_DOUBLE (transform->matrix[0][2]);
! 
!     surface->transform->m[0][1] = XFIXED_TO_DOUBLE (transform->matrix[1][0]);
!     surface->transform->m[1][1] = XFIXED_TO_DOUBLE (transform->matrix[1][1]);
!     surface->transform->m[2][1] = XFIXED_TO_DOUBLE (transform->matrix[1][2]);
  
      if (glc_matrix_invert (surface->transform)) {
***************
*** 132,136 ****
        surface->transform = NULL;
        glc_surface_status_add (surface, GLC_STATUS_INVALID_MATRIX_MASK);
-       return;
      }
    } else {
--- 123,126 ----
***************
*** 215,217 ****
--- 205,208 ----
    glEnable (GL_SCISSOR_TEST);
    glScissor (0, 0, surface->width, surface->height);
+   glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
  }

Index: glc_trap.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_trap.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_trap.c	1 Dec 2003 12:21:10 -0000	1.2
--- glc_trap.c	3 Dec 2003 16:55:50 -0000	1.3
***************
*** 115,119 ****
      return;
    
!   if (!src->repeat) {
      if (bounds.x1 > (src->width - x_src))
        return;
--- 115,119 ----
      return;
    
!   if ((!src->repeat) && (!src->transform)) {
      if (bounds.x1 > (src->width - x_src))
        return;
***************
*** 134,138 ****
                             &x_draw_offset, &y_draw_offset);
  
!   mask = glc_surface_create_intermediate (dst,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
--- 134,142 ----
                             &x_draw_offset, &y_draw_offset);
  
!   if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
!       mask_bounds.y2 - mask_bounds.y1 <= 0)
!     return;
! 
!   mask = glc_surface_create_intermediate (src,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
***************
*** 259,262 ****
--- 263,269 ----
      glc_intermediate_bounds (dst, &bounds, &ibounds,
                               &x_draw_offset, &y_draw_offset);
+ 
+     if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
+       return;
      
      intermediate = surface =
***************
*** 357,361 ****
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_width - (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);
--- 364,369 ----
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_height -
!                          (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);

Index: glc_tri.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_tri.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_tri.c	1 Dec 2003 12:21:10 -0000	1.2
--- glc_tri.c	3 Dec 2003 16:55:50 -0000	1.3
***************
*** 81,85 ****
      return;
  
!   if (!src->repeat) {
      if (bounds.x1 > (src->width - x_src))
        return;
--- 81,85 ----
      return;
  
!   if ((!src->repeat) && (!src->transform)) {
      if (bounds.x1 > (src->width - x_src))
        return;
***************
*** 99,104 ****
    glc_intermediate_bounds (dst, &bounds, &mask_bounds,
                             &x_draw_offset, &y_draw_offset);
      
!   mask = glc_surface_create_intermediate (dst,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
--- 99,108 ----
    glc_intermediate_bounds (dst, &bounds, &mask_bounds,
                             &x_draw_offset, &y_draw_offset);
+ 
+   if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
+       mask_bounds.y2 - mask_bounds.y1 <= 0)
+     return;
      
!   mask = glc_surface_create_intermediate (src,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
***************
*** 175,179 ****
      return;
  
!   if (!src->repeat) {
      if (bounds.x1 > (src->width - x_src))
        return;
--- 179,183 ----
      return;
  
!   if ((!src->repeat) && (!src->transform)) {
      if (bounds.x1 > (src->width - x_src))
        return;
***************
*** 193,198 ****
    glc_intermediate_bounds (dst, &bounds, &mask_bounds,
                             &x_draw_offset, &y_draw_offset);
      
!   mask = glc_surface_create_intermediate (dst,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
--- 197,206 ----
    glc_intermediate_bounds (dst, &bounds, &mask_bounds,
                             &x_draw_offset, &y_draw_offset);
+ 
+   if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
+       mask_bounds.y2 - mask_bounds.y1 <= 0)
+     return;
      
!   mask = glc_surface_create_intermediate (src,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
***************
*** 264,268 ****
      return;
  
!   if (!src->repeat) {
      if (bounds.x1 > (src->width - x_src))
        return;
--- 272,276 ----
      return;
  
!   if ((!src->repeat) && (!src->transform)) {
      if (bounds.x1 > (src->width - x_src))
        return;
***************
*** 282,287 ****
    glc_intermediate_bounds (dst, &bounds, &mask_bounds,
                             &x_draw_offset, &y_draw_offset);
      
!   mask = glc_surface_create_intermediate (dst,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
--- 290,299 ----
    glc_intermediate_bounds (dst, &bounds, &mask_bounds,
                             &x_draw_offset, &y_draw_offset);
+ 
+   if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
+       mask_bounds.y2 - mask_bounds.y1 <= 0)
+     return;
      
!   mask = glc_surface_create_intermediate (src,
                                            mask_bounds.x2 - mask_bounds.x1,
                                            mask_bounds.y2 - mask_bounds.y1);
***************
*** 408,411 ****
--- 420,426 ----
      glc_intermediate_bounds (dst, &bounds, &ibounds,
                               &x_draw_offset, &y_draw_offset);
+ 
+     if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
+       return;
      
      intermediate = surface =
***************
*** 493,497 ****
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_width - (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);
--- 508,513 ----
      glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
                           ibounds.x1,
!                          dst->real_height -
!                          (ibounds.y1 + intermediate->height),
                           0, 0,
                           intermediate->width, intermediate->height);

Index: glc_util.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_util.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** glc_util.c	27 Nov 2003 11:46:15 -0000	1.1.1.1
--- glc_util.c	3 Dec 2003 16:55:50 -0000	1.2
***************
*** 30,36 ****
  #endif
  
- #include <stdlib.h>
- #include <math.h>
- 
  #include "glcint.h"
  
--- 30,33 ----
***************
*** 65,130 ****
    *y_draw_offset = (ibounds->y1 > 0)? -ibounds->y1: 0;
  }
- 
- /* Matrix functions originally written by Carl D. Worth <cworth at isi.edu>
-    for the cairo library, modified for libglc by
-    David Reveman <c99drn at cs.umu.se>
- */
- static void
- _glc_matrix_scalar_multiply (double *matrix, double scalar)
- {
-   matrix[0]  *= scalar;
-   matrix[1]  *= scalar;
-   matrix[4]  *= scalar;
-   matrix[5]  *= scalar;
-   matrix[12] *= scalar;
-   matrix[13] *= scalar;
- }
- 
- /* This function isn't a correct adjoint in that the implicit 1 in the
-    homogeneous result should actually be ad-bc instead. But, since this
-    adjoint is only used in the computation of the inverse, which
-    divides by det (A)=ad-bc anyway, everything works out in the end. */
- static void
- _glc_matrix_compute_adjoint (double *matrix)
- {
-   /* adj (A) = transpose (C:cofactor (A,i,j)) */
-   double a, b, c, d, tx, ty;
- 
-   a  = matrix[0];  b  = matrix[1];
-   c  = matrix[4];  d  = matrix[5];
-   tx = matrix[12]; ty = matrix[13];
- 
-   matrix[0]  = d;               matrix[1]  = -b;
-   matrix[4]  = -c;              matrix[5]  = a;
-   matrix[12] = c * ty - d * tx; matrix[13] = b * tx - a * ty;
- }
- 
- static glc_status_t
- _glc_matrix_compute_determinant (double *matrix, double *det)
- {
-   double a, b, c, d;
- 
-   a = matrix[0]; b = matrix[1];
-   c = matrix[4]; d = matrix[5];
- 
-   *det = a * d - b * c;
- 
-   return GLC_STATUS_SUCCESS;
- }
- 
- glc_status_t
- glc_matrix_invert (double *matrix)
- {
-   /* inv (A) = 1/det (A) * adj (A) */
-   double det;
- 
-   _glc_matrix_compute_determinant (matrix, &det);
- 
-   if (det == 0)
- 	return GLC_STATUS_INVALID_MATRIX;
- 
-   _glc_matrix_compute_adjoint (matrix);
-   _glc_matrix_scalar_multiply (matrix, 1 / det);
- 
-   return GLC_STATUS_SUCCESS;
- }
--- 62,63 ----

Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glcint.h	1 Dec 2003 12:21:10 -0000	1.2
--- glcint.h	3 Dec 2003 16:55:50 -0000	1.3
***************
*** 47,50 ****
--- 47,62 ----
  #define GLC_STATUS_INVALID_MATRIX_MASK     (1L << 6)
  
+ typedef struct _glc_region_box_t {
+   int x1, x2, y1, y2;
+ } glc_region_box_t;
+ 
+ typedef struct _glc_point_t {
+   double x, y;
+ } glc_point_t;
+ 
+ typedef struct _glc_matrix_t {
+   double m[3][2];
+ } glc_matrix_t;
+ 
  typedef struct glc_surface_backend {
    glc_surface_t *
***************
*** 77,93 ****
    glc_bool_t repeat;
    glc_polyedge_t polyedge;
!   double *transform;
    glc_bool_t disable_transform;
    int width, height;
    int real_width, real_height;
    GLuint texture;
  };
  
  extern void __internal_linkage
! glc_set_operator (glc_operator_t op);
  
! typedef struct _glc_region_box_t {
!   int x1, x2, y1, y2;
! } glc_region_box_t;
  
  extern void __internal_linkage
--- 89,109 ----
    glc_bool_t repeat;
    glc_polyedge_t polyedge;
!   glc_matrix_t *transform;
    glc_bool_t disable_transform;
    int width, height;
    int real_width, real_height;
    GLuint texture;
+   glc_bool_t red, green, blue, alpha;
  };
  
  extern void __internal_linkage
! glc_matrix_transform_point (glc_matrix_t *matrix,
!                             glc_point_t *point);
  
! extern glc_status_t __internal_linkage
! glc_matrix_invert (glc_matrix_t *matrix);
! 
! extern void __internal_linkage
! glc_set_operator (glc_operator_t op);
  
  extern void __internal_linkage
***************
*** 98,104 ****
                           int *y_draw_offset);
  
- extern glc_status_t __internal_linkage
- glc_matrix_invert (double *matrix);
- 
  extern GLuint __internal_linkage
  glc_texture_create (int width,
--- 114,117 ----





More information about the cairo-commit mailing list