Skip to content

[vector_graphics] Moved color and colorFilter effects into the raster cache to reduce rendering overhead. #9398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gaodi-sec
Copy link
Contributor

This PR addresses a performance issue in the VectorGraphic widget when using the raster rendering strategy. Specifically, it moves the color and colorFilter effects into the raster cache stage, avoiding the need to apply them via saveLayer during every frame of rendering.

This issue was highlighted in flutter/flutter#166184, where rendering multiple SVGs in raster mode led to excessive overhead due to the use of saveLayer. Rather than being applied during drawing time, these effects can be baked into the cached image once, resulting in faster and more efficient rendering.

Note: This PR is proposed separately from flutter/packages#8932, which introduced a new auto strategy. Although related in purpose (performance improvements), this fix is independent and directly targets the saveLayer overhead problem.

Before this PR

With the current behavior, SVGs using raster mode with color or colorFilter incur significant rendering costs. For example, rendering 20 SVGs may trigger many sub render passes caused by saveLayer:

before The small blocks at the bottom of EntityPass::OnRender represent additional GPU passes (e.g., vkCmdBeginRenderPass, vkQueueSubmit): saveLayer render passes

After this PR

The effects are applied once at caching time. As a result, runtime rendering becomes a simple drawImage call, with no subpasses introduced:

after

Pre-Review Checklist

…cache for VectorGraphic when using the raster RenderingStrategy, to avoid additional saveLayer overhead during rendering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant