From 16c411205fe94f9ffb9f867e34f59fca123de55b Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 5 Jun 2017 12:21:14 -0700 Subject: [PATCH] Render software rasterizer bitmaps through the SurfaceHolder (#3736) --- .../android/io/flutter/view/FlutterView.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index aa2af85b7a..8883e05792 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -86,8 +86,6 @@ public class FlutterView extends SurfaceView private long mNativePlatformView; private boolean mIsSoftwareRenderingEnabled = false; // using the software renderer or not - private volatile Bitmap mSoftwareRenderingBitmap; - public FlutterView(Context context) { this(context, null); } @@ -206,19 +204,16 @@ public class FlutterView extends SurfaceView return super.onKeyDown(keyCode, event); } - @Override - protected void onDraw(Canvas canvas) { - if (mSoftwareRenderingBitmap != null) { - canvas.drawBitmap(mSoftwareRenderingBitmap, new Matrix(), new Paint()); - } - } - // This method will be called on the GPU Thread. public void updateSoftwareBuffer(ByteBuffer buffer, int width, int height) { - Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - newBitmap.copyPixelsFromBuffer(buffer); - mSoftwareRenderingBitmap = newBitmap; - postInvalidate(); + Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + bitmap.copyPixelsFromBuffer(buffer); + + Canvas canvas = getHolder().lockCanvas(); + if (canvas != null) { + canvas.drawBitmap(bitmap, new Matrix(), null); + getHolder().unlockCanvasAndPost(canvas); + } } public void addActivityLifecycleListener(ActivityLifecycleListener listener) { -- GitLab