Use SurfaceViewPreview when hardware acceleration is off (#36)

pull/39/head
Mattia Iavarone 7 years ago committed by GitHub
parent 66077c1eaa
commit 200816ca84
  1. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  2. 2
      cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceViewPreview.java

@ -159,7 +159,10 @@ public class CameraView extends FrameLayout {
protected Preview instantiatePreview(Context context, ViewGroup container) { 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);
} }

@ -8,7 +8,7 @@ import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
// This is not used. // Fallback preview when hardware acceleration is off.
class SurfaceViewPreview extends Preview<SurfaceView, SurfaceHolder> { class SurfaceViewPreview extends Preview<SurfaceView, SurfaceHolder> {

Loading…
Cancel
Save