mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
scene: fixing nested masking
For any type of masking composition may be required. @Issue: https://github.com/Samsung/thorvg/issues/1295
This commit is contained in:
parent
57e3efc6ab
commit
5c59c9aa71
2 changed files with 13 additions and 2 deletions
|
@ -25,7 +25,7 @@
|
|||
/* External Class Implementation */
|
||||
/************************************************************************/
|
||||
|
||||
Scene::Scene() : pImpl(new Impl())
|
||||
Scene::Scene() : pImpl(new Impl(this))
|
||||
{
|
||||
Paint::pImpl->id = TVG_CLASS_ID_SCENE;
|
||||
Paint::pImpl->method(new PaintMethod<Scene::Impl>(pImpl));
|
||||
|
|
|
@ -60,6 +60,11 @@ struct Scene::Impl
|
|||
Array<Paint*> paints;
|
||||
uint8_t opacity; //for composition
|
||||
RenderMethod* renderer = nullptr; //keep it for explicit clear
|
||||
Scene* scene = nullptr;
|
||||
|
||||
Impl(Scene* s) : scene(s)
|
||||
{
|
||||
}
|
||||
|
||||
~Impl()
|
||||
{
|
||||
|
@ -81,8 +86,14 @@ struct Scene::Impl
|
|||
|
||||
bool needComposition(uint32_t opacity)
|
||||
{
|
||||
if (opacity == 0 || paints.count == 0) return false;
|
||||
|
||||
//Masking may require composition (even if opacity == 255)
|
||||
auto compMethod = scene->composite(nullptr);
|
||||
if (compMethod != CompositeMethod::None && compMethod != CompositeMethod::ClipPath) return true;
|
||||
|
||||
//Half translucent requires intermediate composition.
|
||||
if (opacity == 255 || opacity == 0) return false;
|
||||
if (opacity == 255) return false;
|
||||
|
||||
//If scene has several children or only scene, it may require composition.
|
||||
if (paints.count > 1) return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue