62 lines
2.2 KiB
Java
62 lines
2.2 KiB
Java
|
package c.o.b.e;
|
||
|
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.opengl.EGL14;
|
||
|
import android.opengl.GLES20;
|
||
|
import c.o.b.c.b;
|
||
|
import c.o.b.c.d;
|
||
|
import c.o.b.c.e;
|
||
|
import d0.z.d.m;
|
||
|
import java.io.OutputStream;
|
||
|
import java.nio.ByteBuffer;
|
||
|
import java.nio.ByteOrder;
|
||
|
import java.util.Objects;
|
||
|
/* compiled from: EglSurface.kt */
|
||
|
public abstract class a {
|
||
|
public int a = -1;
|
||
|
public int b = -1;
|
||
|
|
||
|
/* renamed from: c reason: collision with root package name */
|
||
|
public c.o.b.a.a f1517c;
|
||
|
public e d;
|
||
|
|
||
|
public a(c.o.b.a.a aVar, e eVar) {
|
||
|
m.checkNotNullParameter(aVar, "eglCore");
|
||
|
m.checkNotNullParameter(eVar, "eglSurface");
|
||
|
m.checkNotNullParameter(aVar, "eglCore");
|
||
|
m.checkNotNullParameter(eVar, "eglSurface");
|
||
|
this.f1517c = aVar;
|
||
|
this.d = eVar;
|
||
|
}
|
||
|
|
||
|
public final void a(OutputStream outputStream, Bitmap.CompressFormat compressFormat) {
|
||
|
m.checkNotNullParameter(outputStream, "stream");
|
||
|
m.checkNotNullParameter(compressFormat, "format");
|
||
|
c.o.b.a.a aVar = this.f1517c;
|
||
|
e eVar = this.d;
|
||
|
Objects.requireNonNull(aVar);
|
||
|
m.checkNotNullParameter(eVar, "eglSurface");
|
||
|
if (m.areEqual(aVar.b, new b(EGL14.eglGetCurrentContext())) && m.areEqual(eVar, new e(EGL14.eglGetCurrentSurface(d.h)))) {
|
||
|
int i = this.a;
|
||
|
if (i < 0) {
|
||
|
i = this.f1517c.a(this.d, d.f);
|
||
|
}
|
||
|
int i2 = this.b;
|
||
|
if (i2 < 0) {
|
||
|
i2 = this.f1517c.a(this.d, d.g);
|
||
|
}
|
||
|
ByteBuffer allocateDirect = ByteBuffer.allocateDirect(i * i2 * 4);
|
||
|
allocateDirect.order(ByteOrder.LITTLE_ENDIAN);
|
||
|
GLES20.glReadPixels(0, 0, i, i2, 6408, 5121, allocateDirect);
|
||
|
c.o.b.a.d.b("glReadPixels");
|
||
|
allocateDirect.rewind();
|
||
|
Bitmap createBitmap = Bitmap.createBitmap(i, i2, Bitmap.Config.ARGB_8888);
|
||
|
createBitmap.copyPixelsFromBuffer(allocateDirect);
|
||
|
createBitmap.compress(compressFormat, 90, outputStream);
|
||
|
createBitmap.recycle();
|
||
|
return;
|
||
|
}
|
||
|
throw new RuntimeException("Expected EGL context/surface is not current");
|
||
|
}
|
||
|
}
|