gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r12280: Add tests to make sure that


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r12280: Add tests to make sure that dynamic transforms don't affect BitmapData.draw.
Date: Sun, 04 Jul 2010 11:53:49 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 12280 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sun 2010-07-04 11:53:49 +0200
message:
  Add tests to make sure that dynamic transforms don't affect BitmapData.draw.
modified:
  testsuite/actionscript.all/BitmapData.as
=== modified file 'testsuite/actionscript.all/BitmapData.as'
--- a/testsuite/actionscript.all/BitmapData.as  2010-01-01 17:48:26 +0000
+++ b/testsuite/actionscript.all/BitmapData.as  2010-06-29 12:23:16 +0000
@@ -298,10 +298,118 @@
 flash.geom.Rectangle = backup;
 check_equals(bmp.rectangle.toString(), "(x=0, y=0, w=20, h=10)");
 
+////////////////////
+// BitmapData.draw
+////////////////////
+
+// First we check that all user-defined transformations are ignored.
+
+// Note: at the corners of these tests antialiasing makes a difference. The
+// value can vary according to the transformation of the clip. We're not
+// really interested in the exact values of anti-aliased pixels.
+
+d = _root.createEmptyMovieClip("tar", 600);
+d.beginFill(0x00ff00);
+d.moveTo(20, 20);
+d.lineTo(20, 80);
+d.lineTo(80, 80);
+d.lineTo(80, 40);
+d.lineTo(20, 20);
+
+d.moveTo(50, 50);
+d.beginFill(0xff0000);
+d.lineTo(60, 50);
+d.lineTo(60, 60);
+d.lineTo(50, 60);
+d.lineTo(50, 50);
+
+
+// 100x100, no transparency
+b = new Bitmap(100, 100, false);
+b.draw(d);
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+// Hard ref
+b.draw(_level0.tar);
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+// User-defined translation makes no difference.
+d._x = 500;
+b.draw(d);
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+// User defined transform makes no difference.
+d._height = 30;
+b.draw(d);
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+// User defined transform makes no difference.
+d._width = 30;
+b.draw(d);
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+// Color transform the old way (no difference).
+c = new Color("_level0.tar");  
+c.setRGB(0xff5500);
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+// Color transform the new way.
+var tr = d.transform;
+tr.colorTransform = new flash.geom.ColorTransform(0.5, 0.5, 0.5, 0.5, 34, 34, 
34, 34);
+d.transform = tr;
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+dom = new flash.geom.Matrix();
+dom.rotate(Math.PI / 4);
+tr.matrix = dom;
+d.transform = tr;
+check_equals(b.getPixel(1, 1), 0xffffff);
+xcheck_equals(b.getPixel(21, 21), 0x00ff00);
+check_equals(b.getPixel(19, 20), 0xffffff);
+xcheck_equals(b.getPixel(79, 79), 0x00ff00);
+check_equals(b.getPixel(50, 25), 0xffffff);
+xcheck_equals(b.getPixel(55, 55), 0xff0000);
+
+
 //-------------------------------------------------------------
 // END OF TEST
 //-------------------------------------------------------------
 
-totals(121);
+totals(169);
 
 #endif // OUTPUT_VERSION >= 8


reply via email to

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