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

Commit 72aba070 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6110375 from 1ca25ba9 to rvc-release

Change-Id: Iaa885bf588a3eb414ee4ed6b83fa53e9030df6e5
parents 84b3e237 1ca25ba9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const {
    if ((status = parcel->writeInt64Vector(angleDriverLoadingTime)) != OK) return status;
    if ((status = parcel->writeBool(cpuVulkanInUse)) != OK) return status;
    if ((status = parcel->writeBool(falsePrerotation)) != OK) return status;
    if ((status = parcel->writeBool(gles1InUse)) != OK) return status;
    return OK;
}

@@ -99,6 +100,7 @@ status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) {
    if ((status = parcel->readInt64Vector(&angleDriverLoadingTime)) != OK) return status;
    if ((status = parcel->readBool(&cpuVulkanInUse)) != OK) return status;
    if ((status = parcel->readBool(&falsePrerotation)) != OK) return status;
    if ((status = parcel->readBool(&gles1InUse)) != OK) return status;
    return OK;
}

@@ -108,6 +110,7 @@ std::string GpuStatsAppInfo::toString() const {
    StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode);
    StringAppendF(&result, "cpuVulkanInUse = %d\n", cpuVulkanInUse);
    StringAppendF(&result, "falsePrerotation = %d\n", falsePrerotation);
    StringAppendF(&result, "gles1InUse = %d\n", gles1InUse);
    result.append("glDriverLoadingTime:");
    for (int32_t loadingTime : glDriverLoadingTime) {
        StringAppendF(&result, " %d", loadingTime);
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public:
    std::vector<int64_t> angleDriverLoadingTime = {};
    bool cpuVulkanInUse = false;
    bool falsePrerotation = false;
    bool gles1InUse = false;
};

/*
@@ -95,6 +96,7 @@ public:
    enum Stats {
        CPU_VULKAN_IN_USE = 0,
        FALSE_PREROTATION = 1,
        GLES_1_IN_USE = 2,
    };

    GpuStatsInfo() = default;
+2 −0
Original line number Diff line number Diff line
@@ -984,6 +984,8 @@ EGLContext eglCreateContextImpl(EGLDisplay dpy, EGLConfig config,
                    if (attr == EGL_CONTEXT_CLIENT_VERSION) {
                        if (value == 1) {
                            version = egl_connection_t::GLESv1_INDEX;
                            android::GraphicsEnv::getInstance().setTargetStats(
                                    android::GpuStatsInfo::Stats::GLES_1_IN_USE);
                        } else if (value == 2 || value == 3) {
                            version = egl_connection_t::GLESv2_INDEX;
                        }
+3 −0
Original line number Diff line number Diff line
@@ -145,6 +145,9 @@ void GpuStats::insertTargetStats(const std::string& appPackageName,
        case GpuStatsInfo::Stats::FALSE_PREROTATION:
            mAppStats[appStatsKey].falsePrerotation = true;
            break;
        case GpuStatsInfo::Stats::GLES_1_IN_USE:
            mAppStats[appStatsKey].gles1InUse = true;
            break;
        default:
            break;
    }
+0 −182
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ using android::HdrMetadata;
using android::Rect;
using android::Region;
using android::sp;
using android::hardware::Return;
using android::hardware::Void;

namespace HWC2 {

@@ -60,188 +58,8 @@ inline bool hasMetadataKey(const std::set<Hwc2::PerFrameMetadataKey>& keys,
    return keys.find(key) != keys.end();
}

class ComposerCallbackBridge : public Hwc2::IComposerCallback {
public:
    ComposerCallbackBridge(ComposerCallback* callback, int32_t sequenceId,
                           bool vsyncSwitchingSupported)
          : mCallback(callback),
            mSequenceId(sequenceId),
            mVsyncSwitchingSupported(vsyncSwitchingSupported) {}

    Return<void> onHotplug(Hwc2::Display display,
                           IComposerCallback::Connection conn) override
    {
        HWC2::Connection connection = static_cast<HWC2::Connection>(conn);
        mCallback->onHotplugReceived(mSequenceId, display, connection);
        return Void();
    }

    Return<void> onRefresh(Hwc2::Display display) override
    {
        mCallback->onRefreshReceived(mSequenceId, display);
        return Void();
    }

    Return<void> onVsync(Hwc2::Display display, int64_t timestamp) override
    {
        if (!mVsyncSwitchingSupported) {
            mCallback->onVsyncReceived(mSequenceId, display, timestamp, std::nullopt);
        } else {
            ALOGW("Unexpected onVsync callback on composer >= 2.4, ignoring.");
        }
        return Void();
    }

    Return<void> onVsync_2_4(Hwc2::Display display, int64_t timestamp,
                             Hwc2::VsyncPeriodNanos vsyncPeriodNanos) override {
        if (mVsyncSwitchingSupported) {
            // TODO(b/140201379): use vsyncPeriodNanos in the new DispSync
            mCallback->onVsyncReceived(mSequenceId, display, timestamp,
                                       std::make_optional(vsyncPeriodNanos));
        } else {
            ALOGW("Unexpected onVsync_2_4 callback on composer <= 2.3, ignoring.");
        }
        return Void();
    }

    Return<void> onVsyncPeriodTimingChanged(
            Hwc2::Display display,
            const Hwc2::VsyncPeriodChangeTimeline& updatedTimeline) override {
        hwc_vsync_period_change_timeline_t timeline;
        timeline.newVsyncAppliedTimeNanos = updatedTimeline.newVsyncAppliedTimeNanos;
        timeline.refreshRequired = updatedTimeline.refreshRequired;
        timeline.refreshTimeNanos = updatedTimeline.refreshTimeNanos;
        mCallback->onVsyncPeriodTimingChangedReceived(mSequenceId, display, timeline);
        return Void();
    }

private:
    ComposerCallback* mCallback;
    int32_t mSequenceId;
    const bool mVsyncSwitchingSupported;
};

} // namespace anonymous


// Device methods

Device::Device(std::unique_ptr<android::Hwc2::Composer> composer) : mComposer(std::move(composer)) {
    loadCapabilities();
}

void Device::registerCallback(ComposerCallback* callback, int32_t sequenceId) {
    if (mRegisteredCallback) {
        ALOGW("Callback already registered. Ignored extra registration "
                "attempt.");
        return;
    }
    mRegisteredCallback = true;
    sp<ComposerCallbackBridge> callbackBridge(
            new ComposerCallbackBridge(callback, sequenceId,
                                       mComposer->isVsyncPeriodSwitchSupported()));
    mComposer->registerCallback(callbackBridge);
}

// Required by HWC2 device

std::string Device::dump() const
{
    return mComposer->dumpDebugInfo();
}

uint32_t Device::getMaxVirtualDisplayCount() const
{
    return mComposer->getMaxVirtualDisplayCount();
}

Error Device::getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
                                           std::vector<uint8_t>* outData) const {
    auto intError = mComposer->getDisplayIdentificationData(hwcDisplayId, outPort, outData);
    return static_cast<Error>(intError);
}

Error Device::createVirtualDisplay(uint32_t width, uint32_t height,
        PixelFormat* format, Display** outDisplay)
{
    ALOGI("Creating virtual display");

    hwc2_display_t displayId = 0;
    auto intError = mComposer->createVirtualDisplay(width, height,
            format, &displayId);
    auto error = static_cast<Error>(intError);
    if (error != Error::None) {
        return error;
    }

    auto display = std::make_unique<impl::Display>(*mComposer.get(), mCapabilities, displayId,
                                                   DisplayType::Virtual);
    display->setConnected(true);
    *outDisplay = display.get();
    mDisplays.emplace(displayId, std::move(display));
    ALOGI("Created virtual display");
    return Error::None;
}

void Device::destroyDisplay(hwc2_display_t displayId)
{
    ALOGI("Destroying display %" PRIu64, displayId);
    mDisplays.erase(displayId);
}

void Device::onHotplug(hwc2_display_t displayId, Connection connection) {
    if (connection == Connection::Connected) {
        // If we get a hotplug connected event for a display we already have,
        // destroy the display and recreate it. This will force us to requery
        // the display params and recreate all layers on that display.
        auto oldDisplay = getDisplayById(displayId);
        if (oldDisplay != nullptr && oldDisplay->isConnected()) {
            ALOGI("Hotplug connecting an already connected display."
                    " Clearing old display state.");
        }
        mDisplays.erase(displayId);

        auto newDisplay = std::make_unique<impl::Display>(*mComposer.get(), mCapabilities,
                                                          displayId, DisplayType::Physical);
        newDisplay->setConnected(true);
        mDisplays.emplace(displayId, std::move(newDisplay));
    } else if (connection == Connection::Disconnected) {
        // The display will later be destroyed by a call to
        // destroyDisplay(). For now we just mark it disconnected.
        auto display = getDisplayById(displayId);
        if (display) {
            display->setConnected(false);
        } else {
            ALOGW("Attempted to disconnect unknown display %" PRIu64,
                  displayId);
        }
    }
}

// Other Device methods

Display* Device::getDisplayById(hwc2_display_t id) {
    auto iter = mDisplays.find(id);
    return iter == mDisplays.end() ? nullptr : iter->second.get();
}

// Device initialization methods

void Device::loadCapabilities()
{
    static_assert(sizeof(Capability) == sizeof(int32_t),
            "Capability size has changed");
    auto capabilities = mComposer->getCapabilities();
    for (auto capability : capabilities) {
        mCapabilities.emplace(static_cast<Capability>(capability));
    }
}

Error Device::flushCommands()
{
    return static_cast<Error>(mComposer->executeCommands());
}

// Display methods
Display::~Display() = default;

Loading