[cairo-commit] cairo/src cairo_gstate.c,1.38,1.39 cairo_path.c,1.11,1.12 cairoint.h,1.47,1.48

Carl Worth commit at pdx.freedesktop.org
Tue Dec 16 07:10:50 PST 2003


Committed by: cworth

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

Modified Files:
	cairo_gstate.c cairo_path.c cairoint.h 
Log Message:

        * src/cairoint.h: Move all current_point state fields from
        cairo_gstate_t to cairo_path_t.

        * src/cairo_path.c (_cairo_path_init):
        (_cairo_path_init_copy):
        (_cairo_path_fini):
        (_cairo_path_move_to):
        (_cairo_path_line_to):
        (_cairo_path_curve_to):
        (_cairo_path_close_path): Add current_point state.
        (_cairo_path_current_point): New function.
        (_cairo_path_rel_move_to):
        (_cairo_path_rel_line_to):
        (_cairo_path_rel_curve_to): New functions.

        * src/cairo_gstate.c (_cairo_gstate_init):
        (_cairo_gstate_new_path):
        (_cairo_gstate_move_to):
        (_cairo_gstate_line_to):
        (_cairo_gstate_curve_to):
        (_cairo_gstate_rel_move_to):
        (_cairo_gstate_rel_line_to):
        (_cairo_gstate_rel_curve_to):
        (_cairo_gstate_close_path):
        (_cairo_gstate_current_point): Eliminate current_point state.
        (_cairo_gstate_show_text): 
        (_cairo_gstate_text_path): Use new _cairo_path_current_point.


Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** cairo_gstate.c	16 Dec 2003 14:50:37 -0000	1.38
--- cairo_gstate.c	16 Dec 2003 15:10:48 -0000	1.39
***************
*** 31,37 ****
  #include "cairoint.h"
  
- static void
- _cairo_gstate_set_current_point (cairo_gstate_t *gstate, double x, double y);
- 
  static cairo_status_t
  _cairo_gstate_ensure_source (cairo_gstate_t *gstate);
--- 31,34 ----
***************
*** 95,102 ****
      _cairo_path_init (&gstate->path);
  
-     gstate->current_point.x = 0.0;
-     gstate->current_point.y = 0.0;
-     gstate->has_current_point = 0;
- 
      _cairo_pen_init_empty (&gstate->pen_regular);
  
--- 92,95 ----
***************
*** 681,698 ****
  }
  
- static void
- _cairo_gstate_set_current_point (cairo_gstate_t *gstate, double x, double y)
- {
-     gstate->current_point.x = x;
-     gstate->current_point.y = y;
- 
-     gstate->has_current_point = 1;
- }
- 
  cairo_status_t
  _cairo_gstate_new_path (cairo_gstate_t *gstate)
  {
      _cairo_path_fini (&gstate->path);
-     gstate->has_current_point = 0;
  
      return CAIRO_STATUS_SUCCESS;
--- 674,681 ----
***************
*** 702,716 ****
  _cairo_gstate_move_to (cairo_gstate_t *gstate, double x, double y)
  {
-     cairo_status_t status;
- 
      cairo_matrix_transform_point (&gstate->ctm, &x, &y);
  
!     status = _cairo_path_move_to (&gstate->path, x, y);
! 
!     _cairo_gstate_set_current_point (gstate, x, y);
! 
!     gstate->last_move_point = gstate->current_point;
! 
!     return status;
  }
  
--- 685,691 ----
  _cairo_gstate_move_to (cairo_gstate_t *gstate, double x, double y)
  {
      cairo_matrix_transform_point (&gstate->ctm, &x, &y);
  
!     return _cairo_path_move_to (&gstate->path, x, y);
  }
  
***************
*** 718,730 ****
  _cairo_gstate_line_to (cairo_gstate_t *gstate, double x, double y)
  {
-     cairo_status_t status;
- 
      cairo_matrix_transform_point (&gstate->ctm, &x, &y);
  
!     status = _cairo_path_line_to (&gstate->path, x, y);
! 
!     _cairo_gstate_set_current_point (gstate, x, y);
! 
!     return status;
  }
  
--- 693,699 ----
  _cairo_gstate_line_to (cairo_gstate_t *gstate, double x, double y)
  {
      cairo_matrix_transform_point (&gstate->ctm, &x, &y);
  
!     return _cairo_path_line_to (&gstate->path, x, y);
  }
  
***************
*** 735,752 ****
  			double x3, double y3)
  {
-     cairo_status_t status;
- 
      cairo_matrix_transform_point (&gstate->ctm, &x1, &y1);
      cairo_matrix_transform_point (&gstate->ctm, &x2, &y2);
      cairo_matrix_transform_point (&gstate->ctm, &x3, &y3);
  
!     status = _cairo_path_curve_to (&gstate->path,
! 				   x1, y1,
! 				   x2, y2,
! 				   x3, y3);
! 
!     _cairo_gstate_set_current_point (gstate, x3, y3);
! 
!     return status;
  }
  
--- 704,715 ----
  			double x3, double y3)
  {
      cairo_matrix_transform_point (&gstate->ctm, &x1, &y1);
      cairo_matrix_transform_point (&gstate->ctm, &x2, &y2);
      cairo_matrix_transform_point (&gstate->ctm, &x3, &y3);
  
!     return _cairo_path_curve_to (&gstate->path,
! 				 x1, y1,
! 				 x2, y2,
! 				 x3, y3);
  }
  
***************
*** 1026,1044 ****
  _cairo_gstate_rel_move_to (cairo_gstate_t *gstate, double dx, double dy)
  {
-     cairo_status_t status;
-     double x, y;
- 
      cairo_matrix_transform_distance (&gstate->ctm, &dx, &dy);
  
!     x = gstate->current_point.x + dx;
!     y = gstate->current_point.y + dy;
! 
!     status = _cairo_path_move_to (&gstate->path, x, y);
! 
!     _cairo_gstate_set_current_point (gstate, x, y);
! 
!     gstate->last_move_point = gstate->current_point;
! 
!     return status;
  }
  
--- 989,995 ----
  _cairo_gstate_rel_move_to (cairo_gstate_t *gstate, double dx, double dy)
  {
      cairo_matrix_transform_distance (&gstate->ctm, &dx, &dy);
  
!     return _cairo_path_rel_move_to (&gstate->path, dx, dy);
  }
  
***************
*** 1046,1062 ****
  _cairo_gstate_rel_line_to (cairo_gstate_t *gstate, double dx, double dy)
  {
-     cairo_status_t status;
-     double x, y;
- 
      cairo_matrix_transform_distance (&gstate->ctm, &dx, &dy);
  
!     x = gstate->current_point.x + dx;
!     y = gstate->current_point.y + dy;
! 
!     status = _cairo_path_line_to (&gstate->path, x, y);
! 
!     _cairo_gstate_set_current_point (gstate, x, y);
! 
!     return status;
  }
  
--- 997,1003 ----
  _cairo_gstate_rel_line_to (cairo_gstate_t *gstate, double dx, double dy)
  {
      cairo_matrix_transform_distance (&gstate->ctm, &dx, &dy);
  
!     return _cairo_path_rel_line_to (&gstate->path, dx, dy);
  }
  
***************
*** 1067,1086 ****
  			    double dx3, double dy3)
  {
-     cairo_status_t status;
- 
      cairo_matrix_transform_distance (&gstate->ctm, &dx1, &dy1);
      cairo_matrix_transform_distance (&gstate->ctm, &dx2, &dy2);
      cairo_matrix_transform_distance (&gstate->ctm, &dx3, &dy3);
  
!     status = _cairo_path_curve_to (&gstate->path,
! 				   gstate->current_point.x + dx1, gstate->current_point.y + dy1,
! 				   gstate->current_point.x + dx2, gstate->current_point.y + dy2,
! 				   gstate->current_point.x + dx3, gstate->current_point.y + dy3);
! 
!     _cairo_gstate_set_current_point (gstate,
! 			  gstate->current_point.x + dx3,
! 			  gstate->current_point.y + dy3);
! 
!     return status;
  }
  
--- 1008,1017 ----
  			    double dx3, double dy3)
  {
      cairo_matrix_transform_distance (&gstate->ctm, &dx1, &dy1);
      cairo_matrix_transform_distance (&gstate->ctm, &dx2, &dy2);
      cairo_matrix_transform_distance (&gstate->ctm, &dx3, &dy3);
  
!     return _cairo_path_rel_curve_to (&gstate->path,
! 				     dx1, dy1, dx2, dy2, dx3, dy3);
  }
  
***************
*** 1099,1111 ****
  _cairo_gstate_close_path (cairo_gstate_t *gstate)
  {
!     cairo_status_t status;
! 
!     status = _cairo_path_close_path (&gstate->path);
! 
!     _cairo_gstate_set_current_point (gstate,
! 				     gstate->last_move_point.x, 
! 				     gstate->last_move_point.y);
! 
!     return status;
  }
  
--- 1030,1034 ----
  _cairo_gstate_close_path (cairo_gstate_t *gstate)
  {
!     return _cairo_path_close_path (&gstate->path);
  }
  
***************
*** 1113,1125 ****
  _cairo_gstate_current_point (cairo_gstate_t *gstate, double *x_ret, double *y_ret)
  {
      double x, y;
  
!     if (gstate->has_current_point) {
! 	x = gstate->current_point.x;
! 	y = gstate->current_point.y;
! 	cairo_matrix_transform_point (&gstate->ctm_inverse, &x, &y);
!     } else {
  	x = 0.0;
  	y = 0.0;
      }
  
--- 1036,1048 ----
  _cairo_gstate_current_point (cairo_gstate_t *gstate, double *x_ret, double *y_ret)
  {
+     cairo_status_t status;
      double x, y;
  
!     status = _cairo_path_current_point (&gstate->path, &x, &y);
!     if (status == CAIRO_STATUS_NO_CURRENT_POINT) {
  	x = 0.0;
  	y = 0.0;
+     } else {
+ 	cairo_matrix_transform_point (&gstate->ctm_inverse, &x, &y);
      }
  
***************
*** 1717,1728 ****
      cairo_matrix_t saved_font_matrix;
  
!     /* XXX: I believe this is correct, but it would be much more clear
!        to have some explicit current_point accesor functions, (one for
!        user- and one for device-space). */
! 
!     if (gstate->has_current_point) {
! 	x = gstate->current_point.x;
! 	y = gstate->current_point.y;
!     } else {
  	x = 0;
  	y = 0;
--- 1640,1645 ----
      cairo_matrix_t saved_font_matrix;
  
!     status = _cairo_path_current_point (&gstate->path, &x, &y);
!     if (status == CAIRO_STATUS_NO_CURRENT_POINT) {
  	x = 0;
  	y = 0;
***************
*** 1789,1793 ****
      
      return status;
- 
  }
  
--- 1706,1709 ----
***************
*** 1806,1817 ****
  	return status;
  
!     /* XXX: I believe this is correct, but it would be much more clear
!        to have some explicit current_point accesor functions, (one for
!        user- and one for device-space). */
! 
!     if (gstate->has_current_point) {
! 	x = gstate->current_point.x;
! 	y = gstate->current_point.y;
!     } else {
  	x = 0;
  	y = 0;
--- 1722,1727 ----
  	return status;
  
!     status = _cairo_path_current_point (&gstate->path, &x, &y);
!     if (status == CAIRO_STATUS_NO_CURRENT_POINT) {
  	x = 0;
  	y = 0;

Index: cairo_path.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_path.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** cairo_path.c	8 Dec 2003 21:38:26 -0000	1.11
--- cairo_path.c	16 Dec 2003 15:10:48 -0000	1.12
***************
*** 71,74 ****
--- 71,79 ----
      path->arg_head = NULL;
      path->arg_tail = NULL;
+ 
+     path->current_point.x = 0.0;
+     path->current_point.y = 0.0;
+     path->has_current_point = 0;
+     path->last_move_point = path->current_point;
  }
  
***************
*** 80,83 ****
--- 85,91 ----
  
      _cairo_path_init (path);
+     path->current_point = other->current_point;
+     path->has_current_point = other->has_current_point;
+     path->last_move_point = other->last_move_point;
  
      for (other_op = other->op_head; other_op; other_op = other_op->next) {
***************
*** 121,124 ****
--- 129,134 ----
      }
      path->arg_tail = NULL;
+ 
+     path->has_current_point = 0;
  }
  
***************
*** 126,129 ****
--- 136,140 ----
  _cairo_path_move_to (cairo_path_t *path, double x, double y)
  {
+     cairo_status_t status;
      cairo_point_t point;
  
***************
*** 131,135 ****
      point.y = _cairo_fixed_from_double (y);
  
!     return _cairo_path_add (path, CAIRO_PATH_OP_MOVE_TO, &point, 1);
  }
  
--- 142,166 ----
      point.y = _cairo_fixed_from_double (y);
  
!     status = _cairo_path_add (path, CAIRO_PATH_OP_MOVE_TO, &point, 1);
!     if (status)
! 	return status;
! 
!     path->current_point.x = x;
!     path->current_point.y = y;
!     path->has_current_point = 1;
!     path->last_move_point = path->current_point;
! 
!     return CAIRO_STATUS_SUCCESS;
! }
! 
! cairo_status_t
! _cairo_path_rel_move_to (cairo_path_t *path, double dx, double dy)
! {
!     double x, y;
! 
!     x = path->current_point.x + dx;
!     y = path->current_point.y + dy;
! 
!     return _cairo_path_move_to (path, x, y);
  }
  
***************
*** 137,140 ****
--- 168,172 ----
  _cairo_path_line_to (cairo_path_t *path, double x, double y)
  {
+     cairo_status_t status;
      cairo_point_t point;
  
***************
*** 142,146 ****
      point.y = _cairo_fixed_from_double (y);
  
!     return _cairo_path_add (path, CAIRO_PATH_OP_LINE_TO, &point, 1);
  }
  
--- 174,197 ----
      point.y = _cairo_fixed_from_double (y);
  
!     status = _cairo_path_add (path, CAIRO_PATH_OP_LINE_TO, &point, 1);
!     if (status)
! 	return status;
! 
!     path->current_point.x = x;
!     path->current_point.y = y;
!     path->has_current_point = 1;
! 
!     return CAIRO_STATUS_SUCCESS;
! }
! 
! cairo_status_t
! _cairo_path_rel_line_to (cairo_path_t *path, double dx, double dy)
! {
!     double x, y;
! 
!     x = path->current_point.x + dx;
!     y = path->current_point.y + dy;
! 
!     return _cairo_path_line_to (path, x, y);
  }
  
***************
*** 151,154 ****
--- 202,206 ----
  		      double x3, double y3)
  {
+     cairo_status_t status;
      cairo_point_t point[3];
  
***************
*** 162,166 ****
      point[2].y = _cairo_fixed_from_double (y3);
  
!     return _cairo_path_add (path, CAIRO_PATH_OP_CURVE_TO, point, 3);
  }
  
--- 214,246 ----
      point[2].y = _cairo_fixed_from_double (y3);
  
!     status = _cairo_path_add (path, CAIRO_PATH_OP_CURVE_TO, point, 3);
!     if (status)
! 	return status;
! 
!     path->current_point.x = x3;
!     path->current_point.y = y3;
!     path->has_current_point = 1;
! 
!     return CAIRO_STATUS_SUCCESS;
! }
! 
! cairo_status_t
! _cairo_path_rel_curve_to (cairo_path_t *path,
! 			  double dx1, double dy1,
! 			  double dx2, double dy2,
! 			  double dx3, double dy3)
! {
!     double x1, y1, x2, y2, x3, y3;
! 
!     x1 = path->current_point.x + dx1;
!     y1 = path->current_point.y + dy1;
! 
!     x2 = path->current_point.x + dx2;
!     y2 = path->current_point.y + dy2;
! 
!     x3 = path->current_point.x + dx3;
!     y3 = path->current_point.y + dy3;
! 
!     return _cairo_path_curve_to (path, x1, y1, x2, y2, x3, y3);
  }
  
***************
*** 168,172 ****
  _cairo_path_close_path (cairo_path_t *path)
  {
!     return _cairo_path_add (path, CAIRO_PATH_OP_CLOSE_PATH, NULL, 0);
  }
  
--- 248,274 ----
  _cairo_path_close_path (cairo_path_t *path)
  {
!     cairo_status_t status;
! 
!     status = _cairo_path_add (path, CAIRO_PATH_OP_CLOSE_PATH, NULL, 0);
!     if (status)
! 	return status;
! 
!     path->current_point.x = path->last_move_point.x;
!     path->current_point.y = path->last_move_point.y;
!     path->has_current_point = 1;
! 
!     return CAIRO_STATUS_SUCCESS;
! }
! 
! cairo_status_t
! _cairo_path_current_point (cairo_path_t *path, double *x, double *y)
! {
!     if (! path->has_current_point)
! 	return CAIRO_STATUS_NO_CURRENT_POINT;
! 
!     *x = path->current_point.x;
!     *y = path->current_point.y;
! 
!     return CAIRO_STATUS_SUCCESS;
  }
  

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** cairoint.h	16 Dec 2003 14:50:37 -0000	1.47
--- cairoint.h	16 Dec 2003 15:10:48 -0000	1.48
***************
*** 201,204 ****
--- 201,208 ----
      cairo_path_arg_buf_t *arg_head;
      cairo_path_arg_buf_t *arg_tail;
+ 
+     cairo_point_double_t last_move_point;
+     cairo_point_double_t current_point;
+     int has_current_point;
  } cairo_path_t;
  
***************
*** 507,514 ****
      cairo_path_t path;
  
-     cairo_point_double_t last_move_point;
-     cairo_point_double_t current_point;
-     int has_current_point;
- 
      cairo_pen_t pen_regular;
  
--- 511,514 ----
***************
*** 916,922 ****
--- 916,928 ----
  
  extern cairo_status_t __internal_linkage
+ _cairo_path_rel_move_to (cairo_path_t *path, double dx, double dy);
+ 
+ extern cairo_status_t __internal_linkage
  _cairo_path_line_to (cairo_path_t *path, double x, double y);
  
  extern cairo_status_t __internal_linkage
+ _cairo_path_rel_line_to (cairo_path_t *path, double dx, double dy);
+ 
+ extern cairo_status_t __internal_linkage
  _cairo_path_curve_to (cairo_path_t *path,
  		      double x1, double y1,
***************
*** 925,931 ****
--- 931,946 ----
  
  extern cairo_status_t __internal_linkage
+ _cairo_path_rel_curve_to (cairo_path_t *path,
+ 			  double dx1, double dy1,
+ 			  double dx2, double dy2,
+ 			  double dx3, double dy3);
+ 
+ extern cairo_status_t __internal_linkage
  _cairo_path_close_path (cairo_path_t *path);
  
  extern cairo_status_t __internal_linkage
+ _cairo_path_current_point (cairo_path_t *path, double *x, double *y);
+ 
+ extern cairo_status_t __internal_linkage
  _cairo_path_interpret (cairo_path_t *path,
  		       cairo_direction_t dir,





More information about the cairo-commit mailing list