BitmapData.lock benchmark
Well, I don’t know if anybody read the Thomas Pfeiffer aka Kiroukou (the Sandy3D creator and project leader) commented on my previous post.
Here’s what he said.
Indeed Sandy does a clone of the original texture, for few reasons:
- avoid an unfortunate dispose call.
- allowing to have a setTransparency method to dynamically change the transparency without changing the original bitmapdata of the user.Concerning the lock() and unclock() are you sure it has a performance impact?
as far I know, this can’t provide any performance boost since the bitmapdata isn’t attached to the flash display list. When the object is out of stage, there’s no advantage to lock it.
But I’d be interessted to have your feedback about that, and your performance test.
About the BitmapData.clone(), he got his point.
It just don’t work for me because I’m using too many 3d Objects with different BitmapMaterial for each, so, the system memory gets too high.
But, about the setTransparency method, he is right.
About the lock and unlock methods, I runned a little benchmark test, because I got curious too how much performance boost you can get.
Here’s the two test I made. (Clicking on the flash area it will re-run the benchmark test)
Using the lock and unlock methods.
Not using the lock and unlock methods.
It’s a really simple test, just to make a benchmark test.
Actually, it’s not a situation that uses any 3d framework.
Creating a BitmapData.
Creating 1000 Bitmaps.
Applying 1000 times a BlurFilter over the BitmapData.
On my PC I get about 150ms faster with locking the BitmapData.
keita
Martin said,
December 4, 2007 @ 10:26 pm
Keita:
I only get a 5ms difference, I’m in a Core2Duo with WinXP, Player version: 9.0 r47
But even if the difference is noticeable only to some users, you have a point.
keita said,
December 5, 2007 @ 1:51 pm
yeah yeah…
hehe, actually, it’s beacuse I want to use those BitmapData.lock/unlock methods somewhere, and I didn’t find where I could use… so as it improves either 150 ms or 5ms, its a improve…