[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-commit] gnash ChangeLog server/character.cpp testsuite/...
From: |
Sandro Santilli |
Subject: |
Re: [Gnash-commit] gnash ChangeLog server/character.cpp testsuite/... |
Date: |
Wed, 18 Apr 2007 12:49:52 +0200 |
On Wed, Apr 18, 2007 at 04:51:10PM +0800, zou lunkai wrote:
> >>- w = TWIPS_TO_PIXELS(int(bounds.width()));
> >>+ w = TWIPS_TO_PIXELS(rint(bounds.width()));
>
> Does this fix any testcase? This is the reference I get from
> internet. "rint" is implementation-dependent, either identical to
> ceil() or floor(). Then why not just using ceil() or floor()
> instead?
We want a round() I think.
Yes, it fixed some tests.
Try changing it and see what happens there.
Consider also using Range2d<int>(Range2d<float>) cast as an alternative.
--strk;
>
> original link:
> http://www.opengroup.org/onlinepubs/7990989775/xsh/rint.html
>
>
>
> double rint(double x);
>
> DESCRIPTION
> The rint() function returns the integral value (represented as a
> double) nearest x in the direction of the current rounding mode. The
> current rounding mode is implementation-dependent.
> If the current rounding mode rounds toward negative infinity, then
> rint() is identical to floor(). If the current rounding mode rounds
> toward positive infinity, then rint() is identical to ceil().
>
>
>
>
>
> On 4/15/07, Sandro Santilli <address@hidden> wrote:
> >CVSROOT: /sources/gnash
> >Module name: gnash
> >Changes by: Sandro Santilli <strk> 07/04/14 18:19:49
> >
> >Modified files:
> > . : ChangeLog
> > server : character.cpp
> > testsuite/swfdec: PASSING
> > testsuite/misc-ming.all: Makefile.am
> >Added files:
> > testsuite/misc-ming.all: matrix_test.c
> >
> >Log message:
> > * server/character.cpp (height_getset, width_getset): round
> > width and heights to nearest integer twip.
> > * testsuite/swfdec/PASSING: height4.swf succeeds.
> > * testsuite/misc-ming.all: Makefile.am, matrix_test.c: new
> > test
> > for statically-defined matrix interpretation (just
> > started, needs
> > many more tests).
> >
> >CVSWeb URLs:
> >http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2873&r2=1.2874
> >http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.33&r2=1.34
> >http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.15&r2=1.16
> >http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.90&r2=1.91
> >http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/matrix_test.c?cvsroot=gnash&rev=1.1
> >
> >Patches:
> >Index: ChangeLog
> >===================================================================
> >RCS file: /sources/gnash/gnash/ChangeLog,v
> >retrieving revision 1.2873
> >retrieving revision 1.2874
> >diff -u -b -r1.2873 -r1.2874
> >--- ChangeLog 14 Apr 2007 16:27:22 -0000 1.2873
> >+++ ChangeLog 14 Apr 2007 18:19:49 -0000 1.2874
> >@@ -1,5 +1,14 @@
> > 2007-04-14 Sandro Santilli <address@hidden>
> >
> >+ * server/character.cpp (height_getset, width_getset): round
> >+ width and heights to nearest integer twip.
> >+ * testsuite/swfdec/PASSING: height4.swf succeeds.
> >+ * testsuite/misc-ming.all: Makefile.am, matrix_test.c: new test
> >+ for statically-defined matrix interpretation (just started, needs
> >+ many more tests).
> >+
> >+2007-04-14 Sandro Santilli <address@hidden>
> >+
> > * server/sprite_instance.cpp (sprite_getBounds): round bounds
> > to twips.
> > * testsuite/actionscript.all/MovieClip.as: more successes.
> >
> >Index: server/character.cpp
> >===================================================================
> >RCS file: /sources/gnash/gnash/server/character.cpp,v
> >retrieving revision 1.33
> >retrieving revision 1.34
> >diff -u -b -r1.33 -r1.34
> >--- server/character.cpp 12 Apr 2007 16:29:14 -0000 1.33
> >+++ server/character.cpp 14 Apr 2007 18:19:49 -0000 1.34
> >@@ -18,7 +18,7 @@
> > //
> > //
> >
> >-/* $Id: character.cpp,v 1.33 2007/04/12 16:29:14 strk Exp $ */
> >+/* $Id: character.cpp,v 1.34 2007/04/14 18:19:49 strk Exp $ */
> >
> > #ifdef HAVE_CONFIG_H
> > #include "config.h"
> >@@ -458,13 +458,13 @@
> > as_value rv;
> > if ( fn.nargs == 0 ) // getter
> > {
> >- float w = 0;
> >+ double w = 0;
> > if ( bounds.isFinite() )
> > {
> > matrix m = ptr->get_matrix();
> > m.transform(bounds);
> > assert(bounds.isFinite());
> >- w = TWIPS_TO_PIXELS(int(bounds.width()));
> >+ w = TWIPS_TO_PIXELS(rint(bounds.width()));
> > }
> > rv = as_value(w);
> > }
> >@@ -503,13 +503,13 @@
> > as_value rv;
> > if ( fn.nargs == 0 ) // getter
> > {
> >- float h = 0;
> >+ double h = 0;
> > if ( bounds.isFinite() )
> > {
> > matrix m = ptr->get_matrix();
> > m.transform(bounds);
> > assert(bounds.isFinite());
> >- h = TWIPS_TO_PIXELS(int(bounds.height()));
> >+ h = TWIPS_TO_PIXELS(rint(bounds.height()));
> > }
> > rv = as_value(h);
> > }
> >
> >Index: testsuite/swfdec/PASSING
> >===================================================================
> >RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
> >retrieving revision 1.15
> >retrieving revision 1.16
> >diff -u -b -r1.15 -r1.16
> >--- testsuite/swfdec/PASSING 12 Apr 2007 09:14:37 -0000 1.15
> >+++ testsuite/swfdec/PASSING 14 Apr 2007 18:19:49 -0000 1.16
> >@@ -52,3 +52,4 @@
> > undefined2-7.swf
> > height1.swf
> > height3.swf
> >+height4.swf
> >
> >Index: testsuite/misc-ming.all/Makefile.am
> >===================================================================
> >RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
> >retrieving revision 1.90
> >retrieving revision 1.91
> >diff -u -b -r1.90 -r1.91
> >--- testsuite/misc-ming.all/Makefile.am 9 Apr 2007 09:04:09 -0000
> >1.90
> >+++ testsuite/misc-ming.all/Makefile.am 14 Apr 2007 18:19:49 -0000
> >1.91
> >@@ -52,7 +52,6 @@
> > -DMING_VERSION_CODE=$(MING_VERSION_CODE) \
> > $(NULL)
> >
> >-
> > check_PROGRAMS = \
> > ButtonEventsTest \
> > ButtonEventsTest-Runner \
> >@@ -86,6 +85,7 @@
> > registerClassTestRunner \
> > goto_frame_test \
> > consecutive_goto_frame_test \
> >+ matrix_test \
> > multi_doactions_and_goto_frame_test \
> > simple_loop_test \
> > simple_loop_testrunner \
> >@@ -140,6 +140,7 @@
> > reverse_execute_PlaceObject2_test2runner \
> > displaylist_depths_testrunner \
> > get_frame_number_testrunner \
> >+ matrix_testrunner \
> > $(NULL)
> >
> > if MAKESWF_SUPPORTS_PREBUILT_CLIPS
> >@@ -372,6 +373,20 @@
> > sh $< -r5 $(top_builddir) displaylist_depths_test.swf > $@
> > chmod 755 $@
> >
> >+matrix_test_SOURCES = \
> >+ matrix_test.c \
> >+ ming_utils.h \
> >+ ming_utils.c \
> >+ $(NULL)
> >+matrix_test_LDADD = $(MING_LIBS)
> >+
> >+matrix_test.swf: matrix_test
> >+ ./matrix_test $(top_srcdir)/testsuite/media
> >+
> >+matrix_testrunner: $(srcdir)/../generic-testrunner.sh matrix_test.swf
> >+ sh $< -r5 $(top_builddir) matrix_test.swf > $@
> >+ chmod 755 $@
> >+
> > get_frame_number_test_SOURCES = \
> > get_frame_number_test.c \
> > ming_utils.h \
> >@@ -892,6 +907,7 @@
> > reverse_execute_PlaceObject2_test1runner \
> > reverse_execute_PlaceObject2_test2runner \
> > displaylist_depths_testrunner \
> >+ matrix_testrunner \
> > $(NULL)
> >
> > if MAKESWF_SUPPORTS_PREBUILT_CLIPS
> >
> >Index: testsuite/misc-ming.all/matrix_test.c
> >===================================================================
> >RCS file: testsuite/misc-ming.all/matrix_test.c
> >diff -N testsuite/misc-ming.all/matrix_test.c
> >--- /dev/null 1 Jan 1970 00:00:00 -0000
> >+++ testsuite/misc-ming.all/matrix_test.c 14 Apr 2007 18:19:49 -0000
> >1.1
> >@@ -0,0 +1,138 @@
> >+/*
> >+ * Copyright (C) 2007 Free Software Foundation, Inc.
> >+ *
> >+ * This program is free software; you can redistribute it and/or modify
> >+ * it under the terms of the GNU General Public License as published by
> >+ * the Free Software Foundation; either version 2 of the License, or
> >+ * (at your option) any later version.
> >+ *
> >+ * This program is distributed in the hope that it will be useful,
> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> >+ * GNU General Public License for more details.
> >+ * You should have received a copy of the GNU General Public License
> >+ * along with this program; if not, write to the Free Software
> >+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
> >USA
> >+ *
> >+ */
> >+
> >+/*
> >+ * Sandro Santilli, address@hidden
> >+ *
> >+ * Test extracting _width, _height, _xscale, _yscale, _x, _y and _rotation
> >+ * from hard-coded matrices.
> >+ *
> >+ * run as ./matrix_test
> >+ */
> >+
> >+#include "ming_utils.h"
> >+
> >+#include <stdlib.h>
> >+#include <stdio.h>
> >+#include <ming.h>
> >+
> >+#define OUTPUT_VERSION 6
> >+#define OUTPUT_FILENAME "matrix_test.swf"
> >+
> >+SWFDisplayItem add_static_mc(SWFMovie mo, const char* name, int depth,
> >int x, int y, int width, int height);
> >+
> >+SWFDisplayItem
> >+add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int
> >width, int height)
> >+{
> >+ SWFShape sh;
> >+ SWFMovieClip mc, mc2;
> >+ SWFDisplayItem it;
> >+
> >+ sh = make_fill_square (-(width/2), -(height/2), width, height,
> >255, 0, 0, 255, 0, 0);
> >+ mc = newSWFMovieClip();
> >+ SWFMovieClip_add(mc, (SWFBlock)sh);
> >+
> >+ sh = make_square (-(width/2)+5, -(height/2)+5, width-10,
> >height-10, 0, 0, 0);
> >+ mc2 = newSWFMovieClip(); // child
> >+ SWFMovieClip_add(mc2, (SWFBlock)sh);
> >+ SWFMovieClip_nextFrame(mc2);
> >+
> >+ it = SWFMovieClip_add(mc, (SWFBlock)mc2);
> >+ SWFDisplayItem_setName(it, "child");
> >+ SWFMovieClip_nextFrame(mc);
> >+
> >+ it = SWFMovie_add(mo, (SWFBlock)mc);
> >+ SWFDisplayItem_setDepth(it, depth);
> >+ SWFDisplayItem_moveTo(it, x, y);
> >+ SWFDisplayItem_setName(it, name);
> >+
> >+ return it;
> >+}
> >+
> >+
> >+int
> >+main(int argc, char** argv)
> >+{
> >+ SWFMovie mo;
> >+ SWFMovieClip dejagnuclip;
> >+ SWFDisplayItem it;
> >+ int i;
> >+
> >+ const char *srcdir=".";
> >+ if ( argc>1 )
> >+ srcdir=argv[1];
> >+ else
> >+ {
> >+ //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
> >+ //return 1;
> >+ }
> >+
> >+ Ming_init();
> >+ mo = newSWFMovieWithVersion(OUTPUT_VERSION);
> >+ SWFMovie_setDimension(mo, 800, 600);
> >+ SWFMovie_setRate (mo, 1);
> >+
> >+ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir),
> >10, 0, 0, 800, 600);
> >+ SWFMovie_add(mo, (SWFBlock)dejagnuclip);
> >+
> >+ add_actions(mo, "printBounds = function(b) { return
> >''+b.xMin+','+b.yMin+' '+b.xMax+','+b.yMax; };");
> >+
> >+ SWFMovie_nextFrame(mo);
> >+
> >+
> >+ // Static 60x60 movieclip
> >+ it = add_static_mc(mo, "staticmc", 3, 50, 300, 60, 60);
> >+
> >+ // Check if we cleaned them all now
> >+ check_equals(mo, "typeof(staticmc)", "'movieclip'");
> >+ check_equals(mo, "staticmc._x", "50");
> >+ check_equals(mo, "staticmc._y", "300");
> >+ check_equals(mo, "staticmc._xscale", "100");
> >+ check_equals(mo, "staticmc._yscale", "100");
> >+ check_equals(mo, "staticmc._rotation", "0");
> >+ check_equals(mo, "Math.round(staticmc._width)", "60");
> >+ check_equals(mo, "Math.round(staticmc._height)", "60");
> >+
> >+ SWFMovie_nextFrame(mo);
> >+
> >+ SWFDisplayItem_rotate(it, -45);
> >+
> >+ check_equals(mo, "staticmc._x", "50");
> >+ check_equals(mo, "staticmc._y", "300");
> >+ check_equals(mo, "Math.round(staticmc._xscale)", "100");
> >+ check_equals(mo, "Math.round(staticmc._yscale)", "100");
> >+ check_equals(mo, "staticmc._rotation", "45");
> >+ check_equals(mo, "printBounds(staticmc.getBounds())",
> >"'-30.05,-30.05 30.05,30.05'");
> >+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
> >"'7.5,257.5 92.5,342.5'");
> >+ check_equals(mo, "staticmc._width", "85");
> >+ check_equals(mo, "staticmc._height", "85");
> >+
> >+ // TODO:
> >+ // - test mixing rotation and scale !
> >+
> >+
> >+
> >+ add_actions(mo, "_root.totals(); stop();");
> >+ SWFMovie_nextFrame(mo);
> >+
> >+ //Output movie
> >+ puts("Saving " OUTPUT_FILENAME );
> >+ SWFMovie_save(mo, OUTPUT_FILENAME);
> >+
> >+ return 0;
> >+}
> >
> >
> >_______________________________________________
> >Gnash-commit mailing list
> >address@hidden
> >http://lists.gnu.org/mailman/listinfo/gnash-commit
> >
--
() ASCII Ribbon Campaign
/\ Keep it simple!