common paint: prevent fastrack except Shapes.

Use fasttrack only for Shape types, as it is suitable for them.
It is not recommended to use it for other types.
This commit is contained in:
Hermet Park 2023-04-10 21:24:47 +09:00
parent b018c83e93
commit 352539fe8e

View file

@ -162,8 +162,6 @@ bool Paint::Impl::render(RenderMethod& renderer)
{ {
Compositor* cmp = nullptr; Compositor* cmp = nullptr;
//OPTIMIZE_ME: Can we replace the simple AlphaMasking with ClipPath?
/* Note: only ClipPath is processed in update() step. /* Note: only ClipPath is processed in update() step.
Create a composition image. */ Create a composition image. */
if (compData && compData->method != CompositeMethod::ClipPath && !(compData->target->pImpl->ctxFlag & ContextFlag::FastTrack)) { if (compData && compData->method != CompositeMethod::ClipPath && !(compData->target->pImpl->ctxFlag & ContextFlag::FastTrack)) {
@ -208,20 +206,22 @@ RenderData Paint::Impl::update(RenderMethod& renderer, const RenderTransform* pT
/* If transform has no rotation factors && ClipPath / AlphaMasking is a simple rectangle, /* If transform has no rotation factors && ClipPath / AlphaMasking is a simple rectangle,
we can avoid regular ClipPath / AlphaMasking sequence but use viewport for performance */ we can avoid regular ClipPath / AlphaMasking sequence but use viewport for performance */
auto tryFastTrack = false; auto tryFastTrack = false;
if (method == CompositeMethod::ClipPath) tryFastTrack = true; if (target->identifier() == TVG_CLASS_ID_SHAPE) {
else if (method == CompositeMethod::AlphaMask && target->identifier() == TVG_CLASS_ID_SHAPE) { if (method == CompositeMethod::ClipPath) tryFastTrack = true;
auto shape = static_cast<Shape*>(target); else if (method == CompositeMethod::AlphaMask) {
uint8_t a; auto shape = static_cast<Shape*>(target);
shape->fillColor(nullptr, nullptr, nullptr, &a); uint8_t a;
if (a == 255 && shape->opacity() == 255 && !shape->fill()) tryFastTrack = true; shape->fillColor(nullptr, nullptr, nullptr, &a);
} if (a == 255 && shape->opacity() == 255 && !shape->fill()) tryFastTrack = true;
if (tryFastTrack) { }
RenderRegion viewport2; if (tryFastTrack) {
if ((compFastTrack = _compFastTrack(target, pTransform, target->pImpl->rTransform, viewport2))) { RenderRegion viewport2;
viewport = renderer.viewport(); if ((compFastTrack = _compFastTrack(target, pTransform, target->pImpl->rTransform, viewport2))) {
viewport2.intersect(viewport); viewport = renderer.viewport();
renderer.viewport(viewport2); viewport2.intersect(viewport);
target->pImpl->ctxFlag |= ContextFlag::FastTrack; renderer.viewport(viewport2);
target->pImpl->ctxFlag |= ContextFlag::FastTrack;
}
} }
} }
if (!compFastTrack) { if (!compFastTrack) {