176 lines
6.7 KiB
Java
176 lines
6.7 KiB
Java
package c.o.a.v;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.SurfaceTexture;
|
|
import android.opengl.EGL14;
|
|
import android.opengl.EGLContext;
|
|
import android.opengl.EGLDisplay;
|
|
import android.opengl.EGLSurface;
|
|
import android.opengl.GLES20;
|
|
import android.opengl.Matrix;
|
|
import android.util.Log;
|
|
import android.view.Surface;
|
|
import c.o.a.l;
|
|
import c.o.a.u.a;
|
|
import c.o.a.x.b;
|
|
import c.o.b.a.a;
|
|
import c.o.b.c.c;
|
|
import c.o.b.c.d;
|
|
import c.o.b.c.e;
|
|
import d0.z.d.m;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.util.Objects;
|
|
/* compiled from: SnapshotGlPictureRecorder */
|
|
public class h implements Runnable {
|
|
public final /* synthetic */ SurfaceTexture i;
|
|
public final /* synthetic */ int j;
|
|
public final /* synthetic */ float k;
|
|
public final /* synthetic */ float l;
|
|
public final /* synthetic */ EGLContext m;
|
|
public final /* synthetic */ g n;
|
|
|
|
public h(g gVar, SurfaceTexture surfaceTexture, int i, float f, float f2, EGLContext eGLContext) {
|
|
this.n = gVar;
|
|
this.i = surfaceTexture;
|
|
this.j = i;
|
|
this.k = f;
|
|
this.l = f2;
|
|
this.m = eGLContext;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:56:0x01f7, code lost:
|
|
r0 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:57:0x01f8, code lost:
|
|
d0.y.b.closeFinally(r4, r0);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:58:0x01fc, code lost:
|
|
throw r0;
|
|
*/
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
?? r3;
|
|
g gVar = this.n;
|
|
SurfaceTexture surfaceTexture = this.i;
|
|
int i = this.j;
|
|
float f = this.k;
|
|
float f2 = this.l;
|
|
EGLContext eGLContext = this.m;
|
|
Objects.requireNonNull(gVar);
|
|
SurfaceTexture surfaceTexture2 = new SurfaceTexture(9999);
|
|
b bVar = gVar.i.d;
|
|
surfaceTexture2.setDefaultBufferSize(bVar.i, bVar.j);
|
|
a aVar = new a(eGLContext, 1);
|
|
c.o.b.e.b bVar2 = new c.o.b.e.b(aVar, surfaceTexture2);
|
|
a aVar2 = bVar2.f1517c;
|
|
e eVar = bVar2.d;
|
|
Objects.requireNonNull(aVar2);
|
|
m.checkNotNullParameter(eVar, "eglSurface");
|
|
if (aVar2.a == d.b) {
|
|
Log.v("EglCore", "NOTE: makeSurfaceCurrent w/o display");
|
|
}
|
|
c cVar = aVar2.a;
|
|
c.o.b.c.b bVar3 = aVar2.b;
|
|
EGLDisplay eGLDisplay = cVar.a;
|
|
EGLSurface eGLSurface = eVar.a;
|
|
if (EGL14.eglMakeCurrent(eGLDisplay, eGLSurface, eGLSurface, bVar3.a)) {
|
|
float[] fArr = gVar.r.b;
|
|
surfaceTexture.getTransformMatrix(fArr);
|
|
Matrix.translateM(fArr, 0, (1.0f - f) / 2.0f, (1.0f - f2) / 2.0f, 0.0f);
|
|
Matrix.scaleM(fArr, 0, f, f2, 1.0f);
|
|
Matrix.translateM(fArr, 0, 0.5f, 0.5f, 0.0f);
|
|
Matrix.rotateM(fArr, 0, (float) (i + gVar.i.f1473c), 0.0f, 0.0f, 1.0f);
|
|
Matrix.scaleM(fArr, 0, 1.0f, -1.0f, 1.0f);
|
|
Matrix.translateM(fArr, 0, -0.5f, -0.5f, 0.0f);
|
|
if (gVar.p) {
|
|
c.o.a.u.b bVar4 = gVar.q;
|
|
a.EnumC0167a aVar3 = a.EnumC0167a.PICTURE_SNAPSHOT;
|
|
Objects.requireNonNull(bVar4);
|
|
try {
|
|
Canvas lockCanvas = bVar4.d.lockCanvas(null);
|
|
lockCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
|
((c.o.a.u.c) bVar4.b).a(aVar3, lockCanvas);
|
|
bVar4.d.unlockCanvasAndPost(lockCanvas);
|
|
} catch (Surface.OutOfResourcesException e) {
|
|
c.o.a.u.b.a.a(2, "Got Surface.OutOfResourcesException while drawing video overlays", e);
|
|
}
|
|
synchronized (bVar4.g) {
|
|
GLES20.glBindTexture(36197, bVar4.f.a);
|
|
bVar4.f1506c.updateTexImage();
|
|
}
|
|
bVar4.f1506c.getTransformMatrix(bVar4.e.b);
|
|
Matrix.translateM(gVar.q.e.b, 0, 0.5f, 0.5f, 0.0f);
|
|
Matrix.rotateM(gVar.q.e.b, 0, (float) gVar.i.f1473c, 0.0f, 0.0f, 1.0f);
|
|
Matrix.scaleM(gVar.q.e.b, 0, 1.0f, -1.0f, 1.0f);
|
|
Matrix.translateM(gVar.q.e.b, 0, -0.5f, -0.5f, 0.0f);
|
|
}
|
|
gVar.i.f1473c = 0;
|
|
long timestamp = surfaceTexture.getTimestamp() / 1000;
|
|
i.l.a(1, "takeFrame:", "timestampUs:", Long.valueOf(timestamp));
|
|
gVar.r.a(timestamp);
|
|
if (gVar.p) {
|
|
c.o.a.u.b bVar5 = gVar.q;
|
|
Objects.requireNonNull(bVar5);
|
|
GLES20.glDisable(2884);
|
|
GLES20.glDisable(2929);
|
|
GLES20.glEnable(3042);
|
|
GLES20.glBlendFunc(770, 771);
|
|
synchronized (bVar5.g) {
|
|
bVar5.e.a(timestamp);
|
|
}
|
|
}
|
|
l.a aVar4 = gVar.i;
|
|
Bitmap.CompressFormat compressFormat = Bitmap.CompressFormat.JPEG;
|
|
m.checkNotNullParameter(compressFormat, "format");
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
bVar2.a(byteArrayOutputStream, compressFormat);
|
|
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
|
m.checkNotNullExpressionValue(byteArray, "it.toByteArray()");
|
|
d0.y.b.closeFinally(byteArrayOutputStream, null);
|
|
aVar4.f = byteArray;
|
|
c.o.b.a.a aVar5 = bVar2.f1517c;
|
|
e eVar2 = bVar2.d;
|
|
Objects.requireNonNull(aVar5);
|
|
m.checkNotNullParameter(eVar2, "eglSurface");
|
|
EGL14.eglDestroySurface(aVar5.a.a, eVar2.a);
|
|
bVar2.d = d.f1512c;
|
|
bVar2.b = -1;
|
|
bVar2.a = -1;
|
|
gVar.r.b();
|
|
surfaceTexture2.release();
|
|
if (gVar.p) {
|
|
c.o.a.u.b bVar6 = gVar.q;
|
|
if (bVar6.f != null) {
|
|
GLES20.glBindTexture(36197, 0);
|
|
r3 = 0;
|
|
bVar6.f = null;
|
|
} else {
|
|
r3 = 0;
|
|
}
|
|
SurfaceTexture surfaceTexture3 = bVar6.f1506c;
|
|
if (surfaceTexture3 != null) {
|
|
surfaceTexture3.release();
|
|
bVar6.f1506c = r3;
|
|
}
|
|
Surface surface = bVar6.d;
|
|
if (surface != null) {
|
|
surface.release();
|
|
bVar6.d = r3;
|
|
}
|
|
c.o.a.r.c cVar2 = bVar6.e;
|
|
if (cVar2 != null) {
|
|
cVar2.b();
|
|
bVar6.e = r3;
|
|
}
|
|
}
|
|
aVar.b();
|
|
gVar.b();
|
|
return;
|
|
}
|
|
throw new RuntimeException("eglMakeCurrent failed");
|
|
}
|
|
}
|