mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added some heuristics to EdgeTable to try to improve the table size prediction
This commit is contained in:
parent
dd4230586f
commit
24f023bb23
2 changed files with 9 additions and 5 deletions
|
|
@ -32,8 +32,12 @@ const int juce_edgeTableDefaultEdgesPerLine = 32;
|
|||
//==============================================================================
|
||||
EdgeTable::EdgeTable (Rectangle<int> area, const Path& path, const AffineTransform& transform)
|
||||
: bounds (area),
|
||||
maxEdgesPerLine (juce_edgeTableDefaultEdgesPerLine),
|
||||
lineStrideElements (juce_edgeTableDefaultEdgesPerLine * 2 + 1)
|
||||
// this is a very vague heuristic to make a rough guess at a good table size
|
||||
// for a given path, such that it's big enough to mostly avoid remapping, but also
|
||||
// not so big that it's wasteful for simple paths.
|
||||
maxEdgesPerLine (jmax (juce_edgeTableDefaultEdgesPerLine / 2,
|
||||
4 * (int) std::sqrt (path.numElements))),
|
||||
lineStrideElements (maxEdgesPerLine * 2 + 1)
|
||||
{
|
||||
allocate();
|
||||
int* t = table;
|
||||
|
|
@ -404,7 +408,7 @@ void EdgeTable::remapTableForNumEdges (const int newNumEdgesPerLine)
|
|||
|
||||
inline void EdgeTable::remapWithExtraSpace (int numPoints)
|
||||
{
|
||||
remapTableForNumEdges (numPoints + jmax (juce_edgeTableDefaultEdgesPerLine, numPoints / 2));
|
||||
remapTableForNumEdges (numPoints * 2);
|
||||
jassert (numPoints < maxEdgesPerLine);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -781,9 +781,7 @@ public:
|
|||
void loadPathFromData (const void* data, size_t numberOfBytes);
|
||||
|
||||
/** Stores the path by writing it out to a stream.
|
||||
|
||||
After writing out a path, you can reload it using loadPathFromStream().
|
||||
|
||||
@see loadPathFromStream, loadPathFromData
|
||||
*/
|
||||
void writePathToStream (OutputStream& destination) const;
|
||||
|
|
@ -803,6 +801,8 @@ private:
|
|||
//==============================================================================
|
||||
friend class PathFlatteningIterator;
|
||||
friend class Path::Iterator;
|
||||
friend class EdgeTable;
|
||||
|
||||
ArrayAllocationBase<float, DummyCriticalSection> data;
|
||||
size_t numElements = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue