[cairo-commit] cairo/src cairo_wideint.c, NONE, 1.1 cairo_wideint.h, NONE, 1.1 Makefile.am, 1.24, 1.25 cairo_pattern.c, 1.8, 1.9 cairo_png_surface.c, 1.7, 1.8 cairo_surface.c, 1.31, 1.32 cairo_traps.c, 1.16, 1.17 cairoint.h, 1.64, 1.65

Keith Packard commit at pdx.freedesktop.org
Fri May 28 12:37:18 PDT 2004


Committed by: keithp

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

Modified Files:
	Makefile.am cairo_pattern.c cairo_png_surface.c 
	cairo_surface.c cairo_traps.c cairoint.h 
Added Files:
	cairo_wideint.c cairo_wideint.h 
Log Message:
2004-05-28  Keith Packard  <keithp at keithp.com>

	* configure.in:
	* src/Makefile.am:
	Add WARN_CFLAGS, autodetection for 64/128 bit ints and
	cairo_wideint.[ch]
	
	* src/cairo_gstate.c: (_cairo_gstate_show_glyphs):
	Check status return from _cairo_gstate_glyph_extents
	
	* src/cairo_pattern.c: (_cairo_image_data_set_radial),
	(_cairo_pattern_get_image):
	* src/cairo_png_surface.c: (_cairo_png_surface_copy_page):
	* src/cairo_surface.c: (_cairo_surface_composite):
	Quiet compiler warnings about uninitialized variables

	* src/cairo_traps.c: (_det16_32), (_det32_64),
	(_fixed_16_16_to_fixed_32_32), (_line_segs_intersect_ceil):
	Switch to alternate exact line intersection code.
	
	* src/cairo_wideint.c: (_cairo_uint64_divrem),
	(_cairo_uint32_to_uint64), (_cairo_int32_to_int64),
	(_cairo_uint32s_to_uint64), (_cairo_uint64_add),
	(_cairo_uint64_sub), (_cairo_uint32x32_64_mul),
	(_cairo_uint64_mul), (_cairo_uint64_lsl), (_cairo_uint64_rsl),
	(_cairo_uint64_rsa), (_cairo_uint64_lt), (_cairo_uint64_eq),
	(_cairo_int64_lt), (_cairo_uint64_not), (_cairo_uint64_negate),
	(_cairo_leading_zeros32), (_cairo_uint64x32_normalized_divrem),
	(_cairo_int64_divrem), (_cairo_uint128_divrem),
	(_cairo_uint32_to_uint128), (_cairo_int32_to_int128),
	(_cairo_uint64_to_uint128), (_cairo_int64_to_int128),
	(_cairo_uint128_add), (_cairo_uint128_sub), (uint64_lo),
	(uint64_hi), (uint64_shift32), (_cairo_uint64x64_128_mul),
	(_cairo_uint128_mul), (_cairo_uint128_lsl), (_cairo_uint128_rsl),
	(_cairo_uint128_rsa), (_cairo_uint128_lt), (_cairo_int128_lt),
	(_cairo_uint128_eq), (_cairo_uint128x64_normalized_divrem),
	(_cairo_leading_zeros64), (_cairo_int128_negate),
	(_cairo_int128_not), (_cairo_int128_divrem):
	* src/cairo_wideint.h:
	Add 64/128-bit wide integer arithmetic.
	
	* src/cairoint.h:
	Switch to stdint.h types (and new wide types).


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

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

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/src/Makefile.am,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** a/Makefile.am	9 Apr 2004 21:19:47 -0000	1.24
--- b/Makefile.am	28 May 2004 19:37:15 -0000	1.25
***************
*** 51,54 ****
--- 51,56 ----
  	cairo_traps.c		\
  	cairo_pattern.c		\
+ 	cairo_wideint.c		\
+ 	cairo_wideint.h		\
  	$(libcairo_ps_sources)  \
  	$(libcairo_png_sources) \
***************
*** 60,64 ****
  libcairo_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined
  
! INCLUDES = -I$(srcdir) $(CAIRO_CFLAGS) $(FONTCONFIG_CFLAGS) $(XRENDER_CFLAGS) $(XCB_CFLAGS) $(PNG_CFLAGS) $(GL_CFLAGS)
  
  libcairo_la_LIBADD = $(CAIRO_LIBS) $(FONTCONFIG_LIBS) $(XRENDER_LIBS) $(XCB_LIBS) $(PS_LIBS) $(PNG_LIBS) $(GL_LIBS) -lm
--- 62,66 ----
  libcairo_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined
  
! INCLUDES = -I$(srcdir) $(WARN_CFLAGS) $(CAIRO_CFLAGS) $(FONTCONFIG_CFLAGS) $(XRENDER_CFLAGS) $(XCB_CFLAGS) $(PNG_CFLAGS) $(GL_CFLAGS)
  
  libcairo_la_LIBADD = $(CAIRO_LIBS) $(FONTCONFIG_LIBS) $(XRENDER_LIBS) $(XCB_LIBS) $(PS_LIBS) $(PNG_LIBS) $(GL_LIBS) -lm

Index: cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pattern.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** a/cairo_pattern.c	11 May 2004 18:20:06 -0000	1.8
--- b/cairo_pattern.c	28 May 2004 19:37:15 -0000	1.9
***************
*** 602,605 ****
--- 602,606 ----
  	aligned_circles = 1;
  	r1 = 1.0 / (r1 - r0);
+ 	r1_2 = c0_c1 = 0.0; /* shut up compiler */
      }
  
***************
*** 739,742 ****
--- 740,746 ----
      }
  	break;
+     default:
+ 	surface = NULL;
+ 	break;
      }
      

Index: cairo_png_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_png_surface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/cairo_png_surface.c	24 May 2004 09:28:05 -0000	1.7
--- b/cairo_png_surface.c	28 May 2004 19:37:15 -0000	1.8
***************
*** 293,296 ****
--- 293,299 ----
  	png_color_type = PNG_COLOR_TYPE_GRAY;
  	break;
+     default:
+ 	status = CAIRO_STATUS_NULL_POINTER;
+ 	goto BAIL;
      }
  

Index: cairo_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_surface.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** a/cairo_surface.c	24 May 2004 09:28:05 -0000	1.31
--- b/cairo_surface.c	28 May 2004 19:37:15 -0000	1.32
***************
*** 237,241 ****
  {
      cairo_int_status_t status;
!     cairo_image_surface_t *src_image, *mask_image, *dst_image;
  
      status = dst->backend->composite (operator,
--- 237,241 ----
  {
      cairo_int_status_t status;
!     cairo_image_surface_t *src_image, *mask_image = 0, *dst_image;
  
      status = dst->backend->composite (operator,

Index: cairo_traps.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_traps.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** a/cairo_traps.c	20 Apr 2004 19:35:44 -0000	1.16
--- b/cairo_traps.c	28 May 2004 19:37:15 -0000	1.17
***************
*** 53,62 ****
  _compute_x (cairo_line_t *line, cairo_fixed_t y);
  
- static double
- _compute_inverse_slope (cairo_line_t *l);
- 
- static double
- _compute_x_intercept (cairo_line_t *l, double inverse_slope);
- 
  static int
  _line_segs_intersect_ceil (cairo_line_t *left, cairo_line_t *right, cairo_fixed_t *y_ret);
--- 53,56 ----
***************
*** 328,365 ****
        looked at complexity, (both are probably similar and it probably
        doesn't matter much anyway).
  
! static double
! _det (double a, double b, double c, double d)
  {
!     return a * d - b * c;
  }
  
! static int
! _lines_intersect (cairo_line_t *l1, cairo_line_t *l2, cairo_fixed_t *y_intersection)
  {
!     double dx1 = cairo_fixed_to_double (l1->p1.x - l1->p2.x);
!     double dy1 = cairo_fixed_to_double (l1->p1.y - l1->p2.y);
! 
!     double dx2 = cairo_fixed_to_double (l2->p1.x - l2->p2.x);
!     double dy2 = cairo_fixed_to_double (l2->p1.y - l2->p2.y);
  
!     double l1_det, l2_det;
  
!     double den_det = _det (dx1, dy1, dx2, dy2);
  
!     if (den_det == 0)
  	return 0;
  
!     l1_det = _det (l1->p1.x, l1->p1.y,
! 		  l1->p2.x, l1->p2.y);
!     l2_det = _det (l2->p1.x, l2->p1.y,
! 		  l2->p2.x, l2->p2.y);
  
!     *y_intersection = _det (l1_det, dy1,
! 			   l2_det, dy2) / den_det;
  
      return 1;
  }
! */
  static cairo_fixed_16_16_t
  _compute_x (cairo_line_t *line, cairo_fixed_t y)
--- 322,427 ----
        looked at complexity, (both are probably similar and it probably
        doesn't matter much anyway).
+  */
  
! static const cairo_fixed_32_32_t
! _det16_32 (cairo_fixed_16_16_t a,
! 	   cairo_fixed_16_16_t b,
! 	   cairo_fixed_16_16_t c,
! 	   cairo_fixed_16_16_t d)
  {
!     return _cairo_int64_sub (_cairo_int32x32_64_mul (a, d),
! 			     _cairo_int32x32_64_mul (b, c));
  }
  
! static const cairo_fixed_64_64_t
! _det32_64 (cairo_fixed_32_32_t a,
! 	   cairo_fixed_32_32_t b,
! 	   cairo_fixed_32_32_t c,
! 	   cairo_fixed_32_32_t d)
  {
!     return _cairo_int128_sub (_cairo_int64x64_128_mul (a, d),
! 			      _cairo_int64x64_128_mul (b, c));
! }
  
! static const cairo_fixed_32_32_t
! _fixed_16_16_to_fixed_32_32 (cairo_fixed_16_16_t a)
! {
!     return _cairo_int64_lsl (_cairo_int32_to_int64 (a), 16);
! }
  
! static int
! _line_segs_intersect_ceil (cairo_line_t *l1, cairo_line_t *l2, cairo_fixed_t *y_intersection)
! {
!     cairo_fixed_16_16_t	dx1, dx2, dy1, dy2;
!     cairo_fixed_32_32_t	den_det;
!     cairo_fixed_32_32_t	l1_det, l2_det;
!     cairo_fixed_64_64_t num_det;
!     cairo_fixed_32_32_t	intersect_32_32;
!     cairo_fixed_48_16_t	intersect_48_16;
!     cairo_fixed_16_16_t	intersect_16_16;
!     cairo_quorem128_t	qr;
  
!     dx1 = l1->p1.x - l1->p2.x;
!     dy1 = l1->p1.y - l1->p2.y;
!     dx2 = l2->p1.x - l2->p2.x;
!     dy2 = l2->p1.y - l2->p2.y;
!     den_det = _det16_32 (dx1, dy1,
! 			 dx2, dy2);
!     
!     if (_cairo_int64_eq (den_det, _cairo_int32_to_int64(0)))
  	return 0;
  
!     l1_det = _det16_32 (l1->p1.x, l1->p1.y,
! 			l1->p2.x, l1->p2.y);
!     l2_det = _det16_32 (l2->p1.x, l2->p1.y,
! 			l2->p2.x, l2->p2.y);
  
!     
!     num_det = _det32_64 (l1_det, _fixed_16_16_to_fixed_32_32 (dy1),
! 			 l2_det, _fixed_16_16_to_fixed_32_32 (dy2));
!     
!     /*
!      * Ok, this one is a bit tricky in fixed point, the denominator
!      * needs to be left with 32-bits of fraction so that the
!      * result of the divide ends up with 32-bits of fraction (64 - 32 = 32)
!      */
!     qr = _cairo_int128_divrem (num_det, _cairo_int64_to_int128 (den_det));
!     
!     intersect_32_32 = _cairo_int128_to_int64 (qr.quo);
!     
!     /*
!      * Find the ceiling of the quotient -- divrem returns
!      * the quotient truncated towards zero, so if the
!      * quotient should be positive (num_den and den_det have same sign)
!      * bump the quotient up by one.
!      */
!     
!     if (_cairo_int128_ne (qr.rem, _cairo_int32_to_int128 (0)) &&
! 	(_cairo_int128_ge (num_det, _cairo_int32_to_int128 (0)) ==
! 	 _cairo_int64_ge (den_det, _cairo_int32_to_int64 (0))))
!     {
! 	intersect_32_32 = _cairo_int64_add (intersect_32_32,
! 					    _cairo_int32_to_int64 (1));
!     }
! 	
!     /* 
!      * Now convert from 32.32 to 48.16 and take the ceiling;
!      * this requires adding in 15 1 bits and shifting the result
!      */
! 
!     intersect_32_32 = _cairo_int64_add (intersect_32_32,
! 					_cairo_int32_to_int64 ((1 << 16) - 1));
!     intersect_48_16 = _cairo_int64_rsa (intersect_32_32, 16);
!     
!     /*
!      * And drop the top bits
!      */
!     intersect_16_16 = _cairo_int64_to_int32 (intersect_48_16);
!     
!     *y_intersection = intersect_16_16;
  
      return 1;
  }
! 
  static cairo_fixed_16_16_t
  _compute_x (cairo_line_t *line, cairo_fixed_t y)
***************
*** 372,375 ****
--- 434,438 ----
  }
  
+ #if 0
  static double
  _compute_inverse_slope (cairo_line_t *l)
***************
*** 461,464 ****
--- 524,528 ----
      return 1;
  }
+ #endif
  
  /* The algorithm here is pretty simple:

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** a/cairoint.h	24 May 2004 09:28:05 -0000	1.64
--- b/cairoint.h	28 May 2004 19:37:15 -0000	1.65
***************
*** 37,40 ****
--- 37,44 ----
  #define _CAIROINT_H_
  
+ #if HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+ 
  #include <assert.h>
  #include <stdlib.h>
***************
*** 42,45 ****
--- 46,50 ----
  #include <math.h>
  #include <limits.h>
+ #include <stdint.h>
  
  #include "cairo.h"
***************
*** 96,120 ****
  #endif
  
! #ifdef WIN32
! typedef __int64		cairo_fixed_32_32_t;
! #else
! #  if defined(__alpha__) || defined(__alpha) || \
!       defined(ia64) || defined(__ia64__) || \
!       defined(__sparc64__) || \
!       defined(__s390x__) || \
!       defined(x86_64) || defined (__x86_64__)
! typedef long		cairo_fixed_32_32_t;
! # else
! #  if defined(__GNUC__) && \
!     ((__GNUC__ > 2) || \
!      ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
! __extension__
! #  endif
! typedef long long int	cairo_fixed_32_32_t;
! # endif
! #endif
  
! typedef cairo_fixed_32_32_t cairo_fixed_48_16_t;
! typedef int32_t cairo_fixed_16_16_t;
  
  /* The common 16.16 format gets a shorter name */
--- 101,111 ----
  #endif
  
! #include "cairo_wideint.h"
  
! typedef int32_t		cairo_fixed_16_16_t;
! typedef cairo_int64_t	cairo_fixed_32_32_t;
! typedef cairo_int64_t	cairo_fixed_48_16_t;
! typedef cairo_int128_t	cairo_fixed_64_64_t;
! typedef cairo_int128_t	cairo_fixed_96_32_t;
  
  /* The common 16.16 format gets a shorter name */





More information about the cairo-commit mailing list