-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
Background
Flutter has transitioned to Impeller as its rendering engine. However, Impeller does not currently support raster cache, meaning every frame is fully redrawn in real-time.
When rendering an SVG widget, the default rendering strategy is Picture, which records a list of drawing commands and replays them every frame.
Problem
Some SVGs internally use saveLayer, which triggers offscreen rendering. Additionally, if the SVG applies colorfilter, it results in another offscreen pass. This leads to two separate render passes, increasing rendering overhead.
While vector_graphics provides a Raster strategy that pre-builds a raster cache, it has some limitations:
-
The raster cache size must match the actual rendering resolution. However, in the current raster mode, when a Transform is applied, the cache size may become inconsistent with the expected resolution. This makes it less flexible and requires manual adjustments to maintain the correct size.
-
Color filter still require an additional render pass.
Proposal
Proposal
Introduce a new, adaptive rendering strategy that dynamically selects the most efficient method based on the SVG content. This approach aims to optimize performance and reduce unnecessary offscreen passes in Impeller.
Auto Render Strategy Features:
Picture Mode for Large Sizes – Uses the default picture-based rendering when the SVG size is large to maintain efficiency.
Raster Cache When Beneficial – Automatically enables raster caching when it improves performance.
Correct Raster Cache Sizing – Ensures the raster cache matches the actual rendering resolution, even when transformations are applied.
This strategy provides a more flexible and performant way to handle SVG rendering in Impeller.