[cairo-commit] glitz/src glitz.c, 1.4, 1.5 glitz_trap.c, 1.1.1.1, 1.2 glitz_tri.c, 1.1.1.1, 1.2

David Reveman commit at pdx.freedesktop.org
Mon May 10 07:34:30 PDT 2004


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv5157/src

Modified Files:
	glitz.c glitz_trap.c glitz_tri.c 
Log Message:
Fixed simultaneous transform and repeat

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** a/glitz.c	6 May 2004 14:55:03 -0000	1.4
--- b/glitz.c	10 May 2004 14:34:28 -0000	1.5
***************
*** 396,399 ****
--- 396,407 ----
  }
  
+ typedef enum {
+   GLITZ_REPEAT_NONE = 0,
+   GLITZ_REPEAT_SOUTHEAST,
+   GLITZ_REPEAT_SOUTHWEST,
+   GLITZ_REPEAT_NORTHEAST,
+   GLITZ_REPEAT_NORTHWEST
+ } glitz_repeat_direction_t;
+ 
  void
  glitz_composite (glitz_operator_t op,
***************
*** 640,754 ****
      /* CASE 2: Either none power of two sized texture or
         transformation is set. */
!     double save_tlx, save_trx, save_blx, save_brx;
  
      glitz_texture_ensure_repeat (gl, texture, 0);
  
!     bl.x = tl.x = 0;
!     tr.y = tl.y = 0;
!     tr.x = br.x = src->width;
!     bl.y = br.y = src->height;
  
!     if (src->transform) {
        glitz_texture_ensure_filter (gl, texture, src->filter);
!       glitz_matrix_transform_point (src->transform, &tl);
!       glitz_matrix_transform_point (src->transform, &bl);
!       glitz_matrix_transform_point (src->transform, &tr);
!       glitz_matrix_transform_point (src->transform, &br);
!     } else
        glitz_texture_ensure_filter (gl, texture, GLITZ_FILTER_NEAREST);
      
!     /* 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) {
!       x_src = abs (x_src);
!       if (SURFACE_REPEAT (src))
!         x_src = (x_src % src->width);
!       tl.x -= x_src;
!       bl.x -= x_src;
!       tr.x -= x_src;
!       br.x -= x_src;
!     }
!     if (y_src) {
!       y_src = abs (y_src);
!       if (SURFACE_REPEAT (src))
!         y_src = (y_src % src->height);
!       tl.y -= y_src;
!       bl.y -= y_src;
!       tr.y -= y_src;
!       br.y -= y_src;
!     }
  
!     save_tlx = tl.x;
!     save_blx = bl.x;
!     save_trx = tr.x;
!     save_brx = br.x;
  
!     do {
!       do {
!         /* Clip to original source area if repeat and transform are both
!            used. */
!         if (src->transform && SURFACE_REPEAT (src)) {
!           glitz_region_box_t src_clip, intersect_clip;
!           
!           src_clip.x1 = tl.x;
!           src_clip.y1 = tl.y;
!           src_clip.x2 = src_clip.x1 + src->width;
!           src_clip.y2 = src_clip.y1 + src->height;
  
!           glitz_intersect_region (&clip, &src_clip, &intersect_clip);
  
!           gl->scissor (intersect_clip.x1,
!                        dst->height - (intersect_clip.y1 +
!                                       (intersect_clip.y2 - intersect_clip.y1)),
!                        intersect_clip.x2 - intersect_clip.x1,
!                        intersect_clip.y2 - intersect_clip.y1);
!         }
!         
!         gl->begin (GLITZ_GL_QUADS);
!         gl->tex_coord_2d (0.0, texture->texcoord_height);
!         gl->vertex_2d (tl.x, tl.y);
!         gl->tex_coord_2d (texture->texcoord_width, texture->texcoord_height);
!         gl->vertex_2d (tr.x, tr.y);
!         gl->tex_coord_2d (texture->texcoord_width, 0.0);
!         gl->vertex_2d (br.x, br.y);
!         gl->tex_coord_2d (0.0, 0.0);
!         gl->vertex_2d (bl.x, bl.y);
!         gl->end ();
  
!         if (SURFACE_REPEAT (src)) {
!           bl.x += src->width;
!           tl.x += src->width;
!           tr.x += src->width;
!           br.x += src->width;
!         }
!         
!       } while (SURFACE_REPEAT (src) && (tl.x < (x_dst + width)));
  
!       if (SURFACE_REPEAT (src)) {
!         bl.y += src->height;
!         tl.y += src->height;
!         tr.y += src->height;
!         br.y += src->height;
  
!         tl.x = save_tlx;
!         bl.x = save_blx;
!         tr.x = save_trx;
!         br.x = save_brx;
!       }
!       
!     } while (SURFACE_REPEAT (src) && (tl.y < (y_dst + height)));  
    }
  
--- 648,813 ----
      /* CASE 2: Either none power of two sized texture or
         transformation is set. */
!     glitz_point_t base_tl, base_bl, base_br, base_tr;
!     int x_dir, y_dir, continue_y, continue_x, x_is_ok, y_is_ok,
!       in_destination_area;
!     double save_base_x1, save_base_x2;
!     glitz_repeat_direction_t repeat_direction;
  
      glitz_texture_ensure_repeat (gl, texture, 0);
  
!     base_bl.x = base_tl.x = 0;
!     base_tr.y = base_tl.y = 0;
!     base_tr.x = base_br.x = src->width;
!     base_bl.y = base_br.y = src->height;
  
!     /* Start repeating in southeast direction */
!     repeat_direction = GLITZ_REPEAT_SOUTHEAST;
!     x_dir = y_dir = 1;
! 
!     if (src->transform)
        glitz_texture_ensure_filter (gl, texture, src->filter);
!     else
        glitz_texture_ensure_filter (gl, texture, GLITZ_FILTER_NEAREST);
+ 
+     while (repeat_direction) {
+       save_base_x1 = base_tl.x;
+       save_base_x2 = base_tr.x;
+       
+       do {
+         continue_y = continue_x = in_destination_area = 0;
+         do {
+           bl = base_bl;
+           br = base_br;
+           tl = base_tl;
+           tr = base_tr;
+         
+           if (src->transform) {
+             glitz_matrix_transform_point (src->transform, &tl);
+             glitz_matrix_transform_point (src->transform, &bl);
+             glitz_matrix_transform_point (src->transform, &tr);
+             glitz_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) {
!             x_src = abs (x_src);
!             if (SURFACE_REPEAT (src))
!               x_src = (x_src % src->width);
!             tl.x -= x_src;
!             bl.x -= x_src;
!             tr.x -= x_src;
!             br.x -= x_src;
!           }
!           if (y_src) {
!             y_src = abs (y_src);
!             if (SURFACE_REPEAT (src))
!               y_src = (y_src % src->height);
!             tl.y -= y_src;
!             bl.y -= y_src;
!             tr.y -= y_src;
!             br.y -= y_src;
!           }
  
!           if ((tl.x > (x_dst + width) && bl.x > (x_dst + width)) ||
!               (tr.x < x_dst && br.x < x_dst))
!             x_is_ok = 0;
!           else
!             x_is_ok = 1;
  
!           if ((tl.y > (y_dst + height) && tr.y > (y_dst + height)) ||
!               (bl.y < y_dst && br.y < y_dst))
!             y_is_ok = 0;
!           else
!             y_is_ok = 1;
!         
!           if (x_is_ok && y_is_ok) {
!             gl->begin (GLITZ_GL_QUADS);
!             gl->tex_coord_2d (0.0, texture->texcoord_height);
!             gl->vertex_2d (tl.x, tl.y);
!             gl->tex_coord_2d (texture->texcoord_width,
!                               texture->texcoord_height);
!             gl->vertex_2d (tr.x, tr.y);
!             gl->tex_coord_2d (texture->texcoord_width, 0.0);
!             gl->vertex_2d (br.x, br.y);
!             gl->tex_coord_2d (0.0, 0.0);
!             gl->vertex_2d (bl.x, bl.y);
!             gl->end ();
!             in_destination_area = 1;
!           }
  
!           if (SURFACE_REPEAT (src)) {
!             base_bl.x += src->width * x_dir;
!             base_tl.x += src->width * x_dir;
!             base_tr.x += src->width * x_dir;
!             base_br.x += src->width * x_dir;
  
!             if (y_is_ok)
!               continue_y = 1;
  
!             if (in_destination_area)
!               continue_x = (x_is_ok && y_is_ok);
!             else
!               continue_x = (x_is_ok || y_is_ok);
!           }
!         } while (SURFACE_REPEAT (src) && continue_x);
  
!         if (SURFACE_REPEAT (src)) {
!           base_bl.y += src->height * y_dir;
!           base_tl.y += src->height * y_dir;
!           base_tr.y += src->height * y_dir;
!           base_br.y += src->height * y_dir;
  
!           base_tl.x = base_bl.x = save_base_x1;
!           base_tr.x = base_br.x = save_base_x2;
!         }
!       } while (SURFACE_REPEAT (src) && continue_y);
!     
!       if (src->transform && SURFACE_REPEAT (src)) {
!         switch (repeat_direction) {
!         case GLITZ_REPEAT_SOUTHEAST:
!           y_dir = -1;
!           base_tl.y = base_tr.y = -src->height;
!           base_bl.y = base_br.y = 0.0;
!           repeat_direction = GLITZ_REPEAT_SOUTHWEST;
!           break;
!         case GLITZ_REPEAT_SOUTHWEST:
!           x_dir = -1;
!           base_tl.y = base_tr.y = -src->height;
!           base_bl.y = base_br.y = 0.0;
!           base_tl.x = base_bl.x = -src->width;
!           base_tr.x = base_br.x = 0.0;
!           repeat_direction = GLITZ_REPEAT_NORTHEAST;
!           break;
!         case GLITZ_REPEAT_NORTHEAST:
!           y_dir = 1;
!           base_tl.y = base_tr.y = 0.0;
!           base_bl.y = base_br.y = src->height;
!           base_tl.x = base_bl.x = -src->width;
!           base_tr.x = base_br.x = 0.0;
!           repeat_direction = GLITZ_REPEAT_NORTHWEST;
!           break;
!         case GLITZ_REPEAT_NORTHWEST:
!           repeat_direction = GLITZ_REPEAT_NONE;
!           break;
!         case GLITZ_REPEAT_NONE:
!           break;
!         }
!       } else
!         repeat_direction = GLITZ_REPEAT_NONE;
!     }
    }
  

Index: glitz_trap.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_trap.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** a/glitz_trap.c	30 Mar 2004 17:07:18 -0000	1.1.1.1
--- b/glitz_trap.c	10 May 2004 14:34:28 -0000	1.2
***************
*** 218,223 ****
        return;
      
!     mask = glitz_int_surface_create_similar (dst, GLITZ_STANDARD_A8,
!                                              1,
                                               bounds.x2 - bounds.x1,
                                               bounds.y2 - bounds.y1);
--- 218,222 ----
        return;
      
!     mask = glitz_int_surface_create_similar (dst, GLITZ_STANDARD_ARGB32, 1,
                                               bounds.x2 - bounds.x1,
                                               bounds.y2 - bounds.y1);

Index: glitz_tri.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_tri.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** a/glitz_tri.c	30 Mar 2004 17:07:19 -0000	1.1.1.1
--- b/glitz_tri.c	10 May 2004 14:34:28 -0000	1.2
***************
*** 181,186 ****
        return;
    
!     mask = glitz_int_surface_create_similar (dst, GLITZ_STANDARD_A8,
!                                              1,
                                               bounds.x2 - bounds.x1,
                                               bounds.y2 - bounds.y1);
--- 181,185 ----
        return;
    
!     mask = glitz_int_surface_create_similar (dst, GLITZ_STANDARD_ARGB32, 1,
                                               bounds.x2 - bounds.x1,
                                               bounds.y2 - bounds.y1);
***************
*** 193,197 ****
      mask->hint_mask |= GLITZ_INT_HINT_IMPLICIT_MASK_MASK;
  
!     if (!glitz_surface_push_current (mask, GLITZ_CN_SURFACE_DRAWABLE_CURRENT)) {
        glitz_surface_pop_current (mask);
        return;
--- 192,197 ----
      mask->hint_mask |= GLITZ_INT_HINT_IMPLICIT_MASK_MASK;
  
!     if (!glitz_surface_push_current (mask,
!                                      GLITZ_CN_SURFACE_DRAWABLE_CURRENT)) {
        glitz_surface_pop_current (mask);
        return;





More information about the cairo-commit mailing list