SurfaceView drawBitmap耗时太长,最长耗时200ms

时间:2016-10-25 06:51:26

标签: android android-canvas surfaceview surfaceholder drawbitmap

我使用Surface来显示来自JNI的位图,以显示视频,这是我的代码:

       SurfaceHolder holder = surfaceView.getHolder();
       while(true) {
            if(getBitmap() == null) {
                continue;
            }
            Canvas canvas = holder.lockCanvas();
            canvas.drawBitmap(getBitmap(), matrix, null);
            if(viewInterface == null) {
                break;
            }
            holder.unlockCanvasAndPost(canvas);
            setBitmap(null);
        }

我去计算每个方法花费的时间,我发现了方法

//longest time consuming 71ms
holder.lockCanvas(); 

//longest time consuming 50ms
canvas.drawBitmap(getBitmap(), matrix, null);

//longest time consuming 111ms
holder.unlockCanvasAndPost(canvas);

我不知道问题出在哪里,下次drawBitmap会发生什么事情

0 个答案:

没有答案