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

Commit 4ed1c919 authored by Huihong Luo's avatar Huihong Luo
Browse files

Convert FrameStats to AIDL parcelable

And migrate related ISurfaceComposer methods to AIDL.
(1) add android::gui::FrameStats parcelable for serialization
(2) convert between FrameStats and gui::FrameStats
(3) migrate clearAnimationFrameStats
(4) migrate getAnimationFrameStats

Bug: 220910000
Test: atest libgui_test
Change-Id: I7c0aadbd791834e6bd22ccfc75dad39642d08160
parent ca3d9a42
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
@@ -225,29 +225,6 @@ public:
        return result;
    }

    status_t clearAnimationFrameStats() override {
        Parcel data, reply;
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (result != NO_ERROR) {
            ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
            return result;
        }
        result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
        if (result != NO_ERROR) {
            ALOGE("clearAnimationFrameStats failed to transact: %d", result);
            return result;
        }
        return reply.readInt32();
    }

    status_t getAnimationFrameStats(FrameStats* outStats) const override {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
        reply.read(*outStats);
        return reply.readInt32();
    }

    virtual status_t overrideHdrTypes(const sp<IBinder>& display,
                                      const std::vector<ui::Hdr>& hdrTypes) {
        Parcel data, reply;
@@ -1046,20 +1023,6 @@ status_t BnSurfaceComposer::onTransact(
            reply->writeStrongBinder(IInterface::asBinder(connection));
            return NO_ERROR;
        }
        case CLEAR_ANIMATION_FRAME_STATS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            status_t result = clearAnimationFrameStats();
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case GET_ANIMATION_FRAME_STATS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            FrameStats stats;
            status_t result = getAnimationFrameStats(&stats);
            reply->write(stats);
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case ENABLE_VSYNC_INJECTIONS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            bool enable = false;
+21 −2
Original line number Diff line number Diff line
@@ -2360,11 +2360,30 @@ bool SurfaceComposerClient::getProtectedContentSupport() {
}

status_t SurfaceComposerClient::clearAnimationFrameStats() {
    return ComposerService::getComposerService()->clearAnimationFrameStats();
    binder::Status status = ComposerServiceAIDL::getComposerService()->clearAnimationFrameStats();
    return status.transactionError();
}

status_t SurfaceComposerClient::getAnimationFrameStats(FrameStats* outStats) {
    return ComposerService::getComposerService()->getAnimationFrameStats(outStats);
    gui::FrameStats stats;
    binder::Status status =
            ComposerServiceAIDL::getComposerService()->getAnimationFrameStats(&stats);
    if (status.isOk()) {
        outStats->refreshPeriodNano = stats.refreshPeriodNano;
        outStats->desiredPresentTimesNano.setCapacity(stats.desiredPresentTimesNano.size());
        for (const auto& t : stats.desiredPresentTimesNano) {
            outStats->desiredPresentTimesNano.add(t);
        }
        outStats->actualPresentTimesNano.setCapacity(stats.actualPresentTimesNano.size());
        for (const auto& t : stats.actualPresentTimesNano) {
            outStats->actualPresentTimesNano.add(t);
        }
        outStats->frameReadyTimesNano.setCapacity(stats.frameReadyTimesNano.size());
        for (const auto& t : stats.frameReadyTimesNano) {
            outStats->frameReadyTimesNano.add(t);
        }
    }
    return status.transactionError();
}

status_t SurfaceComposerClient::overrideHdrTypes(const sp<IBinder>& display,
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.gui;

// Make sure to sync with libui FrameStats.h

/** @hide */
parcelable FrameStats {
    /*
     * Approximate refresh time, in nanoseconds.
     */
    long refreshPeriodNano;

    /*
     * The times in nanoseconds for when the frame contents were posted by the producer (e.g.
     * the application). They are either explicitly set or defaulted to the time when
     * Surface::queueBuffer() was called.
     */
    long[] desiredPresentTimesNano;

    /*
     * The times in milliseconds for when the frame contents were presented on the screen.
     */
    long[] actualPresentTimesNano;

    /*
     * The times in nanoseconds for when the frame contents were ready to be presented. Note that
     * a frame can be posted and still it contents being rendered asynchronously in GL. In such a
     * case these are the times when the frame contents were completely rendered (i.e. their fences
     * signaled).
     */
    long[] frameReadyTimesNano;
}
+13 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.gui.DisplayBrightness;
import android.gui.DisplayPrimaries;
import android.gui.DisplayState;
import android.gui.DisplayStatInfo;
import android.gui.FrameStats;
import android.gui.StaticDisplayInfo;
import android.gui.DynamicDisplayInfo;
import android.gui.IHdrLayerInfoListener;
@@ -138,6 +139,18 @@ interface ISurfaceComposer {
     */
    void captureLayers(in LayerCaptureArgs args, IScreenCaptureListener listener);

    /* Clears the frame statistics for animations.
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
    void clearAnimationFrameStats();

    /* Gets the frame statistics for animations.
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
    FrameStats getAnimationFrameStats();

    /*
     * Queries whether the given display is a wide color display.
     * Requires the ACCESS_SURFACE_FLINGER permission.
+5 −17
Original line number Diff line number Diff line
@@ -160,18 +160,6 @@ public:
    virtual status_t getSupportedFrameTimestamps(
            std::vector<FrameEvent>* outSupported) const = 0;

    /* Clears the frame statistics for animations.
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
    virtual status_t clearAnimationFrameStats() = 0;

    /* Gets the frame statistics for animations.
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
    virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0;

    /* Overrides the supported HDR modes for the given display device.
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
@@ -435,8 +423,8 @@ public:
        GET_DISPLAY_STATE,
        CAPTURE_DISPLAY,             // Deprecated. Autogenerated by .aidl now.
        CAPTURE_LAYERS,              // Deprecated. Autogenerated by .aidl now.
        CLEAR_ANIMATION_FRAME_STATS,
        GET_ANIMATION_FRAME_STATS,
        CLEAR_ANIMATION_FRAME_STATS, // Deprecated. Autogenerated by .aidl now.
        GET_ANIMATION_FRAME_STATS,   // Deprecated. Autogenerated by .aidl now.
        SET_POWER_MODE,              // Deprecated. Autogenerated by .aidl now.
        GET_DISPLAY_STATS,
        GET_HDR_CAPABILITIES,    // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
Loading