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

Commit 75ba8bcd authored by Marin Shalamanov's avatar Marin Shalamanov Committed by Android (Google) Code Review
Browse files

Merge "setFrameRate: Make shouldBeSeamless an enum" into sc-dev

parents 7f56cf87 c5986778
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -455,10 +455,10 @@ void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transactio
                                                 __INTRODUCED_IN(29);

/**
 * Same as ASurfaceTransaction_setFrameRateWithSeamlessness(transaction, surface_control,
 * frameRate, compatibility, true).
 * Same as ASurfaceTransaction_setFrameRateWithChangeStrategy(transaction, surface_control,
 * frameRate, compatibility, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS).
 *
 * See ASurfaceTransaction_setFrameRateWithSeamlessness().
 * See ASurfaceTransaction_setFrameRateWithChangeStrategy().
 *
 * Available since API level 30.
 */
@@ -486,17 +486,15 @@ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction,
 * influence the system's choice of display frame rate. To specify a compatibility use the
 * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum.
 *
 * \param shouldBeSeamless Whether display refresh rate transitions should be seamless. A
 * seamless transition is one that doesn't have any visual interruptions, such as a black
 * screen for a second or two. True indicates that any frame rate changes caused by this
 * request should be seamless. False indicates that non-seamless refresh rates are also
 * acceptable.
 * \param changeFrameRateStrategy Whether display refresh rate transitions should be seamless.
 * A seamless transition is one that doesn't have any visual interruptions, such as a black
 * screen for a second or two. See the ANATIVEWINDOW_CHANGE_FRAME_RATE_* values.
 *
 * Available since API level 31.
 */
void ASurfaceTransaction_setFrameRateWithSeamlessness(ASurfaceTransaction* transaction,
void ASurfaceTransaction_setFrameRateWithChangeStrategy(ASurfaceTransaction* transaction,
                                      ASurfaceControl* surface_control, float frameRate,
                                      int8_t compatibility, bool shouldBeSeamless)
                                      int8_t compatibility, int8_t changeFrameRateStrategy)
                                      __INTRODUCED_IN(31);

__END_DECLS
+5 −3
Original line number Diff line number Diff line
@@ -555,11 +555,13 @@ public:
        }).detach();
    }

    status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) override {
        if (!ValidateFrameRate(frameRate, compatibility, "BBQSurface::setFrameRate")) {
    status_t setFrameRate(float frameRate, int8_t compatibility,
                          int8_t changeFrameRateStrategy) override {
        if (!ValidateFrameRate(frameRate, compatibility, changeFrameRateStrategy,
                               "BBQSurface::setFrameRate")) {
            return BAD_VALUE;
        }
        return mBbq->setFrameRate(frameRate, compatibility, shouldBeSeamless);
        return mBbq->setFrameRate(frameRate, compatibility, changeFrameRateStrategy);
    }

    status_t setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) override {
+20 −56
Original line number Diff line number Diff line
@@ -1033,39 +1033,15 @@ public:
    }

    status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
                          int8_t compatibility, bool shouldBeSeamless) override {
                          int8_t compatibility, int8_t changeFrameRateStrategy) override {
        Parcel data, reply;
        status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (err != NO_ERROR) {
            ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err);
            return err;
        }

        err = data.writeStrongBinder(IInterface::asBinder(surface));
        if (err != NO_ERROR) {
            ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err);
            return err;
        }

        err = data.writeFloat(frameRate);
        if (err != NO_ERROR) {
            ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err);
            return err;
        }

        err = data.writeByte(compatibility);
        if (err != NO_ERROR) {
            ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err);
            return err;
        }

        err = data.writeBool(shouldBeSeamless);
        if (err != NO_ERROR) {
            ALOGE("setFrameRate: failed writing bool: %s (%d)", strerror(-err), -err);
            return err;
        }
        SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());
        SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(surface));
        SAFE_PARCEL(data.writeFloat, frameRate);
        SAFE_PARCEL(data.writeByte, compatibility);
        SAFE_PARCEL(data.writeByte, changeFrameRateStrategy);

        err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
        status_t err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
        if (err != NO_ERROR) {
            ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);
            return err;
@@ -1894,36 +1870,24 @@ status_t BnSurfaceComposer::onTransact(
        case SET_FRAME_RATE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> binder;
            status_t err = data.readStrongBinder(&binder);
            if (err != NO_ERROR) {
                ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
                return err;
            }
            SAFE_PARCEL(data.readStrongBinder, &binder);

            sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
            if (!surface) {
                ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
                      strerror(-err), -err);
                return err;
                ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer");
                return BAD_VALUE;
            }
            float frameRate;
            err = data.readFloat(&frameRate);
            if (err != NO_ERROR) {
                ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
                return err;
            }
            SAFE_PARCEL(data.readFloat, &frameRate);

            int8_t compatibility;
            err = data.readByte(&compatibility);
            if (err != NO_ERROR) {
                ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
                return err;
            }
            bool shouldBeSeamless;
            err = data.readBool(&shouldBeSeamless);
            if (err != NO_ERROR) {
                ALOGE("setFrameRate: failed to read bool: %s (%d)", strerror(-err), -err);
                return err;
            }
            status_t result = setFrameRate(surface, frameRate, compatibility, shouldBeSeamless);
            SAFE_PARCEL(data.readByte, &compatibility);

            int8_t changeFrameRateStrategy;
            SAFE_PARCEL(data.readByte, &changeFrameRateStrategy);

            status_t result =
                    setFrameRate(surface, frameRate, compatibility, changeFrameRateStrategy);
            reply->writeInt32(result);
            return NO_ERROR;
        }
+13 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <apex/window.h>
#include <inttypes.h>

#include <android/native_window.h>
#include <binder/Parcel.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposerClient.h>
@@ -60,7 +61,7 @@ layer_state_t::layer_state_t()
        frameRateSelectionPriority(-1),
        frameRate(0.0f),
        frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
        shouldBeSeamless(true),
        changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
        fixedTransformHint(ui::Transform::ROT_INVALID),
        frameNumber(0),
        autoRefresh(false),
@@ -148,7 +149,7 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority);
    SAFE_PARCEL(output.writeFloat, frameRate);
    SAFE_PARCEL(output.writeByte, frameRateCompatibility);
    SAFE_PARCEL(output.writeBool, shouldBeSeamless);
    SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
    SAFE_PARCEL(output.writeUint32, fixedTransformHint);
    SAFE_PARCEL(output.writeUint64, frameNumber);
    SAFE_PARCEL(output.writeBool, autoRefresh);
@@ -269,7 +270,7 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
    SAFE_PARCEL(input.readFloat, &frameRate);
    SAFE_PARCEL(input.readByte, &frameRateCompatibility);
    SAFE_PARCEL(input.readBool, &shouldBeSeamless);
    SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
    SAFE_PARCEL(input.readUint32, &tmpUint32);
    fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
    SAFE_PARCEL(input.readUint64, &frameNumber);
@@ -531,7 +532,7 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eFrameRateChanged;
        frameRate = other.frameRate;
        frameRateCompatibility = other.frameRateCompatibility;
        shouldBeSeamless = other.shouldBeSeamless;
        changeFrameRateStrategy = other.changeFrameRateStrategy;
    }
    if (other.what & eFixedTransformHintChanged) {
        what |= eFixedTransformHintChanged;
@@ -624,8 +625,8 @@ status_t InputWindowCommands::read(const Parcel& input) {
    return NO_ERROR;
}

bool ValidateFrameRate(float frameRate, int8_t compatibility, const char* inFunctionName,
                       bool privileged) {
bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy,
                       const char* inFunctionName, bool privileged) {
    const char* functionName = inFunctionName != nullptr ? inFunctionName : "call";
    int floatClassification = std::fpclassify(frameRate);
    if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) {
@@ -641,6 +642,12 @@ bool ValidateFrameRate(float frameRate, int8_t compatibility, const char* inFunc
        return false;
    }

    if (changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS &&
        changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS) {
        ALOGE("%s failed - invalid change frame rate strategy value %d", functionName,
              changeFrameRateStrategy);
    }

    return true;
}

+7 −5
Original line number Diff line number Diff line
@@ -1729,8 +1729,8 @@ int Surface::dispatchGetLastQueueDuration(va_list args) {
int Surface::dispatchSetFrameRate(va_list args) {
    float frameRate = static_cast<float>(va_arg(args, double));
    int8_t compatibility = static_cast<int8_t>(va_arg(args, int));
    bool shouldBeSeamless = static_cast<bool>(va_arg(args, int));
    return setFrameRate(frameRate, compatibility, shouldBeSeamless);
    int8_t changeFrameRateStrategy = static_cast<int8_t>(va_arg(args, int));
    return setFrameRate(frameRate, compatibility, changeFrameRateStrategy);
}

int Surface::dispatchAddCancelInterceptor(va_list args) {
@@ -2575,16 +2575,18 @@ void Surface::ProducerListenerProxy::onBuffersDiscarded(const std::vector<int32_
    mSurfaceListener->onBuffersDiscarded(discardedBufs);
}

status_t Surface::setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) {
status_t Surface::setFrameRate(float frameRate, int8_t compatibility,
                               int8_t changeFrameRateStrategy) {
    ATRACE_CALL();
    ALOGV("Surface::setFrameRate");

    if (!ValidateFrameRate(frameRate, compatibility, "Surface::setFrameRate")) {
    if (!ValidateFrameRate(frameRate, compatibility, changeFrameRateStrategy,
                           "Surface::setFrameRate")) {
        return BAD_VALUE;
    }

    return composerService()->setFrameRate(mGraphicBufferProducer, frameRate, compatibility,
                                           shouldBeSeamless);
                                           changeFrameRateStrategy);
}

status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) {
Loading