what-the-bank/sources/com/kofax/kmc/ken/engines/gpu/GPUImageHolderImpl.java

137 lines
4.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.kmc.ken.engines.gpu;
import android.content.Context;
import android.graphics.Bitmap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import o.InterfaceC13391fZD;
/* loaded from: classes3.dex */
public class GPUImageHolderImpl implements IGPUImageHolder {
private Context V;
private d gs = null;
volatile int count = 0;
private ExecutorService gt = null;
/* JADX INFO: Access modifiers changed from: package-private */
@InterfaceC13391fZD
public GPUImageHolderImpl(Context context) {
this.V = context;
}
@Override // com.kofax.kmc.ken.engines.gpu.IGPUImageHolder
public void init() {
synchronized (this) {
this.count++;
if (this.gt == null) {
this.gt = Executors.newSingleThreadExecutor();
}
}
}
@Override // com.kofax.kmc.ken.engines.gpu.IGPUImageHolder
public void destroy() {
synchronized (this) {
this.count--;
if (this.count == 0) {
call(new Callable<Void>(this) { // from class: com.kofax.kmc.ken.engines.gpu.GPUImageHolderImpl.1
final GPUImageHolderImpl gu;
{
this.gu = this;
}
@Override // java.util.concurrent.Callable
public Void call() throws Exception {
if (this.gu.gs != null) {
this.gu.gs.destroy();
this.gu.gs = null;
}
return null;
}
});
this.gt.shutdown();
try {
this.gt.awaitTermination(1L, TimeUnit.DAYS);
this.gt = null;
} catch (InterruptedException unused) {
throw new RuntimeException("Interrupted");
}
}
}
}
@Override // com.kofax.kmc.ken.engines.gpu.IGPUImageHolder
public void handleData(byte[] bArr, int i, int i2, IGPUImageRenderer iGPUImageRenderer) {
call(new Callable<Void>(this, bArr, i, i2, iGPUImageRenderer) { // from class: com.kofax.kmc.ken.engines.gpu.GPUImageHolderImpl.2
final byte[] gn;
final GPUImageHolderImpl gu;
final IGPUImageRenderer gv;
final int h;
final int i;
{
this.gu = this;
this.gn = bArr;
this.h = i;
this.i = i2;
this.gv = iGPUImageRenderer;
}
@Override // java.util.concurrent.Callable
public Void call() throws Exception {
if (this.gu.gs == null) {
GPUImageHolderImpl gPUImageHolderImpl = this.gu;
gPUImageHolderImpl.gs = new d(gPUImageHolderImpl.V);
}
this.gu.gs.handleData(this.gn, this.h, this.i, this.gv);
return null;
}
});
}
@Override // com.kofax.kmc.ken.engines.gpu.IGPUImageHolder
public Bitmap getBitmap(int i) {
return (Bitmap) call(new Callable<Bitmap>(this, i) { // from class: com.kofax.kmc.ken.engines.gpu.GPUImageHolderImpl.3
final GPUImageHolderImpl gu;
final int gw;
{
this.gu = this;
this.gw = i;
}
@Override // java.util.concurrent.Callable
/* renamed from: U, reason: merged with bridge method [inline-methods] */
public Bitmap call() throws Exception {
return this.gu.gs.getBitmap(this.gw);
}
});
}
public <T> T call(Callable<T> callable) {
try {
return this.gt.submit(callable).get();
} catch (InterruptedException unused) {
throw new RuntimeException("Interrupted");
} catch (ExecutionException e) {
throwIfUnchecked(e.getCause());
throw new RuntimeException("Unexpected exception");
}
}
public static void throwIfUnchecked(Throwable th) {
throwIfInstanceOf(th, RuntimeException.class);
throwIfInstanceOf(th, Error.class);
}
public static <T extends Throwable> void throwIfInstanceOf(Throwable th, Class<T> cls) throws Throwable {
if (cls.isInstance(th)) {
throw cls.cast(th);
}
}
}