Skip to content

[vector_graphics] Fix raster cache size calculation and incorporate ColorFilter/Opacity effects into cache #9082

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

This PR fixes the bugs mentioned in #8932.

  1. The raster cache size generated by vector_graphics takes BoxFit into account but does not consider the impact of the Transform widget. In practice, the raster cache size can be derived directly from the canvas's scale, which naturally reflects all visual transformations—including BoxFit, Transform, and any other factors affecting the final display size of the component. This PR replaces the previous size calculation with one based on the canvas scale.

  2. Currently, the raster cache does not include ColorFilter or Opacity, meaning that rendering overhead remains high when either is present, due to the need for additional offscreen rendering passes. However, in real-world scenarios—especially when using SVG assets—it's very common to apply ColorFilter for tinting. This PR incorporates ColorFilter and Opacity effects into the raster cache, reducing the overall rendering cost.

Of course, this PR also aims to address issue #166184.

Regarding point 2, before applying the fix, the trace output was as follows:
image

At that time, two SVGs were causing two vkQueueSubmit calls, resulting in two offscreen renderings, which took approximately 2ms.

After the fix, the trace output is as follows:

image

The vkQueueSubmit calls are no longer present, and the processing time has decreased to 0.6ms.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

…e and reduce extra rendering cost from ColorFilter/Opacity in raster mode.
@gaodi-sec gaodi-sec force-pushed the fix_vector_graphics_scale branch from b1ef7b9 to d17d97e Compare April 17, 2025 03:12
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