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

Commit f4f0f642 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Add setColorSpaceAgnostic API to SurfaceControl.

Some layers, for example ScreenDecorOverlay*, only carry black, white or gray
with some transpanrency, these values are special as they are color space
agnostic. We don't need to do color conversion on them, instead we want to
intercept the color space before we send to hardware composer for validation.
This patch adds an API to allow this to happen, layers that can be considered
color space agnostic can call this API.

BUG: 126616348
Test: Build, flash and boot. Verify by calling in Letterbox.
Change-Id: I2e1384865bbae6c1bca5ab55962af6a4d529d81d
parent 436a76d1
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ public final class SurfaceControl implements Parcelable {
            float dtdy, float dsdy);
    private static native void nativeSetColorTransform(long transactionObj, long nativeObject,
            float[] matrix, float[] translation);
    private static native void nativeSetColorSpaceAgnostic(long transactionObj, long nativeObject,
            boolean agnostic);
    private static native void nativeSetGeometry(long transactionObj, long nativeObject,
            Rect sourceCrop, Rect dest, long orientation);
    private static native void nativeSetColor(long transactionObj, long nativeObject, float[] color);
@@ -1206,6 +1208,19 @@ public final class SurfaceControl implements Parcelable {
        }
    }

    /**
     * Sets the Surface to be color space agnostic. If a surface is color space agnostic,
     * the color can be interpreted in any color space.
     * @param agnostic A boolean to indicate whether the surface is color space agnostic
     * @hide
     */
    public void setColorSpaceAgnostic(boolean agnostic) {
        checkNotReleased();
        synchronized (SurfaceControl.class) {
            sGlobalTransaction.setColorSpaceAgnostic(this, agnostic);
        }
    }

    /**
     * Bounds the surface and its children to the bounds specified. Size of the surface will be
     * ignored and only the crop and buffer size will be used to determine the bounds of the
@@ -2226,6 +2241,18 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the Surface to be color space agnostic. If a surface is color space agnostic,
         * the color can be interpreted in any color space.
         * @param agnostic A boolean to indicate whether the surface is color space agnostic
         * @hide
         */
        public Transaction setColorSpaceAgnostic(SurfaceControl sc, boolean agnostic) {
            sc.checkNotReleased();
            nativeSetColorSpaceAgnostic(mNativeObject, sc.mNativeObject, agnostic);
            return this;
        }

        /**
         * @hide
         */
+9 −0
Original line number Diff line number Diff line
@@ -463,6 +463,13 @@ static void nativeSetColorTransform(JNIEnv* env, jclass clazz, jlong transaction
    transaction->setColorTransform(surfaceControl, matrix, translation);
}

static void nativeSetColorSpaceAgnostic(JNIEnv* env, jclass clazz, jlong transactionObj,
        jlong nativeObject, jboolean agnostic) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    SurfaceControl* const surfaceControl = reinterpret_cast<SurfaceControl*>(nativeObject);
    transaction->setColorSpaceAgnostic(surfaceControl, agnostic);
}

static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong transactionObj,
        jlong nativeObject,
        jint l, jint t, jint r, jint b) {
@@ -1206,6 +1213,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetMatrix },
    {"nativeSetColorTransform", "(JJ[F[F)V",
            (void*)nativeSetColorTransform },
    {"nativeSetColorSpaceAgnostic", "(JJZ)V",
            (void*)nativeSetColorSpaceAgnostic },
    {"nativeSetFlags", "(JJII)V",
            (void*)nativeSetFlags },
    {"nativeSetWindowCrop", "(JJIIII)V",
+1 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ public class Letterbox {
                    .setFlags(HIDDEN).setColorLayer().build();
            mSurface.setLayer(-1);
            mSurface.setColor(new float[]{0, 0, 0});
            mSurface.setColorSpaceAgnostic(true);
        }

        void attachInput(WindowState win) {