gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11746: Tests, bug fixes, documentat


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11746: Tests, bug fixes, documentation, and code cleanups.
Date: Wed, 13 Jan 2010 11:19:49 +0100
User-agent: Bazaar (2.0.2)

------------------------------------------------------------
revno: 11746 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2010-01-13 11:19:49 +0100
message:
  Tests, bug fixes, documentation, and code cleanups.
modified:
  backend/Renderer_agg_style.h
  libcore/CharacterProxy.cpp
  libcore/DynamicShape.cpp
  libcore/MovieClip.cpp
  libcore/abc/AbcBlock.cpp
  libcore/asobj/flash/display/MovieClip_as.cpp
  libcore/asobj/flash/text/TextFormat_as.cpp
  libcore/fill_style.cpp
  libcore/fill_style.h
  libcore/vm/Machine.cpp
  libcore/vm/VM.cpp
  testsuite/actionscript.all/TextFormat.as
  testsuite/actionscript.all/XML.as
=== modified file 'backend/Renderer_agg_style.h'
--- a/backend/Renderer_agg_style.h      2010-01-11 06:41:38 +0000
+++ b/backend/Renderer_agg_style.h      2010-01-13 07:54:28 +0000
@@ -65,9 +65,9 @@
 private:
 
   // for solid styles:
-  bool _solid;
+  const bool _solid;
 
-  agg::rgba8 _color; 
+  const agg::rgba8 _color; 
   
 };
 
@@ -82,9 +82,6 @@
     :
     agg_style_base(true, color)
   {
-#ifdef DEBUG_LIMIT_COLOR_ALPHA
-    m_color.a = m_color.a>127 ? 127 : m_color.a;
-#endif    
   }
 
   void generate_span(agg::rgba8* /*span*/, int /*x*/, int /*y*/,
@@ -199,15 +196,16 @@
     // Build gradient lookup table
     m_gradient_lut.remove_all(); 
     
-    for (int i = 0, e = fs.get_color_stop_count(); i != e; ++i) {
+    const size_t size = fs.get_color_stop_count();
+    
+    // It is essential that at least two colours are added; otherwise agg
+    // will use uninitialized values.
+    assert(size > 1);
+
+    for (int i = 0; i != size; ++i) {
     
       const gradient_record& gr = fs.get_color_stop(i); 
       rgba trans_color = m_cx.transform(gr.m_color);
-      
-#ifdef DEBUG_LIMIT_COLOR_ALPHA
-      trans_color.m_a = trans_color.m_a>127 ? 127 : trans_color.m_a;
-#endif
-
       if (trans_color.m_a < 255) m_need_premultiply = true;    
       
       m_gradient_lut.add_color(gr.m_ratio/255.0, agg::rgba8(trans_color.m_r, 

=== modified file 'libcore/CharacterProxy.cpp'
--- a/libcore/CharacterProxy.cpp        2010-01-11 06:41:38 +0000
+++ b/libcore/CharacterProxy.cpp        2010-01-13 09:32:19 +0000
@@ -23,11 +23,10 @@
 #endif
 
 #include "CharacterProxy.h"
-
-#include "utility.h" // for typeName
-#include "DisplayObject.h" // for isDestroyed, getOrigTarget, ...
-#include "VM.h" // for VM::getRoot()
-#include "movie_root.h" // for findCharacterByTarget
+#include "utility.h"
+#include "DisplayObject.h" 
+#include "VM.h" 
+#include "movie_root.h" 
 
 #include <string>
 

=== modified file 'libcore/DynamicShape.cpp'
--- a/libcore/DynamicShape.cpp  2010-01-01 17:48:26 +0000
+++ b/libcore/DynamicShape.cpp  2010-01-08 09:49:57 +0000
@@ -107,7 +107,8 @@
 DynamicShape::beginLinearGradientFill(const std::vector<gradient_record>& 
grad, const SWFMatrix& mat)
 {
        // Add the new fill style and set as current
-       fill_style style; style.setLinearGradient(grad, mat);
+       fill_style style;
+    style.setLinearGradient(grad, mat);
 
        endFill();
 

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2010-01-11 06:41:38 +0000
+++ b/libcore/MovieClip.cpp     2010-01-13 09:32:52 +0000
@@ -1740,8 +1740,8 @@
 }
 
 
-/// register DisplayObjects as key listeners if they have clip key events 
defined.
-/// Don't call twice for the same chracter.
+/// Register DisplayObjects as key listeners if they have clip key events
+/// defined. Don't call twice for the same character.
 void
 MovieClip::registerAsListener()
 {

=== modified file 'libcore/abc/AbcBlock.cpp'
--- a/libcore/abc/AbcBlock.cpp  2010-01-01 17:48:26 +0000
+++ b/libcore/abc/AbcBlock.cpp  2010-01-13 07:48:10 +0000
@@ -1212,6 +1212,10 @@
                method.setBody(new CodeStream(body));
                
         // Exception count and exceptions
+        
+        // Note: catch type and variable name are documented to be
+        // indices in the string pool, but they are in fact indices
+        // in the multiname pool.
                const boost::uint32_t ecount = _stream->read_V32();
                for (unsigned int j = 0; j < ecount; ++j) {
                        asException *ex = mCH->newException();

=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp      2010-01-01 17:48:26 
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp      2010-01-08 10:37:35 
+0000
@@ -37,6 +37,7 @@
 #include "builtin_function.h" // need builtin_function
 #include "NativeFunction.h" 
 #include "Bitmap.h"
+#include "Array_as.h"
 
 #include <boost/lexical_cast.hpp>
 
@@ -1900,13 +1901,22 @@
     return as_value();
 }
 
+
+/// Create a dynamic gradient fill.
+//
+/// fillType, colors, alphas, ratios, matrix, [spreadMethod,
+/// [interpolationMethod, [focalPointRatio]]]
+//
+/// Colors, alphas and ratios must be (possibly fake) arrays, and must have
+/// the same size. This applies even when there are more gradients than
+/// allowed.
 as_value
 movieclip_beginGradientFill(const fn_call& fn)
 {
     MovieClip* movieclip = ensure<IsDisplayObject<MovieClip> >(fn);
 
-    if ( fn.nargs < 5 )
-    {
+    // The arguments up to and including matrix must be present.
+    if (fn.nargs < 5) {
         IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
         log_aserror(_("%s.beginGradientFill(%s): invalid call: 5 arguments "
@@ -1916,22 +1926,20 @@
         return as_value();
     }
 
-    IF_VERBOSE_ASCODING_ERRORS(
-    if ( fn.nargs > 5 )
-    {
+    // There are optional arguments that we do not implement!
+    if (fn.nargs > 5) {
         std::stringstream ss; fn.dump_args(ss);
-        log_aserror(_("MovieClip.beginGradientFill(%s): args after "
-                        "the first five will be discarded"), ss.str());
+        LOG_ONCE(log_unimpl(_("MovieClip.beginGradientFill(%s): args after "
+                        "the first five will be discarded"), ss.str()));
     }
-    );
 
     bool radial = false;
     std::string typeStr = fn.arg(0).to_string();
+
     // Case-sensitive comparison needed for this ...
-    if ( typeStr == "radial" ) radial = true;
-    else if ( typeStr == "linear" ) radial = false;
-    else
-    {
+    if (typeStr == "radial") radial = true;
+    else if (typeStr == "linear") radial = false;
+    else {
         IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
         log_aserror(_("%s.beginGradientFill(%s): first arg must be "
@@ -1948,8 +1956,7 @@
     ObjPtr ratios = fn.arg(3).to_object(getGlobal(fn));
     ObjPtr matrixArg = fn.arg(4).to_object(getGlobal(fn));
 
-    if ( ! colors || ! alphas || ! ratios || ! matrixArg )
-    {
+    if (!colors || !alphas || !ratios || !matrixArg ) {
         IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
         log_aserror(_("%s.beginGradientFill(%s): one or more of the "
@@ -1959,6 +1966,32 @@
         return as_value();
     }
 
+    size_t stops = arrayLength(*colors);
+
+    // Check that the arrays are all the same size.
+    if (stops != arrayLength(*alphas) || stops != arrayLength(*ratios)) {
+
+        IF_VERBOSE_ASCODING_ERRORS(
+            std::stringstream ss; fn.dump_args(ss);
+            log_aserror(_("%s.beginGradientFill(%s): colors, alphas and "
+                "ratios args don't have same length"),
+                movieclip->getTarget(), ss.str());
+        );
+        return as_value();
+    }
+    
+    // Then limit gradients. It's documented to be a maximum of 15, though
+    // this isn't tested. The arrays must be the same size regardless of
+    // this limit.
+    if (stops > 15) {
+        std::stringstream ss; fn.dump_args(ss);
+        log_debug(_("%s.beginGradientFill(%s) : too many array elements"
+            " for colors and ratios (%d), will trim to 8"), 
+            movieclip->getTarget(), ss.str(), stops); 
+        stops = 15;
+    }
+
+
     // ----------------------------
     // Parse SWFMatrix
     // ----------------------------
@@ -1974,16 +2007,13 @@
     //             always transforming the gnash gradients to the
     //             expected gradients and subsequently applying
     //             user-specified SWFMatrix; for 'boxed' SWFMatrixType
-    //             this simplification would increas cost, but
+    //             this simplification would increase cost, but
     //             it's too early to apply optimizations to the
     //             code (correctness first!!).
-    //
-
     SWFMatrix mat;
     SWFMatrix input_matrix;
 
-    if ( matrixArg->getMember(NSV::PROP_MATRIX_TYPE).to_string() == "box" )
-    {
+    if (matrixArg->getMember(NSV::PROP_MATRIX_TYPE).to_string() == "box") {
         
         boost::int32_t valX = pixelsToTwips(
                 matrixArg->getMember(NSV::PROP_X).to_number()); 
@@ -1995,8 +2025,7 @@
                 matrixArg->getMember(NSV::PROP_H).to_number()); 
         float valR = matrixArg->getMember(NSV::PROP_R).to_number(); 
 
-        if ( radial )
-        {
+        if (radial) {
             // Radial gradient is 64x64 twips.
             input_matrix.set_scale(64.0/valW, 64.0/valH);
 
@@ -2008,8 +2037,7 @@
             //             fill is at 0,0 making any rotation meaningless).
 
         }
-        else
-        {
+        else {
             // Linear gradient is 256x1 twips.
             //
             // No idea why we should use the 256 value for Y scale, but 
@@ -2024,8 +2052,7 @@
 
         mat.concatenate(input_matrix);
     }
-    else
-    {
+    else {
         float valA = matrixArg->getMember(NSV::PROP_A).to_number() ; // xx
         float valB = matrixArg->getMember(NSV::PROP_B).to_number() ; // yx
         float valD = matrixArg->getMember(NSV::PROP_D).to_number() ; // xy
@@ -2048,8 +2075,7 @@
         // gradient for Gnash (in flash they should be the same)
         SWFMatrix gnashToFlash;
 
-        if ( radial )
-        {
+        if (radial) {
 
             // Gnash radial gradients are 64x64 with center at 32,32
             // Should be 20x20 with center at 0,0
@@ -2058,8 +2084,7 @@
             gnashToFlash.concatenate_translation(-32, -32);
 
         }
-        else
-        {
+        else {
             // First define a SWFMatrix that would transform
             // the gnash gradient to the expected flash gradient:
             // this means translating our gradient to put the
@@ -2087,45 +2112,22 @@
     // Create the gradients vector
     // ----------------------------
 
-    size_t ngradients = toInt(colors->getMember(NSV::PROP_LENGTH));
-    // Check length compatibility of all args
-    if (ngradients != (size_t)toInt(alphas->getMember(NSV::PROP_LENGTH)) ||
-        ngradients != (size_t)toInt(ratios->getMember(NSV::PROP_LENGTH)))
-    {
-        IF_VERBOSE_ASCODING_ERRORS(
-        std::stringstream ss; fn.dump_args(ss);
-        log_aserror(_("%s.beginGradientFill(%s): colors, alphas and "
-            "ratios args don't have same length"),
-            movieclip->getTarget(), ss.str());
-        );
-        return as_value();
-    }
-
-    // TODO: limit ngradients to a max ?
-    if ( ngradients > 8 )
-    {
-        std::stringstream ss; fn.dump_args(ss);
-        log_debug(_("%s.beginGradientFill(%s) : too many array elements"
-            " for colors and ratios (%d), will trim to 8"), 
-            movieclip->getTarget(), ss.str(), ngradients); 
-        ngradients = 8;
-    }
-
     string_table& st = getStringTable(fn);
 
     std::vector<gradient_record> gradients;
-    gradients.reserve(ngradients);
-    for (size_t i=0; i<ngradients; ++i)
-    {
+    gradients.reserve(stops);
+    for (size_t i=0; i < stops; ++i) {
 
         string_table::key key = st.find(boost::lexical_cast<std::string>(i));
 
         as_value colVal = colors->getMember(key);
         boost::uint32_t col = colVal.is_number() ? toInt(colVal) : 0;
 
+        /// Alpha is the range 0..100.
         as_value alpVal = alphas->getMember(key);
-        boost::uint8_t alp = alpVal.is_number() ? 
-            clamp<int>(toInt(alpVal), 0, 255) : 0;
+        const double a = alpVal.is_number() ?
+            clamp<double>(alpVal.to_number(), 0, 100) : 0;
+        const boost::uint8_t alp = 0xff * (a / 100);
 
         as_value ratVal = ratios->getMember(key);
         boost::uint8_t rat = ratVal.is_number() ? 
@@ -2138,12 +2140,10 @@
         gradients.push_back(gradient_record(rat, color));
     }
 
-    if ( radial )
-    {
+    if (radial) {
         movieclip->beginRadialGradientFill(gradients, mat);
     }
-    else
-    {
+    else {
         movieclip->beginLinearGradientFill(gradients, mat);
     }
 

=== modified file 'libcore/asobj/flash/text/TextFormat_as.cpp'
--- a/libcore/asobj/flash/text/TextFormat_as.cpp        2010-01-11 06:41:38 
+0000
+++ b/libcore/asobj/flash/text/TextFormat_as.cpp        2010-01-13 07:54:28 
+0000
@@ -40,7 +40,6 @@
 namespace {
     
     as_value textformat_new(const fn_call& fn);
-    as_object* getTextFormatInterface();
     void attachTextFormatInterface(as_object& o);
     const char* getAlignString(TextField::TextAlignment a);
        const char* getDisplayString(TextField::TextFormatDisplay a);

=== modified file 'libcore/fill_style.cpp'
--- a/libcore/fill_style.cpp    2010-01-01 17:48:26 +0000
+++ b/libcore/fill_style.cpp    2010-01-13 08:19:25 +0000
@@ -182,15 +182,14 @@
         }
     
         uint8_t num_gradients = grad_props & 0xF;
-        if ( ! num_gradients )
-        {
+        if (!num_gradients) {
             IF_VERBOSE_MALFORMED_SWF(
                 log_swferror(_("num gradients 0"));
             );
             return;
         }
     
-        if ( num_gradients > 8 + ((t == SWF::DEFINESHAPE4 ||
+        if (num_gradients > 8 + ((t == SWF::DEFINESHAPE4 ||
             t == SWF::DEFINESHAPE4_) ? 7 : 0))
         {
            // see: http://sswf.sourceforge.net/SWFalexref.html#swf_gradient
@@ -371,8 +370,7 @@
         || m_type == SWF::FILL_RADIAL_GRADIENT
         || m_type == SWF::FILL_FOCAL_GRADIENT);
 
-    if ( m_gradients.empty() )
-    {
+    if (m_gradients.empty()) {
         static const rgba black;
         return black;
     }
@@ -395,7 +393,7 @@
         return m_gradients[0].m_color;
     }
 
-    if ( ratio >= m_gradients.back().m_ratio )
+    if (ratio >= m_gradients.back().m_ratio)
     {
         return m_gradients.back().m_color;
     }
@@ -580,20 +578,21 @@
     }
 
     // fill style bitmap or gradient SWFMatrix
-    if ( usesMatrix ) _matrix.set_lerp(a._matrix, b._matrix, t);
+    if (usesMatrix) _matrix.set_lerp(a._matrix, b._matrix, t);
 }
 
 
-int 
+size_t
 fill_style::get_color_stop_count() const 
 {
-  return m_gradients.size();
+    return m_gradients.size();
 }
 
 const gradient_record& 
-fill_style::get_color_stop(int index) const
+fill_style::get_color_stop(size_t index) const
 {
-  return m_gradients[index];
+    assert(index < m_gradients.size());
+    return m_gradients[index];
 }
 
 fill_style::fill_style(const BitmapInfo* const bitmap, const SWFMatrix& mat)
@@ -610,14 +609,27 @@
 {
     m_type = SWF::FILL_SOLID;
     m_color = color;
+    _bitmapInfo = 0;
 }
 
 void
 fill_style::setLinearGradient(const std::vector<gradient_record>& gradients,
         const SWFMatrix& mat)
 {
+
+    assert(!gradients.empty());
+    
+    // We must ensure that all gradients have more than one colour stop
+    // because asking the renderer to render a gradient with one colour
+    // leads to problems.
+    if (gradients.size() < 2) {
+        setSolid(gradients[0].m_color);
+        return;
+    }
+
     m_type = SWF::FILL_LINEAR_GRADIENT;
     m_gradients = gradients;
+
     _matrix = mat;
     _bitmapInfo = 0;
 }
@@ -626,8 +638,16 @@
 fill_style::setRadialGradient(const std::vector<gradient_record>& gradients,
         const SWFMatrix& mat)
 {
-    m_type = SWF::FILL_RADIAL_GRADIENT;
-    m_gradients = gradients;
+    assert(!gradients.empty());
+    
+    // We must ensure that all gradients have more than one colour stop
+    // because asking the renderer to render a gradient with one colour
+    // leads to problems.
+    if (gradients.size() < 2) {
+        setSolid(gradients[0].m_color);
+        return;
+    }
+    
     _matrix = mat;
     _bitmapInfo = 0;
 }

=== modified file 'libcore/fill_style.h'
--- a/libcore/fill_style.h      2010-01-01 17:48:26 +0000
+++ b/libcore/fill_style.h      2010-01-13 08:19:25 +0000
@@ -40,23 +40,23 @@
 class gradient_record
 {
 public:
-       gradient_record()
-               :
-               m_ratio(0),
-               m_color()
-       {}
-
-       gradient_record(boost::uint8_t ratio, const rgba& color)
-               :
-               m_ratio(ratio),
-               m_color(color)
-       {}
-
-       void read(SWFStream& in, SWF::TagType tag);
-       
-       //data:
-       boost::uint8_t  m_ratio;
-       rgba    m_color;
+    gradient_record()
+        :
+        m_ratio(0),
+        m_color()
+    {}
+
+    gradient_record(boost::uint8_t ratio, const rgba& color)
+        :
+        m_ratio(ratio),
+        m_color(color)
+    {}
+
+    void read(SWFStream& in, SWF::TagType tag);
+    
+    //data:
+    boost::uint8_t    m_ratio;
+    rgba    m_color;
 };
 
 
@@ -102,163 +102,161 @@
     };
     
 
-       /// Create a solid opaque white fill.
-       fill_style();
-
-       /// Construct a clipped bitmap fill style, for
-       /// use by bitmap shape DisplayObject.
-       ///
-       /// TODO: use a subclass for this
-       /// TODO: provide a setBitmap, for consisteny with other setType() 
methods
-       ///
-       /// @param bitmap
-       ///     The bitmap DisplayObject definition to use with this bitmap 
fill.
-       ///
-       /// @param mat
-       ///     The SWFMatrix to apply to the bitmap.
-       ///
-       fill_style(const BitmapInfo* const bitmap, const SWFMatrix& mat);
-
-       void setSolid(const rgba& color);
-
-       /// Turn this fill style into a linear gradient
-       //
-       /// @param gradients
-       ///     Gradient records.
-       ///
-       /// @param mat
-       ///     Gradient SWFMatrix.
-       ///
-       ///
-       void setLinearGradient(const std::vector<gradient_record>& gradients, 
-                       const SWFMatrix& mat);
-
-       /// Turn this fill style into a radial gradient
-       //
-       /// @param gradients
-       ///     Gradient records.
-       ///
-       /// @param mat
-       ///     Gradient SWFMatrix.
-       ///
-       ///
-       void setRadialGradient(const std::vector<gradient_record>& gradients,
-                       const SWFMatrix& mat);
-
-       /// Turn this fill style into a focal gradient
-       //
-       /// @param gradients
-       ///     Gradient records.
-       ///
-       /// @param mat
-       ///     Gradient SWFMatrix.
-       ///
-       /// @param fpoint
-       ///     Focal point.
-       ///
-       void setRadialGradient(const std::vector<gradient_record>& gradients,
-                       const SWFMatrix& mat, float fpoint);
-
-       ~fill_style() {}
-       
-       /// Read the fill style from a stream
-       //
-       /// TODO: use a subclass for this (swf_fill_style?)
-       ///
-       /// Throw a ParserException if there's no enough bytes in the
-       /// currently opened tag for reading. See stream::ensureBytes()
-       ///
-       void read(SWFStream& in, SWF::TagType t, movie_definition& m,
+    /// Create a solid opaque white fill.
+    fill_style();
+
+    /// Construct a clipped bitmap fill style, for
+    /// use by bitmap shape DisplayObject.
+    ///
+    /// TODO: use a subclass for this
+    /// TODO: provide a setBitmap, for consisteny with other setType() methods
+    ///
+    /// @param bitmap
+    ///    The bitmap DisplayObject definition to use with this bitmap fill.
+    ///
+    /// @param mat
+    ///    The SWFMatrix to apply to the bitmap.
+    ///
+    fill_style(const BitmapInfo* const bitmap, const SWFMatrix& mat);
+
+    ~fill_style() {}
+
+    /// Turn this fill style into a solid fill.
+    //
+    /// This is used for dynamic gradient generation.
+    //
+    void setSolid(const rgba& color);
+
+    /// Turn this fill style into a linear gradient
+    //
+    /// This is used for dynamic gradient generation.
+    //
+    /// Note: passing only one gradient record will result in a solid fill
+    /// style, not a gradient. This is for compatibility with dynamic
+    /// fill style generation.
+    //
+    /// @param gradients    Gradient records.
+    /// @param mat          Gradient SWFMatrix.
+    void setLinearGradient(const std::vector<gradient_record>& gradients, 
+            const SWFMatrix& mat);
+
+    /// Turn this fill style into a radial gradient
+    //
+    /// This is used for dynamic gradient generation.
+    //
+    /// Note: passing only one gradient record will result in a solid fill
+    /// style, not a gradient. This is for compatibility with dynamic
+    /// fill style generation.
+    //
+    /// @param gradients    Gradient records.
+    /// @param mat          Gradient SWFMatrix.
+    void setRadialGradient(const std::vector<gradient_record>& gradients,
+            const SWFMatrix& mat);
+    
+    /// Read the fill style from a stream
+    //
+    /// TODO: use a subclass for this (swf_fill_style?)
+    ///
+    /// Throw a ParserException if there's no enough bytes in the
+    /// currently opened tag for reading. See stream::ensureBytes()
+    void read(SWFStream& in, SWF::TagType t, movie_definition& m,
             const RunResources& r, fill_style *pOther = 0);
 
-       /// \brief
-       /// Make a BitmapInfo* corresponding to our gradient.
-       /// We can use this to set the gradient fill style.
-       const BitmapInfo* create_gradient_bitmap(Renderer& renderer) const;
-       
-       /// \brief
-       /// Makes sure that _gradientBitmapInfo is not NULL. Calls 
-       /// create_gradient_bitmap() if necessary and returns 
_gradientBitmapInfo.
-       const BitmapInfo* need_gradient_bitmap(Renderer& renderer) const; 
-       
-       rgba    get_color() const { return m_color; }
-
-       void    set_color(rgba new_color) { m_color = new_color; }
-
-       /// Get fill type, see SWF::fill_style_type
-       uint8_t get_type() const { return m_type; }
-
-       SWF::gradient_spread_mode get_gradient_spread_mode()
-       { return m_spread_mode; }
-
-       SWF::gradient_interpolation_mode get_gradient_interpolation_mode()
-       { return m_interpolation; }
-       
-       /// Sets this style to a blend of a and b.  t = [0,1] (for shape 
morphing)
-       void    set_lerp(const fill_style& a, const fill_style& b, float t);
-       
-       /// Returns the bitmap info for all styles except solid fills
-       //
-       /// NOTE: calling this method against a solid fill style will
-       ///       result in a failed assertion.
-       /// 
-       /// NOTE2: this function can return NULL if the DisplayObject_id
-       ///        specified for the style in the SWF does not resolve
-       ///        to a DisplayObject defined in the DisplayObjects dictionary.
-       ///        (it happens..)
-       ///
-       const BitmapInfo* get_bitmap_info(Renderer& renderer) const;
+    /// \brief
+    /// Make a BitmapInfo* corresponding to our gradient.
+    /// We can use this to set the gradient fill style.
+    const BitmapInfo* create_gradient_bitmap(Renderer& renderer) const;
+    
+    /// \brief
+    /// Makes sure that _gradientBitmapInfo is not NULL. Calls 
+    /// create_gradient_bitmap() if necessary and returns _gradientBitmapInfo.
+    const BitmapInfo* need_gradient_bitmap(Renderer& renderer) const; 
+    
+    rgba get_color() const {
+        return m_color;
+    }
+
+    void set_color(rgba new_color) {
+        m_color = new_color;
+    }
+
+    /// Get fill type, see SWF::fill_style_type
+    uint8_t get_type() const {
+        return m_type;
+    }
+
+    SWF::gradient_spread_mode get_gradient_spread_mode() const {
+        return m_spread_mode;
+    }
+
+    SWF::gradient_interpolation_mode get_gradient_interpolation_mode() const {
+        return m_interpolation;
+    }
+    
+    /// Sets this style to a blend of a and b.  t = [0,1] (for shape morphing)
+    void set_lerp(const fill_style& a, const fill_style& b, float t);
+    
+    /// Returns the bitmap info for all styles except solid fills
+    //
+    /// NOTE: calling this method against a solid fill style will
+    ///       result in a failed assertion.
+    /// 
+    /// NOTE2: this function can return NULL if the DisplayObject_id
+    ///        specified for the style in the SWF does not resolve
+    ///        to a DisplayObject defined in the DisplayObjects dictionary.
+    ///        (it happens..)
+    ///
+    const BitmapInfo* get_bitmap_info(Renderer& renderer) const;
 
     BitmapSmoothingPolicy getBitmapSmoothingPolicy() const {
         return _bitmapSmoothingPolicy;
     }
-       
-       /// Returns the bitmap transformation SWFMatrix
-       const SWFMatrix& getBitmapMatrix() const; 
-       
-       /// Returns the gradient transformation SWFMatrix
-       const SWFMatrix& getGradientMatrix() const; 
-       
-       /// Returns the number of color stops in the gradient
-       int get_color_stop_count() const;
-       
-       /// Returns the color stop value at a specified index
-       const gradient_record& get_color_stop(int index) const;
+    
+    /// Returns the bitmap transformation SWFMatrix
+    const SWFMatrix& getBitmapMatrix() const; 
+    
+    /// Returns the gradient transformation SWFMatrix
+    const SWFMatrix& getGradientMatrix() const; 
+    
+    /// Returns the number of color stops in the gradient
+    size_t get_color_stop_count() const;
+    
+    /// Returns the color stop value at a specified index
+    const gradient_record& get_color_stop(size_t index) const;
 
-       /// Get and set the focal point for gradient focal fills.
-       /// This should be from -1.0 to 1.0, representing the left
-       /// and right edges of the rectangle.
-       float get_focal_point() const { return m_focal_point; }
-       void set_focal_point(float f) { m_focal_point = f; }
+    /// Get and set the focal point for gradient focal fills.
+    /// This should be from -1.0 to 1.0, representing the left
+    /// and right edges of the rectangle.
+    float get_focal_point() const { return m_focal_point; }
+    void set_focal_point(float f) { m_focal_point = f; }
 
 private:
 
-       /// Return the color at the specified ratio into our gradient.
-       //
-       /// @param ratio
-       ///     Ratio is in the range [0, 255].
-       ///
-       rgba sample_gradient(boost::uint8_t ratio) const;
-
-       // For BITMAP or GRADIENT types 
-       SWFMatrix       _matrix;
-
-       // For BITMAP or GRADIENT types
-       boost::intrusive_ptr<const BitmapInfo> _bitmapInfo;
-
-       // For SOLID type (and arguably GRADIENT too)
-       rgba    m_color;
-
-       // Only for GRADIENT type
-       float m_focal_point; // For focal fill gradients.
-       std::vector<gradient_record> m_gradients;
-       SWF::gradient_spread_mode m_spread_mode;
-       SWF::gradient_interpolation_mode m_interpolation;
-
-       /// Fill type, see SWF::fill_style_type
-       uint8_t m_type;
-
-       // Only for BITMAP type
+    /// Return the color at the specified ratio into our gradient.
+    //
+    /// @param ratio
+    ///    Ratio is in the range [0, 255].
+    rgba sample_gradient(boost::uint8_t ratio) const;
+
+    // For BITMAP or GRADIENT types 
+    SWFMatrix _matrix;
+
+    // For BITMAP or GRADIENT types
+    boost::intrusive_ptr<const BitmapInfo> _bitmapInfo;
+
+    // For SOLID type (and arguably GRADIENT too)
+    rgba m_color;
+
+    // Only for GRADIENT type
+    float m_focal_point; // For focal fill gradients.
+    std::vector<gradient_record> m_gradients;
+    SWF::gradient_spread_mode m_spread_mode;
+    SWF::gradient_interpolation_mode m_interpolation;
+
+    /// Fill type, see SWF::fill_style_type
+    uint8_t m_type;
+
+    // Only for BITMAP type
     //
     // 0: unspecified (smooth with _quality >= BEST)
     // 1: smooth (smooth with _quality >= MEDIUM)

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2010-01-01 17:48:26 +0000
+++ b/libcore/vm/Machine.cpp    2010-01-13 07:48:30 +0000
@@ -2095,6 +2095,9 @@
                 /// Stack Out:
                 ///  .
                 /// Do: obj.slots[slot_index] = value
+                //
+                /// Slot index must be greater than 0 and less than or
+                /// equal to the number of slots (so one-based index?).
                 case SWF::ABC_ACTION_SETSLOT:
                 {
                     boost::uint32_t sindex = mStream->read_V32();

=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2010-01-11 06:41:38 +0000
+++ b/libcore/vm/VM.cpp 2010-01-13 09:10:35 +0000
@@ -324,19 +324,12 @@
     // The order of the operations is important: op2 is converted to
     // primitive before op1.
 
+    /// It doesn't matter if either of these fail.
        try { convertToPrimitive(r, vm); }
-       catch (ActionTypeError& e)
-       {
-        log_debug(_("%s.to_primitive() threw an error during "
-                "ActionNewAdd"), r);
-       }
+       catch (ActionTypeError& e) {}
        
     try { convertToPrimitive(op1, vm); }
-       catch (ActionTypeError& e)
-       {
-        log_debug(_("%s.to_primitive() threw an error during "
-                "ActionNewAdd"), op1);
-       }
+       catch (ActionTypeError& e) {}
 
 #if GNASH_DEBUG
        log_debug(_("(%s + %s) [primitive conversion done]"), op1, r);

=== modified file 'testsuite/actionscript.all/TextFormat.as'
--- a/testsuite/actionscript.all/TextFormat.as  2010-01-01 17:48:26 +0000
+++ b/testsuite/actionscript.all/TextFormat.as  2010-01-13 08:21:36 +0000
@@ -117,4 +117,35 @@
 check_equals(a.toString(), "string");
 xcheck_equals(tf.tabStops.toString(), "6");
 
-check_totals(65);
+tf2 = new TextFormat("Arial", 12);
+te = tf2.getTextExtent("Hello");
+
+// The object is a bare object
+te.hasOwnProperty = Object.prototype.hasOwnProperty;
+
+xcheck(te.hasOwnProperty("ascent"));
+xcheck(te.hasOwnProperty("descent"));
+xcheck(te.hasOwnProperty("textFieldWidth"));
+xcheck(te.hasOwnProperty("textFieldHeight"));
+xcheck(te.hasOwnProperty("width"));
+xcheck(te.hasOwnProperty("height"));
+
+xcheck_equals(Math.round(te.textFieldHeight), 18);
+xcheck_equals(Math.round(te.textFieldWidth), 33);
+
+te = tf2.getTextExtent("Hello", 10);
+xcheck_equals(Math.round(te.textFieldHeight), 60);
+xcheck_equals(te.textFieldWidth, 10);
+xcheck_equals(Math.round(te.width), 9);
+
+te = tf2.getTextExtent("Hello", 5);
+xcheck_equals(Math.round(te.textFieldHeight), 74);
+xcheck_equals(te.textFieldWidth, 5);
+// Width of largest character?
+xcheck_equals(Math.round(te.width), 9);
+
+te = tf2.getTextExtent("Longer sentence with more words.", 30);
+xcheck_equals(te.textFieldWidth, 30);
+xcheck_equals(Math.round(te.width), 25);
+
+check_totals(81);

=== modified file 'testsuite/actionscript.all/XML.as'
--- a/testsuite/actionscript.all/XML.as 2010-01-11 06:41:38 +0000
+++ b/testsuite/actionscript.all/XML.as 2010-01-13 07:54:28 +0000
@@ -913,9 +913,9 @@
                check_totals(429);
 #else
 # if OUTPUT_VERSION < 8
-               check_totals(464);
+               check_totals(466);
 # else
-               check_totals(445);
+               check_totals(447);
 # endif
 #endif
                play();
@@ -1084,5 +1084,17 @@
 check_equals(typeof(h.docTypeDecl), "string");
 check_equals(h.docTypeDecl, "98");
 check_equals(h.toString(), "798<tag />");
+
+#if OUTPUT_VERSION > 5
+
+/// Check special characters
+r = new XML("1: &#229; 2: &#228; 3: &#1025; 4: &#02312; 5: &#0228;");
+xcheck_equals(r.toString(), "1: å 2: ä 3: Ё 4: ई 5: ä");
+
+r = new XML("1: &#229e2; 2: &#76e9; 3: &#ee229; 4: &#fee; 5: &#97;");
+xcheck_equals(r.toString(), "1: å 2: L 3: &amp;#ee229; 4: &amp;#fee; 5: a");
+
+#endif
+
 stop();
 


reply via email to

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