skia /
skia /
5218f67ec716edb39f5d005ddaf6e9d70eca7cc9 Emit StructElem ID only when referenced
If a StructElem ID is referenced by an emitted attribute then the
StructElem must be emitted and its ID listed in the IDTree. If a
StructElem is not used or referenced then it should not be emitted. If a
StructElem ID is not referenced by an emitted attribute then its ID
should not be listed in the IDTree. Currently the only way that a
StructElem ID is referenced is through AttributeList::appendNodeIdArray.
This commit changes the way StructElem are marked as used. Previously
this was tracked with fCanDiscard with could be unknown, yes, or no and
started out as unknown. The invariant for this is difficult to reason
about as it required a complex finalization step which was tightly
coupled to finishing the document and emitting the tag tree. Instead
have a simple boolean fUsed which tracks if the StructElem has been
referenced. This requires adding a fParent pointer so that it is
possible to quickly mark the parent as used as well, but also makes
marking referenced StructElem simple as well as making the invariant
much easier to understand (the StructElem is marked as used if it has
been used by the document).
Change-Id: If1cf50f597b8c10c761d7645d1697f5c17b39066
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/891179
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2 files changed