gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9802: Make Transform_as's sprite_in


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9802: Make Transform_as's sprite_instance reference safe (I think), pending more
Date: Sat, 20 Sep 2008 14:29:25 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9802
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2008-09-20 14:29:25 +0200
message:
  Make Transform_as's sprite_instance reference safe (I think), pending more
  tests about how the binding should be done.
  
  Implement matrix setter because it's easy, may be useful in testing, and
  makes all the senocular Matrix demonstrations work, which is nice.
  
  Transform.as matrix tests all pass (apart from one accuracy-based one).
modified:
  libcore/asobj/flash/geom/Transform_as.cpp
  testsuite/actionscript.all/Transform.as
    ------------------------------------------------------------
    revno: 9795.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Sat 2008-09-20 11:45:41 +0200
    message:
      Implement Transform.matrix setter.
      
      Add a few more logging messages (needs many more and lots of tidying up).
    modified:
      libcore/asobj/flash/geom/Transform_as.cpp
    ------------------------------------------------------------
    revno: 9795.1.6
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Sat 2008-09-20 12:52:20 +0200
    message:
      Tests for MovieClip binding.
    modified:
      testsuite/actionscript.all/Transform.as
    ------------------------------------------------------------
    revno: 9795.1.7
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Sat 2008-09-20 14:04:02 +0200
    message:
       Mark reachable resources, add TODOs.
    modified:
      libcore/asobj/flash/geom/Transform_as.cpp
=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2008-09-20 09:21:17 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2008-09-20 12:04:02 +0000
@@ -103,6 +103,15 @@
 
     const matrix& getMatrix() const { return _movieClip.get_matrix(); }
     const cxform& getColorTransform() const { return _movieClip.get_cxform(); }
+    void setMatrix(const matrix& mat) { _movieClip.set_matrix(mat); }
+
+protected:
+
+    void markReachableResources()
+    {
+        _movieClip.setReachable();
+        markAsObjectReachable();
+    }
 
 private:
 
@@ -142,6 +151,8 @@
 Transform_matrix_getset(const fn_call& fn)
 {
 
+    const double factor = 65536.0;
+
     // TODO: What happens if you do: "mat = mc.transform.matrix; mat.a = 6;"
     // (where mc is a MovieClip)? Nothing (probable), or does it change mc (how
     // would that work?)?
@@ -204,11 +215,6 @@
         std::auto_ptr<std::vector<as_value> > args(new std::vector<as_value>);
         const matrix& m = ptr->getMatrix();
 
-        log_debug("Sprite matrix: %d, %d, %d, %d, %d, %d", m.sx, m.shx
-            , m.sy, m.shy, m.tx, m.ty);
-
-        const double factor = 65536.0;
-
         args->push_back(m.sx / factor);
         args->push_back(m.shx / factor);
         args->push_back(m.shy / factor);
@@ -223,7 +229,48 @@
     }
 
     // Setter
-       LOG_ONCE(log_unimpl("flash.geom.Transform.matrix setter"));
+
+    if (fn.nargs > 1)
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+            std::ostringstream ss;
+            fn.dump_args(ss);
+            log_aserror("Transform.matrix(%s): extra arguments discarded", 
ss.str());
+        );
+    }
+
+
+    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object();
+    if (!obj)
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+            std::ostringstream ss;
+            fn.dump_args(ss);
+            log_aserror("Transform.matrix(%s): argument is not an object", 
ss.str());
+        );
+        return as_value();
+    }
+    
+    // TODO: does this have to be an AS matrix or can it be any object
+    // (more likely)? 
+    as_value a, b, c, d, tx, ty;
+    obj->get_member(NSV::PROP_A, &a);
+    obj->get_member(NSV::PROP_B, &b);
+    obj->get_member(NSV::PROP_C, &c);
+    obj->get_member(NSV::PROP_D, &d);
+    obj->get_member(NSV::PROP_TX, &tx);
+    obj->get_member(NSV::PROP_TY, &ty);
+
+    matrix m;
+    m.sx = a.to_number() * factor;
+    m.shx = b.to_number() * factor;
+    m.shy = c.to_number() * factor;
+    m.sy = d.to_number() * factor;
+    m.set_x_translation(PIXELS_TO_TWIPS(tx.to_number()));
+    m.set_y_translation(PIXELS_TO_TWIPS(ty.to_number()));
+
+    ptr->setMatrix(m);
+
     return as_value();
 
 }
@@ -248,7 +295,7 @@
         IF_VERBOSE_ASCODING_ERRORS(
             std::ostringstream ss;
             fn.dump_args(ss);
-            log_aserror("Transform constructor: needs one argument", ss.str());
+            log_aserror("flash.geom.Transform(%s): needs one argument", 
ss.str());
         );
         return as_value();
     }
@@ -261,6 +308,7 @@
                LOG_ONCE( log_unimpl("Transform(%s): %s", ss.str(), 
_("arguments discarded")) );
        }
 
+    // TODO: does this have to be a MovieClip or can it be any character?
     boost::intrusive_ptr<sprite_instance> mc = 
ensureType<sprite_instance>(fn.arg(0).to_object());
 
        boost::intrusive_ptr<as_object> obj = new Transform_as(*mc);
@@ -301,6 +349,8 @@
 
        // Register _global.Transform
     string_table& st = where.getVM().getStringTable();
-    where.init_destructive_property(st.find("Transform"), 
get_flash_geom_transform_constructor);}
+    where.init_destructive_property(st.find("Transform"), 
get_flash_geom_transform_constructor);
+
+}
 
 } // end of gnash namespace

=== modified file 'testsuite/actionscript.all/Transform.as'
--- a/testsuite/actionscript.all/Transform.as   2008-09-20 12:06:35 +0000
+++ b/testsuite/actionscript.all/Transform.as   2008-09-20 12:29:25 +0000
@@ -131,22 +131,22 @@
 
 trans.matrix = new Matrix(2, 0, 0, 2, 10, 11);
 
-xcheck_equals(trans.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, ty=11)");
-xcheck_equals(mc2.transform.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, 
ty=11)");
+check_equals(trans.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, ty=11)");
+check_equals(mc2.transform.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, 
ty=11)");
 
 delete mc2;
 
 check_equals(mc2.transform.matrix.toString(), undefined);
-xcheck_equals(trans.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, ty=11)");
+check_equals(trans.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, ty=11)");
 check_equals(mat.toString(), "(a=1, b=0, c=0, d=1, tx=0, ty=0)");
 
 mc2 = undefined;
 
-xcheck_equals(trans.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, ty=11)");
+check_equals(trans.matrix.toString(), "(a=2, b=0, c=0, d=2, tx=10, ty=11)");
 
 // Identity;
 trans.matrix = new Matrix;
-xcheck_equals(trans.matrix.toString(), "(a=1, b=0, c=0, d=1, tx=0, ty=0)");
+check_equals(trans.matrix.toString(), "(a=1, b=0, c=0, d=1, tx=0, ty=0)");
 
 
 mc = _root.createEmptyMovieClip("mc", getNextHighestDepth());
@@ -154,8 +154,8 @@
 
 mcOld = mc;
 trans.matrix = new Matrix(3, 0.5, 0.5, 2, 0, 1);
-xcheck_equals(mc.transform.matrix.toString(), "(a=3, b=0.5, c=0.5, d=2, tx=0, 
ty=1)");
-xcheck_equals(mcOld.transform.matrix.toString(), "(a=3, b=0.5, c=0.5, d=2, 
tx=0, ty=1)");
+check_equals(mc.transform.matrix.toString(), "(a=3, b=0.5, c=0.5, d=2, tx=0, 
ty=1)");
+check_equals(mcOld.transform.matrix.toString(), "(a=3, b=0.5, c=0.5, d=2, 
tx=0, ty=1)");
 
 
 mcOld = mc;


reply via email to

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