Flash DrawImage exended method is super-slow

Monkey Targets Forums/Flash/Flash DrawImage exended method is super-slow

Grey Alien(Posted 2013) [#1]
Hiya, I made a game where it draws about 500 tiles on screen.

If I draw them like this:

DrawImage(image, drawX, drawY)

it is super-fast and fine. But if I use the extended function form that supports rotation and scaling and frame number, it goes super-slow EVEN IF I supply 0 for the rotation and 1 for the scale and frame 0:

DrawImage(image, drawX, drawY, 0, 1, 1, 0)

I'm not sure if it's the rotation or the scale slowing it down tons because I can't test them separately.

However, I've been able to optimise my code by saying if not rotation/scaled don't call the extended method and I get a MASSIVE speed gain.

So my suggestion is that for Flash (and possibly for other targets although GLFW seemed fine), that Monkey should do that kind of check internally and not set rotation or scale if it doesn't need to.

What do you think?


therevills(Posted 2013) [#2]
Could you try setting the Matrix before calling DrawImage? The overrided DrawImage (see below) is meant to be a convenient method.

Function DrawImage : Int ( image:Image, x:Float, y:Float, rotation:Float, scaleX:Float, scaleY:Float, frame:Int=0 )
Draws an image at coordinates x, y, offset by the image's handle.

The image is drawn using the current color, alpha, blend mode and matrix, and is clipped to the current scissor rectangle.

The rotation and scaleX, scaleY parameters provide a convenient way for you to 'locally' rotate and scale the image.



Grey Alien(Posted 2013) [#3]
Yes that would tell me if it's the scale or rotation I guess. Run out of time tonight though.