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

Commit 01d95064 authored by Ady Abraham's avatar Ady Abraham Committed by Automerger Merge Worker
Browse files

Merge "SurfaceFlinger: expose vsync id extra buffers" into sc-dev am: d486b821

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/13475352

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I40b975d3332d2ff505495a1fda23382bd57481a1
parents 5940462a d486b821
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -1235,6 +1235,18 @@ public:
        }
        return reply.readInt32();
    }

    status_t getExtraBufferCount(int* extraBuffers) const override {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        status_t err = remote()->transact(BnSurfaceComposer::GET_EXTRA_BUFFER_COUNT, data, &reply);
        if (err != NO_ERROR) {
            ALOGE("getExtraBufferCount failed to read data:  %s (%d)", strerror(-err), err);
            return err;
        }

        return reply.readInt32(extraBuffers);
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -2107,6 +2119,16 @@ status_t BnSurfaceComposer::onTransact(
            SAFE_PARCEL(reply->writeInt32, priority);
            return NO_ERROR;
        }
        case GET_EXTRA_BUFFER_COUNT: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            int extraBuffers = 0;
            int err = getExtraBufferCount(&extraBuffers);
            if (err != NO_ERROR) {
                return err;
            }
            SAFE_PARCEL(reply->writeInt32, extraBuffers);
            return NO_ERROR;
        }
        default: {
            return BBinder::onTransact(code, data, reply, flags);
        }
+15 −0
Original line number Diff line number Diff line
@@ -1499,6 +1499,9 @@ int Surface::perform(int operation, va_list args)
    case NATIVE_WINDOW_SET_FRAME_TIMELINE_INFO:
        res = dispatchSetFrameTimelineInfo(args);
        break;
    case NATIVE_WINDOW_GET_EXTRA_BUFFER_COUNT:
        res = dispatchGetExtraBufferCount(args);
        break;
    default:
        res = NAME_NOT_FOUND;
        break;
@@ -1815,6 +1818,14 @@ int Surface::dispatchSetFrameTimelineInfo(va_list args) {
    return setFrameTimelineInfo({frameTimelineVsyncId, inputEventId});
}

int Surface::dispatchGetExtraBufferCount(va_list args) {
    ATRACE_CALL();
    auto extraBuffers = static_cast<int*>(va_arg(args, int*));

    ALOGV("Surface::dispatchGetExtraBufferCount");
    return getExtraBufferCount(extraBuffers);
}

bool Surface::transformToDisplayInverse() {
    return (mTransform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) ==
            NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
@@ -2584,4 +2595,8 @@ status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInf
    return composerService()->setFrameTimelineInfo(mGraphicBufferProducer, frameTimelineInfo);
}

status_t Surface::getExtraBufferCount(int* extraBuffers) const {
    return composerService()->getExtraBufferCount(extraBuffers);
}

}; // namespace android
+19 −0
Original line number Diff line number Diff line
@@ -505,6 +505,24 @@ public:
     * Gets priority of the RenderEngine in SurfaceFlinger.
     */
    virtual int getGPUContextPriority() = 0;

    /**
     * Gets the extra buffers a client would need to allocate if it passes
     * the Choreographer#getVsyncId with its buffers.
     *
     * When Choreographer#getVsyncId is passed to SurfaceFlinger, it is used
     * as an indication of when to latch the buffer. SurfaceFlinger will make
     * sure that it will give the app at least the time configured as the
     * 'appDuration' before trying to latch the buffer.
     *
     * The total buffers needed for a given configuration is basically the
     * numbers of vsyncs a single buffer is used across the stack. For the default
     * configuration a buffer is held ~1 vsync by the app, ~1 vsync by SurfaceFlinger
     * and 1 vsync by the display. The extra buffers are calculated as the
     * number of additional buffers on top of the 3 buffers already allocated
     * by the app.
     */
    virtual status_t getExtraBufferCount(int* extraBuffers) const = 0;
};

// ----------------------------------------------------------------------------
@@ -567,6 +585,7 @@ public:
        SET_FRAME_TIMELINE_INFO,
        ADD_TRANSACTION_TRACE_LISTENER,
        GET_GPU_CONTEXT_PRIORITY,
        GET_EXTRA_BUFFER_COUNT,
        // Always append new enum to the end.
    };

+2 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ public:

    virtual status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless);
    virtual status_t setFrameTimelineInfo(const FrameTimelineInfo& info);
    virtual status_t getExtraBufferCount(int* extraBuffers) const;

protected:
    virtual ~Surface();
@@ -275,6 +276,7 @@ private:
    int dispatchAddQueryInterceptor(va_list args);
    int dispatchGetLastQueuedBuffer(va_list args);
    int dispatchSetFrameTimelineInfo(va_list args);
    int dispatchGetExtraBufferCount(va_list args);
    bool transformToDisplayInverse();

protected:
+2 −0
Original line number Diff line number Diff line
@@ -889,6 +889,8 @@ public:

    int getGPUContextPriority() override { return 0; };

    status_t getExtraBufferCount(int* /*extraBuffers*/) const override { return NO_ERROR; }

protected:
    IBinder* onAsBinder() override { return nullptr; }

Loading