Re: gtk+-2.6.1 on windows when?



Tor Lillqvist writes:
 > Only if the passed-in matrix actually is different from the identity
 > matrix should pango_win32_render_transformed() call the above
 > functions.
 > 
 > Actually, for suitably restricted transforms, it could do without
 > SetWorldTransform() and just use SetMapMode(MM_ANISOTROPIC),
 > ScaleViewportExtEx() and SetViewportOrgEx(), which *are* implemented
 > on Win9x.

Hmm, how does the below look? I couldn't, off-hand, find a quick way
to test the Win9x code path for scaled or translated but not rotated
rendering.

--tml

Index: pango/pangowin32.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangowin32.c,v
retrieving revision 1.52
diff -p -u -2 -r1.52 pangowin32.c
--- pango/pangowin32.c	18 Dec 2004 17:05:14 -0000	1.52
+++ pango/pangowin32.c	7 Feb 2005 18:38:53 -0000
@@ -415,28 +415,74 @@ pango_win32_render_transformed (HDC     
 {
   XFORM xForm;
-  XFORM xFormPrev = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
-  int   mode = GetGraphicsMode (hdc);
+  XFORM xFormIdentity = {1, 0, 0, 1, 0, 0};
+  static const PangoMatrix identity = PANGO_MATRIX_INIT;
+  int gmode = -1;
+  int mmode = -1;
 
-  if (!SetGraphicsMode (hdc, GM_ADVANCED))
-    g_warning ("SetGraphicsMode() failed");
-  else if (!GetWorldTransform (hdc, &xFormPrev))
-    g_warning ("GetWorldTransform() failed");
-  else if (matrix)
+  if (matrix &&
+      (matrix->xx != identity.xx ||
+       matrix->xy != identity.xy ||
+       matrix->yx != identity.yx ||
+       matrix->x0 != identity.x0 ||
+       matrix->y0 != identity.y0))
     {
-      xForm.eM11 = matrix->xx;
-      xForm.eM12 = matrix->xy;
-      xForm.eM21 = matrix->yx;
-      xForm.eM22 = matrix->yy;
-      xForm.eDx = matrix->x0;
-      xForm.eDy = matrix->y0;
-      if (!SetWorldTransform (hdc, &xForm))
-        g_warning ("GetWorldTransform() failed");
+      if (G_WIN32_IS_NT_BASED ())
+	{
+	  if ((gmode = SetGraphicsMode (hdc, GM_ADVANCED)) == 0)
+	    g_warning ("SetGraphicsMode() failed");
+	  else
+	    {
+	      xForm.eM11 = matrix->xx;
+	      xForm.eM12 = matrix->xy;
+	      xForm.eM21 = matrix->yx;
+	      xForm.eM22 = matrix->yy;
+	      xForm.eDx = matrix->x0;
+	      xForm.eDy = matrix->y0;
+	      if (!SetWorldTransform (hdc, &xForm))
+		g_warning ("GetWorldTransform() failed");
+	    }
+	}
+      else
+	{
+	  if (matrix->xy == 0 &&
+	      matrix->yx == 0)
+	    {
+	      mmode = SetMapMode (hdc, MM_ANISOTROPIC);
+	      SetWindowOrgEx (hdc, -matrix->x0, -matrix->y0, NULL);
+	      ScaleWindowExtEx (hdc, 1000*matrix->xx, 1000,
+				1000*matrix->yy, 1000, NULL);
+	    }
+	  else
+	    {
+	      static gboolean warned = FALSE;
+	      if (!warned)
+		{
+		  g_warning ("Transformed rendering not supported on Win9x");
+		  warned = TRUE;
+		}
+	    }
+	}
     }
 
   pango_win32_render (hdc, font, glyphs, x/PANGO_SCALE, y/PANGO_SCALE);
 
-  /* restore */
-  SetWorldTransform (hdc, &xFormPrev);
-  SetGraphicsMode (hdc, mode);
+  /* Restore mapping if necessary */
+  if (G_WIN32_IS_NT_BASED ())
+    {
+      if (gmode != -1)
+	{
+	  SetWorldTransform (hdc, &xFormIdentity);
+	  SetGraphicsMode (hdc, GM_COMPATIBLE);
+	}
+    }
+  else
+    {
+      if (mmode != -1)
+	{
+	  SetWindowOrgEx (hdc, 0, 0, NULL);
+	  ScaleWindowExtEx (hdc, 1, 1, 1, 1, NULL);
+	  SetMapMode (hdc, MM_TEXT);
+	}
+    }
 }
 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]