From 6cd587ba5f36c83c1f42cbcf6347affd5d1fb3e3 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 25 Feb 2021 15:59:14 +0900 Subject: [PATCH] scene: fix a composition regression bug. Pre-condition is broken when this commit come - b60a773d12ef5ab558e95066b2deecea8d859e8c Both condition should be identitcal so that comp logic is perfectly performed. --- src/lib/tvgSceneImpl.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib/tvgSceneImpl.h b/src/lib/tvgSceneImpl.h index 1d28ea52..26269cf1 100644 --- a/src/lib/tvgSceneImpl.h +++ b/src/lib/tvgSceneImpl.h @@ -44,12 +44,23 @@ struct Scene::Impl return true; } + bool needComposition(uint32_t opacity) + { + //Half translucent requires intermediate composition. + if (opacity == 255 || opacity == 0) return false; + + //If scene has several children or only scene, it may require composition. + if (paints.count > 1) return true; + if (paints.count == 1 && (*paints.data)->pImpl->type == PaintType::Scene) return true; + return false; + } + void* update(RenderMethod &renderer, const RenderTransform* transform, uint32_t opacity, Array& clips, RenderUpdateFlag flag) { /* Overriding opacity value. If this scene is half-translucent, It must do intermeidate composition with that opacity value. */ this->opacity = static_cast(opacity); - if (opacity > 0) opacity = 255; + if (needComposition(opacity)) opacity = 255; for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { (*paint)->pImpl->update(renderer, transform, opacity, clips, static_cast(flag)); @@ -64,14 +75,7 @@ struct Scene::Impl { Compositor* cmp = nullptr; - //If scene has several children or only scene, it may require composition. - auto condition = false; - if ((paints.count > 1) || (paints.count == 1 && (*paints.data)->pImpl->type == PaintType::Scene)) { - condition = true; - } - - //Half translucent. This condition requires intermediate composition. - if ((opacity < 255 && opacity > 0) && condition) { + if (needComposition(opacity)) { uint32_t x, y, w, h; if (!bounds(renderer, &x, &y, &w, &h)) return false; cmp = renderer.target(x, y, w, h);