gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9540: Some minor improvements to Bi


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9540: Some minor improvements to BitmapData. This needs more testing.
Date: Fri, 25 Jul 2008 15:59:01 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9540
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-07-25 15:59:01 +0200
message:
  Some minor improvements to BitmapData. This needs more testing.
modified:
  libcore/asobj/flash/display/BitmapData_as.cpp
  libcore/asobj/flash/display/BitmapData_as.h
  testsuite/actionscript.all/BitmapData.as
    ------------------------------------------------------------
    revno: 9536.1.8
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Fri 2008-07-25 15:09:43 +0200
    message:
      More tests.
    modified:
      testsuite/actionscript.all/BitmapData.as
    ------------------------------------------------------------
    revno: 9536.1.9
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Fri 2008-07-25 15:09:58 +0200
    message:
      Implement dispose(). Return -1 for all properties if the bitmap has been
      disposed.
      
      actionscript.all/BitmapData.as (and swfdec/bitmapdata-getters.as) show 
that
      the rectangle property can be overridden by redefining 
flash.geom.Rectangle.
      This may apply to other flash package classes too. Gnash always constructs
      a genuine Rectangle.
    modified:
      libcore/asobj/flash/display/BitmapData_as.cpp
      libcore/asobj/flash/display/BitmapData_as.h
    ------------------------------------------------------------
    revno: 9536.1.10
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Fri 2008-07-25 15:50:32 +0200
    message:
      check->xcheck.
    modified:
      testsuite/actionscript.all/BitmapData.as
=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp     2008-07-25 11:19:08 
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp     2008-07-25 13:09:58 
+0000
@@ -171,6 +171,10 @@
 void
 BitmapData_as::fillRect(int x, int y, int w, int h, boost::uint32_t color)
 {
+    // The bitmap has been "disposed".
+    if (_bitmapData.empty()) return;
+    assert (_bitmapData.size() == _width * _height);
+
     if (w < 0 || h < 0) return;
 
     // Nothing to do if x or y are outside the image (negative height
@@ -221,6 +225,12 @@
 
 }
 
+void
+BitmapData_as::dispose()
+{
+    _bitmapData.clear();
+}
+
 as_function* getFlashDisplayBitmapDataConstructor()
 {
     static builtin_function* cl = NULL;
@@ -281,12 +291,10 @@
 static as_value
 BitmapData_dispose(const fn_call& fn)
 {
-
     // Should free the memory storing the bitmap.
-    // What is the size afterwards? Can it be reused?
+    // All properties afterwards are -1 (even the rectangle)
        boost::intrusive_ptr<BitmapData_as> ptr = 
ensureType<BitmapData_as>(fn.this_ptr);
-       UNUSED(ptr);
-       LOG_ONCE( log_unimpl (__FUNCTION__) );
+    ptr->dispose();
        return as_value();
 }
 
@@ -499,7 +507,8 @@
     // Read-only
     if (fn.nargs) return as_value();
     
-    // Returns the immutable height of the bitmap.
+    // Returns the immutable height of the bitmap or -1 if dispose() has been 
called.
+    if (ptr->getBitmapData().empty()) return -1;
        return as_value(ptr->getHeight());
 }
 
@@ -508,6 +517,9 @@
 {
        boost::intrusive_ptr<BitmapData_as> ptr = 
ensureType<BitmapData_as>(fn.this_ptr);
 
+    // Returns the immutable rectangle of the bitmap or -1 if dispose() has 
been called.
+    if (ptr->getBitmapData().empty()) return -1;
+
        boost::intrusive_ptr<as_object> obj = init_Rectangle_instance();
 
        obj->set_member(NSV::PROP_X, 0);
@@ -526,7 +538,8 @@
     // Read-only
     if (fn.nargs) return as_value();
     
-    // Returns the immutable height of the bitmap.
+    // Returns whether bitmap is transparent or -1 if dispose() has been 
called.
+    if (ptr->getBitmapData().empty()) return -1;
        return as_value(ptr->isTransparent());
 }
 
@@ -538,7 +551,8 @@
     // Read-only
     if (fn.nargs) return as_value();
     
-    // Returns the immutable height of the bitmap.
+    // Returns the immutable width of the bitmap or -1 if dispose() has been 
called.
+    if (ptr->getBitmapData().empty()) return -1;
        return as_value(ptr->getWidth());
 }
 

=== modified file 'libcore/asobj/flash/display/BitmapData_as.h'
--- a/libcore/asobj/flash/display/BitmapData_as.h       2008-06-21 15:32:20 
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.h       2008-07-25 13:09:58 
+0000
@@ -60,6 +60,9 @@
     
     // Fill the bitmap with a colour starting at x, y
     void fillRect(int x, int y, int w, int h, boost::uint32_t color);
+    
+    // Free the bitmap data (clear the array)
+    void dispose();
 
 private:
 

=== modified file 'testsuite/actionscript.all/BitmapData.as'
--- a/testsuite/actionscript.all/BitmapData.as  2008-07-25 11:19:08 +0000
+++ b/testsuite/actionscript.all/BitmapData.as  2008-07-25 13:50:32 +0000
@@ -209,22 +209,48 @@
 mc.attachBitmap(bmp, this.getNextHighestDepth());
 
 bmp.dispose();
-xcheck_equals(bmp.height, -1);
-xcheck_equals(bmp.width, -1);
-xcheck_equals(bmp.transparent, -1);
-xcheck_equals(typeof(bmp.rectangle), "number");
-xcheck_equals(bmp.rectangle, -1);
-xcheck_equals(bmp.rectangle.toString(), "-1");
+check_equals(bmp.height, -1);
+check_equals(bmp.width, -1);
+check_equals(bmp.transparent, -1);
+check_equals(typeof(bmp.rectangle), "number");
+check_equals(bmp.rectangle, -1);
+check_equals(bmp.rectangle.toString(), "-1");
 
 check(bmp instanceOf Bitmap);
 bmp.height = 2;
-xcheck_equals(bmp.height, -1);
-
+check_equals(bmp.height, -1);
+
+bmp = new Bitmap(20, 10, true);
+backup = flash.geom.Rectangle;
+flash.geom.Rectangle = 2;
+xcheck_equals(bmp.rectangle, -1);
+
+flash.geom.Rectangle = function (x, y, w, h)
+{
+    this.y = x + 5;
+    this.x = 10.5;
+    this.width = h;
+    this.height = w;
+};
+xcheck_equals(bmp.rectangle.toString(), "[object Object]");
+
+flash.geom.Rectangle = function (x, y, w, h)
+{
+};
+xcheck_equals(bmp.rectangle.toString(), "[object Object]");
+
+flash.geom.Rectangle = function ()
+{
+};
+xcheck_equals(bmp.rectangle.toString(), "[object Object]");
+
+flash.geom.Rectangle = backup;
+check_equals(bmp.rectangle.toString(), "(x=0, y=0, w=20, h=10)");
 
 //-------------------------------------------------------------
 // END OF TEST
 //-------------------------------------------------------------
 
-totals(98);
+totals(103);
 
 #endif // OUTPUT_VERSION >= 8


reply via email to

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