150 lines
4.6 KiB
Java
150 lines
4.6 KiB
Java
package c.o.a.w;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.SurfaceTexture;
|
|
import android.view.LayoutInflater;
|
|
import android.view.TextureView;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.f.e.o.c;
|
|
import c.o.a.w.a;
|
|
import com.google.android.gms.tasks.TaskCompletionSource;
|
|
import com.otaliastudios.cameraview.R;
|
|
import java.util.concurrent.ExecutionException;
|
|
/* compiled from: TextureCameraPreview */
|
|
public class j extends a<TextureView, SurfaceTexture> {
|
|
public View j;
|
|
|
|
/* compiled from: TextureCameraPreview */
|
|
public class a implements Runnable {
|
|
public final /* synthetic */ a.b i;
|
|
|
|
public a(a.b bVar) {
|
|
this.i = bVar;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
int i;
|
|
int i2;
|
|
float f;
|
|
j jVar = j.this;
|
|
if (jVar.h == 0 || jVar.g == 0 || (i = jVar.f) == 0 || (i2 = jVar.e) == 0) {
|
|
a.b bVar = this.i;
|
|
if (bVar != null) {
|
|
bVar.a();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
c.o.a.x.a f2 = c.o.a.x.a.f(i2, i);
|
|
j jVar2 = j.this;
|
|
c.o.a.x.a f3 = c.o.a.x.a.f(jVar2.g, jVar2.h);
|
|
float f4 = 1.0f;
|
|
if (f2.i() >= f3.i()) {
|
|
f = f2.i() / f3.i();
|
|
} else {
|
|
f4 = f3.i() / f2.i();
|
|
f = 1.0f;
|
|
}
|
|
((TextureView) j.this.f1509c).setScaleX(f4);
|
|
((TextureView) j.this.f1509c).setScaleY(f);
|
|
j.this.d = f4 > 1.02f || f > 1.02f;
|
|
c.o.a.b bVar2 = a.a;
|
|
bVar2.a(1, "crop:", "applied scaleX=", Float.valueOf(f4));
|
|
bVar2.a(1, "crop:", "applied scaleY=", Float.valueOf(f));
|
|
a.b bVar3 = this.i;
|
|
if (bVar3 != null) {
|
|
bVar3.a();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: TextureCameraPreview */
|
|
public class b implements Runnable {
|
|
public final /* synthetic */ int i;
|
|
public final /* synthetic */ TaskCompletionSource j;
|
|
|
|
public b(int i, TaskCompletionSource taskCompletionSource) {
|
|
this.i = i;
|
|
this.j = taskCompletionSource;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
Matrix matrix = new Matrix();
|
|
j jVar = j.this;
|
|
int i = jVar.e;
|
|
float f = ((float) i) / 2.0f;
|
|
int i2 = jVar.f;
|
|
float f2 = ((float) i2) / 2.0f;
|
|
if (this.i % 180 != 0) {
|
|
float f3 = ((float) i2) / ((float) i);
|
|
matrix.postScale(f3, 1.0f / f3, f, f2);
|
|
}
|
|
matrix.postRotate((float) this.i, f, f2);
|
|
((TextureView) j.this.f1509c).setTransform(matrix);
|
|
this.j.a.t(null);
|
|
}
|
|
}
|
|
|
|
public j(@NonNull Context context, @NonNull ViewGroup viewGroup) {
|
|
super(context, viewGroup);
|
|
}
|
|
|
|
@Override // c.o.a.w.a
|
|
public void e(@Nullable a.b bVar) {
|
|
((TextureView) this.f1509c).post(new a(null));
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // c.o.a.w.a
|
|
@NonNull
|
|
public SurfaceTexture i() {
|
|
return ((TextureView) this.f1509c).getSurfaceTexture();
|
|
}
|
|
|
|
@Override // c.o.a.w.a
|
|
@NonNull
|
|
public Class<SurfaceTexture> j() {
|
|
return SurfaceTexture.class;
|
|
}
|
|
|
|
@Override // c.o.a.w.a
|
|
@NonNull
|
|
public View k() {
|
|
return this.j;
|
|
}
|
|
|
|
/* Return type fixed from 'android.view.View' to match base method */
|
|
@Override // c.o.a.w.a
|
|
@NonNull
|
|
public TextureView n(@NonNull Context context, @NonNull ViewGroup viewGroup) {
|
|
View inflate = LayoutInflater.from(context).inflate(R.b.cameraview_texture_view, viewGroup, false);
|
|
viewGroup.addView(inflate, 0);
|
|
TextureView textureView = (TextureView) inflate.findViewById(R.a.texture_view);
|
|
textureView.setSurfaceTextureListener(new i(this));
|
|
this.j = inflate;
|
|
return textureView;
|
|
}
|
|
|
|
@Override // c.o.a.w.a
|
|
public void r(int i) {
|
|
this.i = i;
|
|
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
|
|
((TextureView) this.f1509c).post(new b(i, taskCompletionSource));
|
|
try {
|
|
c.c(taskCompletionSource.a);
|
|
} catch (InterruptedException | ExecutionException unused) {
|
|
}
|
|
}
|
|
|
|
@Override // c.o.a.w.a
|
|
public boolean u() {
|
|
return true;
|
|
}
|
|
}
|