Radek Sołdek
Radek Sołdek

Reputation: 53

Draw performance in canvas

I am using draw function in my app

public void draw(Canvas canvas) {
   if (canvas != null)
      canvas.drawBitmap(animation.getImage(), x, y, null);
}

This function is further invoked in main thread

try {
   canvas = this.surfaceHolder.lockCanvas();
   synchronized (surfaceHolder) {
      this.gamePanel.update();
      this.gamePanel.draw(canvas);
   }
} 

When I draw one PNG file (1800 x 1000 px) the frame rate is about 60 FPS, but when I separate this image to 3 files (600 x 1000 px) and draw them separately the framerate drops to 40 FPS. I need to have more smaller images, beacause I want the parallax effect and other things in the app, but how to increase the performence of that separate drawing?

Upvotes: 2

Views: 182

Answers (0)

Related Questions