An unrelated CL got me randomly looking at SkLayerDrawLooper; in particular the hand-rolled linked list implementation that seems unnecessarily complex. Here's what I'm thinking, but wanted to vet the idea here because it touches Skia's public API:
1. Add a SkLayerDrawLooper::Builder::reserve(size_t) function to allow callers to indicate how many layers they plan to add (similar to std::vector<T>::reserve).
2. Change callers of addLayer to use addLayerOnTop instead. (Turns out there's only one; see below.)
3. Change Chromium and Blink to use the new reserve function.
4. Remove SkLayerDrawLooper::Builder::addLayer.
5. Change SkLayerDrawLooper and its Builder to use a std::vector<Rec> instead of a linked list of Recs. addLayerOnTop uses push_back. Builder::detachLooper can swap the vectors so it'll remain zero copy.
I looked through Android and Chromium and found:
- Blink only uses SkLayerDrawLooper::Builder's addLayerOnTop function; never its addLayer function.
- Further, both Blink and Chromium know how many layers they plan on adding to the SkLayerDrawLooper. (Or at least they do within a couple of call frames; near enough that it wouldn't be hard to plumb that information through to SkLayerDrawLooper::Builder.)
Thoughts?