Repository navigation
fix(usvgr): hash a nested group's opacity and blend mode in the layer cache key - #25
Conversation
… cache key The layer of an isolated group is cached by the group's Hash, which left out opacity and blend mode for the group and for every group inside it. Those of a nested group are part of the cached pixels, so a frame that changed only them reused the layer of an earlier frame.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes dmtrKovalenko/fframes#264.
Problem
render_isolated_groupcaches the layer of an isolated group under the group'sHash, the layer size and the final transform.impl Hash for Groupleft outopacityandblend_mode, because the renderer applies them when it draws the cached layer. But the impl hashed the children with the sameHash, so it left them out for nested groups too, and those are part of the cached pixels.Two frames that differ only in the opacity or blend mode of a nested group got the same key. The second frame reused the layer of the first, so a fade inside a group with opacity, a clip, a mask or a filter did not fade when the frames shared a cache.
Fix
Group::hashstill leaves out the opacity and blend mode of the group it is called on. For every group below it, it hashes them.Group::content_hashalready does the same for the filter layer cache.A group's own layer keeps its key when only its own opacity changes, so that case still hits the cache.
Test
nested_group_opacity_and_blend_mode_change_cached_layerrenders three frames with oneSvgrCacheand compares each with a render without a cache. The frames differ in the nested group's opacity, then in its blend mode. It fails onmainwithstale layer for opacity="0.25".cargo test -p svgr -p usvgrpasses.Summary by CodeRabbit