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

Commit 6110e07f authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "Rename SurfaceControl.DisplayMode#refreshRate to peakRefreshRate" into main

parents 47b3086d 74296b12
Loading
Loading
Loading
Loading
+52 −17
Original line number Diff line number Diff line
@@ -2094,7 +2094,8 @@ public final class Display {
        private final int mModeId;
        private final int mWidth;
        private final int mHeight;
        private final float mRefreshRate;
        private final float mPeakRefreshRate;
        private final float mVsyncRate;
        @NonNull
        private final float[] mAlternativeRefreshRates;
        @NonNull
@@ -2106,7 +2107,15 @@ public final class Display {
         */
        @TestApi
        public Mode(int width, int height, float refreshRate) {
            this(INVALID_MODE_ID, width, height, refreshRate, new float[0], new int[0]);
            this(INVALID_MODE_ID, width, height, refreshRate, refreshRate, new float[0],
                    new int[0]);
        }

        /**
         * @hide
         */
        public Mode(int width, int height, float refreshRate, float vsyncRate) {
            this(INVALID_MODE_ID, width, height, refreshRate, vsyncRate, new float[0], new int[0]);
        }

        /**
@@ -2114,18 +2123,29 @@ public final class Display {
         */
        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
        public Mode(int modeId, int width, int height, float refreshRate) {
            this(modeId, width, height, refreshRate, new float[0], new int[0]);
            this(modeId, width, height, refreshRate, refreshRate, new float[0], new int[0]);
        }

        /**
         * @hide
         */
        public Mode(int modeId, int width, int height, float refreshRate,
                    float[] alternativeRefreshRates,
                    @HdrCapabilities.HdrType int[] supportedHdrTypes) {
            this(modeId, width, height, refreshRate, refreshRate, alternativeRefreshRates,
                    supportedHdrTypes);
        }

        /**
         * @hide
         */
        public Mode(int modeId, int width, int height, float refreshRate, float vsyncRate,
                float[] alternativeRefreshRates, @HdrCapabilities.HdrType int[] supportedHdrTypes) {
            mModeId = modeId;
            mWidth = width;
            mHeight = height;
            mRefreshRate = refreshRate;
            mPeakRefreshRate = refreshRate;
            mVsyncRate = vsyncRate;
            mAlternativeRefreshRates =
                    Arrays.copyOf(alternativeRefreshRates, alternativeRefreshRates.length);
            Arrays.sort(mAlternativeRefreshRates);
@@ -2176,7 +2196,17 @@ public final class Display {
         * Returns the refresh rate in frames per second.
         */
        public float getRefreshRate() {
            return mRefreshRate;
            return mPeakRefreshRate;
        }

        /**
         * Returns the vsync rate in frames per second.
         * The physical vsync rate may be higher than the refresh rate, as the refresh rate may be
         * constrained by the system.
         * @hide
         */
        public float getVsyncRate() {
            return mVsyncRate;
        }

        /**
@@ -2222,7 +2252,7 @@ public final class Display {
        public boolean matches(int width, int height, float refreshRate) {
            return mWidth == width &&
                    mHeight == height &&
                    Float.floatToIntBits(mRefreshRate) == Float.floatToIntBits(refreshRate);
                    Float.floatToIntBits(mPeakRefreshRate) == Float.floatToIntBits(refreshRate);
        }

        /**
@@ -2235,9 +2265,9 @@ public final class Display {
         *
         * @hide
         */
        public boolean matchesIfValid(int width, int height, float refreshRate) {
        public boolean matchesIfValid(int width, int height, float peakRefreshRate) {
            if (!isWidthValid(width) && !isHeightValid(height)
                    && !isRefreshRateValid(refreshRate)) {
                    && !isRefreshRateValid(peakRefreshRate)) {
                return false;
            }
            if (isWidthValid(width) != isHeightValid(height)) {
@@ -2245,8 +2275,9 @@ public final class Display {
            }
            return (!isWidthValid(width) || mWidth == width)
                    && (!isHeightValid(height) || mHeight == height)
                    && (!isRefreshRateValid(refreshRate)
                    || Float.floatToIntBits(mRefreshRate) == Float.floatToIntBits(refreshRate));
                    && (!isRefreshRateValid(peakRefreshRate)
                    || Float.floatToIntBits(mPeakRefreshRate)
                            == Float.floatToIntBits(peakRefreshRate));
        }

        /**
@@ -2265,7 +2296,7 @@ public final class Display {
         * @hide
         */
        public boolean isRefreshRateSet() {
            return mRefreshRate != INVALID_DISPLAY_REFRESH_RATE;
            return mPeakRefreshRate != INVALID_DISPLAY_REFRESH_RATE;
        }

        /**
@@ -2286,7 +2317,8 @@ public final class Display {
                return false;
            }
            Mode that = (Mode) other;
            return mModeId == that.mModeId && matches(that.mWidth, that.mHeight, that.mRefreshRate)
            return mModeId == that.mModeId
                    && matches(that.mWidth, that.mHeight, that.mPeakRefreshRate)
                    && Arrays.equals(mAlternativeRefreshRates, that.mAlternativeRefreshRates)
                    && Arrays.equals(mSupportedHdrTypes, that.mSupportedHdrTypes);
        }
@@ -2297,7 +2329,8 @@ public final class Display {
            hash = hash * 17 + mModeId;
            hash = hash * 17 + mWidth;
            hash = hash * 17 + mHeight;
            hash = hash * 17 + Float.floatToIntBits(mRefreshRate);
            hash = hash * 17 + Float.floatToIntBits(mPeakRefreshRate);
            hash = hash * 17 + Float.floatToIntBits(mVsyncRate);
            hash = hash * 17 + Arrays.hashCode(mAlternativeRefreshRates);
            hash = hash * 17 + Arrays.hashCode(mSupportedHdrTypes);
            return hash;
@@ -2309,7 +2342,8 @@ public final class Display {
                    .append("id=").append(mModeId)
                    .append(", width=").append(mWidth)
                    .append(", height=").append(mHeight)
                    .append(", fps=").append(mRefreshRate)
                    .append(", fps=").append(mPeakRefreshRate)
                    .append(", vsync=").append(mVsyncRate)
                    .append(", alternativeRefreshRates=")
                    .append(Arrays.toString(mAlternativeRefreshRates))
                    .append(", supportedHdrTypes=")
@@ -2324,8 +2358,8 @@ public final class Display {
        }

        private Mode(Parcel in) {
            this(in.readInt(), in.readInt(), in.readInt(), in.readFloat(), in.createFloatArray(),
                    in.createIntArray());
            this(in.readInt(), in.readInt(), in.readInt(), in.readFloat(), in.readFloat(),
                    in.createFloatArray(), in.createIntArray());
        }

        @Override
@@ -2333,7 +2367,8 @@ public final class Display {
            out.writeInt(mModeId);
            out.writeInt(mWidth);
            out.writeInt(mHeight);
            out.writeFloat(mRefreshRate);
            out.writeFloat(mPeakRefreshRate);
            out.writeFloat(mVsyncRate);
            out.writeFloatArray(mAlternativeRefreshRates);
            out.writeIntArray(mSupportedHdrTypes);
        }
+4 −4
Original line number Diff line number Diff line
@@ -1796,7 +1796,7 @@ public final class SurfaceControl implements Parcelable {
        public float yDpi;

        // Some modes have peak refresh rate lower than the panel vsync rate.
        public float refreshRate;
        public float peakRefreshRate;
        // Fixed rate of vsync deadlines for the panel.
        // This can be higher then the peak refresh rate for some panel technologies
        // See: VrrConfig.aidl
@@ -1820,7 +1820,7 @@ public final class SurfaceControl implements Parcelable {
                    + ", height=" + height
                    + ", xDpi=" + xDpi
                    + ", yDpi=" + yDpi
                    + ", refreshRate=" + refreshRate
                    + ", peakRefreshRate=" + peakRefreshRate
                    + ", vsyncRate=" + vsyncRate
                    + ", appVsyncOffsetNanos=" + appVsyncOffsetNanos
                    + ", presentationDeadlineNanos=" + presentationDeadlineNanos
@@ -1838,7 +1838,7 @@ public final class SurfaceControl implements Parcelable {
                    && height == that.height
                    && Float.compare(that.xDpi, xDpi) == 0
                    && Float.compare(that.yDpi, yDpi) == 0
                    && Float.compare(that.refreshRate, refreshRate) == 0
                    && Float.compare(that.peakRefreshRate, peakRefreshRate) == 0
                    && Float.compare(that.vsyncRate, vsyncRate) == 0
                    && appVsyncOffsetNanos == that.appVsyncOffsetNanos
                    && presentationDeadlineNanos == that.presentationDeadlineNanos
@@ -1848,7 +1848,7 @@ public final class SurfaceControl implements Parcelable {

        @Override
        public int hashCode() {
            return Objects.hash(id, width, height, xDpi, yDpi, refreshRate, vsyncRate,
            return Objects.hash(id, width, height, xDpi, yDpi, peakRefreshRate, vsyncRate,
                    appVsyncOffsetNanos, presentationDeadlineNanos, group,
                    Arrays.hashCode(supportedHdrTypes));
        }
+3 −3
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ static struct {
    jfieldID height;
    jfieldID xDpi;
    jfieldID yDpi;
    jfieldID refreshRate;
    jfieldID peakRefreshRate;
    jfieldID vsyncRate;
    jfieldID appVsyncOffsetNanos;
    jfieldID presentationDeadlineNanos;
@@ -1232,7 +1232,7 @@ static jobject convertDisplayModeToJavaObject(JNIEnv* env, const ui::DisplayMode
    env->SetFloatField(object, gDisplayModeClassInfo.xDpi, config.xDpi);
    env->SetFloatField(object, gDisplayModeClassInfo.yDpi, config.yDpi);

    env->SetFloatField(object, gDisplayModeClassInfo.refreshRate, config.refreshRate);
    env->SetFloatField(object, gDisplayModeClassInfo.peakRefreshRate, config.peakRefreshRate);
    env->SetFloatField(object, gDisplayModeClassInfo.vsyncRate, config.vsyncRate);
    env->SetLongField(object, gDisplayModeClassInfo.appVsyncOffsetNanos, config.appVsyncOffset);
    env->SetLongField(object, gDisplayModeClassInfo.presentationDeadlineNanos,
@@ -2396,7 +2396,7 @@ int register_android_view_SurfaceControl(JNIEnv* env)
    gDisplayModeClassInfo.height = GetFieldIDOrDie(env, modeClazz, "height", "I");
    gDisplayModeClassInfo.xDpi = GetFieldIDOrDie(env, modeClazz, "xDpi", "F");
    gDisplayModeClassInfo.yDpi = GetFieldIDOrDie(env, modeClazz, "yDpi", "F");
    gDisplayModeClassInfo.refreshRate = GetFieldIDOrDie(env, modeClazz, "refreshRate", "F");
    gDisplayModeClassInfo.peakRefreshRate = GetFieldIDOrDie(env, modeClazz, "peakRefreshRate", "F");
    gDisplayModeClassInfo.vsyncRate = GetFieldIDOrDie(env, modeClazz, "vsyncRate", "F");
    gDisplayModeClassInfo.appVsyncOffsetNanos =
            GetFieldIDOrDie(env, modeClazz, "appVsyncOffsetNanos", "J");
+3 −3
Original line number Diff line number Diff line
@@ -120,14 +120,14 @@ abstract class DisplayAdapter {
    }

    public static Display.Mode createMode(int width, int height, float refreshRate) {
        return createMode(width, height, refreshRate, new float[0], new int[0]);
        return createMode(width, height, refreshRate, refreshRate, new float[0], new int[0]);
    }

    public static Display.Mode createMode(int width, int height, float refreshRate,
    public static Display.Mode createMode(int width, int height, float refreshRate, float vsyncRate,
            float[] alternativeRefreshRates,
            @Display.HdrCapabilities.HdrType int[] supportedHdrTypes) {
        return new Display.Mode(NEXT_DISPLAY_MODE_ID.getAndIncrement(), width, height, refreshRate,
                alternativeRefreshRates, supportedHdrTypes);
                vsyncRate, alternativeRefreshRates, supportedHdrTypes);
    }

    public interface Listener {
+1 −0
Original line number Diff line number Diff line
@@ -1132,6 +1132,7 @@ public final class DisplayManagerService extends SystemService {
                    new Display.Mode(Display.DISPLAY_MODE_ID_FOR_FRAME_RATE_OVERRIDE,
                            currentMode.getPhysicalWidth(), currentMode.getPhysicalHeight(),
                            overriddenInfo.refreshRateOverride,
                            currentMode.getVsyncRate(),
                            new float[0], currentMode.getSupportedHdrTypes());
            overriddenInfo.modeId =
                    overriddenInfo.supportedModes[overriddenInfo.supportedModes.length - 1]
Loading