From 200816ca84140859e66a56e8224e6532b8ca662a Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 8 Sep 2017 16:23:55 +0200 Subject: [PATCH] Use SurfaceViewPreview when hardware acceleration is off (#36) --- .../main/java/com/otaliastudios/cameraview/CameraView.java | 5 ++++- .../com/otaliastudios/cameraview/SurfaceViewPreview.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index e79066a0..e6c22a26 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -159,7 +159,10 @@ public class CameraView extends FrameLayout { protected Preview instantiatePreview(Context context, ViewGroup container) { - return new TextureViewPreview(context, container, null); + // TextureView is not supported without hardware acceleration. + return isHardwareAccelerated() ? + new TextureViewPreview(context, container, null) : + new SurfaceViewPreview(context, container, null); } diff --git a/cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceViewPreview.java b/cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceViewPreview.java index ed5e3f60..4fe2b73a 100644 --- a/cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceViewPreview.java +++ b/cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceViewPreview.java @@ -8,7 +8,7 @@ import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; -// This is not used. +// Fallback preview when hardware acceleration is off. class SurfaceViewPreview extends Preview {