0

I am using Surface to show bitmap from JNI, to show a video, this is my code :

       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);
        }

I went to calculate the time spent in each method,I found that the method

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

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

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

I don't know where the problem is, what happens next time to drawBitmap for so long time

ml_bright
  • 11
  • 1
  • Include the `Matrix` in your code too. Any code in getBitmap()? – Nikola Despotoski Oct 25 '16 at 06:53
  • I use to canvas.drawBitmap(getBitmap(), 0, 0 , null); it also take a lot of time in lockCanvas(), the getbitmap method just only get bitmap in memory `private Bitmap bufferBitmap public Bitmap getBitmap() { return bufferBitmap; }` – ml_bright Oct 25 '16 at 07:19
  • Check if getBitmap() takes too much time. Is your surfaceview hardware accelerated? – Nikola Despotoski Oct 25 '16 at 07:21
  • gitBitmap() is determined not to spend time, surfaceView is in activity hardware accelerated. If I want to have a good performance, Should not be used canvas , shold used opengl to drawbitmap ? – ml_bright Oct 25 '16 at 07:34

0 Answers0