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

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

Merge "HDR ratio indicator needs to vote for NO_VOTE as setFrameRate" into main

parents b19b1255 6f02040b
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ HdrSdrRatioOverlay::HdrSdrRatioOverlay(ConstructorTag)
        ALOGE("%s: Failed to create buffer state layer", __func__);
        return;
    }
    SurfaceComposerClient::Transaction()
    createTransaction()
            .setLayer(mSurfaceControl->get(), INT32_MAX - 2)
            .setTrustedOverlay(mSurfaceControl->get(), true)
            .apply();
@@ -130,7 +130,7 @@ void HdrSdrRatioOverlay::changeHdrSdrRatio(float currentHdrSdrRatio) {
}

void HdrSdrRatioOverlay::setLayerStack(ui::LayerStack stack) {
    SurfaceComposerClient::Transaction().setLayerStack(mSurfaceControl->get(), stack).apply();
    createTransaction().setLayerStack(mSurfaceControl->get(), stack).apply();
}

void HdrSdrRatioOverlay::setViewport(ui::Size viewport) {
@@ -141,7 +141,7 @@ void HdrSdrRatioOverlay::setViewport(ui::Size viewport) {
    // set the ratio frame to the top right of the screen
    frame.offsetBy(viewport.width - frame.width(), height >> 4);

    SurfaceComposerClient::Transaction()
    createTransaction()
            .setMatrix(mSurfaceControl->get(), frame.getWidth() / static_cast<float>(kBufferWidth),
                       0, 0, frame.getHeight() / static_cast<float>(kBufferHeight))
            .setPosition(mSurfaceControl->get(), frame.left, frame.top)
@@ -167,7 +167,7 @@ auto HdrSdrRatioOverlay::getOrCreateBuffers(float currentHdrSdrRatio) -> const s
        }
    }();

    SurfaceComposerClient::Transaction().setTransform(mSurfaceControl->get(), transform).apply();
    createTransaction().setTransform(mSurfaceControl->get(), transform).apply();

    constexpr SkColor kMinRatioColor = SK_ColorBLUE;
    constexpr SkColor kMaxRatioColor = SK_ColorGREEN;
@@ -194,9 +194,21 @@ auto HdrSdrRatioOverlay::getOrCreateBuffers(float currentHdrSdrRatio) -> const s

void HdrSdrRatioOverlay::animate() {
    if (!std::isfinite(mCurrentHdrSdrRatio) || mCurrentHdrSdrRatio < 1.0f) return;
    SurfaceComposerClient::Transaction()
    createTransaction()
            .setBuffer(mSurfaceControl->get(), getOrCreateBuffers(mCurrentHdrSdrRatio))
            .apply();
}

SurfaceComposerClient::Transaction HdrSdrRatioOverlay::createTransaction() const {
    constexpr float kFrameRate = 0.f;
    constexpr int8_t kCompatibility = ANATIVEWINDOW_FRAME_RATE_NO_VOTE;
    constexpr int8_t kSeamlessness = ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS;

    const sp<SurfaceControl>& surface = mSurfaceControl->get();

    SurfaceComposerClient::Transaction transaction;
    transaction.setFrameRate(surface, kFrameRate, kCompatibility, kSeamlessness);
    return transaction;
}

} // namespace android
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -53,5 +53,7 @@ private:

    size_t mIndex = 0;
    std::array<sp<GraphicBuffer>, 2> mRingBuffer;

    SurfaceComposerClient::Transaction createTransaction() const;
};
} // namespace android