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

Commit 38603fd6 authored by Huihong Luo's avatar Huihong Luo
Browse files

Convert DynamicDisplayInfo to AIDL parcelable

And migrate related ISurfaceComposer::getDynamicDisplayInfo() method to AIDL.
(1) add android::gui::DynamicDisplayInfo etc. for serialization
(2) remove serialization code from the orignal DynamicDisplayInfo and
DisplayMode and HdrCapabilities classes
(3) convert between ui::DynamicDisplayInfo and gui::DynamicDisplayInfo

Bug: 220074970
Test: manual
Change-Id: If3c81c5fd006c281f6d38766bf415a971b0a1925
parent c2a2d2a1
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -225,17 +225,6 @@ public:
        return result;
    }

    status_t getDynamicDisplayInfo(const sp<IBinder>& display,
                                   ui::DynamicDisplayInfo* info) override {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(display);
        remote()->transact(BnSurfaceComposer::GET_DYNAMIC_DISPLAY_INFO, data, &reply);
        const status_t result = reply.readInt32();
        if (result != NO_ERROR) return result;
        return reply.read(*info);
    }

    status_t getDisplayNativePrimaries(const sp<IBinder>& display,
                                       ui::DisplayPrimaries& primaries) override {
        Parcel data, reply;
@@ -1133,16 +1122,6 @@ status_t BnSurfaceComposer::onTransact(
            reply->writeStrongBinder(IInterface::asBinder(connection));
            return NO_ERROR;
        }
        case GET_DYNAMIC_DISPLAY_INFO: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            ui::DynamicDisplayInfo info;
            const sp<IBinder> display = data.readStrongBinder();
            const status_t result = getDynamicDisplayInfo(display, &info);
            SAFE_PARCEL(reply->writeInt32, result);
            if (result != NO_ERROR) return result;
            SAFE_PARCEL(reply->write, info);
            return NO_ERROR;
        }
        case GET_DISPLAY_NATIVE_PRIMARIES: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            ui::DisplayPrimaries primaries;
+5 −4
Original line number Diff line number Diff line
@@ -366,12 +366,13 @@ status_t Surface::getHdrSupport(bool* supported) {
        return NAME_NOT_FOUND;
    }

    ui::DynamicDisplayInfo info;
    if (status_t err = composerService()->getDynamicDisplayInfo(display, &info); err != NO_ERROR) {
        return err;
    gui::DynamicDisplayInfo info;
    if (binder::Status status = composerServiceAIDL()->getDynamicDisplayInfo(display, &info);
        !status.isOk()) {
        return status.transactionError();
    }

    *supported = !info.hdrCapabilities.getSupportedHdrTypes().empty();
    *supported = !info.hdrCapabilities.supportedHdrTypes.empty();
    return NO_ERROR;
}

+47 −2
Original line number Diff line number Diff line
@@ -2187,8 +2187,53 @@ status_t SurfaceComposerClient::getStaticDisplayInfo(const sp<IBinder>& display,
}

status_t SurfaceComposerClient::getDynamicDisplayInfo(const sp<IBinder>& display,
                                                      ui::DynamicDisplayInfo* info) {
    return ComposerService::getComposerService()->getDynamicDisplayInfo(display, info);
                                                      ui::DynamicDisplayInfo* outInfo) {
    gui::DynamicDisplayInfo ginfo;
    binder::Status status =
            ComposerServiceAIDL::getComposerService()->getDynamicDisplayInfo(display, &ginfo);
    if (status.isOk()) {
        // convert gui::DynamicDisplayInfo to ui::DynamicDisplayInfo
        outInfo->supportedDisplayModes.clear();
        outInfo->supportedDisplayModes.reserve(ginfo.supportedDisplayModes.size());
        for (const auto& mode : ginfo.supportedDisplayModes) {
            ui::DisplayMode outMode;
            outMode.id = mode.id;
            outMode.resolution.width = mode.resolution.width;
            outMode.resolution.height = mode.resolution.height;
            outMode.xDpi = mode.xDpi;
            outMode.yDpi = mode.yDpi;
            outMode.refreshRate = mode.refreshRate;
            outMode.appVsyncOffset = mode.appVsyncOffset;
            outMode.sfVsyncOffset = mode.sfVsyncOffset;
            outMode.presentationDeadline = mode.presentationDeadline;
            outMode.group = mode.group;
            outInfo->supportedDisplayModes.push_back(outMode);
        }

        outInfo->activeDisplayModeId = ginfo.activeDisplayModeId;

        outInfo->supportedColorModes.clear();
        outInfo->supportedColorModes.reserve(ginfo.supportedColorModes.size());
        for (const auto& cmode : ginfo.supportedColorModes) {
            outInfo->supportedColorModes.push_back(static_cast<ui::ColorMode>(cmode));
        }

        outInfo->activeColorMode = static_cast<ui::ColorMode>(ginfo.activeColorMode);

        std::vector<ui::Hdr> types;
        types.reserve(ginfo.hdrCapabilities.supportedHdrTypes.size());
        for (const auto& hdr : ginfo.hdrCapabilities.supportedHdrTypes) {
            types.push_back(static_cast<ui::Hdr>(hdr));
        }
        outInfo->hdrCapabilities = HdrCapabilities(types, ginfo.hdrCapabilities.maxLuminance,
                                                   ginfo.hdrCapabilities.maxAverageLuminance,
                                                   ginfo.hdrCapabilities.minLuminance);

        outInfo->autoLowLatencyModeSupported = ginfo.autoLowLatencyModeSupported;
        outInfo->gameContentTypeSupported = ginfo.gameContentTypeSupported;
        outInfo->preferredBootDisplayMode = ginfo.preferredBootDisplayMode;
    }
    return status.transactionError();
}

status_t SurfaceComposerClient::getActiveDisplayMode(const sp<IBinder>& display,
+36 −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;

import android.gui.Size;

// Mode supported by physical display.
// Make sure to sync with libui DisplayMode.h

/** @hide */
parcelable DisplayMode {
    int id;
    Size resolution;
    float xDpi = 0.0f;
    float yDpi = 0.0f;

    float refreshRate = 0.0f;
    long appVsyncOffset = 0;
    long sfVsyncOffset = 0;
    long presentationDeadline = 0;
    int group = -1;
}
+45 −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;

import android.gui.DisplayMode;
import android.gui.HdrCapabilities;

// Information about a physical display which may change on hotplug reconnect.
// Make sure to sync with libui DynamicDisplayInfo.h

/** @hide */
parcelable DynamicDisplayInfo {
    List<DisplayMode> supportedDisplayModes;

    int activeDisplayModeId;

    int[] supportedColorModes;
    int activeColorMode;
    HdrCapabilities hdrCapabilities;

    // True if the display reports support for HDMI 2.1 Auto Low Latency Mode.
    // For more information, see the HDMI 2.1 specification.
    boolean autoLowLatencyModeSupported;

    // True if the display reports support for Game Content Type.
    // For more information, see the HDMI 1.4 specification.
    boolean gameContentTypeSupported;

    // The boot display mode preferred by the implementation.
    int preferredBootDisplayMode;
}
Loading