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

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

SF: Clean up remaining display identifiers

Bug: 74619554
Test: Build
Change-Id: Icd8457b6496f02c6010c724cfa6ae678f6e01adf
parent f9750f28
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -706,8 +706,7 @@ void BufferLayer::onFirstRef() {
        mProducer->setMaxDequeuedBufferCount(2);
        mProducer->setMaxDequeuedBufferCount(2);
    }
    }


    const sp<const DisplayDevice> hw(mFlinger->getDefaultDisplayDevice());
    updateTransformHint(mFlinger->getDefaultDisplayDevice());
    updateTransformHint(hw);
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
+20 −23
Original line number Original line Diff line number Diff line
@@ -96,17 +96,16 @@ void HWComposer::registerCallback(HWC2::ComposerCallback* callback,
    mHwcDevice->registerCallback(callback, sequenceId);
    mHwcDevice->registerCallback(callback, sequenceId);
}
}


bool HWComposer::getDisplayIdentificationData(hwc2_display_t displayId, uint8_t* outPort,
bool HWComposer::getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
                                              DisplayIdentificationData* outData) const {
                                              DisplayIdentificationData* outData) const {
    HWC2::Display* display = mHwcDevice->getDisplayById(displayId);
    HWC2::Display* display = mHwcDevice->getDisplayById(hwcDisplayId);
    if (!display) {
    if (!display) {
        ALOGE("getDisplayIdentificationData: Attempted to access invalid display %" PRIu64,
        ALOGE("%s: Attempted to access invalid display %" PRIu64, __FUNCTION__, hwcDisplayId);
              displayId);
        return false;
        return false;
    }
    }
    const auto error = display->getIdentificationData(outPort, outData);
    const auto error = display->getIdentificationData(outPort, outData);
    if (error != HWC2::Error::None) {
    if (error != HWC2::Error::None) {
        ALOGE("getDisplayIdentificationData failed for display %" PRIu64, displayId);
        ALOGE("%s failed for display %" PRIu64, __FUNCTION__, hwcDisplayId);
        return false;
        return false;
    }
    }
    return true;
    return true;
@@ -147,49 +146,47 @@ void HWComposer::validateChange(HWC2::Composition from, HWC2::Composition to) {
    }
    }
}
}


std::optional<DisplayId> HWComposer::onHotplug(hwc2_display_t displayId, int32_t displayType,
std::optional<DisplayId> HWComposer::onHotplug(hwc2_display_t hwcDisplayId, int32_t displayType,
                                               HWC2::Connection connection) {
                                               HWC2::Connection connection) {
    if (displayType >= HWC_NUM_PHYSICAL_DISPLAY_TYPES) {
    if (displayType >= HWC_NUM_PHYSICAL_DISPLAY_TYPES) {
        ALOGE("Invalid display type of %d", displayType);
        ALOGE("Invalid display type of %d", displayType);
        return {};
        return {};
    }
    }


    ALOGV("hotplug: %" PRIu64 ", %s %s", displayId,
    ALOGV("hotplug: %" PRIu64 ", %s %s", hwcDisplayId,
          displayType == DisplayDevice::DISPLAY_PRIMARY ? "primary" : "external",
          displayType == DisplayDevice::DISPLAY_PRIMARY ? "primary" : "external",
          to_string(connection).c_str());
          to_string(connection).c_str());
    mHwcDevice->onHotplug(displayId, connection);
    mHwcDevice->onHotplug(hwcDisplayId, connection);


    std::optional<DisplayId> stableId;
    std::optional<DisplayId> displayId;


    uint8_t port;
    uint8_t port;
    DisplayIdentificationData data;
    DisplayIdentificationData data;
    if (getDisplayIdentificationData(displayId, &port, &data)) {
    if (getDisplayIdentificationData(hwcDisplayId, &port, &data)) {
        stableId = generateDisplayId(port, data);
        displayId = generateDisplayId(port, data);
        ALOGE_IF(!stableId, "Failed to generate stable ID for display %" PRIu64, displayId);
        ALOGE_IF(!displayId, "Failed to generate stable ID for display %" PRIu64, hwcDisplayId);
    }
    }


    // Disconnect is handled through HWComposer::disconnectDisplay via
    // Disconnect is handled through HWComposer::disconnectDisplay via
    // SurfaceFlinger's onHotplugReceived callback handling
    // SurfaceFlinger's onHotplugReceived callback handling
    if (connection == HWC2::Connection::Connected) {
    if (connection == HWC2::Connection::Connected) {
        mDisplayData[displayType].hwcDisplay = mHwcDevice->getDisplayById(displayId);
        mDisplayData[displayType].hwcDisplay = mHwcDevice->getDisplayById(hwcDisplayId);
        mHwcDisplaySlots[displayId] = displayType;
        mHwcDisplaySlots[hwcDisplayId] = displayType;
    }
    }


    return stableId;
    return displayId;
}
}


bool HWComposer::onVsync(hwc2_display_t displayId, int64_t timestamp,
bool HWComposer::onVsync(hwc2_display_t hwcDisplayId, int64_t timestamp, int32_t* outDisplay) {
                         int32_t* outDisplay) {
    auto display = mHwcDevice->getDisplayById(hwcDisplayId);
    auto display = mHwcDevice->getDisplayById(displayId);
    if (!display) {
    if (!display) {
        ALOGE("onVsync Failed to find display %" PRIu64, displayId);
        ALOGE("%s: Failed to find display %" PRIu64, __FUNCTION__, hwcDisplayId);
        return false;
        return false;
    }
    }
    auto displayType = HWC2::DisplayType::Invalid;
    auto displayType = HWC2::DisplayType::Invalid;
    auto error = display->getType(&displayType);
    auto error = display->getType(&displayType);
    if (error != HWC2::Error::None) {
    if (error != HWC2::Error::None) {
        ALOGE("onVsync: Failed to determine type of display %" PRIu64,
        ALOGE("%s: Failed to determine type of display %" PRIu64, __FUNCTION__, display->getId());
                display->getId());
        return false;
        return false;
    }
    }


+3 −4
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ public:
    void registerCallback(HWC2::ComposerCallback* callback,
    void registerCallback(HWC2::ComposerCallback* callback,
                          int32_t sequenceId);
                          int32_t sequenceId);


    bool getDisplayIdentificationData(hwc2_display_t displayId, uint8_t* outPort,
    bool getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
                                      DisplayIdentificationData* outData) const;
                                      DisplayIdentificationData* outData) const;


    bool hasCapability(HWC2::Capability capability) const;
    bool hasCapability(HWC2::Capability capability) const;
@@ -152,9 +152,8 @@ public:


    // Returns true if successful, false otherwise. The
    // Returns true if successful, false otherwise. The
    // DisplayDevice::DisplayType of the display is returned as an output param.
    // DisplayDevice::DisplayType of the display is returned as an output param.
    bool onVsync(hwc2_display_t displayId, int64_t timestamp,
    bool onVsync(hwc2_display_t hwcDisplayId, int64_t timestamp, int32_t* outDisplay);
                 int32_t* outDisplay);
    std::optional<DisplayId> onHotplug(hwc2_display_t hwcDisplayId, int32_t displayType,
    std::optional<DisplayId> onHotplug(hwc2_display_t displayId, int32_t displayType,
                                       HWC2::Connection connection);
                                       HWC2::Connection connection);


    void setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled);
    void setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled);
+7 −7
Original line number Original line Diff line number Diff line
@@ -363,7 +363,7 @@ FloatRect Layer::computeBounds(const Region& activeTransparentRegion) const {
    return reduce(floatWin, activeTransparentRegion);
    return reduce(floatWin, activeTransparentRegion);
}
}


Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& hw) const {
Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& display) const {
    // the crop is the area of the window that gets cropped, but not
    // the crop is the area of the window that gets cropped, but not
    // scaled in any ways.
    // scaled in any ways.
    const State& s(getDrawingState());
    const State& s(getDrawingState());
@@ -382,7 +382,7 @@ Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& hw) const {


    Transform t = getTransform();
    Transform t = getTransform();
    activeCrop = t.transform(activeCrop);
    activeCrop = t.transform(activeCrop);
    if (!activeCrop.intersect(hw->getViewport(), &activeCrop)) {
    if (!activeCrop.intersect(display->getViewport(), &activeCrop)) {
        activeCrop.clear();
        activeCrop.clear();
    }
    }
    if (!s.finalCrop.isEmpty()) {
    if (!s.finalCrop.isEmpty()) {
@@ -393,14 +393,14 @@ Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& hw) const {


    const auto& p = mDrawingParent.promote();
    const auto& p = mDrawingParent.promote();
    if (p != nullptr) {
    if (p != nullptr) {
        auto parentCrop = p->computeInitialCrop(hw);
        auto parentCrop = p->computeInitialCrop(display);
        activeCrop.intersect(parentCrop, &activeCrop);
        activeCrop.intersect(parentCrop, &activeCrop);
    }
    }


    return activeCrop;
    return activeCrop;
}
}


FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
FloatRect Layer::computeCrop(const sp<const DisplayDevice>& display) const {
    // the content crop is the area of the content that gets scaled to the
    // the content crop is the area of the content that gets scaled to the
    // layer's size. This is in buffer space.
    // layer's size. This is in buffer space.
    FloatRect crop = getContentCrop().toFloatRect();
    FloatRect crop = getContentCrop().toFloatRect();
@@ -409,7 +409,7 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
    const State& s(getDrawingState());
    const State& s(getDrawingState());


    // Screen space to make reduction to parent crop clearer.
    // Screen space to make reduction to parent crop clearer.
    Rect activeCrop = computeInitialCrop(hw);
    Rect activeCrop = computeInitialCrop(display);
    Transform t = getTransform();
    Transform t = getTransform();
    // Back to layer space to work with the content crop.
    // Back to layer space to work with the content crop.
    activeCrop = t.inverse().transform(activeCrop);
    activeCrop = t.inverse().transform(activeCrop);
@@ -1371,13 +1371,13 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const {
    return usage;
    return usage;
}
}


void Layer::updateTransformHint(const sp<const DisplayDevice>& hw) const {
void Layer::updateTransformHint(const sp<const DisplayDevice>& display) const {
    uint32_t orientation = 0;
    uint32_t orientation = 0;
    if (!mFlinger->mDebugDisableTransformHint) {
    if (!mFlinger->mDebugDisableTransformHint) {
        // The transform hint is used to improve performance, but we can
        // The transform hint is used to improve performance, but we can
        // only have a single transform hint, it cannot
        // only have a single transform hint, it cannot
        // apply to all displays.
        // apply to all displays.
        const Transform& planeTransform(hw->getTransform());
        const Transform& planeTransform = display->getTransform();
        orientation = planeTransform.getOrientation();
        orientation = planeTransform.getOrientation();
        if (orientation & Transform::ROT_INVALID) {
        if (orientation & Transform::ROT_INVALID) {
            orientation = 0;
            orientation = 0;
+4 −4
Original line number Original line Diff line number Diff line
@@ -328,7 +328,7 @@ public:
    HWC2::Composition getCompositionType(int32_t displayId) const;
    HWC2::Composition getCompositionType(int32_t displayId) const;
    void setClearClientTarget(int32_t displayId, bool clear);
    void setClearClientTarget(int32_t displayId, bool clear);
    bool getClearClientTarget(int32_t displayId) const;
    bool getClearClientTarget(int32_t displayId) const;
    void updateCursorPosition(const sp<const DisplayDevice>& hw);
    void updateCursorPosition(const sp<const DisplayDevice>& display);


    /*
    /*
     * called after page-flip
     * called after page-flip
@@ -425,7 +425,7 @@ public:


    // Updates the transform hint in our SurfaceFlingerConsumer to match
    // Updates the transform hint in our SurfaceFlingerConsumer to match
    // the current orientation of the display device.
    // the current orientation of the display device.
    void updateTransformHint(const sp<const DisplayDevice>& hw) const;
    void updateTransformHint(const sp<const DisplayDevice>& display) const;


    /*
    /*
     * returns the rectangle that crops the content of the layer and scales it
     * returns the rectangle that crops the content of the layer and scales it
@@ -556,12 +556,12 @@ protected:


    uint32_t getEffectiveUsage(uint32_t usage) const;
    uint32_t getEffectiveUsage(uint32_t usage) const;


    FloatRect computeCrop(const sp<const DisplayDevice>& hw) const;
    FloatRect computeCrop(const sp<const DisplayDevice>& display) const;
    // Compute the initial crop as specified by parent layers and the
    // Compute the initial crop as specified by parent layers and the
    // SurfaceControl for this layer. Does not include buffer crop from the
    // SurfaceControl for this layer. Does not include buffer crop from the
    // IGraphicBufferProducer client, as that should not affect child clipping.
    // IGraphicBufferProducer client, as that should not affect child clipping.
    // Returns in screen space.
    // Returns in screen space.
    Rect computeInitialCrop(const sp<const DisplayDevice>& hw) const;
    Rect computeInitialCrop(const sp<const DisplayDevice>& display) const;


    // drawing
    // drawing
    void clearWithOpenGL(const RenderArea& renderArea, float r, float g, float b,
    void clearWithOpenGL(const RenderArea& renderArea, float r, float g, float b,
Loading