gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. a2938126c00bb70b00e6


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. a2938126c00bb70b00e661eb5b7aa7f3ce7a6706
Date: Thu, 21 Oct 2010 11:41:25 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  a2938126c00bb70b00e661eb5b7aa7f3ce7a6706 (commit)
       via  37ff91ea4fd39f3a5f25dfdbf76a38767a677f94 (commit)
       via  85d65d84cbf4beb3e258298f10a0c05f0ae5538e (commit)
       via  4cc1a4157b97c77286f9f2e9a45de3aa5e360bc1 (commit)
       via  993a1e961de5ab2fd93e8ee49582de5ad50bb62c (commit)
      from  4a80536ce996db998c99e611f1f9425c95eabc00 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=a2938126c00bb70b00e661eb5b7aa7f3ce7a6706


commit a2938126c00bb70b00e661eb5b7aa7f3ce7a6706
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 21 13:35:14 2010 +0200

    Add documentation.

diff --git a/libcore/parser/TypesParser.h b/libcore/parser/TypesParser.h
index db7759c..e724759 100644
--- a/libcore/parser/TypesParser.h
+++ b/libcore/parser/TypesParser.h
@@ -57,8 +57,10 @@ typedef std::pair<FillStyle, boost::optional<FillStyle> > 
OptionalFillPair;
 OptionalFillPair readFills(SWFStream& in, SWF::TagType t, movie_definition& m,
         bool readMorph);
 
+/// Read a RGB CxForm from the input stream
 SWFCxForm readCxFormRGB(SWFStream& in);
 
+/// Read a CxForm with alpha from the input stream
 SWFCxForm readCxFormRGBA(SWFStream& in);
 
 } // namespace gnash

http://git.savannah.gnu.org/cgit//commit/?id=37ff91ea4fd39f3a5f25dfdbf76a38767a677f94


commit 37ff91ea4fd39f3a5f25dfdbf76a38767a677f94
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 21 13:29:59 2010 +0200

    Run test.

diff --git a/testsuite/libcore.all/Makefile.am 
b/testsuite/libcore.all/Makefile.am
index abe1f69..7a1c30c 100644
--- a/testsuite/libcore.all/Makefile.am
+++ b/testsuite/libcore.all/Makefile.am
@@ -44,6 +44,7 @@ check_PROGRAMS = \
        DisplayListTest \
        ClassSizes \
        SafeStackTest \
+       CxFormTest \
        $(NULL)
 
 if ENABLE_AVM2
@@ -111,6 +112,9 @@ ClassSizes_LDADD = $(AM_LDFLAGS)
 SafeStackTest_SOURCES = SafeStackTest.cpp
 SafeStackTest_LDADD = $(AM_LDFLAGS)
 
+CxFormTest_SOURCES = CxFormTest.cpp
+CxFormTest_LDADD = $(AM_LDFLAGS)
+
 CodeStreamTest_SOURCES = CodeStreamTest.cpp
 CodeStreamTest_LDADD = $(AM_LDFLAGS)
 CodeStreamTest_DEPENDENCIES = $(AM_LDFLAGS)

http://git.savannah.gnu.org/cgit//commit/?id=85d65d84cbf4beb3e258298f10a0c05f0ae5538e


commit 85d65d84cbf4beb3e258298f10a0c05f0ae5538e
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 21 13:29:45 2010 +0200

    Add unit test for CxForm.

diff --git a/testsuite/libcore.all/CxFormTest.cpp 
b/testsuite/libcore.all/CxFormTest.cpp
new file mode 100644
index 0000000..f265eab
--- /dev/null
+++ b/testsuite/libcore.all/CxFormTest.cpp
@@ -0,0 +1,98 @@
+// 
+//   Copyright (C) 2005, 2006, 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
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include "log.h"
+
+#include <iostream>
+#include <sstream>
+#include <cassert>
+#include <cmath>
+#include <string>
+
+#include "check.h"
+#include "SWFCxForm.h"
+
+int main()
+{
+    gnash::SWFCxForm c;
+
+    // A default constructed CxForm must be:
+    // 256, 256, 256, 256, 0, 0, 0, 0.
+    check_equals(c.ra, 256);
+    check_equals(c.ba, 256);
+    check_equals(c.ga, 256);
+    check_equals(c.aa, 256);
+    check_equals(c.rb, 0);
+    check_equals(c.bb, 0);
+    check_equals(c.gb, 0);
+    check_equals(c.ab, 0);
+    
+    boost::uint8_t r = 0;
+    boost::uint8_t b = 0;
+    boost::uint8_t g = 0;
+    boost::uint8_t a = 0;
+
+    c.transform(r, b, g, a);
+    check_equals(r, 0);
+    check_equals(b, 0);
+    check_equals(g, 0);
+    check_equals(a, 0);
+
+    r = 255;
+    b = 255;
+    g = 0;
+    a = 0;
+
+    c.transform(r, b, g, a);
+    check_equals(+r, 255);
+    check_equals(+b, 255);
+    check_equals(+g, 0);
+    check_equals(+a, 0);
+
+    c.rb = 30000;
+    c.gb = -30000;
+
+    r = 255;
+    b = 255;
+    g = 0;
+    a = 0;
+
+    c.transform(r, b, g, a);
+    check_equals(+r, 255);
+    check_equals(+b, 0);
+    check_equals(+g, 0);
+    check_equals(+a, 0);
+
+    c.ba = 30000;
+    c.aa = -30000;
+
+    r = 255;
+    b = 100;
+    g = 1;
+    a = 60;
+
+    c.transform(r, b, g, a);
+    check_equals(+r, 255);
+    check_equals(+b, 0);
+    check_equals(+g, 117);
+    check_equals(+a, 0);
+}

http://git.savannah.gnu.org/cgit//commit/?id=4cc1a4157b97c77286f9f2e9a45de3aa5e360bc1


commit 4cc1a4157b97c77286f9f2e9a45de3aa5e360bc1
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 21 13:11:43 2010 +0200

    Remove verbose casts as the conversion is performed anyway.

diff --git a/libcore/SWFCxForm.cpp b/libcore/SWFCxForm.cpp
index f8a028c..1197d53 100644
--- a/libcore/SWFCxForm.cpp
+++ b/libcore/SWFCxForm.cpp
@@ -60,20 +60,20 @@ SWFCxForm::transform(boost::uint8_t& r, boost::uint8_t& g, 
boost::uint8_t& b,
         boost::uint8_t& a) const
 {
     // force conversion to int16 first, kind of optimization.
-    boost::int16_t rt = (boost::int16_t)r;
-    boost::int16_t gt = (boost::int16_t)g;
-    boost::int16_t bt = (boost::int16_t)b;
-    boost::int16_t at = (boost::int16_t)a;
+    boost::int16_t rt = r;
+    boost::int16_t gt = g;
+    boost::int16_t bt = b;
+    boost::int16_t at = a;
     
     rt = (rt * ra >> 8) + rb;
     gt = (gt * ga >> 8) + gb;
     bt = (bt * ba >> 8) + bb;
     at = (at * aa >> 8) + ab;
 
-    r = (boost::uint8_t)(clamp<boost::int16_t>(rt, 0, 255));
-    g = (boost::uint8_t)(clamp<boost::int16_t>(gt, 0, 255));
-    b = (boost::uint8_t)(clamp<boost::int16_t>(bt, 0, 255));
-    a = (boost::uint8_t)(clamp<boost::int16_t>(at, 0, 255));
+    r = clamp<boost::int16_t>(rt, 0, 255);
+    g = clamp<boost::int16_t>(gt, 0, 255);
+    b = clamp<boost::int16_t>(bt, 0, 255);
+    a = clamp<boost::int16_t>(at, 0, 255);
 }
 
 std::ostream&

http://git.savannah.gnu.org/cgit//commit/?id=993a1e961de5ab2fd93e8ee49582de5ad50bb62c


commit 993a1e961de5ab2fd93e8ee49582de5ad50bb62c
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 21 13:00:29 2010 +0200

    Handle CxForm in types parser.

diff --git a/libcore/SWFCxForm.cpp b/libcore/SWFCxForm.cpp
index 713deb6..f8a028c 100644
--- a/libcore/SWFCxForm.cpp
+++ b/libcore/SWFCxForm.cpp
@@ -16,15 +16,13 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-// 
-//
-
 #include "SWFCxForm.h"
+
+#include <iomanip>
+
 #include "RGBA.h" 
-#include "SWFStream.h" // for reading from SWF
 #include "log.h"
 #include "GnashNumeric.h"
-#include <iomanip>
 
 namespace gnash {
 
@@ -78,86 +76,6 @@ SWFCxForm::transform(boost::uint8_t& r, boost::uint8_t& g, 
boost::uint8_t& b,
     a = (boost::uint8_t)(clamp<boost::int16_t>(at, 0, 255));
 }
 
-void
-SWFCxForm::read_rgb(SWFStream& in)
-{
-    in.align();
-
-    in.ensureBits(6);
-    int  field =  in.read_uint(6);
-    bool has_add  =  field & (1 << 5);
-    bool has_mult =  field & (1 << 4);
-    int  nbits = field & 0x0f;
-
-    int reads = has_mult + has_add; // 0, 1 or 2
-    assert(reads <= 2);
-    if ( reads ) {
-        in.ensureBits(nbits*reads*3);
-    }
-    else {
-        return;
-    }
-
-    if (has_mult) {
-        ra = in.read_sint(nbits);
-        ga = in.read_sint(nbits);
-        ba = in.read_sint(nbits);
-        aa = 256;
-    }
-    else {
-        ra = ga = ba = aa = 256; 
-    }
-    if (has_add) {
-        rb = in.read_sint(nbits);
-        gb = in.read_sint(nbits);
-        bb = in.read_sint(nbits);
-        ab = 0;
-    }
-    else {
-        rb = gb = bb = ab = 0; 
-    }
-}
-
-void
-SWFCxForm::read_rgba(SWFStream& in)
-{
-    in.align();
-
-    in.ensureBits(6);
-    int  field =  in.read_uint(6);
-    bool has_add  =  field & (1 << 5);
-    bool has_mult =  field & (1 << 4);
-    int  nbits = field & 0x0f;
-
-    int reads = has_mult + has_add; // 0, 1 or 2
-    assert(reads <= 2);
-    if ( reads ) {
-        in.ensureBits(nbits*reads*4);
-    }
-    else {
-        return;
-    }
-
-    if (has_mult) {
-        ra = in.read_sint(nbits);
-        ga = in.read_sint(nbits);
-        ba = in.read_sint(nbits);
-        aa = in.read_sint(nbits);
-    }
-    else {
-        ra = ga = ba = aa = 256; 
-    }
-    if (has_add) {
-        rb = in.read_sint(nbits);
-        gb = in.read_sint(nbits);
-        bb = in.read_sint(nbits);
-        ab = in.read_sint(nbits);
-    }
-    else {
-        rb = gb = bb = ab = 0; 
-    }
-}
-
 std::ostream&
 operator<<(std::ostream& os, const SWFCxForm& cx) 
 {
diff --git a/libcore/SWFCxForm.h b/libcore/SWFCxForm.h
index 50a02c7..b71585e 100644
--- a/libcore/SWFCxForm.h
+++ b/libcore/SWFCxForm.h
@@ -26,7 +26,6 @@
 
 namespace gnash {
        class rgba;
-       class SWFStream;
 }
 
 namespace gnash {
@@ -73,12 +72,6 @@ public:
     void transform(boost::uint8_t& r, boost::uint8_t& g, boost::uint8_t& b,
             boost::uint8_t& a) const;    
     
-    /// Read RGB from the SWF input stream.
-    void read_rgb(SWFStream& in);
-
-    /// Read RGBA from the SWF input stream.
-    void read_rgba(SWFStream& in);
-
 };
 
 inline bool
diff --git a/libcore/parser/TypesParser.cpp b/libcore/parser/TypesParser.cpp
index 341d582..a6d5062 100644
--- a/libcore/parser/TypesParser.cpp
+++ b/libcore/parser/TypesParser.cpp
@@ -28,6 +28,7 @@
 #include "RGBA.h"
 #include "SWFMatrix.h"
 #include "SWFRect.h"
+#include "SWFCxForm.h"
 #include "FillStyle.h"
 #include "log.h"
 #include "movie_definition.h"
@@ -308,6 +309,74 @@ readFills(SWFStream& in, SWF::TagType t, movie_definition& 
md, bool readMorph)
     }
 }
 
+SWFCxForm
+readCxFormRGB(SWFStream& in)
+{
+    in.align();
+
+    in.ensureBits(6);
+    const boost::uint8_t field =  in.read_uint(6);
+    const bool has_add = field & (1 << 5);
+    const bool has_mult = field & (1 << 4);
+    const boost::uint8_t nbits = field & 0x0f;
+    const size_t reads = has_mult + has_add; // 0, 1 or 2
+
+    SWFCxForm ret;
+
+    if (!reads) return ret;
+
+    if (has_mult) {
+        ret.ra = in.read_sint(nbits);
+        ret.ga = in.read_sint(nbits);
+        ret.ba = in.read_sint(nbits);
+        // aa is already 256.
+    }
+
+    if (has_add) {
+        ret.rb = in.read_sint(nbits);
+        ret.gb = in.read_sint(nbits);
+        ret.bb = in.read_sint(nbits);
+        // ab is already 0.
+    }
+    return ret;
+}
+
+SWFCxForm
+readCxFormRGBA(SWFStream& in)
+{
+    in.align();
+
+    in.ensureBits(6);
+    const boost::uint8_t field =  in.read_uint(6);
+    const bool has_add = field & (1 << 5);
+    const bool has_mult = field & (1 << 4);
+    const boost::uint8_t nbits = field & 0x0f;
+    const size_t reads = has_mult + has_add; // 0, 1 or 2
+
+    SWFCxForm ret;
+
+    if (!reads) return ret;
+    
+    in.ensureBits(nbits * reads * 4);
+
+    // Default is 256 for these values.
+    if (has_mult) {
+        ret.ra = in.read_sint(nbits);
+        ret.ga = in.read_sint(nbits);
+        ret.ba = in.read_sint(nbits);
+        ret.aa = in.read_sint(nbits);
+    }
+
+    if (has_add) {
+        ret.rb = in.read_sint(nbits);
+        ret.gb = in.read_sint(nbits);
+        ret.bb = in.read_sint(nbits);
+        ret.ab = in.read_sint(nbits);
+    }
+    return ret;
+}
+
+
 namespace {
 
 OptionalFillPair
diff --git a/libcore/parser/TypesParser.h b/libcore/parser/TypesParser.h
index e04064e..db7759c 100644
--- a/libcore/parser/TypesParser.h
+++ b/libcore/parser/TypesParser.h
@@ -20,7 +20,6 @@
 #ifndef GNASH_TYPESPARSER_H
 #define GNASH_TYPESPARSER_H
 
-
 #include <boost/optional.hpp>
 
 #include "SWF.h"
@@ -29,6 +28,7 @@ namespace gnash {
     class SWFStream;
     class SWFMatrix;
     class SWFRect;
+    class SWFCxForm;
     class rgba;
     class movie_definition;
     class FillStyle;
@@ -57,6 +57,9 @@ typedef std::pair<FillStyle, boost::optional<FillStyle> > 
OptionalFillPair;
 OptionalFillPair readFills(SWFStream& in, SWF::TagType t, movie_definition& m,
         bool readMorph);
 
+SWFCxForm readCxFormRGB(SWFStream& in);
+
+SWFCxForm readCxFormRGBA(SWFStream& in);
 
 } // namespace gnash
 
diff --git a/libcore/swf/DefineButtonTag.cpp b/libcore/swf/DefineButtonTag.cpp
index df4fbde..b149ce0 100644
--- a/libcore/swf/DefineButtonTag.cpp
+++ b/libcore/swf/DefineButtonTag.cpp
@@ -23,6 +23,8 @@
 
 #include "DefineButtonTag.h"
 
+#include <string>
+
 #include "TypesParser.h"
 #include "RunResources.h"
 #include "smart_ptr.h" // GNASH_USE_GC
@@ -432,7 +434,7 @@ ButtonRecord::read(SWFStream& in, TagType t,
     _matrix = readSWFMatrix(in);
 
     if (t == SWF::DEFINEBUTTON2) {
-        _cxform.read_rgba(in);
+        _cxform = readCxFormRGBA(in);
     }
 
     if (buttonHasFilterList) {
diff --git a/libcore/swf/DefineButtonTag.h b/libcore/swf/DefineButtonTag.h
index 4470369..3d9f034 100644
--- a/libcore/swf/DefineButtonTag.h
+++ b/libcore/swf/DefineButtonTag.h
@@ -21,20 +21,21 @@
 #ifndef GNASH_SWF_DEFINEBUTTONTAG_H
 #define GNASH_SWF_DEFINEBUTTONTAG_H
 
-#include "DefinitionTag.h"
-#include "SWFMatrix.h" // for composition
-#include "SWFCxForm.h" // for composition
-#include "action_buffer.h" // for composition of ButtonAction
-#include "filter_factory.h" // for Filters (composition of button_record)
-#include "DefineButtonSoundTag.h"
-#include "SWF.h"
-#include "Button.h"
-
 #include <vector>
 #include <boost/scoped_ptr.hpp>
 #include <boost/cstdint.hpp> 
 #include <memory>
 
+#include "DefinitionTag.h"
+#include "SWFMatrix.h" 
+#include "SWFCxForm.h" 
+#include "action_buffer.h" 
+#include "filter_factory.h" 
+#include "TypesParser.h"
+#include "DefineButtonSoundTag.h"
+#include "SWF.h"
+#include "Button.h"
+
 // Forward declarations
 namespace gnash {
     class movie_definition;
@@ -79,7 +80,7 @@ public:
     /// Cxform is stored in a different tag for SWF2 Buttons
     /// (DEFINEBUTTON tag)
     void readRGBTransform(SWFStream& in) {
-        _cxform.read_rgb(in);
+        _cxform = readCxFormRGB(in);
     }
 
     /// Read a ButtonRecord from the SWF stream.
diff --git a/libcore/swf/PlaceObject2Tag.cpp b/libcore/swf/PlaceObject2Tag.cpp
index 311b8d5..aa23a02 100644
--- a/libcore/swf/PlaceObject2Tag.cpp
+++ b/libcore/swf/PlaceObject2Tag.cpp
@@ -60,7 +60,7 @@ PlaceObject2Tag::readPlaceObject(SWFStream& in)
         m_has_flags2 |= HAS_MATRIX_MASK;
         if (in.tell() < in.get_tag_end_position())
         {
-            m_color_transform.read_rgb(in);
+            m_color_transform = readCxFormRGB(in);
             m_has_flags2 |= HAS_CXFORM_MASK;
         }
     }
@@ -279,7 +279,7 @@ PlaceObject2Tag::readPlaceObject2(SWFStream& in)
 
     if ( hasCxform() )
     {
-        m_color_transform.read_rgba(in);
+        m_color_transform = readCxFormRGBA(in);
     }
 
     if ( hasRatio() )
@@ -366,7 +366,7 @@ PlaceObject2Tag::readPlaceObject3(SWFStream& in)
     }
 
     if (hasCxform()) {
-        m_color_transform.read_rgba(in);
+        m_color_transform = readCxFormRGBA(in);
     }
 
     if (hasRatio()) {

-----------------------------------------------------------------------

Summary of changes:
 libcore/SWFCxForm.cpp                |  104 ++++------------------------------
 libcore/SWFCxForm.h                  |    7 --
 libcore/parser/TypesParser.cpp       |   69 ++++++++++++++++++++++
 libcore/parser/TypesParser.h         |    7 ++-
 libcore/swf/DefineButtonTag.cpp      |    4 +-
 libcore/swf/DefineButtonTag.h        |   21 ++++---
 libcore/swf/PlaceObject2Tag.cpp      |    6 +-
 testsuite/libcore.all/CxFormTest.cpp |   98 ++++++++++++++++++++++++++++++++
 testsuite/libcore.all/Makefile.am    |    4 +
 9 files changed, 205 insertions(+), 115 deletions(-)
 create mode 100644 testsuite/libcore.all/CxFormTest.cpp


hooks/post-receive
-- 
Gnash



reply via email to

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