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

Commit f6a38939 authored by David Sodman's avatar David Sodman
Browse files

Revert "SF: use shared_ptr to track hwcLayer"

This reverts commit 5d89c1d6.

The original commit was part of a larger set that has been backed
out temporarily while some bugs are sorted out.   This change
should have been backed out as well as it depends on the others
in the larger change.

Test: run cts -m CtsViewTestCases
Bug: 79264214

Change-Id: Ifa9388d9f9573073832a40075317fdabf74b180c
parent effad485
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -615,14 +615,14 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
    auto hwcId = displayDevice->getHwcDisplayId();
    auto& hwcInfo = getBE().mHwcLayers[hwcId];
    auto& hwcLayer = hwcInfo.layer;
    auto error = (*hwcLayer)->setVisibleRegion(visible);
    auto error = hwcLayer->setVisibleRegion(visible);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(),
              to_string(error).c_str(), static_cast<int32_t>(error));
        visible.dump(LOG_TAG);
    }

    error = (*hwcLayer)->setSurfaceDamage(surfaceDamageRegion);
    error = hwcLayer->setSurfaceDamage(surfaceDamageRegion);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(),
              to_string(error).c_str(), static_cast<int32_t>(error));
@@ -633,7 +633,7 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
    if (getBE().compositionInfo.hwc.sidebandStream.get()) {
        setCompositionType(hwcId, HWC2::Composition::Sideband);
        ALOGV("[%s] Requesting Sideband composition", mName.string());
        error = (*hwcLayer)->setSidebandStream(getBE().compositionInfo.hwc.sidebandStream->handle());
        error = hwcLayer->setSidebandStream(getBE().compositionInfo.hwc.sidebandStream->handle());
        if (error != HWC2::Error::None) {
            ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", mName.string(),
                  getBE().compositionInfo.hwc.sidebandStream->handle(), to_string(error).c_str(),
@@ -652,14 +652,14 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
    }

    ALOGV("setPerFrameData: dataspace = %d", mCurrentDataSpace);
    error = (*hwcLayer)->setDataspace(mCurrentDataSpace);
    error = hwcLayer->setDataspace(mCurrentDataSpace);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace,
              to_string(error).c_str(), static_cast<int32_t>(error));
    }

    const HdrMetadata& metadata = mConsumer->getCurrentHdrMetadata();
    error = (*hwcLayer)->setPerFrameMetadata(displayDevice->getSupportedPerFrameMetadata(), metadata);
    error = hwcLayer->setPerFrameMetadata(displayDevice->getSupportedPerFrameMetadata(), metadata);
    if (error != HWC2::Error::None && error != HWC2::Error::Unsupported) {
        ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", mName.string(),
              to_string(error).c_str(), static_cast<int32_t>(error));
@@ -671,7 +671,7 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
                                                       &hwcBuffer);

    auto acquireFence = mConsumer->getCurrentFence();
    error = (*hwcLayer)->setBuffer(hwcSlot, hwcBuffer, acquireFence);
    error = hwcLayer->setBuffer(hwcSlot, hwcBuffer, acquireFence);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(),
              getBE().compositionInfo.mBuffer->handle, to_string(error).c_str(),
+4 −4
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
    auto hwcId = displayDevice->getHwcDisplayId();
    auto& hwcInfo = getBE().mHwcLayers[hwcId];
    auto& hwcLayer = hwcInfo.layer;
    auto error = (*hwcLayer)->setVisibleRegion(visible);
    auto error = hwcLayer->setVisibleRegion(visible);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(),
              to_string(error).c_str(), static_cast<int32_t>(error));
@@ -77,14 +77,14 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {

    setCompositionType(hwcId, HWC2::Composition::SolidColor);

    error = (*hwcLayer)->setDataspace(mCurrentDataSpace);
    error = hwcLayer->setDataspace(mCurrentDataSpace);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace,
              to_string(error).c_str(), static_cast<int32_t>(error));
    }

    half4 color = getColor();
    error = (*hwcLayer)->setColor({static_cast<uint8_t>(std::round(255.0f * color.r)),
    error = hwcLayer->setColor({static_cast<uint8_t>(std::round(255.0f * color.r)),
                                static_cast<uint8_t>(std::round(255.0f * color.g)),
                                static_cast<uint8_t>(std::round(255.0f * color.b)), 255});
    if (error != HWC2::Error::None) {
@@ -93,7 +93,7 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
    }

    // Clear out the transform, because it doesn't make sense absent a source buffer
    error = (*hwcLayer)->setTransform(HWC2::Transform::None);
    error = hwcLayer->setTransform(HWC2::Transform::None);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to clear transform: %s (%d)", mName.string(), to_string(error).c_str(),
              static_cast<int32_t>(error));
+18 −18
Original line number Diff line number Diff line
@@ -218,14 +218,15 @@ sp<IBinder> Layer::getHandle() {
bool Layer::createHwcLayer(HWComposer* hwc, int32_t hwcId) {
    LOG_ALWAYS_FATAL_IF(getBE().mHwcLayers.count(hwcId) != 0,
                        "Already have a layer for hwcId %d", hwcId);

    std::shared_ptr<LayerContainer> layer(new LayerContainer(hwc, hwcId));
    HWC2::Layer* layer = hwc->createLayer(hwcId);
    if (!layer) {
        return false;
    }
    LayerBE::HWCInfo& hwcInfo = getBE().mHwcLayers[hwcId];
    hwcInfo.hwc = hwc;
    hwcInfo.layer = layer;
    layer->setLayerDestroyedListener(
            [this, hwcId](HWC2::Layer* /*layer*/) { getBE().mHwcLayers.erase(hwcId); });
    return true;
}

@@ -236,12 +237,11 @@ bool Layer::destroyHwcLayer(int32_t hwcId) {
    auto& hwcInfo = getBE().mHwcLayers[hwcId];
    LOG_ALWAYS_FATAL_IF(hwcInfo.layer == nullptr, "Attempt to destroy null layer");
    LOG_ALWAYS_FATAL_IF(hwcInfo.hwc == nullptr, "Missing HWComposer");
    hwcInfo.layer = nullptr;

    if (getBE().mHwcLayers.count(hwcId) == 1) {
        getBE().mHwcLayers.erase(hwcId);
    }

    hwcInfo.hwc->destroyLayer(hwcId, hwcInfo.layer);
    // The layer destroyed listener should have cleared the entry from
    // mHwcLayers. Verify that.
    LOG_ALWAYS_FATAL_IF(getBE().mHwcLayers.count(hwcId) != 0,
                        "Stale layer entry in getBE().mHwcLayers");
    return true;
}

@@ -500,7 +500,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
        blendMode =
                mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage;
    }
    auto error = (*hwcLayer)->setBlendMode(blendMode);
    auto error = hwcLayer->setBlendMode(blendMode);
    ALOGE_IF(error != HWC2::Error::None,
             "[%s] Failed to set blend mode %s:"
             " %s (%d)",
@@ -548,7 +548,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
    }
    const Transform& tr(displayDevice->getTransform());
    Rect transformedFrame = tr.transform(frame);
    error = (*hwcLayer)->setDisplayFrame(transformedFrame);
    error = hwcLayer->setDisplayFrame(transformedFrame);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set display frame [%d, %d, %d, %d]: %s (%d)", mName.string(),
              transformedFrame.left, transformedFrame.top, transformedFrame.right,
@@ -558,7 +558,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
    }

    FloatRect sourceCrop = computeCrop(displayDevice);
    error = (*hwcLayer)->setSourceCrop(sourceCrop);
    error = hwcLayer->setSourceCrop(sourceCrop);
    if (error != HWC2::Error::None) {
        ALOGE("[%s] Failed to set source crop [%.3f, %.3f, %.3f, %.3f]: "
              "%s (%d)",
@@ -569,13 +569,13 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
    }

    float alpha = static_cast<float>(getAlpha());
    error = (*hwcLayer)->setPlaneAlpha(alpha);
    error = hwcLayer->setPlaneAlpha(alpha);
    ALOGE_IF(error != HWC2::Error::None,
             "[%s] Failed to set plane alpha %.3f: "
             "%s (%d)",
             mName.string(), alpha, to_string(error).c_str(), static_cast<int32_t>(error));

    error = (*hwcLayer)->setZOrder(z);
    error = hwcLayer->setZOrder(z);
    ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set Z %u: %s (%d)", mName.string(), z,
             to_string(error).c_str(), static_cast<int32_t>(error));

@@ -590,7 +590,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
        }
    }

    error = (*hwcLayer)->setInfo(type, appId);
    error = hwcLayer->setInfo(type, appId);
    ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)", mName.string(),
             static_cast<int32_t>(error));

@@ -633,7 +633,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
    } else {
        auto transform = static_cast<HWC2::Transform>(orientation);
        hwcInfo.transform = transform;
        auto error = (*hwcLayer)->setTransform(transform);
        auto error = hwcLayer->setTransform(transform);
        ALOGE_IF(error != HWC2::Error::None,
                 "[%s] Failed to set transform %s: "
                 "%s (%d)",
@@ -686,7 +686,7 @@ void Layer::updateCursorPosition(const sp<const DisplayDevice>& displayDevice) {
    auto& displayTransform(displayDevice->getTransform());
    auto position = displayTransform.transform(frame);

    auto error = (*getBE().mHwcLayers[hwcId].layer)->setCursorPosition(position.left,
    auto error = getBE().mHwcLayers[hwcId].layer->setCursorPosition(position.left,
                                                                              position.top);
    ALOGE_IF(error != HWC2::Error::None,
             "[%s] Failed to set cursor position "
@@ -730,13 +730,13 @@ void Layer::setCompositionType(int32_t hwcId, HWC2::Composition type, bool callI
    }
    auto& hwcInfo = getBE().mHwcLayers[hwcId];
    auto& hwcLayer = hwcInfo.layer;
    ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (*hwcLayer)->getId(), to_string(type).c_str(),
    ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", hwcLayer->getId(), to_string(type).c_str(),
          static_cast<int>(callIntoHwc));
    if (hwcInfo.compositionType != type) {
        ALOGV("    actually setting");
        hwcInfo.compositionType = type;
        if (callIntoHwc) {
            auto error = (*hwcLayer)->setCompositionType(type);
            auto error = hwcLayer->setCompositionType(type);
            ALOGE_IF(error != HWC2::Error::None,
                     "[%s] Failed to set "
                     "composition type %s: %s (%d)",
+1 −9
Original line number Diff line number Diff line
@@ -455,15 +455,7 @@ public:
        if (getBE().mHwcLayers.count(hwcId) == 0) {
            return nullptr;
        }
        return *(getBE().mHwcLayers[hwcId].layer.get());
    }

    bool setHwcLayer(int32_t hwcId) {
        if (getBE().mHwcLayers.count(hwcId) == 0) {
            return false;
        }
        getBE().compositionInfo.hwc.hwcLayer = getBE().mHwcLayers[hwcId].layer;
        return true;
        return getBE().mHwcLayers[hwcId].layer;
    }

    // -----------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) {
}

void CompositionInfo::dumpHwc(const char* tag) const {
    ALOGV("[%s]\thwcLayer=%p", tag, static_cast<HWC2::Layer*>(*hwc.hwcLayer));
    ALOGV("[%s]\thwcLayer=%p", tag, hwc.hwcLayer);
    ALOGV("[%s]\tfence=%p", tag, hwc.fence.get());
    ALOGV("[%s]\ttransform=%d", tag, hwc.transform);
    ALOGV("[%s]\tz=%d", tag, hwc.z);
Loading