PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

rotation/scaling speeds

Hi,

I recently finished coding scaling and rotation for my 2d mobile api and compared it versus gapidraw and edgelib.

I did some benchmarks on my spv c600.

rotating 5000 blits 32x32 to 45degrees
gapidraw - 2203ms
lpl - 1976ms
edge - 2633ms

scaling 5000 blits 32x32 to 64x64
gapidraw - 5877ms
lpl - 1037ms
edge - 8576ms

I also implemented a function which performs both rotation and scaling (rotozoom) but this was pretty slow around 9seconds to gapidraws 6.

I wondered if anyone knew if gapidraw uses a secondry buffer to store the data from the rotation and then scale it as I perform the rotation/scaling together in a set of loops.
Those are some pretty big differences on the scaling which makes me think there is a difference in algorithms used between what you are doing and gapi/edge are doing, are you doing subpixel accuracy?
My method for scaling calculates a ratio for x and y, everything is in fixed point. I then loop around the height and width setting the row in the height loop and then retrieving the column value in the width loop. Only one multiplication is used in the Height loop to calculare the row. The output looks exactly the same as gapidraw/edge.

Also I have just implemented a new rotation algorithm which only calculates the multiplys in the outter loop, ill test this for speed to see if this makes it any faster. Though since I rotate and then scale all in one the output on screen is a scaled rotated sprite which looks different to gapidraws scaled and then rotated which leads me to believe they use a temp buffer.
I have managed to implement a rotation+scale (rotozoom) function.

gapidraw - 6456ms
lpl - 7230ms
edge - 9210ms

Slightly slower than gapidraw but thats about the best im gonna get it with my current algorithm.

I dont know why gapidraw/edge are slow in scaling since I get the exact same output.
Actually it could depend on the screen rotation of the device, since gapidraw stores their images in screen aligned memory, perhaps the alignment is such that it is missing the cache on every read, where yours is hitting it, just a guess.