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

Commit 3fac35a9 authored by Chris Forbes's avatar Chris Forbes
Browse files

HWC2OnFbAdapter: don't claim present fences work

We never produce real present fences, so indicate this to the
compositor. This will prevent GOOGLE_display_timing & friends from being
exposed in the client APIs.

Similar to previous change in HWC2On1Adapter.

Bug: b/111505197
Change-Id: I601a7f5628d4b218431fc0f1abb4807c9941ce64
parent 366c0abb
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@
#include <log/log.h>
#include <sync/sync.h>

using namespace HWC2;

namespace android {

namespace {
@@ -629,9 +631,10 @@ hwc2_function_pointer_t getFunctionHook(hwc2_device_t* /*device*/, int32_t descr
    }
}

void getCapabilitiesHook(hwc2_device_t* /*device*/, uint32_t* outCount,
                         int32_t* /*outCapabilities*/) {
    *outCount = 0;
void getCapabilitiesHook(hwc2_device_t* device, uint32_t* outCount,
                         int32_t* outCapabilities) {
    auto& adapter = HWC2OnFbAdapter::cast(device);
    adapter.getCapabilities(outCount, outCapabilities);
}

int closeHook(hw_device_t* device) {
@@ -656,6 +659,10 @@ HWC2OnFbAdapter::HWC2OnFbAdapter(framebuffer_device_t* fbDevice)
    mFbInfo.xdpi_scaled = int(mFbDevice->xdpi * 1000.0f);
    mFbInfo.ydpi_scaled = int(mFbDevice->ydpi * 1000.0f);

    // Present fences aren't supported, always indicate PresentFenceIsNotReliable
    // for FB devices
    mCapabilities.insert(Capability::PresentFenceIsNotReliable);

    mVsyncThread.start(0, mFbInfo.vsync_period_ns);
}

@@ -791,6 +798,23 @@ void HWC2OnFbAdapter::enableVsync(bool enable) {
    mVsyncThread.enableCallback(enable);
}

void HWC2OnFbAdapter::getCapabilities(uint32_t* outCount,
                                      int32_t* outCapabilities) {
    if (outCapabilities == nullptr) {
        *outCount = mCapabilities.size();
        return;
    }

    auto capabilityIter = mCapabilities.cbegin();
    for (size_t written = 0; written < *outCount; ++written) {
        if (capabilityIter == mCapabilities.cend()) {
            return;
        }
        outCapabilities[written] = static_cast<int32_t>(*capabilityIter);
        ++capabilityIter;
    }
}

int64_t HWC2OnFbAdapter::VsyncThread::now() {
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
+7 −0
Original line number Diff line number Diff line
@@ -23,7 +23,11 @@
#include <thread>
#include <unordered_set>

#define HWC2_INCLUDE_STRINGIFICATION
#define HWC2_USE_CPP11
#include <hardware/hwcomposer2.h>
#undef HWC2_INCLUDE_STRINGIFICATION
#undef HWC2_USE_CPP11

struct framebuffer_device_t;

@@ -75,6 +79,7 @@ public:

    void setVsyncCallback(HWC2_PFN_VSYNC callback, hwc2_callback_data_t data);
    void enableVsync(bool enable);
    void getCapabilities(uint32_t* outCount, int32_t* outCapabilities);

private:
    framebuffer_device_t* mFbDevice{nullptr};
@@ -90,6 +95,8 @@ private:

    buffer_handle_t mBuffer{nullptr};

    std::unordered_set<HWC2::Capability> mCapabilities;

    class VsyncThread {
    public:
        static int64_t now();