Kaynağa Gözat

JUCE fix 190rd + text cache: glyphs drawn without allocations per glyph

JUCE's software renderer copied a glyph's cached layers (a vector and each layer's edge table) for every glyph drawn,
and every glyph cache hit moved its LRU entry with std::list erase + insert. The layers are now drawn in place under
the glyph cache's lock (GlyphCache::lynxWithLayers), a hit moves its entry with std::list::splice, and SolidColour's
rectangle fill steps are forcedinline as their neighbours (with the larger drawGlyph the compiler stopped inlining
them into the rectangle iterators). textcache's look-ups take their layout lambda as a template parameter (a
std::function was built on the heap at every drawText, cache hit or not). Same pixels; the integration round assigns
the JUCE fix number.
Ka1-S 1 hafta önce
ebeveyn
işleme
b006fdc19c
2 değiştirilmiş dosya ile 22 ekleme ve 3 silme
  1. 16 0
      cmake/LynxPatchJuce.cmake
  2. 6 3
      src/ui/TextCache.h

Dosya farkı çok büyük olduğundan ihmal edildi
+ 16 - 0
cmake/LynxPatchJuce.cmake


+ 6 - 3
src/ui/TextCache.h

@@ -26,7 +26,10 @@ inline std::unordered_map<juce::String, juce::GlyphArrangement>& cache()
     return map;
 }
 
-inline const juce::GlyphArrangement& get (const juce::String& key, const std::function<void (juce::GlyphArrangement&)>& make)
+// (round 190rd: `make` a template parameter, no std::function: a lambda with its captures made one on the heap at every
+// call, cache hit or not — one allocation per text drawn)
+template <typename Make>
+inline const juce::GlyphArrangement& get (const juce::String& key, const Make& make)
 {
     auto& map = cache();
     if (const auto it = map.find (key); it != map.end())
@@ -94,8 +97,8 @@ inline std::unordered_multimap<std::uint64_t, Entry>& hashed()
     return map;
 }
 
-inline const juce::GlyphArrangement& getHashed (const Call& call, const juce::Font& font, const juce::String& text,
-                                                const std::function<void (juce::GlyphArrangement&)>& make)
+template <typename Make>
+inline const juce::GlyphArrangement& getHashed (const Call& call, const juce::Font& font, const juce::String& text, const Make& make)
 {
     const auto height = thousandths (font.getHeight()), scale = thousandths (font.getHorizontalScale());
     auto h = mixHash (mixHash (mixHash (1469598103934665603ull, (std::uint64_t) (unsigned char) call.kind), (std::uint64_t) call.width), (std::uint64_t) call.height);

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor