Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
3.2 kB
3
Indexable
Never
public boolean drawBitmap(Bitmap bitmap, Bitmap waveformBitmap) {

        Log.d(TAG, "teddy drawBitmap:");
        if (bitmap == null || mTextureView == null) return false;
        mReviewRawBitmap = bitmap;

       int viewWidth = mTextureView.getWidth();
       int viewHeight = mTextureView.getHeight();
       int bModeViewWidth = viewWidth;
       int bModeViewHeight = viewHeight;

       boolean hasWaveMode = ModeControlManager.getInstance().isWaveMode();

       long lastTime = System.currentTimeMillis();

       //2D image
       int bmpWidth = bitmap.getWidth();
       int bmpHeight = bitmap.getHeight();

       Log.d(TAG, "teddy ByteBuffer.allocate:" + Log.getStackTraceString(new Throwable()));

       Log.d(TAG, "teddy go to native drawBitmap: bmpWidth:" + bmpWidth + ", bmpHeight:" + bmpHeight + ", viewWidth:" + viewWidth + ", viewHeight:" +  viewHeight);
       if (hasWaveMode && waveformBitmap != null) {

           mReviewRawWaveBitmap = waveformBitmap;
           ByteBuffer bufferTop, bufferBottom;
           bufferTop = ByteBuffer.allocateDirect(bmpWidth*bmpHeight*4);
           bufferBottom = ByteBuffer.allocateDirect(waveformBitmap.getWidth()*waveformBitmap.getHeight()*4);
           bitmap.copyPixelsToBuffer(bufferTop);
           waveformBitmap.copyPixelsToBuffer(bufferBottom);
//            VivaJNI.renderTextureView(bufferTop, bufferBottom, bmpWidth, bmpHeight, waveformBitmap.getWidth(), waveformBitmap.getHeight(),
//                    viewWidth, viewHeight, waveFormXOffset, waveFormYOffset, waveFormWidth, waveFormHeight);
           long firstTime = System.currentTimeMillis();

                   VivaJNI.renderTextureView(bufferTop, bmpWidth, bmpHeight, viewWidth, viewHeight);

           long time2d = System.currentTimeMillis();
           long diff2d = time2d - firstTime;

//                    VivaJNI.renderTextureViewWave(bufferBottom, waveformBitmap.getWidth(), waveformBitmap.getHeight(), mWaveTextureView.getWidth(), mWaveTextureView.getHeight());

           long timeWave = System.currentTimeMillis();
           long diffWave = timeWave - time2d;
           Log.d(TAG, "teddy drawBitmap: diff2d:" + diff2d + ", diffWave:" + diffWave);
           Log.d(TAG, "teddy drawBitmap: bmpWidth:" + bmpWidth + ", bmpHeight:" + bmpHeight + ", viewWidth:" + viewWidth + ", viewHeight:" +  viewHeight);
           Log.d(TAG, "teddy drawBitmap: waveformBitmap.getWidth():" + waveformBitmap.getWidth() + ", waveformBitmap.getHeight():" + waveformBitmap.getHeight() + ", mWaveTextureView.getWidth():" + mWaveTextureView.getWidth() + ", mWaveTextureView.getHeight():" +  mWaveTextureView.getHeight());
       } else {
           Log.d(TAG, "teddy drawBitmap: only 2d");
           ByteBuffer buffer;
           buffer = ByteBuffer.allocateDirect(bmpWidth*bmpHeight*4);
           bitmap.copyPixelsToBuffer(buffer);
           VivaJNI.renderTextureView(buffer, bmpWidth, bmpHeight, bModeViewWidth, bModeViewHeight);
       }

       long currentTime = System.currentTimeMillis();
       long diff = currentTime - lastTime;
       Log.d(TAG, "teddy drawBitmap: diff:" + diff);

        return true;
    }