[Commit] Xr/src Xr.h,1.26,1.27 xr.c,1.24,1.25 xrgstate.c,1.34,1.35 xrint.h,1.40,1.41 xrsurface.c,1.15,1.16

Carl Worth commit@keithp.com
Thu, 15 May 2003 21:16:29 -0700


Committed by: cworth

Update of /local/src/CVS/Xr/src
In directory home.keithp.com:/tmp/cvs-serv20153/src

Modified Files:
	Xr.h xr.c xrgstate.c xrint.h xrsurface.c 
Log Message:
Changed default matrix to be 3780 user units per 1 meter physical device

Index: Xr.h
===================================================================
RCS file: /local/src/CVS/Xr/src/Xr.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- Xr.h	15 May 2003 04:59:42 -0000	1.26
+++ Xr.h	16 May 2003 04:16:26 -0000	1.27
@@ -181,10 +181,6 @@
 XrSetMatrix(XrState *xrs,
 	    XrMatrix *matrix);
 
-/* XXX: Postscript has both a defaultmatrix and an identmatrix. But
-   there, they do different things. Here, where they perform the same
-   function, we should probably only have one name to avoid
-   confusion. Any votes? */
 void
 XrDefaultMatrix(XrState *xrs);
 

Index: xr.c
===================================================================
RCS file: /local/src/CVS/Xr/src/xr.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- xr.c	15 May 2003 04:59:42 -0000	1.24
+++ xr.c	16 May 2003 04:16:26 -0000	1.25
@@ -351,7 +351,7 @@
     if (xrs->status)
 	return;
 
-    xrs->status = _XrGStateIdentityMatrix(_XR_CURRENT_GSTATE(xrs));
+    xrs->status = _XrGStateDefaultMatrix(_XR_CURRENT_GSTATE(xrs));
 }
 
 void

Index: xrgstate.c
===================================================================
RCS file: /local/src/CVS/Xr/src/xrgstate.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- xrgstate.c	15 May 2003 04:59:42 -0000	1.34
+++ xrgstate.c	16 May 2003 04:16:26 -0000	1.35
@@ -82,8 +82,9 @@
     gstate->alpha = 1.0;
     _XrColorInit(&gstate->color);
 
-    XrMatrixSetIdentity(&gstate->ctm);
-    XrMatrixSetIdentity(&gstate->ctm_inverse);
+    /* 3780 PPM (~96DPI) is a good enough assumption until we get a surface */
+    gstate->ppm = 3780;
+    _XrGStateDefaultMatrix (gstate);
 
     _XrPathInit(&gstate->path);
 
@@ -282,11 +283,17 @@
 XrStatus
 _XrGStateSetTargetSurface (XrGState *gstate, XrSurface *surface)
 {
+    double scale;
+
     XrSurfaceDestroy (gstate->surface);
 
     gstate->surface = surface;
     _XrSurfaceReference (gstate->surface);
 
+    scale = surface->ppm / gstate->ppm;
+    _XrGStateScale (gstate, scale, scale);
+    gstate->ppm = surface->ppm;
+
     return XrStatusSuccess;
 }
 
@@ -540,6 +547,23 @@
     status = XrMatrixInvert (&gstate->ctm_inverse);
     if (status)
 	return status;
+
+    return XrStatusSuccess;
+}
+
+XrStatus
+_XrGStateDefaultMatrix(XrGState *gstate)
+{
+#define XR_GSTATE_DEFAULT_PPM 3780.0
+
+    int scale = gstate->ppm / XR_GSTATE_DEFAULT_PPM + 0.5;
+    if (scale == 0)
+	scale = 1;
+
+    XrMatrixSetIdentity (&gstate->ctm);
+    XrMatrixScale (&gstate->ctm, scale, scale);
+    XrMatrixCopy (&gstate->ctm_inverse, &gstate->ctm);
+    XrMatrixInvert (&gstate->ctm_inverse);
 
     return XrStatusSuccess;
 }

Index: xrint.h
===================================================================
RCS file: /local/src/CVS/Xr/src/xrint.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- xrint.h	15 May 2003 04:59:42 -0000	1.40
+++ xrint.h	16 May 2003 04:16:26 -0000	1.41
@@ -165,6 +165,8 @@
 
     XcSurface *xc_surface;
 
+    double ppm;
+
     unsigned int ref_count;
 };
 
@@ -246,6 +248,7 @@
     double alpha;
     XrColor color;
 
+    double ppm;
     XrMatrix ctm;
     XrMatrix ctm_inverse;
 
@@ -400,6 +403,9 @@
 XrStatus
 _XrGStateSetMatrix(XrGState *gstate,
 		   XrMatrix *matrix);
+
+XrStatus
+_XrGStateDefaultMatrix(XrGState *gstate);
 
 XrStatus
 _XrGStateIdentityMatrix(XrGState *xrs);

Index: xrsurface.c
===================================================================
RCS file: /local/src/CVS/Xr/src/xrsurface.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- xrsurface.c	15 May 2003 01:30:57 -0000	1.15
+++ xrsurface.c	16 May 2003 04:16:26 -0000	1.16
@@ -49,6 +49,9 @@
 	return NULL;
     }
 
+    /* XXX: We should really get this value from somewhere like Xft.dpy */
+    surface->ppm = 3780;
+
     surface->ref_count = 1;
 
     return surface;
@@ -153,6 +156,9 @@
 	free (surface);
 	return NULL;
     }
+
+    /* Assume a default until the user lets us know otherwise */
+    surface->ppm = 3780;
 
     surface->ref_count = 1;