Android: Low FPS draws a lot of bitmaps as a surface

I am trying to create a game with markers and I ran into a problem. I can’t get more than 17 frames per second after about 500 bullets. The update logic code takes about 1-4 ms for all of them, while the visualization code takes about 40 ms

At the moment, my code

private void drawEntities(Canvas canvas) {
    for (HashMap<UUID, Spatial> h: spatialList) {
        for (Spatial spatial: h.values()) {
            spatial.render(canvas);
            if(spatial.life > 0)
                spatial.life--;
            else if (spatial.life == 0)
                engine.deleteEntity(spatial.owner);
        }
    }
}

spacesList is an array in which each index is a zLevel

The space that displays the actual bullet,

public void render(Canvas canvas) {
    float angle = (float) (vel.getAngle() * (180 / Math.PI));
    matrix.reset();
    matrix.setTranslate(pos.x - bullet.getWidth() / 2, pos.y - bullet.getHeight() / 2);
    matrix.postRotate(angle + 90,  pos.x, pos.y);
    canvas.drawBitmap(bullet, matrix, paint);
    canvas.drawCircle(pos.x, pos.y, col.getRadius(), paint);
}

I can provide more code, but this is apparently the main problem. I have tried everything that I can think of and can no longer find it on the Internet. The only thing I can think of to fix this is to switch from surface view to GLSurfaceview, but I really think there is a better way, and I'm just using bad code.

: , drawcircle, 40 ~ 500, - .

TL;DR; 500 = 17 fps.

+4
3

. ( ) ?

- setFixedSize(), SurfaceView Surface. , . , , .

, , , , . , , 2560x1440 4K. "" 1080p . .

, - drawBitmap(), , drawCircle(), , .

OpenGL ES . "Hardware scaler exerciser" Grafika ( , ) . drawCircle() , , , . ( , SurfaceView, GLSurfaceView, GLES).

+4

. , , . , . " http://www.kilobolt.com/day-6-the-android-game-framework-part-ii.html"

AndroidGraphics AndroidFastRenderView , AndroidGraphics AndroidFastRenderView.

+2

, / drawCircle render(). , , , sin()/cos().

If this helps, you will have to figure out how to replace them with something faster, if not, well ...

0
source

All Articles