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

Commit 5eb3f064 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Make NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY transforms sticky

When a client sets the NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY flag, the buffer producer may
override the flag if it sets a buffer transform. The second issue is that SurfaceFlinger may
apply a transform hint based on display orientation which may be applied by the buffer
producer.

The flag NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY indicates the client wants to submit buffers
in the same orientation regardless of display orientation. So if the flag is set, make it
sticky until the surface is disconnected. Secondly, ignore the transform hint if the flag is
set.

Test: Launch test app and test seamless rotation in portrait mode and landscape mode
Test: go/wm-smoke
Test: atest libsurfaceflinger_unittest libgui_test SurfaceFlinger_test
Bug: 127953232
Change-Id: Ic153faae0f3cdc9d385cdfe8162d3caabac60901
parent 7b5d9813
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -829,8 +829,9 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
    mDefaultHeight = output.height;
    mNextFrameNumber = output.nextFrameNumber;

    // Disable transform hint if sticky transform is set.
    if (mStickyTransform == 0) {
    // Ignore transform hint if sticky transform is set or transform to display inverse flag is
    // set.
    if (mStickyTransform == 0 && !transformToDisplayInverse()) {
        mTransformHint = output.transformHint;
    }

@@ -1271,6 +1272,11 @@ int Surface::dispatchGetConsumerUsage64(va_list args) {
    return getConsumerUsage(usage);
}

bool Surface::transformToDisplayInverse() {
    return (mTransform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) ==
            NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
}

int Surface::connect(int api) {
    static sp<IProducerListener> listener = new DummyProducerListener();
    return connect(api, listener);
@@ -1293,8 +1299,10 @@ int Surface::connect(
        mDefaultHeight = output.height;
        mNextFrameNumber = output.nextFrameNumber;

        // Disable transform hint if sticky transform is set.
        if (mStickyTransform == 0) {
        // Ignore transform hint if sticky transform is set or transform to display inverse flag is
        // set. Transform hint should be ignored if the client is expected to always submit buffers
        // in the same orientation.
        if (mStickyTransform == 0 && !transformToDisplayInverse()) {
            mTransformHint = output.transformHint;
        }

@@ -1591,6 +1599,13 @@ int Surface::setBuffersTransform(uint32_t transform)
    ATRACE_CALL();
    ALOGV("Surface::setBuffersTransform");
    Mutex::Autolock lock(mMutex);
    // Ensure NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY is sticky. If the client sets the flag, do not
    // override it until the surface is disconnected. This is a temporary workaround for camera
    // until they switch to using Buffer State Layers. Currently if client sets the buffer transform
    // it may be overriden by the buffer producer when the producer sets the buffer transform.
    if (transformToDisplayInverse()) {
        transform |= NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
    }
    mTransform = transform;
    return NO_ERROR;
}
+1 −0
Original line number Diff line number Diff line
@@ -230,6 +230,7 @@ private:
    int dispatchGetWideColorSupport(va_list args);
    int dispatchGetHdrSupport(va_list args);
    int dispatchGetConsumerUsage64(va_list args);
    bool transformToDisplayInverse();

protected:
    virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
+2 −4
Original line number Diff line number Diff line
@@ -1225,10 +1225,8 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const {

void Layer::updateTransformHint(const sp<const DisplayDevice>& display) const {
    uint32_t orientation = 0;
    // Disable setting transform hint if the debug flag is set or if the
    // getTransformToDisplayInverse flag is set and the client wants to submit buffers
    // in one orientation.
    if (!mFlinger->mDebugDisableTransformHint && !getTransformToDisplayInverse()) {
    // Disable setting transform hint if the debug flag is set.
    if (!mFlinger->mDebugDisableTransformHint) {
        // The transform hint is used to improve performance, but we can
        // only have a single transform hint, it cannot
        // apply to all displays.