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

Commit 1895e2e9 authored by John Reck's avatar John Reck
Browse files

Don't create layers for negative-sized RenderNodes

Fixes: 257954570
Test: n/a
Flag: EXEMPT trivial bug fix
Change-Id: I82a00ec21b58ea55779d02db4a54d1ef2d37dcc7
parent ea0378dc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ public:
    // this value is only valid after the GPU has been initialized and there is a valid graphics
    // context or if you are using the HWUI_NULL_GPU
    int maxTextureSize() const;
    bool hasMaxTextureSize() const { return mMaxTextureSize > 0; }
    sk_sp<SkColorSpace> getWideColorSpace() const { return mWideColorSpace; }
    SkColorType getWideColorType() {
        static std::once_flag kFlag;
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
    // If we are not a layer OR we cannot be rendered (eg, view was detached)
    // we need to destroy any Layers we may have had previously
    if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable()) ||
        CC_UNLIKELY(properties().getWidth() == 0) || CC_UNLIKELY(properties().getHeight() == 0) ||
        CC_UNLIKELY(properties().getWidth() <= 0) || CC_UNLIKELY(properties().getHeight() <= 0) ||
        CC_UNLIKELY(!properties().fitsOnLayer())) {
        if (CC_UNLIKELY(hasLayer())) {
            this->setLayerSurface(nullptr);
+2 −1
Original line number Diff line number Diff line
@@ -545,7 +545,8 @@ public:
    bool fitsOnLayer() const {
        const DeviceInfo* deviceInfo = DeviceInfo::get();
        return mPrimitiveFields.mWidth <= deviceInfo->maxTextureSize() &&
               mPrimitiveFields.mHeight <= deviceInfo->maxTextureSize();
               mPrimitiveFields.mHeight <= deviceInfo->maxTextureSize() &&
               mPrimitiveFields.mWidth > 0 && mPrimitiveFields.mHeight > 0;
    }

    bool promotedToLayer() const {
+5 −0
Original line number Diff line number Diff line
@@ -418,6 +418,11 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t sy
                                RenderNode* target) {
    mRenderThread.removeFrameCallback(this);

    // Make sure we have a valid device info
    if (!DeviceInfo::get()->hasMaxTextureSize()) {
        (void)mRenderThread.requireGrContext();
    }

    // If the previous frame was dropped we don't need to hold onto it, so
    // just keep using the previous frame's structure instead
    const auto reason = wasSkipped(mCurrentFrameInfo);
+6 −2
Original line number Diff line number Diff line
@@ -40,7 +40,11 @@ TEST(RenderProperties, layerValidity) {
    props.setLeftTopRightBottom(0, 0, maxTextureSize + 1, maxTextureSize + 1);
    ASSERT_FALSE(props.fitsOnLayer());

    // Too small, but still 'fits'. Not fitting is an error case, so don't report empty as such.
    // Too small, we can't create a layer for a 0 width or height
    props.setLeftTopRightBottom(0, 0, 100, 0);
    ASSERT_TRUE(props.fitsOnLayer());
    ASSERT_FALSE(props.fitsOnLayer());

    // Can't create a negative-sized layer
    props.setLeftTopRightBottom(0, 0, -100, 300);
    ASSERT_FALSE(props.fitsOnLayer());
}