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

Commit f81fa528 authored by Jamie Gennis's avatar Jamie Gennis Committed by Android Git Automerger
Browse files

am 0bceb847: surfaceflinger: fix display id selection

* commit '0bceb847':
  surfaceflinger: fix display id selection
parents 21dbb2cd 0bceb847
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -162,6 +162,24 @@ sp<ISurfaceComposerClient> SurfaceFlinger::createConnection()
    return bclient;
}

int32_t SurfaceFlinger::chooseNewDisplayIdLocked() const
{
    int32_t id = DisplayDevice::DISPLAY_ID_COUNT - 1;
    bool available;
    do {
        id++;
        available = true;
        for (size_t i = 0; i < mCurrentState.displays.size(); i++) {
            const DisplayDeviceState& dds(mCurrentState.displays.valueAt(i));
            if (dds.id == id) {
                available = false;
                break;
            }
        }
    } while (!available);
    return id;
}

sp<IBinder> SurfaceFlinger::createDisplay()
{
    class DisplayToken : public BBinder {
@@ -181,7 +199,8 @@ sp<IBinder> SurfaceFlinger::createDisplay()
    sp<BBinder> token = new DisplayToken(this);

    Mutex::Autolock _l(mStateLock);
    DisplayDeviceState info(intptr_t(token.get())); // FIXME: we shouldn't use the address for the id
    int32_t id = chooseNewDisplayIdLocked();
    DisplayDeviceState info(id);
    mCurrentState.displays.add(token, info);

    return token;
+5 −0
Original line number Diff line number Diff line
@@ -363,6 +363,11 @@ private:
        return mProtectedTexName;
    }

    /* ------------------------------------------------------------------------
     * Display management
     */
    int32_t chooseNewDisplayIdLocked() const;

    /* ------------------------------------------------------------------------
     * Debugging & dumpsys
     */