gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/button_character_instanc...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/button_character_instanc...
Date: Thu, 12 Apr 2007 09:14:37 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/12 09:14:37

Modified files:
        .              : ChangeLog 
        server         : button_character_instance.cpp 
                         button_character_instance.h character.cpp 
                         character.h edit_text_character.h 
                         generic_character.h matrix.cpp matrix.h 
                         sprite_instance.cpp sprite_instance.h 
                         video_stream_instance.h 
        testsuite/actionscript.all: MovieClip.as 
        testsuite/swfdec: PASSING 

Log message:
                * server/matrix.{cpp,h}: add transform and transform_by_inverse
                  for Range2d<float> type.
                * server/character.h: add a getBounds() virutual method.
                * server/: generic_character.h, 
button_character_instance.{cpp,h},
                  edit_text_character.h, video_stream_instance.h:
                  Implement getBounds.
                * server/character.cpp: fix width_getset and height_getset
                  to use the new getBounds interface.
                * server/sprite_instance.{cpp,h}: implement getBounds;
                  implement MovieClip.getBounds.
                * testsuite/actionscript.all/MovieClip.as: more tests for
                  getBounds, more successes.
                * testsuite/swfdec/PASSING: height2.swf and height3.swf tests
                  now succeed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2861&r2=1.2862
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.235&r2=1.236
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.94&r2=1.95
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.14&r2=1.15

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2861
retrieving revision 1.2862
diff -u -b -r1.2861 -r1.2862
--- ChangeLog   12 Apr 2007 09:04:01 -0000      1.2861
+++ ChangeLog   12 Apr 2007 09:14:36 -0000      1.2862
@@ -1,3 +1,20 @@
+2007-04-12 Sandro Santilli <address@hidden>
+
+       * server/matrix.{cpp,h}: add transform and transform_by_inverse
+         for Range2d<float> type.
+       * server/character.h: add a getBounds() virutual method.
+       * server/: generic_character.h, button_character_instance.{cpp,h},
+         edit_text_character.h, video_stream_instance.h:
+         Implement getBounds.
+       * server/character.cpp: fix width_getset and height_getset
+         to use the new getBounds interface.
+       * server/sprite_instance.{cpp,h}: implement getBounds;
+         implement MovieClip.getBounds.
+       * testsuite/actionscript.all/MovieClip.as: more tests for
+         getBounds, more successes.
+       * testsuite/swfdec/PASSING: height2.swf and height3.swf tests
+         now succeed.
+
 2007-04-12 Mathew Cucuzella <address@hidden>
 
        * doc/C/internals.xml plugin.xml: Fix typos in documentation

Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/button_character_instance.cpp        11 Apr 2007 14:20:20 -0000      
1.40
+++ server/button_character_instance.cpp        12 Apr 2007 09:14:36 -0000      
1.41
@@ -1,7 +1,23 @@
-// button.cpp  -- Thatcher Ulrich <address@hidden> 2003
+// 
+//   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 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// 
+//
+//
 
-// This source code has been donated to the Public Domain.  Do
-// whatever you want with it.
 
 // SWF buttons.  Mouse-sensitive update/display, actions, etc.
 
@@ -814,6 +830,26 @@
        return 0.0;
 }
 
+geometry::Range2d<float>
+button_character_instance::getBounds() const
+{
+       for (unsigned int i = 0; i < m_def->m_button_records.size(); i++)
+       {
+               button_record&  rec = m_def->m_button_records[i];
+               if (m_record_character[i] == NULL)
+               {
+                       continue;
+               }
+               if ((m_mouse_state == UP && rec.m_up)
+                   || (m_mouse_state == DOWN && rec.m_down)
+                   || (m_mouse_state == OVER && rec.m_over))
+               {
+                       return m_record_character[i]->getBounds();
+               }
+       }
+       return geometry::Range2d<float>(geometry::nullRange);
+}
+
 character*
 button_character_instance::get_relative_target(const std::string& name)
 {

Index: server/button_character_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/button_character_instance.h  19 Mar 2007 17:11:14 -0000      1.17
+++ server/button_character_instance.h  12 Apr 2007 09:14:36 -0000      1.18
@@ -1,11 +1,26 @@
-// Thatcher Ulrich <address@hidden> 2003
-
-// This source code has been donated to the Public Domain.  Do
-// whatever you want with it.
+// 
+//   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 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// 
+//
+//
 
 // SWF buttons.  Mouse-sensitive update/display, actions, etc.
 
-/* $Id: button_character_instance.h,v 1.17 2007/03/19 17:11:14 bjacques Exp $ 
*/
+/* $Id: button_character_instance.h,v 1.18 2007/04/12 09:14:36 strk Exp $ */
 
 #ifndef GNASH_BUTTON_CHARACTER_INSTANCE_H
 #define GNASH_BUTTON_CHARACTER_INSTANCE_H
@@ -127,6 +142,8 @@
 
        virtual float get_height() const;
        
+       geometry::Range2d<float> getBounds() const;
+       
        static as_value enabled_getset(const fn_call& fn);
        
        bool get_enabled();

Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/character.cpp        11 Apr 2007 14:20:20 -0000      1.30
+++ server/character.cpp        12 Apr 2007 09:14:36 -0000      1.31
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.cpp,v 1.30 2007/04/11 14:20:20 strk Exp $ */
+/* $Id: character.cpp,v 1.31 2007/04/12 09:14:36 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -471,7 +471,16 @@
        as_value rv;
        if ( fn.nargs == 0 ) // getter
        {
-               rv = as_value(TWIPS_TO_PIXELS(ptr->get_width()));
+               float w = 0;
+               geometry::Range2d<float> bounds = ptr->getBounds();
+               if ( bounds.isFinite() )
+               {
+                       matrix m = ptr->get_matrix();
+                       m.transform(bounds);
+                       assert(bounds.isFinite());
+                       w = TWIPS_TO_PIXELS(int(bounds.width()));
+               }
+               rv = as_value(w);
        }
        else // setter
        {
@@ -497,14 +506,23 @@
        as_value rv;
        if ( fn.nargs == 0 ) // getter
        {
-               rv = as_value(TWIPS_TO_PIXELS(ptr->get_height()));
+               float h = 0;
+               geometry::Range2d<float> bounds = ptr->getBounds();
+               if ( bounds.isFinite() )
+               {
+                       matrix m = ptr->get_matrix();
+                       m.transform(bounds);
+                       assert(bounds.isFinite());
+                       h = TWIPS_TO_PIXELS(int(bounds.height()));
+               }
+               rv = as_value(h);
        }
        else // setter
        {
                // @@ tulrich: is parameter in world-coords or local-coords?
                matrix m = ptr->get_matrix();
                m.m_[1][1] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number()));
-               float h = ptr->get_height(); // WARNING: was get_width 
originally, sounds as a bug
+               float h = ptr->get_height(); 
                if (fabsf(h) > 1e-6f)
                {
                        m.m_[1][1] /= h;

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- server/character.h  11 Apr 2007 14:20:20 -0000      1.64
+++ server/character.h  12 Apr 2007 09:14:36 -0000      1.65
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.h,v 1.64 2007/04/11 14:20:20 strk Exp $ */
+/* $Id: character.h,v 1.65 2007/04/12 09:14:36 strk Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -38,6 +38,7 @@
 #include "cxform.h" // for composition
 #include "log.h"
 #include "snappingrange.h"
+#include "Range2d.h"
 
 #include <map>
 #include <cstdarg>
@@ -411,6 +412,21 @@
                return 0;
        }
 
+       /// Returns local, untransformed bounds of this character in TWIPS
+       //
+       /// The default implementation prints an error and returns a NULL rect.
+       ///
+       /// Container characters (sprite and buttons) return the composite
+       /// bounds of all their childrens, appropriaterly transformed with
+       /// their local matrix.
+       ///
+       virtual geometry::Range2d<float> getBounds() const
+       {
+               log_error("FIXME: character %s did not override the getBounds() 
method",
+                               typeid(*this).name());
+               return geometry::Range2d<float>(geometry::nullRange);
+       }
+
        /// Return the "relative" root of this character
        //
        /// The "relative" is the movie_instance created by

Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/edit_text_character.h        28 Mar 2007 20:38:35 -0000      1.26
+++ server/edit_text_character.h        12 Apr 2007 09:14:36 -0000      1.27
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//   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
@@ -26,6 +26,8 @@
 #include "edit_text_character_def.h" // for inlines
 #include "styles.h" // for fill_style and line_style
 #include "text.h" // for text_glyph_record
+#include "Range2d.h"
+#include "rect.h" // for inlines
 
 
 // Forward declarations
@@ -92,6 +94,11 @@
        virtual float   get_height() const;
        virtual float   get_width() const;
 
+       geometry::Range2d<float> getBounds() const
+       {
+               return m_def->get_bounds().getRange();
+       }
+
 private:
 
        /// The actual text

Index: server/generic_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/generic_character.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/generic_character.h  28 Feb 2007 17:25:26 -0000      1.19
+++ server/generic_character.h  12 Apr 2007 09:14:36 -0000      1.20
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//   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
@@ -86,6 +86,11 @@
                return m_def->get_width_local();
        }
 
+       geometry::Range2d<float> getBounds() const
+       {
+               return m_def->get_bound().getRange();
+       }
+
        virtual character* get_topmost_mouse_entity(float x, float y);
 
        /// \brief

Index: server/matrix.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/matrix.cpp   12 Feb 2007 12:26:13 -0000      1.7
+++ server/matrix.cpp   12 Apr 2007 09:14:36 -0000      1.8
@@ -18,7 +18,7 @@
 //
 // Original author: Thatcher Ulrich <address@hidden> 2003
 //
-// $Id: matrix.cpp,v 1.7 2007/02/12 12:26:13 nihilus Exp $ 
+// $Id: matrix.cpp,v 1.8 2007/04/12 09:14:36 strk Exp $ 
 //
 
 #ifdef HAVE_CONFIG_H
@@ -218,6 +218,29 @@
 }
 
 void
+matrix::transform(geometry::Range2d<float>& r) const
+{
+       if ( ! r.isFinite() ) return;
+
+       float xmin = r.getMinX();
+       float xmax = r.getMaxX();
+       float ymin = r.getMinY();
+       float ymax = r.getMaxY();
+
+       xmin = m_[0][0] * xmin + m_[0][1] * ymin + m_[0][2];
+       ymin = m_[1][0] * xmin + m_[1][1] * ymin + m_[1][2];
+
+       xmax = m_[0][0] * xmax + m_[0][1] * ymax + m_[0][2];
+       ymax = m_[1][0] * xmax + m_[1][1] * ymax + m_[1][2];
+
+       // Rotation can swap the max/min coordinates
+       if ( xmax < xmin ) std::swap(xmin, xmax);
+       if ( ymax < ymin ) std::swap(ymin, ymax);
+
+       r.setTo(xmin, ymin, xmax, ymax);
+}
+
+void
 matrix::transform_vector(point* result, const point& v) const
 // Transform vector 'v' by our matrix. Doesn't apply translation.
 // Put the result in *result.
@@ -238,6 +261,15 @@
        m.transform(result, p);
 }
 
+void
+matrix::transform_by_inverse(geometry::Range2d<float>& r) const
+{
+       // @@ TODO optimize this!
+       matrix  m;
+       m.set_inverse(*this);
+       m.transform(r);
+}
+
 
 void
 matrix::set_inverse(const matrix& m)

Index: server/matrix.h
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/matrix.h     2 Nov 2006 14:00:55 -0000       1.4
+++ server/matrix.h     12 Apr 2007 09:14:36 -0000      1.5
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//   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
@@ -18,7 +18,7 @@
 //
 // Original author: Thatcher Ulrich <address@hidden> 2003
 //
-// $Id: matrix.h,v 1.4 2006/11/02 14:00:55 udog Exp $ 
+// $Id: matrix.h,v 1.5 2007/04/12 09:14:36 strk Exp $ 
 //
 
 #ifndef GNASH_MATRIX_H
@@ -29,13 +29,19 @@
 #endif
 
 #include "tu_config.h" // for DSOEXPORT
+#include "Range2d.h" // for transforming Range2d<float>
 
 #include <iosfwd>
 
+// Forward declarations
+namespace gnash {
+       class point;
+       class stream;
+}
+
+
 namespace gnash {
 
-class point;
-class stream;
 
 /// Matrix type, used by render handler.
 //
@@ -130,6 +136,19 @@
        ///
        void    transform_by_inverse(point* result, const point& p) const;
 
+       /// Transform Range2d<float> 'r' by our matrix. 
+       //
+       /// NULL and WORLD ranges are untouched.
+       ///
+       void    transform(geometry::Range2d<float>& r) const;
+
+       /// Transform Range2d<float> 'r' by the inverse our matrix. 
+       //
+       /// NULL and WORLD ranges are untouched.
+       ///
+       void    transform_by_inverse(geometry::Range2d<float>& r) const;
+
+
        /// Set this matrix to the inverse of the given matrix.
        void    set_inverse(const matrix& m);
 

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -b -r1.235 -r1.236
--- server/sprite_instance.cpp  12 Apr 2007 07:04:16 -0000      1.235
+++ server/sprite_instance.cpp  12 Apr 2007 09:14:36 -0000      1.236
@@ -798,20 +798,54 @@
 {
        boost::intrusive_ptr<sprite_instance> sprite = 
ensureType<sprite_instance>(fn.this_ptr);
 
-       boost::intrusive_ptr<as_object> target;
+
+       geometry::Range2d<float> bounds  = sprite->getBounds();
+
        if ( fn.nargs > 0 )
        {
-               target = fn.arg(0).to_object();
+               boost::intrusive_ptr<sprite_instance> target = 
fn.arg(0).to_sprite();
+               if ( ! target )
+               {
+                       IF_VERBOSE_ASCODING_ERRORS(
+                       log_aserror("MovieClip.getBounds(%s) : invalid call, 
first arg must be a sprite",
+                               fn.arg(0).to_debug_string().c_str());
+                       );
+                       return as_value();
        }
 
-       // TODO: implement 'Range2d<float> character::getBounds(character* 
ref=NULL)'
-       UNUSED(sprite);
-       geometry::Range2d<float> bounds(0, 0, 0, 0); //  = 
sprite->getBounds(target.get());
-
-       double xMin = bounds.getMinX();
-       double yMin = bounds.getMinY();
-       double xMax = bounds.getMaxX();
-       double yMax = bounds.getMaxY();
+               matrix tgtwmat = target->get_world_matrix();
+               matrix srcwmat = sprite->get_world_matrix();
+               // TODO: fixme, we should likely use the world matrixes for a 
straight and inverse transform
+               matrix invtgtwmat; invtgtwmat.set_inverse(tgtwmat);
+               matrix m = srcwmat;
+               m.concatenate(invtgtwmat);
+
+               //m.transform(bounds);
+               //tgtwmat.transform_by_inverse(bounds);
+               std::stringstream ss;
+
+               ss << "Local bounds: " << bounds << endl;
+               srcwmat.transform(bounds);
+               ss << "src-w-transformed bounds: " << bounds << "(srcwmat is " 
<< srcwmat << ")" << endl;
+               tgtwmat.transform_by_inverse(bounds);
+               ss << "tgt-w-invtransfor bounds: " << bounds << "(tgtwmat is " 
<< tgtwmat << ")" << endl;
+               log_msg("%s", ss.str().c_str());
+               log_error("FIXME: MovieClip.getBounds(%s) broken", 
fn.arg(0).to_debug_string().c_str());
+       }
+
+       // Magic numbers here... dunno why
+       double xMin = 6710886.35;
+       double yMin = 6710886.35;
+       double xMax = 6710886.35;
+       double yMax = 6710886.35;
+
+       if ( bounds.isFinite() )
+       {
+               xMin = bounds.getMinX()/20;
+               yMin = bounds.getMinY()/20;
+               xMax = bounds.getMaxX()/20;
+               yMax = bounds.getMaxY()/20;
+       }
 
        boost::intrusive_ptr<as_object> bounds_obj(new as_object());
        bounds_obj->init_member("xMin", as_value(xMin));
@@ -823,7 +857,7 @@
        static bool warned = false;
        if ( ! warned )
        {
-               log_error("FIXME: MovieClip.getBounds() not implemented yet 
(just stubbed)");
+               log_error("FIXME: MovieClip.getBounds() TESTING");
                warned=true;
        }
 
@@ -1411,6 +1445,23 @@
 // sprite_instance helper classes
 //------------------------------------------------
 
+/// A DisplayList visitor used to compute its overall bounds.
+//
+class BoundsFinder {
+public:
+       geometry::Range2d<float>& _bounds;
+       BoundsFinder(geometry::Range2d<float>& b)
+               :
+               _bounds(b)
+       {}
+       void operator() (character* ch)
+       {
+               geometry::Range2d<float> chb = ch->getBounds();
+               matrix m = ch->get_matrix();
+               m.transform(chb);
+               _bounds.expandTo(chb);
+       }
+};
 
 /// A DisplayList visitor used to compute its overall height.
 //
@@ -3484,5 +3535,17 @@
 
 }
 
+geometry::Range2d<float>
+sprite_instance::getBounds() const
+{
+       typedef geometry::Range2d<float> Range;
+
+       Range bounds;
+       BoundsFinder f(bounds);
+       const_cast<DisplayList&>(m_display_list).visitAll(f);
+       Range drawableBounds = _drawable->get_bound().getRange();
+       bounds.expandTo(drawableBounds);
+       return bounds;
+}
 
 } // namespace gnash

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- server/sprite_instance.h    11 Apr 2007 14:20:20 -0000      1.94
+++ server/sprite_instance.h    12 Apr 2007 09:14:36 -0000      1.95
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.94 2007/04/11 14:20:20 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.95 2007/04/12 09:14:36 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -35,6 +35,7 @@
 #include "as_environment.h" // for composition
 #include "DynamicShape.h" // for composition
 //#include "LoadVariablesThread.h" // for composition
+#include "Range2d.h"
 
 #include <vector>
 #include <list>
@@ -139,6 +140,9 @@
 
        float get_height() const;
 
+       /// Get the composite bounds of all component drawing elements
+       geometry::Range2d<float> getBounds() const;
+
        size_t get_current_frame() const
        {
                return m_current_frame;

Index: server/video_stream_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/video_stream_instance.h      20 Mar 2007 15:01:20 -0000      1.9
+++ server/video_stream_instance.h      12 Apr 2007 09:14:36 -0000      1.10
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 // 
-// $Id: video_stream_instance.h,v 1.9 2007/03/20 15:01:20 strk Exp $
+// $Id: video_stream_instance.h,v 1.10 2007/04/12 09:14:36 strk Exp $
 
 #ifndef GNASH_VIDEO_STREAM_INSTANCE_H
 #define GNASH_VIDEO_STREAM_INSTANCE_H
@@ -49,6 +49,11 @@
 
        ~video_stream_instance();
 
+       geometry::Range2d<float> getBounds() const
+       {
+               return m_def->get_bound().getRange();
+       }
+
        virtual void    advance(float delta_time);
        void    display();
 

Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- testsuite/actionscript.all/MovieClip.as     12 Apr 2007 05:37:33 -0000      
1.53
+++ testsuite/actionscript.all/MovieClip.as     12 Apr 2007 09:14:36 -0000      
1.54
@@ -22,7 +22,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: MovieClip.as,v 1.53 2007/04/12 05:37:33 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.54 2007/04/12 09:14:36 strk Exp $";
 
 #include "check.as"
 
@@ -523,10 +523,10 @@
 check_equals(typeof(b.yMin), 'number');
 check_equals(typeof(b.yMax), 'number');
 // Returned number is (2^28/2)-1 twips : any ringing bell ?
-xcheck_equals(b.xMin, 6710886.35);
-xcheck_equals(b.xMax, 6710886.35);
-xcheck_equals(b.yMin, 6710886.35);
-xcheck_equals(b.yMax, 6710886.35);
+check_equals(b.xMin, 6710886.35);
+check_equals(b.xMax, 6710886.35);
+check_equals(b.yMin, 6710886.35);
+check_equals(b.yMax, 6710886.35);
 
 with (draw)
 {
@@ -540,52 +540,177 @@
 check_equals(draw._width, 10);
 check_equals(draw._height, 20);
 b = draw.getBounds();
-xcheck_equals(b.xMin, 10);
-xcheck_equals(b.xMax, 20);
-xcheck_equals(b.yMin, 10);
-xcheck_equals(b.yMax, 30);
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+b = draw.getBounds(container);
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
 
-draw._rotation = 90;
-xcheck_equals(draw._width, 20);
-xcheck_equals(draw._height, 10);
+draw._x += 20;
 b = draw.getBounds();
-xcheck_equals(b.xMin, 10);
-xcheck_equals(b.xMax, 20);
-xcheck_equals(b.yMin, 10);
-xcheck_equals(b.yMax, 30);
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+b = draw.getBounds(container);
+check_equals(b.xMin, 30);
+check_equals(b.xMax, 40);
+container._x -= 20;
+b = draw.getBounds();
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
 b = draw.getBounds(container);
-xcheck_equals(b.xMin, -30);
+check_equals(b.xMin, 30);
+check_equals(b.xMax, 40);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+check_equals(draw._width, 10); 
+check_equals(draw._height, 20);
+b = draw.getBounds(_root);
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+draw._x -= 20;
+container._x += 20;
+
+draw._rotation = 90;
+check_equals(draw._width, 20); 
+xcheck_equals(draw._height, 10); 
+b = draw.getBounds(); // these are local, untransformed
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+b = draw.getBounds(container); // these are transformed by container draw 
matrix
+check_equals(b.xMin, -30);
 xcheck_equals(b.xMax, -10);
 xcheck_equals(b.yMin, 10);
 xcheck_equals(b.yMax, 20);
 
 draw._visible = false;
-xcheck_equals(draw._width, 20);
+check_equals(draw._width, 20);
 xcheck_equals(draw._height, 10);
+b = draw.getBounds(); // these are local, untransformed
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+b = draw.getBounds(container); // these are transformed by container draw 
matrix
+check_equals(b.xMin, -30);
+xcheck_equals(b.xMax, -10);
+xcheck_equals(b.yMin, 10);
+xcheck_equals(b.yMax, 20);
 
 draw._xscale = 200;
-xcheck_equals(draw._width, 20);
-check_equals(draw._height, 20);
+check_equals(draw._width, 20);
+xcheck_equals(draw._height, 20);
 
 draw._rotation = 0;
 xcheck_equals(draw._width, 20);
-check_equals(draw._height, 20);
+xcheck_equals(draw._height, 20);
 
 draw._visible = true;
 draw._xscale = 100;
 check_equals(draw._width, 10);
-check_equals(draw._height, 20);
+xcheck_equals(draw._height, 20);
 
 draw._yscale = 50;
 check_equals(draw._width, 10);
-xcheck_equals(draw._height, 10);
+check_equals(draw._height, 10);
 check_equals(container._width, 10);
-xcheck_equals(container._height, 10);
+check_equals(container._height, 10);
 
 container._xscale = 800;
 check_equals(draw._width, 10);
-xcheck_equals(draw._height, 10);
-xcheck_equals(container._width, 80);
-xcheck_equals(container._height, 10);
+check_equals(draw._height, 10);
+check_equals(container._width, 80);
+check_equals(container._height, 10);
+b = draw.getBounds(); // these are local, untransformed
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+b = draw.getBounds(container); // these are transformed by container draw 
matrix
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 5);
+check_equals(b.yMax, 15);
+
+container._xscale = 100;
+container._yscale = 100;
+draw._yscale = 100;
+draw._xscale = 100;
+b = draw.getBounds(container); // these are transformed by container draw 
matrix
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+container.createEmptyMovieClip("draw2", 6);
+draw = container.draw2;
+with (draw)
+{
+       lineStyle(0, 0x000000);
+       moveTo(60, 20);
+       lineTo(60, 40);
+       lineTo(80, 40);
+       lineTo(80, 20);
+       lineTo(60, 20);
+}
+
+b = container.draw.getBounds(container); 
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+b = container.draw.getBounds(); 
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 20);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 30);
+b = container.draw2.getBounds(container); 
+check_equals(b.xMin, 60);
+check_equals(b.xMax, 80);
+check_equals(b.yMin, 20);
+check_equals(b.yMax, 40);
+b = container.draw2.getBounds(container.draw);
+check_equals(b.xMin, 60);
+check_equals(b.xMax, 80);
+check_equals(b.yMin, 20);
+check_equals(b.yMax, 40);
+b = container.draw2.getBounds(invalid);
+check_equals(typeof(b), 'undefined');
+b = container.draw2.getBounds(__shared_assets);
+check_equals(b.xMin, 60);
+check_equals(b.xMax, 80);
+check_equals(b.yMin, 20);
+check_equals(b.yMax, 40);
+
+b = container.draw2.getBounds(); 
+check_equals(b.xMin, 60);
+check_equals(b.xMax, 80);
+check_equals(b.yMin, 20);
+check_equals(b.yMax, 40);
+b = container.getBounds(); 
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 80);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 40);
+
+container.draw2._x += 20;
+b = container.getBounds(); 
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 100);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 40);
+check_equals(container._width, 90);
+check_equals(container._height, 30);
+
+container.draw2._xscale = 200;
+b = container.getBounds(); 
+check_equals(b.xMin, 10);
+check_equals(b.xMax, 180);
+check_equals(b.yMin, 10);
+check_equals(b.yMax, 40);
 
 #endif // OUTPUT_VERSION >= 6

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- testsuite/swfdec/PASSING    5 Apr 2007 11:16:11 -0000       1.14
+++ testsuite/swfdec/PASSING    12 Apr 2007 09:14:37 -0000      1.15
@@ -50,3 +50,5 @@
 comparisons-7.swf
 doaction-before-placeobject.swf
 undefined2-7.swf
+height1.swf
+height3.swf




reply via email to

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