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

Commit e89987af authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Rename variable disp to displayId for consistency"

parents 8adc012b df0b7059
Loading
Loading
Loading
Loading
+17 −16
Original line number Original line Diff line number Diff line
@@ -309,22 +309,22 @@ std::shared_ptr<HWC2::Layer> HWComposer::createLayer(int32_t displayId) {
    return layer;
    return layer;
}
}


nsecs_t HWComposer::getRefreshTimestamp(int32_t disp) const {
nsecs_t HWComposer::getRefreshTimestamp(int32_t displayId) const {
    // this returns the last refresh timestamp.
    // this returns the last refresh timestamp.
    // if the last one is not available, we estimate it based on
    // if the last one is not available, we estimate it based on
    // the refresh period and whatever closest timestamp we have.
    // the refresh period and whatever closest timestamp we have.
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    nsecs_t now = systemTime(CLOCK_MONOTONIC);
    nsecs_t now = systemTime(CLOCK_MONOTONIC);
    auto vsyncPeriod = getActiveConfig(disp)->getVsyncPeriod();
    auto vsyncPeriod = getActiveConfig(displayId)->getVsyncPeriod();
    return now - ((now - mLastHwVSync[disp]) % vsyncPeriod);
    return now - ((now - mLastHwVSync[displayId]) % vsyncPeriod);
}
}


bool HWComposer::isConnected(int32_t disp) const {
bool HWComposer::isConnected(int32_t displayId) const {
    if (!isValidDisplay(disp)) {
    if (!isValidDisplay(displayId)) {
        ALOGE("isConnected: Attempted to access invalid display %d", disp);
        ALOGE("isConnected: Attempted to access invalid display %d", displayId);
        return false;
        return false;
    }
    }
    return mDisplayData[disp].hwcDisplay->isConnected();
    return mDisplayData[displayId].hwcDisplay->isConnected();
}
}


std::vector<std::shared_ptr<const HWC2::Display::Config>>
std::vector<std::shared_ptr<const HWC2::Display::Config>>
@@ -408,14 +408,15 @@ status_t HWComposer::setActiveColorMode(int32_t displayId, android_color_mode_t
}
}




void HWComposer::setVsyncEnabled(int32_t disp, HWC2::Vsync enabled) {
void HWComposer::setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled) {
    if (disp < 0 || disp >= HWC_DISPLAY_VIRTUAL) {
    if (displayId < 0 || displayId >= HWC_DISPLAY_VIRTUAL) {
        ALOGD("setVsyncEnabled: Ignoring for virtual display %d", disp);
        ALOGD("setVsyncEnabled: Ignoring for virtual display %d", displayId);
        return;
        return;
    }
    }


    if (!isValidDisplay(disp)) {
    if (!isValidDisplay(displayId)) {
        ALOGE("setVsyncEnabled: Attempted to access invalid display %d", disp);
        ALOGE("setVsyncEnabled: Attempted to access invalid display %d",
               displayId);
        return;
        return;
    }
    }


@@ -424,7 +425,7 @@ void HWComposer::setVsyncEnabled(int32_t disp, HWC2::Vsync enabled) {
    // that even if HWC blocks (which it shouldn't), it won't
    // that even if HWC blocks (which it shouldn't), it won't
    // affect other threads.
    // affect other threads.
    Mutex::Autolock _l(mVsyncLock);
    Mutex::Autolock _l(mVsyncLock);
    auto& displayData = mDisplayData[disp];
    auto& displayData = mDisplayData[displayId];
    if (enabled != displayData.vsyncEnabled) {
    if (enabled != displayData.vsyncEnabled) {
        ATRACE_CALL();
        ATRACE_CALL();
        auto error = displayData.hwcDisplay->setVsyncEnabled(enabled);
        auto error = displayData.hwcDisplay->setVsyncEnabled(enabled);
@@ -432,12 +433,12 @@ void HWComposer::setVsyncEnabled(int32_t disp, HWC2::Vsync enabled) {
            displayData.vsyncEnabled = enabled;
            displayData.vsyncEnabled = enabled;


            char tag[16];
            char tag[16];
            snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", disp);
            snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId);
            ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0);
            ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0);
        } else {
        } else {
            ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64
            ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64
                    ": %s (%d)", to_string(enabled).c_str(), disp,
                    ": %s (%d)", to_string(enabled).c_str(), displayId,
                    mDisplayData[disp].hwcDisplay->getId(),
                    mDisplayData[displayId].hwcDisplay->getId(),
                    to_string(error).c_str(), static_cast<int32_t>(error));
                    to_string(error).c_str(), static_cast<int32_t>(error));
        }
        }
    }
    }
+3 −3
Original line number Original line Diff line number Diff line
@@ -145,12 +145,12 @@ public:


    // Events handling ---------------------------------------------------------
    // Events handling ---------------------------------------------------------


    void setVsyncEnabled(int32_t disp, HWC2::Vsync enabled);
    void setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled);


    // Query display parameters.  Pass in a display index (e.g.
    // Query display parameters.  Pass in a display index (e.g.
    // HWC_DISPLAY_PRIMARY).
    // HWC_DISPLAY_PRIMARY).
    nsecs_t getRefreshTimestamp(int32_t disp) const;
    nsecs_t getRefreshTimestamp(int32_t displayId) const;
    bool isConnected(int32_t disp) const;
    bool isConnected(int32_t displayId) const;


    // Non-const because it can update configMap inside of mDisplayData
    // Non-const because it can update configMap inside of mDisplayData
    std::vector<std::shared_ptr<const HWC2::Display::Config>>
    std::vector<std::shared_ptr<const HWC2::Display::Config>>