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

Commit ba2f3e93 authored by Rachel Lee's avatar Rachel Lee
Browse files

Add new ASurfaceTransaction _setFrameRateParams API

The new overload uses same plumbing and same logic as the other
setFrameRate-like functions. This plumbing and logic will be upgraded to
accommodate new parameters in a future CL.

Bug: 362798998
Test: atest SetFrameRateTest
Flag: EXEMPT NDK
Change-Id: I48c63725697b0b23a4dde7da4f14a9f251c62e55
parent c07bdc21
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -283,6 +283,7 @@ LIBANDROID {
    ASurfaceTransaction_setEnableBackPressure; # introduced=31
    ASurfaceTransaction_setFrameRate; # introduced=30
    ASurfaceTransaction_setFrameRateWithChangeStrategy; # introduced=31
    ASurfaceTransaction_setFrameRateParams; # introduced=36
    ASurfaceTransaction_clearFrameRate; # introduced=34
    ASurfaceTransaction_setFrameTimeline; # introduced=Tiramisu
    ASurfaceTransaction_setGeometry; # introduced=29
+22 −0
Original line number Diff line number Diff line
@@ -731,6 +731,28 @@ void ASurfaceTransaction_setFrameRateWithChangeStrategy(ASurfaceTransaction* aSu
    transaction->setFrameRate(surfaceControl, frameRate, compatibility, changeFrameRateStrategy);
}

void ASurfaceTransaction_setFrameRateParams(
        ASurfaceTransaction* aSurfaceTransaction, ASurfaceControl* aSurfaceControl,
        float desiredMinRate, float desiredMaxRate, float fixedSourceRate,
        ANativeWindow_ChangeFrameRateStrategy changeFrameRateStrategy) {
    CHECK_NOT_NULL(aSurfaceTransaction);
    CHECK_NOT_NULL(aSurfaceControl);
    Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
    sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);

    if (desiredMaxRate < desiredMinRate) {
        ALOGW("desiredMaxRate must be greater than or equal to desiredMinRate");
        return;
    }
    // TODO(b/362798998): Fix plumbing to send modern params
    int compatibility = fixedSourceRate == 0 ? ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT
                                             : ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
    double frameRate = compatibility == ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE
            ? fixedSourceRate
            : desiredMinRate;
    transaction->setFrameRate(surfaceControl, frameRate, compatibility, changeFrameRateStrategy);
}

void ASurfaceTransaction_clearFrameRate(ASurfaceTransaction* aSurfaceTransaction,
                                        ASurfaceControl* aSurfaceControl) {
    CHECK_NOT_NULL(aSurfaceTransaction);