Speed up svg parsing and rendering - #170
Open
kunitoki wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
==========================================
+ Coverage 80.58% 80.73% +0.15%
==========================================
Files 777 779 +2
Lines 80278 80246 -32
==========================================
+ Hits 64689 64786 +97
+ Misses 15589 15460 -129
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant optimizations and refactorings to the SVG and core text modules, primarily aimed at improving performance and maintainability. The most notable changes are the pre-resolution of gradient and filter references at parse time (avoiding repeated resolution during rendering), the introduction of a hash generator utility for efficient hashing, and the implementation of a fast CSS rule index for SVG parsing. Additionally, blend mode parsing has been simplified and made more robust, and some hot code paths have been optimized to reduce unnecessary allocations.
SVG Parsing and Rendering Optimizations:
hrefchains for gradients and filters once and updating their lookup tables accordingly. (modules/yup_graphics/svg/yup_SVGParser.cpp[1] [2]resolveGradientandresolveFilterfunctions and their usages have been removed from the rendering code, as resolution is now handled during parsing. (modules/yup_graphics/drawables/yup_Drawable.cpp[1] [2] [3] [4]CSS Rule Matching Improvements:
SVGCssRuleIndex, a new structure for fast lookup of CSS rules by tag, id, and class, and integrated it into the SVG CSS parser. This replaces brute-force matching and greatly improves stylesheet application performance. (modules/yup_graphics/svg/yup_SVGCssRule.h[1]modules/yup_graphics/svg/yup_SVGCssParser.h[2]modules/yup_graphics/svg/yup_SVGParser.cpp[3]Hashing Infrastructure Improvements:
HashGeneratorutility for use throughout the codebase, improving code reuse and maintainability. This is now used for hashing in bothStringandStringRef. (modules/yup_core/misc/yup_HashGenerator.h[1]modules/yup_core/text/yup_String.cpp[2]modules/yup_core/text/yup_StringRef.h[3]modules/yup_core/yup_core.h[4]StringRefin the default hash functions to enable its use as a key in hash maps. (modules/yup_core/containers/yup_HashMap.h[1] [2]Blend Mode and Attribute Parsing Simplification:
modules/yup_graphics/svg/yup_SVGParser.cpp[1] [2]modules/yup_graphics/svg/yup_SVGParser.cppmodules/yup_graphics/svg/yup_SVGParser.cppL2060-R2014)