Explorar el Código

optimize _paintCell

xuty hace 4 años
padre
commit
25fecd5137
Se han modificado 1 ficheros con 10 adiciones y 3 borrados
  1. 10 3
      lib/frontend/terminal_view.dart

+ 10 - 3
lib/frontend/terminal_view.dart

@@ -427,6 +427,13 @@ class TerminalPainter extends CustomPainter {
       return;
     }
 
+    final cellHash = hashValues(cell.codePoint, attr);
+    var tp = textLayoutCache.getLayoutFromCache(cellHash);
+    if (tp != null) {
+      tp.paint(canvas, Offset(offsetX, offsetY));
+      return;
+    }
+
     final cellColor = attr.inverse
         ? attr.bgColor ?? terminal.theme.background
         : attr.fgColor ?? terminal.theme.foreground;
@@ -454,7 +461,8 @@ class TerminalPainter extends CustomPainter {
             decoration:
                 attr.underline ? TextDecoration.underline : TextDecoration.none,
             fontFamily: 'monospace',
-            fontFamilyFallback: view.style.fontFamily);
+            fontFamilyFallback: view.style.fontFamily,
+          );
 
     final span = TextSpan(
       text: String.fromCharCode(cell.codePoint!),
@@ -463,8 +471,7 @@ class TerminalPainter extends CustomPainter {
     );
 
     // final tp = textLayoutCache.getOrPerformLayout(span);
-    final tp = textLayoutCacheV2.getOrPerformLayout(
-        span, hashValues(cell.codePoint, attr));
+    tp = textLayoutCache.performAndCacheLayout(span, cellHash);
 
     tp.paint(canvas, Offset(offsetX, offsetY));
   }