Faster canvas.drawBitmap ?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Faster canvas.drawBitmap ?

Postby Jompe71 » Sun Oct 26, 2008 11:00 am

I just did some trace viewing of a game I'm making and noticed that the setting of Rect's took about 10% of the total rendering time. This even if Rects are reused and not newly instantiated.

Since there is no drawBitmap using only primitives for src->dst blitting is there any other way of drawing without having to set a lot of rectangle bounds each time?

The only way I can think of is faster is to split up the source Image into the Tiles I'm using and to draw them with
drawBitmap( Bitmap, int, int, Paint ).

Any other ideas ??
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Top

Postby MrSnowflake » Tue Oct 28, 2008 11:59 am

Canvas.drawBitmap(bmp, matrix, paint) Don't know if that's what you want. This should let you allow to have the same result, but you should reach your goal in a totally different manner.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Jompe71 » Tue Oct 28, 2008 12:55 pm

Don't know if that's what you want

Not really (I think)!

The matrix also requires updates before passing to drawBitmap.
My situation is I draw from different source offsets to different destination offsets in a loop and must therefore update either the Matrix or the Rects. This takes usless CPU time I think.

There should be a drawBitmap( Bitmap, int, int, int, int, int, int, int, int, Paint ) method in my opinion.

Never the less I shall do benchmarking on cropping the source Image into smaller and draw using the drawBitmap( Bitmap, int, int, Paint ) instead.
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Postby MrSnowflake » Tue Oct 28, 2008 1:08 pm

Is the 'slowness' going to be a real problem? Other wise you probably have to do the drawing in OpenGL.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Jompe71 » Tue Oct 28, 2008 1:25 pm

Is the 'slowness' going to be a real problem?

Yes, it's a game. Every millisecond counts... ;)

Other wise you probably have to do the drawing in OpenGL.

Perhaps, but it's a path I haven't gone before. Maybe time to learn something new!
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Postby MrSnowflake » Tue Oct 28, 2008 2:02 pm

Jompe71 wrote:
Is the 'slowness' going to be a real problem?

Yes, it's a game. Every millisecond counts... ;)
Hehe, yeah very true, but as the G1 has a refresh rate of 50hz, you should aim at having 50 fps, if it's more, then you have cpu time left for your game!

Jompe71 wrote:
Other wise you probably have to do the drawing in OpenGL.

Perhaps, but it's a path I haven't gone before. Maybe time to learn something new!
Same for me, never used OpenGL in Java or OpenGL ES. But we are in ICT, so learning new things is stuff we do :).
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Postby jasont » Wed Oct 29, 2008 1:12 am

Use clipping with your draw bitmap call. Simply clip to the frame you want to display and draw the image ;)
jasont
Developer
Developer
 
Posts: 28
Joined: Mon Sep 22, 2008 6:39 pm
Location: California

Postby Jompe71 » Wed Oct 29, 2008 9:25 am

Woohoo (Homer style..)!!

Using the clipRect with the option Region.Op.REPLACE I've got the feature I was looking for.
This should save some rendering time now what the pointless setting of Rects can be removed.

It also makes the game common rendering methods more "compatible", i.e. easier to port to J2ME (sorry for mentioning that word in this forum ;-)) later on.

...thx !!
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests