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

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

Merge "Fix 5x and 6P crash when using HWC2to1adapter"

parents 6f674aef eb3db61f
Loading
Loading
Loading
Loading
+26 −2
Original line number Original line Diff line number Diff line
@@ -132,6 +132,7 @@ HWC2On1Adapter::HWC2On1Adapter(hwc_composer_device_1_t* hwc1Device)
    mHwc1Device(hwc1Device),
    mHwc1Device(hwc1Device),
    mHwc1MinorVersion(getMinorVersion(hwc1Device)),
    mHwc1MinorVersion(getMinorVersion(hwc1Device)),
    mHwc1SupportsVirtualDisplays(false),
    mHwc1SupportsVirtualDisplays(false),
    mHwc1SupportsBackgroundColor(false),
    mHwc1Callbacks(std::make_unique<Callbacks>(*this)),
    mHwc1Callbacks(std::make_unique<Callbacks>(*this)),
    mCapabilities(),
    mCapabilities(),
    mLayers(),
    mLayers(),
@@ -2272,7 +2273,18 @@ void HWC2On1Adapter::Layer::applySolidColorState(hwc_layer_1_t& hwc1Layer,
        bool applyAllState)
        bool applyAllState)
{
{
    if (applyAllState || mColor.isDirty()) {
    if (applyAllState || mColor.isDirty()) {
        // If the device does not support background color it is likely to make
        // assumption regarding backgroundColor and handle (both fields occupy
        // the same location in hwc_layer_1_t union).
        // To not confuse these devices we don't set background color and we
        // make sure handle is a null pointer.
        if (mDisplay.getDevice().supportsBackgroundColor()) {
            hwc1Layer.backgroundColor = mColor.getPendingValue();
            hwc1Layer.backgroundColor = mColor.getPendingValue();
            mHasUnsupportedBackgroundColor = false;
        } else {
            hwc1Layer.handle = nullptr;
            mHasUnsupportedBackgroundColor = true;
        }
        mColor.latch();
        mColor.latch();
    }
    }
}
}
@@ -2299,7 +2311,7 @@ void HWC2On1Adapter::Layer::applyCompositionType(hwc_layer_1_t& hwc1Layer,
    // supports plane alpha (depending on the version). These require us to drop
    // supports plane alpha (depending on the version). These require us to drop
    // some or all layers to client composition.
    // some or all layers to client composition.
    if (mHasUnsupportedDataspace || mHasUnsupportedPlaneAlpha ||
    if (mHasUnsupportedDataspace || mHasUnsupportedPlaneAlpha ||
            mDisplay.hasColorTransform()) {
            mDisplay.hasColorTransform() || mHasUnsupportedBackgroundColor) {
        hwc1Layer.compositionType = HWC_FRAMEBUFFER;
        hwc1Layer.compositionType = HWC_FRAMEBUFFER;
        hwc1Layer.flags = HWC_SKIP_LAYER;
        hwc1Layer.flags = HWC_SKIP_LAYER;
        return;
        return;
@@ -2369,6 +2381,18 @@ void HWC2On1Adapter::populateCapabilities()
    if (mHwc1MinorVersion >= 4U) {
    if (mHwc1MinorVersion >= 4U) {
        mCapabilities.insert(Capability::SidebandStream);
        mCapabilities.insert(Capability::SidebandStream);
    }
    }

    // Check for HWC background color layer support.
    if (mHwc1MinorVersion >= 1U) {
        int backgroundColorSupported = 0;
        auto result = mHwc1Device->query(mHwc1Device,
                                         HWC_BACKGROUND_LAYER_SUPPORTED,
                                         &backgroundColorSupported);
        if ((result == 0) && (backgroundColorSupported == 1)) {
            ALOGV("Found support for HWC background color");
            mHwc1SupportsBackgroundColor = true;
        }
    }
}
}


HWC2On1Adapter::Display* HWC2On1Adapter::getDisplay(hwc2_display_t id)
HWC2On1Adapter::Display* HWC2On1Adapter::getDisplay(hwc2_display_t id)
+6 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,10 @@ private:
        getAdapter(device)->doGetCapabilities(outCount, outCapabilities);
        getAdapter(device)->doGetCapabilities(outCount, outCapabilities);
    }
    }


    bool supportsBackgroundColor() {
        return mHwc1SupportsBackgroundColor;
    }

    // getFunction
    // getFunction


    hwc2_function_pointer_t doGetFunction(HWC2::FunctionDescriptor descriptor);
    hwc2_function_pointer_t doGetFunction(HWC2::FunctionDescriptor descriptor);
@@ -576,6 +580,7 @@ private:
            size_t mHwc1Id;
            size_t mHwc1Id;
            bool mHasUnsupportedDataspace;
            bool mHasUnsupportedDataspace;
            bool mHasUnsupportedPlaneAlpha;
            bool mHasUnsupportedPlaneAlpha;
            bool mHasUnsupportedBackgroundColor;
    };
    };


    template <typename ...Args>
    template <typename ...Args>
@@ -656,6 +661,7 @@ private:
    struct hwc_composer_device_1* const mHwc1Device;
    struct hwc_composer_device_1* const mHwc1Device;
    const uint8_t mHwc1MinorVersion;
    const uint8_t mHwc1MinorVersion;
    bool mHwc1SupportsVirtualDisplays;
    bool mHwc1SupportsVirtualDisplays;
    bool mHwc1SupportsBackgroundColor;


    class Callbacks;
    class Callbacks;
    const std::unique_ptr<Callbacks> mHwc1Callbacks;
    const std::unique_ptr<Callbacks> mHwc1Callbacks;