[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12339: Add testcases.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12339: Add testcases. |
Date: |
Thu, 29 Jul 2010 08:24:31 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12339 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2010-07-29 08:24:31 +0200
message:
Add testcases.
Reduce inclusions of fill_style.h for easier refactoring. Include some headers
explicitly that were previously relying on secondary inclusions from
fill_style.h.
added:
testsuite/misc-ming.all/BeginBitmapFill.c
testsuite/misc-ming.all/BeginBitmapFillRunner.cpp
testsuite/misc-ming.all/BitmapDataDraw.c
testsuite/misc-ming.all/BitmapDataTestRunner.cpp
modified:
libcore/DynamicShape.h
libcore/FreetypeGlyphsProvider.cpp
libcore/MovieClip.cpp
libcore/asobj/MovieClip_as.cpp
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/SWFMovieDefinition.cpp
libcore/swf/DefineMorphShapeTag.cpp
libcore/swf/ShapeRecord.cpp
libcore/swf/ShapeRecord.h
libcore/swf/tag_loaders.cpp
librender/Renderer_agg.cpp
librender/Renderer_cairo.cpp
librender/Renderer_ogl.cpp
testsuite/libcore.all/ClassSizes.cpp
testsuite/misc-ming.all/Makefile.am
=== modified file 'libcore/DynamicShape.h'
--- a/libcore/DynamicShape.h 2010-03-11 01:47:08 +0000
+++ b/libcore/DynamicShape.h 2010-07-28 07:57:23 +0000
@@ -28,6 +28,7 @@
class DisplayObject;
class Renderer;
class fill_style;
+ class gradient_record;
}
namespace gnash {
=== modified file 'libcore/FreetypeGlyphsProvider.cpp'
--- a/libcore/FreetypeGlyphsProvider.cpp 2010-02-23 17:06:43 +0000
+++ b/libcore/FreetypeGlyphsProvider.cpp 2010-07-28 07:57:23 +0000
@@ -27,6 +27,7 @@
#include "GnashException.h"
#include "ShapeRecord.h"
#include "log.h"
+#include "fill_style.h"
#ifdef USE_FREETYPE
# include <ft2build.h>
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2010-07-23 07:18:03 +0000
+++ b/libcore/MovieClip.cpp 2010-07-28 08:11:46 +0000
@@ -49,7 +49,7 @@
#include "ExecutableCode.h" // for inheritance of ConstructEvent
#include "DynamicShape.h" // for composition
#include "namedStrings.h"
-#include "LineStyle.h" // for CapStyle and JoinStyle enums
+#include "LineStyle.h"
#include "PlaceObject2Tag.h"
#include "flash/geom/Matrix_as.h"
#include "GnashNumeric.h"
=== modified file 'libcore/asobj/MovieClip_as.cpp'
--- a/libcore/asobj/MovieClip_as.cpp 2010-07-22 14:16:16 +0000
+++ b/libcore/asobj/MovieClip_as.cpp 2010-07-28 07:57:23 +0000
@@ -17,9 +17,12 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
+#include "MovieClip_as.h"
+
+#include <boost/lexical_cast.hpp>
+
#include "MovieClip.h"
#include "Movie.h"
-#include "MovieClip_as.h"
#include "display/BitmapData_as.h"
#include "NetStream_as.h"
#include "movie_root.h"
@@ -33,9 +36,8 @@
#include "NativeFunction.h"
#include "Bitmap.h"
#include "Array_as.h"
-
+#include "fill_style.h"
#include "namedStrings.h"
-#include <boost/lexical_cast.hpp>
namespace gnash {
=== modified file 'libcore/parser/BitmapMovieDefinition.cpp'
--- a/libcore/parser/BitmapMovieDefinition.cpp 2010-01-01 17:48:26 +0000
+++ b/libcore/parser/BitmapMovieDefinition.cpp 2010-07-28 07:57:23 +0000
@@ -27,6 +27,7 @@
#include "Renderer.h"
#include "Global_as.h"
#include "namedStrings.h"
+#include "BitmapInfo.h"
namespace gnash {
=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp 2010-06-22 07:15:04 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp 2010-07-28 07:57:23 +0000
@@ -22,9 +22,18 @@
#include "gnashconfig.h" // USE_SWFTREE
#endif
+#include "SWFMovieDefinition.h"
+
+#include <boost/bind.hpp>
+#include <boost/version.hpp>
+#include <boost/thread.hpp>
+#include <iomanip>
+#include <memory>
+#include <string>
+#include <algorithm> // std::make_pair
+
#include "GnashSleep.h"
#include "smart_ptr.h" // GNASH_USE_GC
-#include "SWFMovieDefinition.h"
#include "movie_definition.h" // for inheritance
#include "zlib_adapter.h"
#include "IOChannel.h" // for use
@@ -43,14 +52,7 @@
#include "Global_as.h"
#include "namedStrings.h"
#include "as_function.h"
-
-#include <boost/bind.hpp>
-#include <boost/version.hpp>
-#include <boost/thread.hpp>
-#include <iomanip>
-#include <memory>
-#include <string>
-#include <algorithm> // std::make_pair
+#include "BitmapInfo.h"
// Debug frames load
#undef DEBUG_FRAMES_LOAD
=== modified file 'libcore/swf/DefineMorphShapeTag.cpp'
--- a/libcore/swf/DefineMorphShapeTag.cpp 2010-06-11 07:04:03 +0000
+++ b/libcore/swf/DefineMorphShapeTag.cpp 2010-07-28 07:57:23 +0000
@@ -32,6 +32,7 @@
#include "RunResources.h"
#include "Global_as.h"
#include "Renderer.h"
+#include "fill_style.h"
namespace gnash {
namespace SWF {
=== modified file 'libcore/swf/ShapeRecord.cpp'
--- a/libcore/swf/ShapeRecord.cpp 2010-07-26 06:01:48 +0000
+++ b/libcore/swf/ShapeRecord.cpp 2010-07-29 06:24:31 +0000
@@ -145,6 +145,48 @@
read(in, tag, m, r);
}
+ShapeRecord::ShapeRecord()
+{
+}
+
+ShapeRecord::~ShapeRecord()
+{
+}
+
+ShapeRecord::ShapeRecord(const ShapeRecord& other)
+ :
+ _fillStyles(other._fillStyles),
+ _lineStyles(other._lineStyles),
+ _paths(other._paths),
+ _bounds(other._bounds)
+{
+}
+
+ShapeRecord&
+ShapeRecord::operator=(const ShapeRecord& other)
+{
+ _fillStyles = other._fillStyles;
+ _lineStyles = other._lineStyles;
+ _paths = other._paths;
+ _bounds = other._bounds;
+ return *this;
+}
+
+void
+ShapeRecord::clear()
+{
+ _fillStyles.clear();
+ _lineStyles.clear();
+ _paths.clear();
+ _bounds.set_null();
+}
+
+void
+ShapeRecord::addFillStyle(const fill_style& fs)
+{
+ _fillStyles.push_back(fs);
+}
+
void
ShapeRecord::setLerp(const ShapeRecord& a, const ShapeRecord& b,
const double ratio)
=== modified file 'libcore/swf/ShapeRecord.h'
--- a/libcore/swf/ShapeRecord.h 2010-07-26 06:01:48 +0000
+++ b/libcore/swf/ShapeRecord.h 2010-07-29 06:24:31 +0000
@@ -20,7 +20,6 @@
#define GNASH_SWF_SHAPERECORD_H
#include "Geometry.h"
-#include "fill_style.h"
#include "LineStyle.h"
#include "SWFRect.h"
@@ -30,6 +29,7 @@
namespace gnash {
class movie_definition;
class RunResources;
+ class fill_style;
}
namespace gnash {
@@ -58,9 +58,11 @@
/// Construct a ShapeRecord.
//
+ /// This should only really be used for DynamicShapes.
+ //
/// Ideally all immutable ShapeRecords should be constructed with the
/// ctor taking an SWFStream, but some tag formats do not allow this.
- ShapeRecord() {}
+ ShapeRecord();
/// Construct a ShapeRecord from a SWFStream.
//
@@ -68,13 +70,13 @@
ShapeRecord(SWFStream& in, SWF::TagType tag, movie_definition& m,
const RunResources& r);
- ShapeRecord(const ShapeRecord& other)
- :
- _fillStyles(other._fillStyles),
- _lineStyles(other._lineStyles),
- _paths(other._paths),
- _bounds(other._bounds)
- {}
+ /// Copy constructor
+ ShapeRecord(const ShapeRecord& other);
+
+ /// Assignment operator
+ ShapeRecord& operator=(const ShapeRecord& other);
+
+ ~ShapeRecord();
/// Parse path data from a SWFStream.
//
@@ -114,16 +116,9 @@
const double ratio);
/// Reset all shape data.
- void clear() {
- _fillStyles.clear();
- _lineStyles.clear();
- _paths.clear();
- _bounds.set_null();
- }
+ void clear();
- void addFillStyle(const fill_style& fs) {
- _fillStyles.push_back(fs);
- }
+ void addFillStyle(const fill_style& fs);
void addPath(const Path& path) {
_paths.push_back(path);
@@ -138,7 +133,7 @@
}
private:
-
+
/// Shape record flags for use in parsing.
enum ShapeRecordFlags {
SHAPE_END = 0x00,
=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp 2010-07-26 06:14:03 +0000
+++ b/libcore/swf/tag_loaders.cpp 2010-07-29 06:24:31 +0000
@@ -18,11 +18,18 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h" // HAVE_ZLIB_H, USE_SWFTREE
#endif
+#include "tag_loaders.h"
+
+#include <set>
+#include <limits>
+#include <cassert>
+#include <utility> // for std::make_pair
+#include <boost/static_assert.hpp>
+
#include "IOChannel.h" // for StreamAdapter inheritance
#include "utility.h"
#include "action_buffer.h"
@@ -48,15 +55,11 @@
#include "RunResources.h"
#include "Renderer.h"
#include "Movie.h"
+#include "BitmapInfo.h"
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
-#include <set>
-#include <limits>
-#include <cassert>
-#include <utility> // for std::make_pair
-#include <boost/static_assert.hpp>
namespace gnash {
=== modified file 'librender/Renderer_agg.cpp'
--- a/librender/Renderer_agg.cpp 2010-07-19 07:48:54 +0000
+++ b/librender/Renderer_agg.cpp 2010-07-28 07:57:23 +0000
@@ -127,6 +127,7 @@
#include "GnashNumeric.h"
#include "GC.h"
#include "cxform.h"
+#include "fill_style.h"
#ifdef HAVE_VA_VA_H
#include "GnashVaapiImage.h"
=== modified file 'librender/Renderer_cairo.cpp'
--- a/librender/Renderer_cairo.cpp 2010-07-19 07:43:01 +0000
+++ b/librender/Renderer_cairo.cpp 2010-07-28 07:57:23 +0000
@@ -42,6 +42,7 @@
#include "swf/ShapeRecord.h"
#include "Renderer_cairo.h"
#include "utility.h"
+#include "fill_style.h"
#include <cmath>
#include <cairo/cairo.h>
=== modified file 'librender/Renderer_ogl.cpp'
--- a/librender/Renderer_ogl.cpp 2010-07-19 10:14:01 +0000
+++ b/librender/Renderer_ogl.cpp 2010-07-28 07:57:23 +0000
@@ -35,6 +35,7 @@
#include "utility.h"
#include "Range2d.h"
#include "cxform.h"
+#include "fill_style.h"
#if defined(_WIN32) || defined(WIN32)
# include <Windows.h>
=== modified file 'testsuite/libcore.all/ClassSizes.cpp'
--- a/testsuite/libcore.all/ClassSizes.cpp 2010-01-14 13:17:20 +0000
+++ b/testsuite/libcore.all/ClassSizes.cpp 2010-07-29 06:24:31 +0000
@@ -35,6 +35,7 @@
#include "Shape.h"
#include "TextField.h"
#include "SWFStream.h"
+#include "fill_style.h"
#include "swf/DefineFontAlignZonesTag.h"
#include "swf/DefineShapeTag.h"
#include "swf/DefineButtonCxformTag.h"
=== added file 'testsuite/misc-ming.all/BeginBitmapFill.c'
--- a/testsuite/misc-ming.all/BeginBitmapFill.c 1970-01-01 00:00:00 +0000
+++ b/testsuite/misc-ming.all/BeginBitmapFill.c 2010-07-28 07:27:26 +0000
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2007, 2009, 2010 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
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION 8
+#define OUTPUT_FILENAME "BeginBitmapFill.swf"
+
+
+/// The beginBitmapFill test shows that:
+//
+/// 1. The fill always starts at 0, 0 of the MovieClip unless a matrix argument
+/// is passed.
+/// 2. It repeats by default.
+/// 3. If repeat is false, the edge colours are used for the fill.
+/// 4. Changes to the BitmapData affect all fills.
+const char* mediadir=".";
+
+int
+main(int argc, char** argv)
+{
+ SWFMovie mo;
+ SWFMovieClip dejagnuclip;
+
+ if (argc > 1) mediadir=argv[1];
+ else {
+ fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ Ming_init();
+ Ming_useSWFVersion(OUTPUT_VERSION);
+
+ mo = newSWFMovie();
+ SWFMovie_setDimension(mo, 800, 600);
+
+ SWFMovie_setRate(mo, 12);
+ dejagnuclip = get_dejagnu_clip(
+ (SWFBlock)get_default_font(mediadir), 10, 10, 150, 800, 600);
+ SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+
+ SWFMovie_nextFrame(mo);
+
+ add_actions(mo,
+ "b = new flash.display.BitmapData(150, 150, false);"
+ "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 130), 0xff0000);"
+ "b.fillRect(new flash.geom.Rectangle(25, 10, 10, 130), 0x00ff00);"
+ "b.fillRect(new flash.geom.Rectangle(40, 10, 10, 130), 0x0000ff);"
+ "mc = _root.createEmptyMovieClip('mc1', 55);"
+ "with(mc) {"
+
+ // Shape 1
+ " x = 0;"
+ " y = 0;"
+ " moveTo(x + 0, y + 0);"
+ " beginBitmapFill(b);"
+ " lineTo(x + 0, y + 100);"
+ " lineTo(x + 100, y + 100);"
+ " lineTo(x + 100, y + 0);"
+
+ // Shape 2
+ " x = 100;"
+ " y = 0;"
+ " moveTo(x + 0, y + 0);"
+ " beginBitmapFill(b);"
+ " lineTo(x + 100, y + 0);"
+ " lineTo(x + 100, y + 100);"
+ " lineTo(x + 0, y + 100);"
+
+ // Shape 2
+ " x = 300;"
+ " y = 0;"
+ " moveTo(x + 0, y + 0);"
+ " beginBitmapFill(b);"
+ " lineTo(x + 100, y + 100);"
+ " lineTo(x + 0, y + 100);"
+ "};"
+
+ "b = new flash.display.BitmapData(150, 150, false);"
+ "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 130), 0xff00ff);"
+ "b.fillRect(new flash.geom.Rectangle(25, 10, 10, 130), 0xffff00);"
+ "b.fillRect(new flash.geom.Rectangle(40, 10, 10, 130), 0x00ffff);"
+ "mc = _root.createEmptyMovieClip('mc2', 66);"
+ "with(mc) {"
+ " x = 0;"
+ " y = 0;"
+ " moveTo(x + 0, y + 0);"
+ " beginBitmapFill(b);"
+ " lineTo(x + 0, y + 100);"
+ " lineTo(x + 100, y + 100);"
+ " lineTo(x + 100, y + 0);"
+ " transform.matrix = new flash.geom.Matrix(2, -1.3, 2.4, 1, 20,
200);"
+ "};"
+ );
+
+ /// Now with matrix argument. Repeat is true by default
+ add_actions(mo,
+ "b = new flash.display.BitmapData(150, 150, false);"
+ "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 130), 0x000000);"
+ "b.fillRect(new flash.geom.Rectangle(25, 10, 10, 130), 0xaaff00);"
+ "b.fillRect(new flash.geom.Rectangle(40, 10, 10, 130), 0x00ccff);"
+ "mc = _root.createEmptyMovieClip('mc3', 77);"
+ "with(mc) {"
+ " x = 0;"
+ " y = 300;"
+ " moveTo(x + 0, y + 0);"
+ " matrix = new flash.geom.Matrix();"
+ " matrix.rotate(Math.PI / 2);"
+ " beginBitmapFill(b, matrix, true);"
+ " lineTo(x + 0, y + 100);"
+ " lineTo(x + 200, y + 100);"
+ " lineTo(x + 200, y + 0);"
+ "};"
+ );
+
+ // Now with repeat set to false
+ add_actions(mo,
+ "b = new flash.display.BitmapData(20, 20, false);"
+ "b.fillRect(new flash.geom.Rectangle(0, 0, 10, 10), 0x000000);"
+ "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 10), 0xaaff00);"
+ "b.fillRect(new flash.geom.Rectangle(10, 0, 10, 10), 0xaaff00);"
+ "b.fillRect(new flash.geom.Rectangle(0, 10, 10, 10), 0xaaffaa);"
+ "mc = _root.createEmptyMovieClip('mc4', 88);"
+ "with(mc) {"
+ " x = 300;"
+ " y = 300;"
+ " moveTo(x + 0, y + 0);"
+ " m = new flash.geom.Matrix();"
+ " m.tx = 350;"
+ " m.ty = 350;"
+ " beginBitmapFill(b, m, false);"
+ " lineTo(x + 0, y + 100);"
+ " lineTo(x + 150, y + 100);"
+ " lineTo(x + 150, y + 0);"
+ "};"
+
+ "mc = _root.createEmptyMovieClip('mc5', 99);"
+ "with(mc) {"
+ " x = 500;"
+ " y = 300;"
+ " moveTo(x + 0, y + 0);"
+ " m = new flash.geom.Matrix();"
+ " m.tx = 550;"
+ " m.ty = 550;"
+ " beginBitmapFill(b, m, true);"
+ " lineTo(x + 0, y + 100);"
+ " lineTo(x + 150, y + 100);"
+ " lineTo(x + 150, y + 0);"
+ "};"
+ );
+
+ // Change the Bitmap afterwards
+ add_actions(mo,
+ "b = new flash.display.BitmapData(20, 20, false);"
+ "b.fillRect(new flash.geom.Rectangle(0, 0, 10, 10), 0x000000);"
+ "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 10), 0xaaff00);"
+ "b.fillRect(new flash.geom.Rectangle(10, 0, 10, 10), 0xaaff00);"
+ "b.fillRect(new flash.geom.Rectangle(0, 10, 10, 10), 0xaaffaa);"
+ "mc = _root.createEmptyMovieClip('mc4', 111);"
+ "with(mc) {"
+ " x = 10;"
+ " y = 450;"
+ " moveTo(x + 0, y + 0);"
+ " m = new flash.geom.Matrix();"
+ " m.tx = 0;"
+ " m.ty = 450;"
+ " beginBitmapFill(b, m, false);"
+ " lineTo(x + 0, y + 100);"
+ " lineTo(x + 150, y + 100);"
+ " lineTo(x + 150, y + 0);"
+ "};"
+ "b.fillRect(new flash.geom.Rectangle(0, 0, 20, 20), 0xff0000);"
+ );
+
+ SWFMovie_nextFrame(mo);
+
+ //Output movie
+ puts("Saving "OUTPUT_FILENAME);
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return 0;
+}
=== added file 'testsuite/misc-ming.all/BeginBitmapFillRunner.cpp'
--- a/testsuite/misc-ming.all/BeginBitmapFillRunner.cpp 1970-01-01 00:00:00
+0000
+++ b/testsuite/misc-ming.all/BeginBitmapFillRunner.cpp 2010-07-28 07:15:14
+0000
@@ -0,0 +1,63 @@
+//
+// Copyright (C) 2007, 2008, 2009, 2010 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 "BeginBitmapFill.swf"
+
+#include "MovieTester.h"
+#include "MovieClip.h"
+#include "DisplayObject.h"
+#include "DisplayList.h"
+#include "log.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+#include <sstream>
+
+using namespace gnash;
+using namespace gnash::geometry;
+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);
+
+ MovieClip* root = tester.getRootMovie();
+ assert(root);
+
+ const rgba white(255, 255, 255, 255);
+ const rgba blue(0, 0, 255, 255);
+ const rgba cyan(0, 255, 255, 255);
+ const rgba green(0, 255, 0, 255);
+ const rgba yellow(255, 255, 0, 255);
+ const rgba magenta(255, 0, 255, 255);
+ const rgba red(255, 0, 0, 255);
+
+ // Only one frame
+ tester.advance();
+ check_pixel(1, 1, 1, white, 8);
+
+ // TODO: add real tests!
+
+}
+
=== added file 'testsuite/misc-ming.all/BitmapDataDraw.c'
--- a/testsuite/misc-ming.all/BitmapDataDraw.c 1970-01-01 00:00:00 +0000
+++ b/testsuite/misc-ming.all/BitmapDataDraw.c 2010-07-27 07:11:11 +0000
@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2007, 2009, 2010 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
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+#include <string.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION 8
+#define OUTPUT_FILENAME "BitmapDataDraw.swf"
+
+const char* mediadir=".";
+
+
+/// The test shows the following:
+//
+/// The MovieClip itself is drawn with no transformation, i.e. identity matrix.
+/// Any contained MovieClips keep their transformation.
+/// BitmapData.draw draws on top of what's in the BitmapData already.
+/// Dynamically loaded images are not drawn.
+int
+main(int argc, char** argv)
+{
+ SWFMovie mo;
+ SWFMovieClip mc, mc3, mc4, mc5;
+ SWFMovieClip dejagnuclip;
+ SWFShape sh;
+ SWFDisplayItem it;
+ SWFFillStyle fill;
+ SWFBitmap bp;
+ SWFInput inp;
+
+ if (argc > 1) mediadir = argv[1];
+ else {
+ fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ Ming_init();
+ Ming_useSWFVersion (OUTPUT_VERSION);
+
+ mo = newSWFMovie();
+ SWFMovie_setDimension(mo, 800, 600);
+
+ SWFMovie_setRate(mo, 12);
+ dejagnuclip = get_dejagnu_clip(
+ (SWFBlock)get_default_font(mediadir), 10, 10, 150, 800, 600);
+ SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+
+ SWFMovie_nextFrame(mo);
+
+ mc = newSWFMovieClip();
+
+ // Two shapes.
+
+ // Shape 1
+ sh = newSWFShape();
+ fill = newSWFSolidFillStyle(0x00, 0xff, 0xff, 0xff);
+ SWFShape_setRightFillStyle(sh, fill);
+ SWFShape_movePenTo(sh, 10.0, 10.0);
+ SWFShape_drawLine(sh, 90.0, 0.0);
+ SWFShape_drawLine(sh, 0.0, 90.0);
+ SWFShape_drawLine(sh, -90.0, 0.0);
+ SWFShape_drawLine(sh, 0.0, -90.0);
+ SWFMovieClip_add(mc, (SWFBlock)sh);
+
+ // Shape 2
+ sh = newSWFShape();
+ fill = newSWFSolidFillStyle(0xff, 0x00, 0xff, 0xff);
+ SWFShape_setRightFillStyle(sh, fill);
+ SWFShape_movePenTo(sh, 80.0, 80.0);
+ SWFShape_drawLine(sh, 50.0, 0.0);
+ SWFShape_drawLine(sh, 0.0, 50.0);
+ SWFShape_drawLine(sh, -50.0, 0.0);
+ SWFShape_drawLine(sh, 0.0, -50.0);
+ SWFMovieClip_add(mc, (SWFBlock)sh);
+
+ // Show frame for static MovieClip
+ SWFMovieClip_nextFrame(mc);
+
+ it = SWFMovie_add(mo, (SWFBlock)mc);
+ SWFDisplayItem_setName(it, "mc1");
+
+ SWFMovie_nextFrame(mo);
+
+ add_actions(mo,
+ "_root.b = new flash.display.BitmapData(100, 100, false);"
+ "b.draw(mc1);"
+ "c = _root.createEmptyMovieClip('dynmc', 88);"
+ "_root.dynmc._x = 200;"
+ "_root.dynmc.attachBitmap(b, 24);"
+ );
+
+ // Dimensions are restricted to the BitmapData's size.
+ check_equals(mo, "b.width", "100");
+ check_equals(mo, "b.height", "100");
+
+ // The original MovieClip has:
+ // 1. a cyan (0x00ffff) square (10, 10) to (100, 100) and
+ // 2. a magenta (0xff00ff) square (80, 80) to (130, 130).
+
+ // Pixel checking
+ // Top left corner is white
+ check_equals(mo, "b.getPixel(1, 1)", "0xffffff");
+ check_equals(mo, "b.getPixel(8, 8)", "0xffffff");
+ // Cyan square
+ xcheck_equals(mo, "b.getPixel(12, 12)", "0x00ffff");
+ xcheck_equals(mo, "b.getPixel(12, 98)", "0x00ffff");
+ xcheck_equals(mo, "b.getPixel(98, 12)", "0x00ffff");
+ // Magenta square
+ xcheck_equals(mo, "b.getPixel(82, 82)", "0xff00ff");
+
+ // Do the same with double width and height.
+ add_actions(mo,
+ "b = new flash.display.BitmapData(100, 100, false);"
+ "b.draw(mc1, new flash.geom.Matrix(2, 0, 0, 2, 34, 34));"
+ "_root.createEmptyMovieClip('dynmc2', 89);"
+ "_root.dynmc2._x = 200;"
+ "_root.dynmc2.attachBitmap(b, 24);"
+ );
+
+ // Dimensions are restricted to the BitmapData's size.
+ check_equals(mo, "b.width", "100");
+ check_equals(mo, "b.height", "100");
+
+ // Pixel checking
+ // Top left corner is white
+ check_equals(mo, "b.getPixel(1, 1)", "0xffffff");
+ check_equals(mo, "b.getPixel(8, 8)", "0xffffff");
+ // Cyan square is scaled and translated to start at (54, 54)
+ // (10 * 2 + 34)
+ check_equals(mo, "b.getPixel(12, 12)", "0xffffff");
+ check_equals(mo, "b.getPixel(52, 52)", "0xffffff");
+ xcheck_equals(mo, "b.getPixel(56, 56)", "0x00ffff");
+ // Magenta square isn't there because it doesn't fit.
+
+ // Add with a different matrix
+ it = SWFMovie_add(mo, (SWFBlock)mc);
+ SWFDisplayItem_setMatrix(it, 0.5f, 0.f, 0.f, 2.0f, 0.f, 200.f);
+ SWFDisplayItem_setName(it, "mc2");
+
+ // Check that the BitmapData ignores PlaceObject matrix.
+ add_actions(mo,
+ "b = new flash.display.BitmapData(400, 400, false);"
+ "b.draw(mc2);"
+ "_root.createEmptyMovieClip('dynmc2', 88);"
+ "_root.dynmc2._y = 200;"
+ "_root.dynmc2._x = 200;"
+ "_root.dynmc2.attachBitmap(b, 28);"
+ );
+
+ // This is a sanity check more than anything else.
+ check_equals(mo, "b.width", "400");
+ check_equals(mo, "b.height", "400");
+
+ // Pixel checking (Bitmap is now 400x400)
+ // Top left corner is white
+ check_equals(mo, "b.getPixel(1, 1)", "0xffffff");
+ check_equals(mo, "b.getPixel(8, 8)", "0xffffff");
+ // Cyan square
+ xcheck_equals(mo, "b.getPixel(12, 12)", "0x00ffff");
+ xcheck_equals(mo, "b.getPixel(12, 98)", "0x00ffff");
+ xcheck_equals(mo, "b.getPixel(98, 12)", "0x00ffff");
+ check_equals(mo, "b.getPixel(12, 102)", "0xffffff");
+ check_equals(mo, "b.getPixel(102, 12)", "0xffffff");
+ // Magenta square
+ xcheck_equals(mo, "b.getPixel(82, 82)", "0xff00ff");
+ xcheck_equals(mo, "b.getPixel(128, 128)", "0xff00ff");
+ check_equals(mo, "b.getPixel(132, 132)", "0xffffff");
+ xcheck_equals(mo, "b.getPixel(78, 78)", "0x00ffff");
+
+ SWFMovie_nextFrame(mo);
+
+ // Create a nested MovieClip. The clip mc3 contains a
+ // copy of mc with a funny translation.
+ mc3 = newSWFMovieClip();
+ it = SWFMovieClip_add(mc3, (SWFBlock)mc);
+ SWFDisplayItem_setName(it, "mc3_mc1");
+ SWFDisplayItem_setMatrix(it, 0.5f, 0.1f, -0.1f, 0.5f, 20.f, 20.f);
+ SWFMovieClip_nextFrame(mc3);
+
+ it = SWFMovie_add(mo, (SWFBlock)mc3);
+ SWFDisplayItem_setName(it, "mc3");
+
+ // This shows that the matrix of sub-clips is used.
+ add_actions(mo,
+ "b = new flash.display.BitmapData(400, 400, false);"
+ "b.draw(mc3);"
+
+ // Re-use an earlier dynamic clip.
+ "_root.dynmc2._y = 200;"
+ "_root.dynmc2._x = 200;"
+ "_root.dynmc2.attachBitmap(b, 28);"
+ );
+
+ // Top left corner is white
+ check_equals(mo, "b.getPixel(1, 1)", "0xffffff");
+ check_equals(mo, "b.getPixel(8, 8)", "0xffffff");
+ // Cyan square top left corner
+ xcheck_equals(mo, "b.getPixel(25, 28)", "0x00ffff");
+ check_equals(mo, "b.getPixel(20, 30)", "0xffffff");
+ check_equals(mo, "b.getPixel(25, 25)", "0xffffff");
+ // Cyan square bottom left (Check that it's rotated).
+ xcheck_equals(mo, "b.getPixel(18, 68)", "0x00ffff");
+ // Cyan square top right
+ xcheck_equals(mo, "b.getPixel(64, 36)", "0x00ffff");
+ check_equals(mo, "b.getPixel(64, 32)", "0xffffff");
+ // Magenta square top left
+ xcheck_equals(mo, "b.getPixel(54, 71)", "0xff00ff");
+ xcheck_equals(mo, "b.getPixel(54, 67)", "0x00ffff");
+ xcheck_equals(mo, "b.getPixel(50, 71)", "0x00ffff");
+ // Magenta square bottom right
+ check_equals(mo, "b.getPixel(74, 94)", "0xffffff");
+ xcheck_equals(mo, "b.getPixel(70, 94)", "0xff00ff");
+
+ SWFMovie_nextFrame(mo);
+
+ // Add a MovieClip with an image.
+
+ char file[] = "/green.jpg";
+ if (strlen(mediadir) > 1024) {
+ fprintf(stderr, "Path to media dir too long! Fix the testcase");
+ }
+ char path[1024 + sizeof file];
+ strcpy(path, mediadir);
+ strcat(path, file);
+
+ inp = newSWFInput_filename(path);
+ bp = (SWFBitmap)newSWFJpegBitmap_fromInput(inp);
+
+ // Image clip
+ mc5 = newSWFMovieClip();
+ SWFMovieClip_add(mc5, (SWFBlock)bp);
+ SWFMovieClip_nextFrame(mc5);
+
+ // Container clip for image clip.
+ mc4 = newSWFMovieClip();
+ it = SWFMovieClip_add(mc4, (SWFBlock)mc5);
+ SWFDisplayItem_setMatrix(it, 0.75f, -0.2f, 0.3f, 0.35f, 20, 30);
+ SWFMovieClip_nextFrame(mc4);
+
+ it = SWFMovie_add(mo, (SWFBlock)mc4);
+ SWFDisplayItem_setName(it, "mc4");
+
+ // Draw on top of the old Bitmap!
+ add_actions(mo, "b.draw(mc4);");
+
+ check_equals(mo, "b.getPixel(1, 1)", "0xffffff");
+ check_equals(mo, "b.getPixel(8, 8)", "0xffffff");
+ // Cyan square top left corner
+ // Note: The following pixels shouldn't suffer from antialiasing,
+ // but not sure how accurate Gnash will be.
+ xcheck_equals(mo, "b.getPixel(27, 30)", "0x000010");
+ // Cyan square bottom left
+ xcheck_equals(mo, "b.getPixel(18, 68)", "0x00ffff");
+ // Cyan square top right
+ xcheck_equals(mo, "b.getPixel(65, 36)", "0xfffffd");
+ // Magenta square top left
+ xcheck_equals(mo, "b.getPixel(62, 71)", "0x1000f");
+ xcheck_equals(mo, "b.getPixel(50, 71)", "0x00ffff");
+ // Magenta square bottom right
+ check_equals(mo, "b.getPixel(74, 94)", "0xffffff");
+ xcheck_equals(mo, "b.getPixel(70, 94)", "0xff00ff");
+
+ add_actions(mo, "stop();");
+
+ // Output movie
+ puts("Saving " OUTPUT_FILENAME);
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return EXIT_SUCCESS;
+}
=== added file 'testsuite/misc-ming.all/BitmapDataTestRunner.cpp'
--- a/testsuite/misc-ming.all/BitmapDataTestRunner.cpp 1970-01-01 00:00:00
+0000
+++ b/testsuite/misc-ming.all/BitmapDataTestRunner.cpp 2010-07-26 07:48:26
+0000
@@ -0,0 +1,198 @@
+//
+// Copyright (C) 2007, 2008, 2009, 2010 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 "BitmapDataTest.swf"
+
+#include "MovieTester.h"
+#include "MovieClip.h"
+#include "DisplayObject.h"
+#include "DisplayList.h"
+#include "log.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+#include <sstream>
+
+using namespace gnash;
+using namespace gnash::geometry;
+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);
+
+ MovieClip* root = tester.getRootMovie();
+ assert(root);
+
+ const rgba white(255, 255, 255, 255);
+ const rgba blue(0, 0, 255, 255);
+ const rgba cyan(0, 255, 255, 255);
+ const rgba green(0, 255, 0, 255);
+ const rgba yellow(255, 255, 0, 255);
+ const rgba magenta(255, 0, 255, 255);
+ const rgba red(255, 0, 0, 255);
+
+ // Frame 1
+ tester.advance();
+ check_pixel(15, 15, 1, yellow, 8);
+ check_pixel(80, 80, 1, green, 8);
+ check_pixel(95, 95, 1, green, 8);
+
+ // Frame 2
+ tester.click();
+ tester.advance();
+ check_pixel(15, 15, 1, yellow, 8);
+ check_pixel(80, 80, 1, green, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, blue, 8);
+
+ // Frame 3
+ tester.click();
+ tester.advance();
+ check_pixel(15, 15, 1, yellow, 8);
+ check_pixel(80, 80, 1, white, 8);
+ check_pixel(95, 95, 1, white, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ // Frame 4
+ tester.click();
+ tester.advance();
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(80, 80, 1, white, 8);
+ check_pixel(95, 95, 1, white, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, magenta, 8);
+
+ // Frame 5 (same as previous).
+ tester.click();
+ tester.advance();
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(80, 80, 1, white, 8);
+ check_pixel(95, 95, 1, white, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, magenta, 8);
+
+ // Frame 6
+ tester.click();
+ tester.advance();
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(80, 80, 1, green, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, blue, 8);
+
+ check_pixel(315, 15, 1, magenta, 8);
+
+ // Frame 7 (no change)
+ tester.click();
+ tester.advance();
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(80, 80, 1, green, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, blue, 8);
+
+ check_pixel(315, 15, 1, magenta, 8);
+
+ // Frame 8
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, white, 8);
+ check_pixel(15, 15, 1, yellow, 8);
+ check_pixel(30, 30, 1, red, 8);
+ check_pixel(80, 80, 1, green, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, blue, 8);
+
+ check_pixel(315, 15, 1, white, 8);
+
+ // Frame 9
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, red, 8);
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(30, 30, 1, red, 8);
+ check_pixel(95, 95, 1, white, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, white, 8);
+
+ // Frame 10 (no change)
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, red, 8);
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(30, 30, 1, red, 8);
+ check_pixel(95, 95, 1, white, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, white, 8);
+
+ // Frame 11
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, white, 8);
+ check_pixel(30, 30, 1, blue, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, white, 8);
+
+ // Frame 12 (no change)
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, white, 8);
+ check_pixel(30, 30, 1, blue, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, white, 8);
+
+ // Frame 13 (red square, same as frame 9).
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, red, 8);
+ check_pixel(15, 15, 1, red, 8);
+ check_pixel(30, 30, 1, red, 8);
+ check_pixel(95, 95, 1, white, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(315, 15, 1, white, 8);
+
+ // Frame 13
+ tester.click();
+ tester.advance();
+ check_pixel(1, 1, 1, white, 8);
+ check_pixel(30, 30, 1, blue, 8);
+ check_pixel(95, 95, 1, blue, 8);
+ check_pixel(115, 115, 1, white, 8);
+
+ check_pixel(325, 35, 1, blue, 8);
+
+ // Frame 14 (noise patterns, doesn't make much sense to test externally).
+ tester.click();
+ tester.advance();
+
+}
+
=== modified file 'testsuite/misc-ming.all/Makefile.am'
--- a/testsuite/misc-ming.all/Makefile.am 2010-07-12 11:52:24 +0000
+++ b/testsuite/misc-ming.all/Makefile.am 2010-07-29 06:24:31 +0000
@@ -194,7 +194,11 @@
runtime_vm_stack_test \
new_child_in_unload_test \
instanceNameTest \
+ BeginBitmapFill \
+ BeginBitmapFillRunner \
BitmapDataTest \
+ BitmapDataTestRunner \
+ BitmapDataDraw \
BitmapSmoothingTest \
$(NULL)
@@ -261,6 +265,7 @@
endif
check_SCRIPTS = \
+ BitmapDataDrawRunner \
DeviceFontTestRunner \
EmbeddedFontTestRunner \
TextSnapshotTest-Runner \
@@ -1572,6 +1577,74 @@
BitmapDataTest.swf: BitmapDataTest
./BitmapDataTest $(abs_mediadir)
+BitmapDataTestRunner_SOURCES = \
+ BitmapDataTestRunner.cpp \
+ $(NULL)
+
+BitmapDataTestRunner_CXXFLAGS = \
+ -DSRCDIR='"$(srcdir)"' \
+ -DTGTDIR='"$(abs_builddir)"' \
+ $(NULL)
+
+BitmapDataTestRunner_LDADD = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(AM_LDFLAGS) \
+ $(NULL)
+
+BitmapDataTestRunner_DEPENDENCIES = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ BitmapDataTest.swf \
+ $(NULL)
+
+BitmapDataDraw_SOURCES = \
+ BitmapDataDraw.c \
+ $(NULL)
+
+BitmapDataDraw_CFLAGS = \
+ -DMEDIADIR='"$(abs_mediadir)"' \
+ $(NULL)
+
+BitmapDataDraw_LDADD = libgnashmingutils.la
+
+BitmapDataDraw.swf: BitmapDataDraw
+ ./BitmapDataDraw $(abs_mediadir)
+
+BitmapDataDrawRunner: $(srcdir)/../generic-testrunner.sh BitmapDataDraw.swf
+ sh $< $(top_builddir) BitmapDataDraw.swf > $@
+ chmod 755 $@
+
+BeginBitmapFill_SOURCES = \
+ BeginBitmapFill.c \
+ $(NULL)
+
+BeginBitmapFill_CFLAGS = \
+ -DMEDIADIR='"$(abs_mediadir)"' \
+ $(NULL)
+
+BeginBitmapFill_LDADD = libgnashmingutils.la
+
+BeginBitmapFill.swf: BeginBitmapFill
+ ./BeginBitmapFill $(abs_mediadir)
+
+BeginBitmapFillRunner_SOURCES = \
+ BeginBitmapFillRunner.cpp \
+ $(NULL)
+
+BeginBitmapFillRunner_CXXFLAGS = \
+ -DSRCDIR='"$(srcdir)"' \
+ -DTGTDIR='"$(abs_builddir)"' \
+ $(NULL)
+
+BeginBitmapFillRunner_LDADD = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(AM_LDFLAGS) \
+ $(NULL)
+
+BeginBitmapFillRunner_DEPENDENCIES = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ BeginBitmapFill.swf \
+ $(NULL)
+
EmbeddedSoundTest_SOURCES = \
EmbeddedSoundTest.c \
$(NULL)
@@ -2145,6 +2218,9 @@
TEST_DRIVERS = ../simple.exp
TEST_CASES = \
+ BeginBitmapFillRunner \
+ BitmapDataTestRunner \
+ BitmapDataDrawRunner \
LoadVarsTestRunner \
DeviceFontTestRunner \
EmbeddedFontTestRunner \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12339: Add testcases.,
Benjamin Wolsey <=