Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a54976ec authored by Sally Qi's avatar Sally Qi Committed by Android (Google) Code Review
Browse files

Merge "Add DataSpace API to convert between ADataSpace and ColorSpace"

parents c0eb03c7 ac97f99b
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -16456,6 +16456,7 @@ package android.graphics {
    ctor public SurfaceTexture(boolean);
    method public void attachToGLContext(int);
    method public void detachFromGLContext();
    method public long getDataSpace();
    method public long getTimestamp();
    method public void getTransformMatrix(float[]);
    method public boolean isReleased();
@@ -17673,6 +17674,52 @@ package android.hardware {
    method public int getMinFrequency();
  }
  public final class DataSpace {
    method public static long getRange(long);
    method public static long getStandard(long);
    method public static long getTransfer(long);
    method public static long pack(long, long, long);
    field public static final long DATASPACE_ADOBE_RGB = 151715840L; // 0x90b0000L
    field public static final long DATASPACE_BT2020 = 147193856L; // 0x8c60000L
    field public static final long DATASPACE_BT2020_PQ = 163971072L; // 0x9c60000L
    field public static final long DATASPACE_BT601_525 = 281280512L; // 0x10c40000L
    field public static final long DATASPACE_BT601_625 = 281149440L; // 0x10c20000L
    field public static final long DATASPACE_BT709 = 281083904L; // 0x10c10000L
    field public static final long DATASPACE_DCI_P3 = 155844608L; // 0x94a0000L
    field public static final long DATASPACE_DISPLAY_P3 = 143261696L; // 0x88a0000L
    field public static final long DATASPACE_JFIF = 146931712L; // 0x8c20000L
    field public static final long DATASPACE_SCRGB = 411107328L; // 0x18810000L
    field public static final long DATASPACE_SCRGB_LINEAR = 406913024L; // 0x18410000L
    field public static final long DATASPACE_SRGB = 142671872L; // 0x8810000L
    field public static final long DATASPACE_SRGB_LINEAR = 138477568L; // 0x8410000L
    field public static final long DATASPACE_UNKNOWN = 0L; // 0x0L
    field public static final long RANGE_EXTENDED = 402653184L; // 0x18000000L
    field public static final long RANGE_FULL = 134217728L; // 0x8000000L
    field public static final long RANGE_LIMITED = 268435456L; // 0x10000000L
    field public static final long RANGE_UNSPECIFIED = 0L; // 0x0L
    field public static final long STANDARD_ADOBE_RGB = 720896L; // 0xb0000L
    field public static final long STANDARD_BT2020 = 393216L; // 0x60000L
    field public static final long STANDARD_BT2020_CONSTANT_LUMINANCE = 458752L; // 0x70000L
    field public static final long STANDARD_BT470M = 524288L; // 0x80000L
    field public static final long STANDARD_BT601_525 = 262144L; // 0x40000L
    field public static final long STANDARD_BT601_525_UNADJUSTED = 327680L; // 0x50000L
    field public static final long STANDARD_BT601_625 = 131072L; // 0x20000L
    field public static final long STANDARD_BT601_625_UNADJUSTED = 196608L; // 0x30000L
    field public static final long STANDARD_BT709 = 65536L; // 0x10000L
    field public static final long STANDARD_DCI_P3 = 655360L; // 0xa0000L
    field public static final long STANDARD_FILM = 589824L; // 0x90000L
    field public static final long STANDARD_UNSPECIFIED = 0L; // 0x0L
    field public static final long TRANSFER_GAMMA2_2 = 16777216L; // 0x1000000L
    field public static final long TRANSFER_GAMMA2_6 = 20971520L; // 0x1400000L
    field public static final long TRANSFER_GAMMA2_8 = 25165824L; // 0x1800000L
    field public static final long TRANSFER_HLG = 33554432L; // 0x2000000L
    field public static final long TRANSFER_LINEAR = 4194304L; // 0x400000L
    field public static final long TRANSFER_SMPTE_170M = 12582912L; // 0xc00000L
    field public static final long TRANSFER_SRGB = 8388608L; // 0x800000L
    field public static final long TRANSFER_ST2084 = 29360128L; // 0x1c00000L
    field public static final long TRANSFER_UNSPECIFIED = 0L; // 0x0L
  }
  public class GeomagneticField {
    ctor public GeomagneticField(float, float, float, long);
    method public float getDeclination();
@@ -21611,6 +21658,7 @@ package android.media {
  public abstract class Image implements java.lang.AutoCloseable {
    method public abstract void close();
    method public android.graphics.Rect getCropRect();
    method public long getDataSpace();
    method public abstract int getFormat();
    method @Nullable public android.hardware.HardwareBuffer getHardwareBuffer();
    method public abstract int getHeight();
@@ -21618,6 +21666,7 @@ package android.media {
    method public abstract long getTimestamp();
    method public abstract int getWidth();
    method public void setCropRect(android.graphics.Rect);
    method public void setDataSpace(long);
    method public void setTimestamp(long);
  }
+649 −0

File added.

Preview size limit exceeded, changes collapsed.

+17 −11
Original line number Diff line number Diff line
@@ -346,6 +346,11 @@ static jlong SurfaceTexture_getTimestamp(JNIEnv* env, jobject thiz)
    return surfaceTexture->getTimestamp();
}

static jlong SurfaceTexture_getDataSpace(JNIEnv* env, jobject thiz) {
    sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
    return surfaceTexture->getCurrentDataSpace();
}

static void SurfaceTexture_release(JNIEnv* env, jobject thiz)
{
    sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
@@ -370,6 +375,7 @@ static const JNINativeMethod gSurfaceTextureMethods[] = {
        {"nativeAttachToGLContext", "(I)I", (void*)SurfaceTexture_attachToGLContext},
        {"nativeGetTransformMatrix", "([F)V", (void*)SurfaceTexture_getTransformMatrix},
        {"nativeGetTimestamp", "()J", (void*)SurfaceTexture_getTimestamp},
        {"nativeGetDataSpace", "()J", (void*)SurfaceTexture_getDataSpace},
        {"nativeRelease", "()V", (void*)SurfaceTexture_release},
        {"nativeIsReleased", "()Z", (void*)SurfaceTexture_isReleased},
};
+11 −0
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
package android.graphics;

import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.DataSpace.NamedDataSpace;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
@@ -347,6 +349,14 @@ public class SurfaceTexture {
        return nativeGetTimestamp();
    }

    /**
     * Retrieve the dataspace associated with the texture image.
     */
    @SuppressLint("MethodNameUnits")
    public @NamedDataSpace long getDataSpace() {
        return nativeGetDataSpace();
    }

    /**
     * {@code release()} frees all the buffers and puts the SurfaceTexture into the
     * 'abandoned' state. Once put in this state the SurfaceTexture can never
@@ -416,6 +426,7 @@ public class SurfaceTexture {
    private native void nativeFinalize();
    private native void nativeGetTransformMatrix(float[] mtx);
    private native long nativeGetTimestamp();
    private native long nativeGetDataSpace();
    private native void nativeSetDefaultBufferSize(int width, int height);
    private native void nativeUpdateTexImage();
    private native void nativeReleaseTexImage();
+28 −0
Original line number Diff line number Diff line
@@ -17,9 +17,12 @@
package android.media;

import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.graphics.Rect;
import android.hardware.DataSpace;
import android.hardware.DataSpace.NamedDataSpace;
import android.hardware.HardwareBuffer;

import java.nio.ByteBuffer;
@@ -280,6 +283,31 @@ public abstract class Image implements AutoCloseable {
        return;
    }

    private @NamedDataSpace long mDataSpace = DataSpace.DATASPACE_UNKNOWN;

    /**
     * Get the dataspace associated with this frame.
     */
    @SuppressLint("MethodNameUnits")
    public @NamedDataSpace long getDataSpace() {
        throwISEIfImageIsInvalid();
        return mDataSpace;
    }

    /**
     * Set the dataspace associated with this frame.
     * <p>
     * If dataspace for an image is not set, dataspace value depends on {@link android.view.Surface}
     * that is provided in the {@link ImageWriter} constructor.
     * </p>
     *
     * @param dataSpace The Dataspace to be set for this image
     */
    public void setDataSpace(@NamedDataSpace long dataSpace) {
        throwISEIfImageIsInvalid();
        mDataSpace = dataSpace;
    }

    private Rect mCropRect;

    /**
Loading