freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] gsoc-2022-chariri-3 83f52d5 36/36: [ftinspect] Add cac


From: Werner Lemberg
Subject: [freetype2-demos] gsoc-2022-chariri-3 83f52d5 36/36: [ftinspect] Add caching of `QImage` and dimension info in Continuous View.
Date: Wed, 27 Jul 2022 06:32:47 -0400 (EDT)

branch: gsoc-2022-chariri-3
commit 83f52d535c75bd1114b62bd970f9bb1a72f2df6d
Author: Charlie Jiang <w@chariri.moe>
Commit: Charlie Jiang <w@chariri.moe>

    [ftinspect] Add caching of `QImage` and dimension info in Continuous View.
    
    This gives further possibility of implementation click-for-detail and
    dragging features.
    Also improves performance, but very slightly because the cache is purged
    aggresively.
    
    * src/ftinspect/rendering/glyphcontinuous.cpp,
      src/ftinspect/rendering/glyphcontinuous.hpp:
      Implementation the caching, remove non-cached drawing of the glyphs.
    
    * src/ftinspect/engine/stringrenderer.cpp,
      src/ftinspect/engine/stringrenderer.hpp:
      Add an argument to pass the current `GlyphContext` to both callbacks.
    
    * src/ftinspect/panels/continuous.cpp: Purge caches at proper time.
---
 src/ftinspect/engine/stringrenderer.cpp | 4 ++--
 src/ftinspect/engine/stringrenderer.hpp | 8 ++++++--
 src/ftinspect/panels/continuous.cpp     | 2 ++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/ftinspect/engine/stringrenderer.cpp 
b/src/ftinspect/engine/stringrenderer.cpp
index 8d8adbd..a3c2608 100644
--- a/src/ftinspect/engine/stringrenderer.cpp
+++ b/src/ftinspect/engine/stringrenderer.cpp
@@ -510,7 +510,7 @@ StringRenderer::renderLine(int x,
     {
       rect.setX(rect.x() + (pen.x >> 6));
       rect.setY(height - rect.y() - (pen.y >> 6));
-      renderImageCallback_(colorLayerImage, rect);
+      renderImageCallback_(colorLayerImage, rect, ctx);
     }
     else
     {
@@ -569,7 +569,7 @@ StringRenderer::renderLine(int x,
           && bbox.yMin <= height)
       {
         FT_Vector penPos = { (pen.x >> 6), height - (pen.y >> 6) };
-        renderCallback_(image, penPos);
+        renderCallback_(image, penPos, ctx);
       }
 
       FT_Done_Glyph(image);
diff --git a/src/ftinspect/engine/stringrenderer.hpp 
b/src/ftinspect/engine/stringrenderer.hpp
index 610b341..8597587 100644
--- a/src/ftinspect/engine/stringrenderer.hpp
+++ b/src/ftinspect/engine/stringrenderer.hpp
@@ -61,13 +61,17 @@ public:
    * contains no points, and thus can't be translated to the desired pen
    * position.
    */
-  using RenderCallback = std::function<void(FT_Glyph, FT_Vector)>;
+  using RenderCallback = std::function<void(FT_Glyph, 
+                                            FT_Vector, 
+                                            GlyphContext&)>;
   /*
    * For color layered fonts, this will direct render the QImage for you.
    * TODO: Remove `RenderCallback` and do QImage creation in this class?
    * The receiver is responsible for deleteing the QImage.
    */
-  using RenderImageCallback = std::function<void(QImage*, QRect)>;
+  using RenderImageCallback = std::function<void(QImage*, 
+                                                 QRect, 
+                                                 GlyphContext&)>;
   /*
    * The glyph pointer may be replaced. In that case, ownership is transfered
    * to the renderer, and the new glyph will be eventually freed by
diff --git a/src/ftinspect/panels/continuous.cpp 
b/src/ftinspect/panels/continuous.cpp
index be80c57..ebb6a88 100644
--- a/src/ftinspect/panels/continuous.cpp
+++ b/src/ftinspect/panels/continuous.cpp
@@ -30,6 +30,7 @@ ContinuousTab::repaintGlyph()
   sizeSelector_->applyToEngine(engine_);
   
   syncSettings();
+  canvas_->purgeCache();
   canvas_->repaint();
 }
 
@@ -41,6 +42,7 @@ ContinuousTab::reloadFont()
   setGlyphCount(qBound(0, currentGlyphCount_, INT_MAX));
   setCharMaps(engine_->currentFontCharMaps());
   canvas_->stringRenderer().reloadAll();
+  canvas_->purgeCache();
   repaintGlyph();
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]