128 lines
4.6 KiB
Java
128 lines
4.6 KiB
Java
package c.o.a.n.s;
|
|
|
|
import android.graphics.PointF;
|
|
import android.graphics.Rect;
|
|
import android.graphics.RectF;
|
|
import android.hardware.camera2.CameraCharacteristics;
|
|
import android.hardware.camera2.CaptureRequest;
|
|
import android.hardware.camera2.params.MeteringRectangle;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.RequiresApi;
|
|
import c.o.a.n.t.a;
|
|
import c.o.a.t.c;
|
|
/* compiled from: Camera2MeteringTransform */
|
|
@RequiresApi(21)
|
|
public class b implements c<MeteringRectangle> {
|
|
public static final c.o.a.b a = new c.o.a.b(b.class.getSimpleName());
|
|
public final a b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final c.o.a.x.b f1495c;
|
|
public final c.o.a.x.b d;
|
|
public final boolean e;
|
|
public final CameraCharacteristics f;
|
|
public final CaptureRequest.Builder g;
|
|
|
|
public b(@NonNull a aVar, @NonNull c.o.a.x.b bVar, @NonNull c.o.a.x.b bVar2, boolean z2, @NonNull CameraCharacteristics cameraCharacteristics, @NonNull CaptureRequest.Builder builder) {
|
|
this.b = aVar;
|
|
this.f1495c = bVar;
|
|
this.d = bVar2;
|
|
this.e = z2;
|
|
this.f = cameraCharacteristics;
|
|
this.g = builder;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // c.o.a.t.c
|
|
@NonNull
|
|
public MeteringRectangle a(@NonNull RectF rectF, int i) {
|
|
Rect rect = new Rect();
|
|
rectF.round(rect);
|
|
return new MeteringRectangle(rect, i);
|
|
}
|
|
|
|
@Override // c.o.a.t.c
|
|
@NonNull
|
|
public PointF b(@NonNull PointF pointF) {
|
|
PointF pointF2 = new PointF(pointF.x, pointF.y);
|
|
c.o.a.x.b bVar = this.f1495c;
|
|
c.o.a.x.b bVar2 = this.d;
|
|
int i = bVar.i;
|
|
int i2 = bVar.j;
|
|
c.o.a.x.a g = c.o.a.x.a.g(bVar2);
|
|
c.o.a.x.a f = c.o.a.x.a.f(bVar.i, bVar.j);
|
|
if (this.e) {
|
|
if (g.i() > f.i()) {
|
|
float i3 = g.i() / f.i();
|
|
float f2 = pointF2.x;
|
|
float f3 = (float) bVar.i;
|
|
pointF2.x = (((i3 - 1.0f) * f3) / 2.0f) + f2;
|
|
i = Math.round(f3 * i3);
|
|
} else {
|
|
float i4 = f.i() / g.i();
|
|
float f4 = pointF2.y;
|
|
float f5 = (float) bVar.j;
|
|
pointF2.y = (((i4 - 1.0f) * f5) / 2.0f) + f4;
|
|
i2 = Math.round(f5 * i4);
|
|
}
|
|
}
|
|
c.o.a.x.b bVar3 = this.d;
|
|
pointF2.x = (((float) bVar3.i) / ((float) i)) * pointF2.x;
|
|
pointF2.y = (((float) bVar3.j) / ((float) i2)) * pointF2.y;
|
|
int c2 = this.b.c(c.o.a.n.t.b.SENSOR, c.o.a.n.t.b.VIEW, 1);
|
|
boolean z2 = c2 % 180 != 0;
|
|
float f6 = pointF2.x;
|
|
float f7 = pointF2.y;
|
|
if (c2 == 0) {
|
|
pointF2.x = f6;
|
|
pointF2.y = f7;
|
|
} else if (c2 == 90) {
|
|
pointF2.x = f7;
|
|
pointF2.y = ((float) bVar3.i) - f6;
|
|
} else if (c2 == 180) {
|
|
pointF2.x = ((float) bVar3.i) - f6;
|
|
pointF2.y = ((float) bVar3.j) - f7;
|
|
} else if (c2 == 270) {
|
|
pointF2.x = ((float) bVar3.j) - f7;
|
|
pointF2.y = f6;
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.l("Unexpected angle ", c2));
|
|
}
|
|
if (z2) {
|
|
bVar3 = bVar3.f();
|
|
}
|
|
Rect rect = (Rect) this.g.get(CaptureRequest.SCALER_CROP_REGION);
|
|
int width = rect == null ? bVar3.i : rect.width();
|
|
int height = rect == null ? bVar3.j : rect.height();
|
|
pointF2.x = (((float) (width - bVar3.i)) / 2.0f) + pointF2.x;
|
|
pointF2.y = (((float) (height - bVar3.j)) / 2.0f) + pointF2.y;
|
|
Rect rect2 = (Rect) this.g.get(CaptureRequest.SCALER_CROP_REGION);
|
|
pointF2.x += rect2 == null ? 0.0f : (float) rect2.left;
|
|
pointF2.y += rect2 == null ? 0.0f : (float) rect2.top;
|
|
Rect rect3 = (Rect) this.f.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
|
if (rect3 == null) {
|
|
rect3 = new Rect(0, 0, width, height);
|
|
}
|
|
int width2 = rect3.width();
|
|
int height2 = rect3.height();
|
|
c.o.a.b bVar4 = a;
|
|
bVar4.a(1, "input:", pointF, "output (before clipping):", pointF2);
|
|
if (pointF2.x < 0.0f) {
|
|
pointF2.x = 0.0f;
|
|
}
|
|
if (pointF2.y < 0.0f) {
|
|
pointF2.y = 0.0f;
|
|
}
|
|
float f8 = (float) width2;
|
|
if (pointF2.x > f8) {
|
|
pointF2.x = f8;
|
|
}
|
|
float f9 = (float) height2;
|
|
if (pointF2.y > f9) {
|
|
pointF2.y = f9;
|
|
}
|
|
bVar4.a(1, "input:", pointF, "output (after clipping):", pointF2);
|
|
return pointF2;
|
|
}
|
|
}
|