package io.flutter.plugin.platform;

import android.graphics.SurfaceTexture;
import android.view.Surface;
import io.flutter.view.TextureRegistry$SurfaceTextureEntry;

/* JADX INFO: loaded from: classes.dex */
public final class y implements l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final TextureRegistry$SurfaceTextureEntry f28263a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public SurfaceTexture f28264b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Surface f28265c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f28266d = 0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f28267e = 0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f28268f = false;

    public y(io.flutter.embedding.engine.renderer.h hVar) {
        x xVar = new x(this);
        this.f28263a = hVar;
        this.f28264b = hVar.f28028b.surfaceTexture();
        hVar.setOnTrimMemoryListener(xVar);
    }

    @Override // io.flutter.plugin.platform.l
    public final int getHeight() {
        return this.f28267e;
    }

    @Override // io.flutter.plugin.platform.l
    public final long getId() {
        return this.f28263a.id();
    }

    @Override // io.flutter.plugin.platform.l
    public final Surface getSurface() {
        Surface surface = this.f28265c;
        if (surface == null || this.f28268f) {
            if (surface != null) {
                surface.release();
                this.f28265c = null;
            }
            this.f28265c = new Surface(this.f28264b);
            this.f28268f = false;
        }
        SurfaceTexture surfaceTexture = this.f28264b;
        if (surfaceTexture == null || surfaceTexture.isReleased()) {
            return null;
        }
        return this.f28265c;
    }

    @Override // io.flutter.plugin.platform.l
    public final int getWidth() {
        return this.f28266d;
    }

    @Override // io.flutter.plugin.platform.l
    public final void i(int i10, int i11) {
        this.f28266d = i10;
        this.f28267e = i11;
        SurfaceTexture surfaceTexture = this.f28264b;
        if (surfaceTexture != null) {
            surfaceTexture.setDefaultBufferSize(i10, i11);
        }
    }

    @Override // io.flutter.plugin.platform.l
    public final void release() {
        this.f28264b = null;
        Surface surface = this.f28265c;
        if (surface != null) {
            surface.release();
            this.f28265c = null;
        }
    }
}
