gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/text.cpp server/text.h t...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/text.cpp server/text.h t...
Date: Fri, 11 Apr 2008 11:25:24 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/11 11:25:23

Modified files:
        .              : ChangeLog 
        server         : text.cpp text.h 
        testsuite/misc-ming.all: Makefile.am 
Added files:
        testsuite/misc-ming.all: DefineTextTest-Runner.cpp 
                                 DefineTextTest.c 

Log message:
                * server/text.h: don't forget to initialize
                  the _underline member.
                * server/text.cpp (display_glyph_records): don't reset
                  the x/y offsets on every new glyph record (useful for
                  static text) - was a regression I introduced with last
                  commit.
                * testsuite/misc-ming.all/: DefineTextTest-Runner.cpp,
                  DefineTextTest.c, Makefile.am: new test for static text
                  (would fail with the regression introduced in
                  last commit).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6254&r2=1.6255
http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.cpp?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.188&r2=1.189
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineTextTest-Runner.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineTextTest.c?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6254
retrieving revision 1.6255
diff -u -b -r1.6254 -r1.6255
--- ChangeLog   11 Apr 2008 10:56:14 -0000      1.6254
+++ ChangeLog   11 Apr 2008 11:25:22 -0000      1.6255
@@ -1,3 +1,16 @@
+2008-04-11 Sandro Santilli <address@hidden>
+
+       * server/text.h: don't forget to initialize
+         the _underline member.
+       * server/text.cpp (display_glyph_records): don't reset
+         the x/y offsets on every new glyph record (useful for
+         static text) - was a regression I introduced with last 
+         commit.
+       * testsuite/misc-ming.all/: DefineTextTest-Runner.cpp,
+         DefineTextTest.c, Makefile.am: new test for static text
+         (would fail with the regression introduced in
+         last commit).
+
 2008-04-11 Benjamin Wolsey <address@hidden>
 
        * gui/gtk.cpp: explicit cast to int to silence warnings on some

Index: server/text.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/text.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- server/text.cpp     11 Apr 2008 09:58:41 -0000      1.47
+++ server/text.cpp     11 Apr 2008 11:25:23 -0000      1.48
@@ -100,6 +100,9 @@
 
                matrix  base_matrix = mat;
 
+               float x = 0.0f;
+               float y = 0.0f;
+
                for (unsigned int i = 0; i < records.size(); i++)
                {
                        // Draw the characters within the current record; i.e. 
consecutive
@@ -123,8 +126,10 @@
                        log_debug("font for record %u == %p", i, (const 
void*)fnt);
 #endif
 
-                       float x = rec.m_style.hasXOffset() ? 
rec.m_style.getXOffset() : 0.0f;
-                       float y = rec.m_style.hasYOffset() ? 
rec.m_style.getYOffset() : 0.0f;
+                       if ( rec.m_style.hasXOffset() ) x = 
rec.m_style.getXOffset();
+                       if ( rec.m_style.hasYOffset() ) y = 
rec.m_style.getYOffset();
+
+                       float startX = x; // for the underline, if any
 
                        s_dummy_style[0].set_color(rec.m_style.m_color);
 
@@ -185,9 +190,6 @@
                        bool underline = rec.m_style.isUnderlined(); 
                        if ( nglyphs && underline )
                        {
-                               // Starting offset
-                               boost::int16_t startX = 
rec.m_style.hasXOffset() ? (int)rec.m_style.getXOffset() : 0;
-
                                // Underline should end where last displayed 
glyphs
                                // does. 'x' here is where next glyph would be 
displayed
                                // which is normally after some space.

Index: server/text.h
===================================================================
RCS file: /sources/gnash/gnash/server/text.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/text.h       11 Apr 2008 09:58:41 -0000      1.24
+++ server/text.h       11 Apr 2008 11:25:23 -0000      1.25
@@ -50,6 +50,7 @@
                        m_text_height(1.0f),
                        m_has_x_offset(false),
                        m_has_y_offset(false),
+                       _underlined(false),
                        m_font(NULL)
                {
                }

Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -b -r1.188 -r1.189
--- testsuite/misc-ming.all/Makefile.am 4 Apr 2008 15:51:47 -0000       1.188
+++ testsuite/misc-ming.all/Makefile.am 11 Apr 2008 11:25:23 -0000      1.189
@@ -63,6 +63,8 @@
        ButtonEventsTest-Runner \
        SpriteButtonEventsTest \
        SpriteButtonEventsTest-Runner \
+       DefineTextTest \
+       DefineTextTest-Runner \
        DefineEditTextTest \
        DefineEditTextTest-Runner \
        DefineEditTextVariableNameTest \
@@ -325,6 +327,25 @@
        : test absolute url
        ./moviecliploader_test $(top_srcdir)/testsuite/media
 
+DefineTextTest.swf: DefineTextTest
+       ./DefineTextTest $(top_srcdir)/testsuite/media
+
+DefineTextTest_SOURCES =  DefineTextTest.c
+DefineTextTest_LDADD = libgnashmingutils.la
+
+DefineTextTest_Runner_SOURCES = \
+       DefineTextTest-Runner.cpp \
+       $(NULL)
+DefineTextTest_Runner_CXXFLAGS = \
+       -DTGTDIR='"$(abs_builddir)"' \
+       $(NULL)
+DefineTextTest_Runner_LDADD = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(NULL)
+DefineTextTest_Runner_DEPENDENCIES = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       DefineTextTest.swf      \
+       $(NULL)
 
 DefineEditTextTest.swf: DefineEditTextTest
        ./DefineEditTextTest $(top_srcdir)/testsuite/media
@@ -1724,6 +1745,7 @@
 TEST_CASES = \
        DefineEditTextVariableNameTest-Runner \
        DefineEditTextVariableNameTest2-Runner \
+       DefineTextTest-Runner \
        DefineEditTextTest-Runner \
        RollOverOutTest-Runner \
        ButtonEventsTest-Runner \

Index: testsuite/misc-ming.all/DefineTextTest-Runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/DefineTextTest-Runner.cpp
diff -N testsuite/misc-ming.all/DefineTextTest-Runner.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/DefineTextTest-Runner.cpp   11 Apr 2008 11:25:23 
-0000      1.1
@@ -0,0 +1,89 @@
+/* 
+ *   Copyright (C) 2005, 2006, 2007, 2008 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 3 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
+ *
+ *
+ */ 
+
+#define INPUT_FILENAME "DefineTextTest.swf"
+
+#include "MovieTester.h"
+#include "sprite_instance.h"
+#include "character.h"
+#include "dlist.h"
+#include "log.h"
+#include "VM.h"
+#include "string_table.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+
+using namespace gnash;
+using namespace std;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+       string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
+       MovieTester tester(filename);
+
+       gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+       dbglogfile.setVerbosity(1);
+
+       sprite_instance* root = tester.getRootMovie();
+       assert(root);
+
+       check_equals(root->get_frame_count(), 3);
+       check_equals(root->get_play_state(), sprite_instance::PLAY);
+       check_equals(root->get_current_frame(), 0);
+
+       rgba white(255,255,255,255);
+       rgba red(255,0,0,255);
+       rgba green(0,255,0,255);
+
+       geometry::Point2d<int> cXmm(220,327); // character X center
+       geometry::Point2d<int> cXum(220,440); // character X underline/middle
+
+       geometry::Point2d<int> cOmr(135,326); // character O middle/right
+       geometry::Point2d<int> cOml(21,330); // character O middle/left
+       geometry::Point2d<int> cOmm(77,327); // character O center
+       geometry::Point2d<int> cOum(78,440); // character O underline/middle
+
+
+       tester.advance(); // first frame only contains dejagnu
+       check_equals(root->get_current_frame(), 1);
+
+       check_pixel(cXmm.x, cXmm.y, 4, red, 2); // X cross
+       check_pixel(cXum.x, cXum.y, 20, white, 2); // X underline (none)
+
+       check_pixel(cOmm.x, cOmm.y, 8, white, 2); // O hole
+       check_pixel(cOml.x, cOml.y, 4, green, 2); // O left side
+       check_pixel(cOmr.x, cOmr.y, 4, green, 2); // O right side
+       check_pixel(cOum.x, cOum.y, 20, white, 2); // O underline (none)
+
+       for (int i=0; i<2; ++i) tester.advance(); // get to the end
+
+       string_table& st = VM::get().getStringTable();
+       as_value eot;
+       bool endOfTestFound = root->get_member(st.find("endoftest"), &eot);
+       check(endOfTestFound);
+       check(eot.is_bool());
+       check(eot.to_bool());
+
+       // TODO: use check_pixel for checking bacground colors
+}
+

Index: testsuite/misc-ming.all/DefineTextTest.c
===================================================================
RCS file: testsuite/misc-ming.all/DefineTextTest.c
diff -N testsuite/misc-ming.all/DefineTextTest.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/DefineTextTest.c    11 Apr 2008 11:25:23 -0000      
1.1
@@ -0,0 +1,134 @@
+/* 
+ *   Copyright (C) 2005, 2006, 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 3 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
+ *
+ *
+ */ 
+
+/*
+ * Test DefineText tag.
+ * 
+ * run as ./DefineTextTest <mediadir> to produce DefineTextTest.swf
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION 7
+#define OUTPUT_FILENAME "DefineTextTest.swf"
+
+int
+main(int argc, char** argv)
+{
+  SWFMovie mo;
+  const char *srcdir=".";
+  char fdbfont[256];
+  SWFMovieClip  dejagnuclip;
+  
+  /*********************************************
+   *
+   * Initialization
+   *
+   *********************************************/
+
+  if ( argc>1 ) srcdir=argv[1];
+  else
+  {
+    fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+    return 1;
+  }
+
+  sprintf(fdbfont, "%s/Bitstream Vera Sans.fdb", srcdir);
+
+  puts("Setting things up");
+
+  Ming_init();
+  Ming_useSWFVersion (OUTPUT_VERSION);
+  //Ming_setScale(20.0); /* so we talk twips */
+ 
+  mo = newSWFMovie();
+  SWFMovie_setRate(mo, 1.0);
+  SWFMovie_setDimension(mo, 800, 600);
+  
+  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 
800, 600);
+  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+  SWFMovie_nextFrame(mo); // 1st frame 
+
+  /*********************************************
+   *
+   * Add some textfields
+   *
+   *********************************************/
+  {
+    SWFMovieClip mc; // to check sizes
+    SWFDisplayItem it;
+    SWFText tf;
+
+    FILE *font_file = fopen(fdbfont, "r");
+    if ( font_file == NULL )
+    {
+      perror(fdbfont);
+      exit(1);
+    }
+    SWFBrowserFont bfont = newSWFBrowserFont("_sans");
+    SWFFont efont = loadSWFFontFromFile(font_file);
+
+    tf = newSWFText();
+
+    SWFText_setFont(tf, efont);
+    SWFText_setHeight(tf, 200);
+    SWFText_setColor(tf, 0, 255, 0, 0xff);
+    SWFText_addString(tf, "O", NULL);
+
+    SWFText_setFont(tf, efont);
+    SWFText_setHeight(tf, 200);
+    SWFText_setColor(tf, 255, 0, 0, 0xff);
+    SWFText_addString(tf, "X", NULL);
+
+    mc = newSWFMovieClip();
+    it = SWFMovieClip_add(mc, tf);
+    SWFDisplayItem_setName(it, "stext1");
+    SWFMovieClip_nextFrame(mc);
+
+    it = SWFMovie_add(mo, mc);
+    SWFDisplayItem_setName(it, "mc");
+    SWFDisplayItem_moveTo(it, 0, 400);
+  }
+  SWFMovie_nextFrame(mo);  // 2nd frame
+
+  // static text is not a referenceable char
+  check_equals(mo, "mc.stext1", "mc");
+  check_equals(mo, "typeof(mc.stext1)", "'movieclip'");
+  check_equals(mo, "mc.stext1._target", "'/mc'");
+
+  check_equals(mo, "mc._width", "288.05");
+
+  add_actions(mo, "endoftest=true; totals(); stop();");
+  SWFMovie_nextFrame(mo);  // 3rd frame
+
+  /*****************************************************
+   *
+   * Output movie
+   *
+   *****************************************************/
+  puts("Saving " OUTPUT_FILENAME );
+
+  SWFMovie_save(mo, OUTPUT_FILENAME);
+
+  return 0;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]