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

Commit dcb38bbd authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Plumb physical display IDs to libgui

This CL replaces ISurfaceComposer::{eDisplayIdMain,eDisplayIdHdmi} with
the stable 64-bit display IDs generated by SF. Note that the 64-bit IDs
fall back to the old values if the HWC API for display identification is
not supported.

Bug: 74619554
Test: LocalDisplayAdapter and Choreographer receive 64-bit IDs
Test: 64-bit IDs fall back to 0 and 1 on HWC 2.2 and below
Change-Id: I3c08eff6eb8bb179ecce596ab2820a2aa44c8649
parent 8a0222e6
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -222,9 +222,9 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
}
}


bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) {
bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) {
    sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0);
    const sp<IBinder> dpy = mSurfaceComposerClient->getInternalDisplayToken();
    if (dpy == nullptr) {
    if (dpy == nullptr) {
        fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n");
        fprintf(stderr, "SurfaceComposer::getInternalDisplayToken failed.\n");
        return false;
        return false;
    }
    }


+25 −10
Original line number Original line Diff line number Diff line
@@ -275,12 +275,25 @@ public:
        remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
        remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
    }
    }


    virtual sp<IBinder> getBuiltInDisplay(int32_t id)
    virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
            NO_ERROR) {
            std::vector<PhysicalDisplayId> displayIds;
            if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
                return displayIds;
            }
        }

        return {};
    }

    virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInt32(id);
        data.writeUint64(displayId);
        remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
        remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
        return reply.readStrongBinder();
        return reply.readStrongBinder();
    }
    }


@@ -932,10 +945,10 @@ status_t BnSurfaceComposer::onTransact(
            destroyDisplay(display);
            destroyDisplay(display);
            return NO_ERROR;
            return NO_ERROR;
        }
        }
        case GET_BUILT_IN_DISPLAY: {
        case GET_PHYSICAL_DISPLAY_TOKEN: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            int32_t id = data.readInt32();
            PhysicalDisplayId displayId = data.readUint64();
            sp<IBinder> display(getBuiltInDisplay(id));
            sp<IBinder> display = getPhysicalDisplayToken(displayId);
            reply->writeStrongBinder(display);
            reply->writeStrongBinder(display);
            return NO_ERROR;
            return NO_ERROR;
        }
        }
@@ -1294,12 +1307,14 @@ status_t BnSurfaceComposer::onTransact(
            }
            }
            return error;
            return error;
        }
        }
        case GET_PHYSICAL_DISPLAY_IDS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            return reply->writeUint64Vector(getPhysicalDisplayIds());
        }
        default: {
        default: {
            return BBinder::onTransact(code, data, reply, flags);
            return BBinder::onTransact(code, data, reply, flags);
        }
        }
    }
    }
}
}


// ----------------------------------------------------------------------------
} // namespace android

};
+10 −4
Original line number Original line Diff line number Diff line
@@ -321,8 +321,11 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber,
status_t Surface::getWideColorSupport(bool* supported) {
status_t Surface::getWideColorSupport(bool* supported) {
    ATRACE_CALL();
    ATRACE_CALL();


    sp<IBinder> display(
    const sp<IBinder> display = composerService()->getInternalDisplayToken();
        composerService()->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
    if (display == nullptr) {
        return NAME_NOT_FOUND;
    }

    *supported = false;
    *supported = false;
    status_t error = composerService()->isWideColorDisplay(display, supported);
    status_t error = composerService()->isWideColorDisplay(display, supported);
    return error;
    return error;
@@ -331,8 +334,11 @@ status_t Surface::getWideColorSupport(bool* supported) {
status_t Surface::getHdrSupport(bool* supported) {
status_t Surface::getHdrSupport(bool* supported) {
    ATRACE_CALL();
    ATRACE_CALL();


    sp<IBinder> display(
    const sp<IBinder> display = composerService()->getInternalDisplayToken();
        composerService()->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
    if (display == nullptr) {
        return NAME_NOT_FOUND;
    }

    HdrCapabilities hdrCapabilities;
    HdrCapabilities hdrCapabilities;
    status_t err =
    status_t err =
        composerService()->getHdrCapabilities(display, &hdrCapabilities);
        composerService()->getHdrCapabilities(display, &hdrCapabilities);
+14 −2
Original line number Original line Diff line number Diff line
@@ -374,8 +374,20 @@ void SurfaceComposerClient::destroyDisplay(const sp<IBinder>& display) {
    return ComposerService::getComposerService()->destroyDisplay(display);
    return ComposerService::getComposerService()->destroyDisplay(display);
}
}


sp<IBinder> SurfaceComposerClient::getBuiltInDisplay(int32_t id) {
std::vector<PhysicalDisplayId> SurfaceComposerClient::getPhysicalDisplayIds() {
    return ComposerService::getComposerService()->getBuiltInDisplay(id);
    return ComposerService::getComposerService()->getPhysicalDisplayIds();
}

std::optional<PhysicalDisplayId> SurfaceComposerClient::getInternalDisplayId() {
    return ComposerService::getComposerService()->getInternalDisplayId();
}

sp<IBinder> SurfaceComposerClient::getPhysicalDisplayToken(PhysicalDisplayId displayId) {
    return ComposerService::getComposerService()->getPhysicalDisplayToken(displayId);
}

sp<IBinder> SurfaceComposerClient::getInternalDisplayToken() {
    return ComposerService::getComposerService()->getInternalDisplayToken();
}
}


void SurfaceComposerClient::Transaction::setAnimationTransaction() {
void SurfaceComposerClient::Transaction::setAnimationTransaction() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -58,7 +58,7 @@ public:


        struct Header {
        struct Header {
            uint32_t type;
            uint32_t type;
            uint32_t id;
            PhysicalDisplayId displayId;
            nsecs_t timestamp __attribute__((aligned(8)));
            nsecs_t timestamp __attribute__((aligned(8)));
        };
        };


Loading