[cairo-commit] cairo-demo/svgspacewar ChangeLog, 1.4,
1.5 svgspacewar.c, 1.3, 1.4
Carl Worth
commit at pdx.freedesktop.org
Wed Jun 22 10:25:38 PDT 2005
Committed by: cworth
Update of /cvs/cairo/cairo-demo/svgspacewar
In directory gabe:/tmp/cvs-serv15698
Modified Files:
ChangeLog svgspacewar.c
Log Message:
* svgspacewar.c: (scale_for_aspect_ratio): Put the clipping back,
(it actually was needed). But call cairo_clip before cairo_scale
in order to get the fast-path clipping.
Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/svgspacewar/ChangeLog,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ChangeLog 21 Jun 2005 17:44:40 -0000 1.4
+++ ChangeLog 22 Jun 2005 17:25:36 -0000 1.5
@@ -1,3 +1,9 @@
+2005-06-22 Carl Worth <cworth at cworth.org>
+
+ * svgspacewar.c: (scale_for_aspect_ratio): Put the clipping back,
+ (it actually was needed). But call cairo_clip before cairo_scale
+ in order to get the fast-path clipping.
+
2005-06-21 Carl Worth <cworth at cworth.org>
* svgspacewar.c: (on_expose_event): Remove unneeded cairo_clip to
Index: svgspacewar.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/svgspacewar/svgspacewar.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- svgspacewar.c 21 Jun 2005 17:44:40 -0000 1.3
+++ svgspacewar.c 22 Jun 2005 17:25:36 -0000 1.4
@@ -385,26 +385,37 @@
//------------------------------------------------------------------------------
static void
-scale_for_aspect_ratio (cairo_t * cr, int w, int h)
+scale_for_aspect_ratio (cairo_t * cr, int widget_width, int widget_height)
{
- gboolean is_widget_wider = ((w * HEIGHT) > (WIDTH * h)) ? TRUE : FALSE;
+ double scale;
+ int playfield_width, playfield_height;
+ int tx, ty;
+ gboolean is_widget_wider;
+
+ is_widget_wider = (widget_width * HEIGHT) > (WIDTH * widget_height);
if (is_widget_wider)
{
- float scale = ((float) h) / HEIGHT;
- int desired_width = (WIDTH * h) / HEIGHT;
- int delta = (w - desired_width) / 2;
- cairo_translate (cr, delta, 0);
- cairo_scale (cr, scale, scale);
+ scale = ((double) widget_height) / HEIGHT;
+ playfield_width = (WIDTH * widget_height) / HEIGHT;
+ playfield_height = widget_height;
+ tx = (widget_width - playfield_width) / 2;
+ ty = 0;
}
else
{
- float scale = ((float) w) / WIDTH;
- int desired_height = (HEIGHT * w) / WIDTH;
- int delta = (h - desired_height) / 2;
- cairo_translate (cr, 0, delta);
- cairo_scale (cr, scale, scale);
+ scale = ((double) widget_width) / WIDTH;
+ playfield_width = widget_width;
+ playfield_height = (HEIGHT * widget_width) / WIDTH;
+ tx = 0;
+ ty = (widget_height - playfield_height) / 2;
}
+
+ cairo_translate (cr, tx, ty);
+ cairo_rectangle (cr, 0, 0, playfield_width, playfield_height);
+ cairo_clip (cr);
+
+ cairo_scale (cr, scale, scale);
}
//------------------------------------------------------------------------------
More information about the cairo-commit
mailing list