From 28257ec807b81a59d94e4cafe7ecc58b94ae9ce5 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 25 May 2023 00:02:44 +0900 Subject: [PATCH] common masking: optimize InvAlphaMask try fast track if InvAlphaMask has 0 opacity + rectangle shape. --- src/lib/tvgPaint.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/tvgPaint.cpp b/src/lib/tvgPaint.cpp index 5746fe49..c7fbafbc 100644 --- a/src/lib/tvgPaint.cpp +++ b/src/lib/tvgPaint.cpp @@ -209,11 +209,18 @@ RenderData Paint::Impl::update(RenderMethod& renderer, const RenderTransform* pT auto tryFastTrack = false; if (target->identifier() == TVG_CLASS_ID_SHAPE) { if (method == CompositeMethod::ClipPath) tryFastTrack = true; + //OPTIMIZE HERE: Actually, this condition AlphaMask is useless. We can skip it? else if (method == CompositeMethod::AlphaMask) { auto shape = static_cast(target); uint8_t a; shape->fillColor(nullptr, nullptr, nullptr, &a); if (a == 255 && shape->opacity() == 255 && !shape->fill()) tryFastTrack = true; + //OPTIMIZE HERE: Actually, this condition InvAlphaMask is useless. We can skip it? + } else if (method == CompositeMethod::InvAlphaMask) { + auto shape = static_cast(target); + uint8_t a; + shape->fillColor(nullptr, nullptr, nullptr, &a); + if ((a == 0 || shape->opacity() == 0) && !shape->fill()) tryFastTrack = true; } if (tryFastTrack) { RenderRegion viewport2;