diff options
author | 2016-07-11 12:20:51 -0700 | |
---|---|---|
committer | 2016-07-11 19:26:18 +0000 | |
commit | e3e481df762747c5f01bbd1503800fa29457fc1b (patch) | |
tree | d8aa5a01bcc5150999b472c0be25dcb1f98374d9 | |
parent | 377a8dd1e4909aa78d57ae3eb4ce885a7bad61c0 (diff) |
Avoid throwing when 0 size layer requested
bug:30032790
Change-Id: I8553af0d0b0d59fea6535d03479c4e7134a9f4f9
-rw-r--r-- | libs/hwui/RenderNode.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/RenderProperties.h | 4 | ||||
-rw-r--r-- | libs/hwui/tests/unit/RenderPropertiesTests.cpp | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index f8797bf63442..6facf20b025c 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -301,7 +301,10 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) { LayerType layerType = properties().effectiveLayerType(); // 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())) { + if (CC_LIKELY(layerType != LayerType::RenderLayer) + || CC_UNLIKELY(!isRenderable()) + || CC_UNLIKELY(properties().getWidth() == 0) + || CC_UNLIKELY(properties().getHeight() == 0)) { if (CC_UNLIKELY(mLayer)) { destroyLayer(mLayer); mLayer = nullptr; diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h index 696cc29de3a4..395279806adb 100644 --- a/libs/hwui/RenderProperties.h +++ b/libs/hwui/RenderProperties.h @@ -611,9 +611,7 @@ public: bool fitsOnLayer() const { const DeviceInfo* deviceInfo = DeviceInfo::get(); return mPrimitiveFields.mWidth <= deviceInfo->maxTextureSize() - && mPrimitiveFields.mHeight <= deviceInfo->maxTextureSize() - && mPrimitiveFields.mWidth > 0 - && mPrimitiveFields.mHeight > 0; + && mPrimitiveFields.mHeight <= deviceInfo->maxTextureSize(); } bool promotedToLayer() const { diff --git a/libs/hwui/tests/unit/RenderPropertiesTests.cpp b/libs/hwui/tests/unit/RenderPropertiesTests.cpp index 90010983f154..85655fc2728a 100644 --- a/libs/hwui/tests/unit/RenderPropertiesTests.cpp +++ b/libs/hwui/tests/unit/RenderPropertiesTests.cpp @@ -42,7 +42,7 @@ TEST(RenderProperties, layerValidity) { props.setLeftTopRightBottom(0, 0, maxTextureSize + 1, maxTextureSize + 1); ASSERT_FALSE(props.fitsOnLayer()); - // Too small - can't have 0 dimen layer + // Too small, but still 'fits'. Not fitting is an error case, so don't report empty as such. props.setLeftTopRightBottom(0, 0, 100, 0); - ASSERT_FALSE(props.fitsOnLayer()); + ASSERT_TRUE(props.fitsOnLayer()); } |