How to optimize Canvas drawing - drawBitmap on Android? -


i've done profiling , seems of time spent during drawbitmap, called (understandingly) on every frame.

i use surfaceview/updating thread/canvas locking approach demonstrated in lunarlander sample. i've changed (according this question)

  • on first frame construct bitmap buffer , paint onto it
  • paint each subsequent frame reusing bitmap (not on screen changes)
  • at end of each frame paint buffer once target canvas (to screen)

traceview showed me drawbitmap takes 5ms each frame on 800x480 device. can better or 'carved stone' , have optimize other parts of code achieve frames per second?

it depends on many things, drawbitmap() fast can get. in particular case, if don't need blending, make sure using opaque bitmap. in addition, try use bitmap in format compatible surface. instance, if using 16 bits surface, drawing 16-bits (rgb565) bitmap fast (it's memcpy call.) if surface 32 bits, use argb8888 opaque bitmap.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -