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

Commit 016d73c2 authored by Chris Forbes's avatar Chris Forbes
Browse files

hwc2: Cache display type at construction

The display type is constant for the life of the display. Query it
upfront to avoid the binder transaction later.

V2: fixup HWC1 path

Test: boot to launcher on bullhead; build on fugu for HWC1 path
Bug: b/36597125
Change-Id: I2a4c3d9ff449960957376afef78f424261fcc282
parent 273e1442
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -531,9 +531,23 @@ Display::Display(Device& device, hwc2_display_t id)
  : mDevice(device),
    mId(id),
    mIsConnected(false),
    mIsVirtual(false)
    mIsVirtual(false),
    mType(DisplayType::Invalid)
{
    ALOGV("Created display %" PRIu64, id);

#ifdef BYPASS_IHWC
    int32_t intError = mDevice.mGetDisplayType(mDevice.mHwcDevice, mId,
            reinterpret_cast<int32_t *>(&mType));
#else
    auto intError = mDevice.mComposer->getDisplayType(mId,
            reinterpret_cast<Hwc2::IComposerClient::DisplayType *>(&mType));
#endif
    auto error = static_cast<Error>(intError);
    if (error != Error::None) {
        ALOGE("getDisplayType(%" PRIu64 ") failed: %s (%d)",
              id, to_string(error).c_str(), intError);
    }
}

Display::~Display()
@@ -802,21 +816,7 @@ Error Display::getRequests(HWC2::DisplayRequest* outDisplayRequests,

Error Display::getType(DisplayType* outType) const
{
#ifdef BYPASS_IHWC
    int32_t intType = 0;
    int32_t intError = mDevice.mGetDisplayType(mDevice.mHwcDevice, mId,
            &intType);
#else
    Hwc2::IComposerClient::DisplayType intType =
        Hwc2::IComposerClient::DisplayType::INVALID;
    auto intError = mDevice.mComposer->getDisplayType(mId, &intType);
#endif
    auto error = static_cast<Error>(intError);
    if (error != Error::None) {
        return error;
    }

    *outType = static_cast<DisplayType>(intType);
    *outType = mType;
    return Error::None;
}

+1 −0
Original line number Diff line number Diff line
@@ -376,6 +376,7 @@ private:
    hwc2_display_t mId;
    bool mIsConnected;
    bool mIsVirtual;
    DisplayType mType;
    std::unordered_map<hwc2_layer_t, std::weak_ptr<Layer>> mLayers;
    std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
};