You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(directdraw): prevent EDT freeze when scrolling long text
getVisibilityHintsForIndex dominated the EDT during drawString: it tested
each glyph against the clip Path2D (Path2D.contains/rectCrossings) and
recomputed substring widths via stringWidth on every binary-search step —
O(n·log n) plus per-probe allocation for each painted token. Caret-driven
scrollRectToVisible made even line-by-line scrolling of long source hang.
- DirectDrawUtils: probe the clip's Rectangle2D bounds instead of the
Path2D shape (the true clip is re-applied at render time, so bounds is a
safe over-approximation) and use precomputed cumulative advance widths,
making each probe O(1) and allocation-free. Identical indices vs the old
implementation across 400k random cases; ~12x faster on long lines.
- DirectDrawUtils: make getFontInfo thread-safe via a ThreadLocal
SunGraphics2D (was a shared mutable static).
- RenderUtil: fix iprtCopyArea blitting the target onto its own raster,
which smeared scroll-style copies on the snapshot path; stage the source
through a snapshot. Output matches Graphics.copyArea across all deltas.
- LRUDrawConstantPoolCache: drop misleading synchronized on contains and
document the single-threaded encode-path invariant (no behavior change).
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
Copy file name to clipboardExpand all lines: webswing-directdraw/webswing-directdraw-swing/src/main/java/org/webswing/directdraw/util/DirectDrawUtils.java
Copy file name to clipboardExpand all lines: webswing-directdraw/webswing-directdraw-swing/src/main/java/org/webswing/directdraw/util/LRUDrawConstantPoolCache.java
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,14 @@
4
4
5
5
importjava.util.HashMap;
6
6
7
+
/**
8
+
* LRU cache for {@link DrawConstant} entries. NOT thread-safe by design: all access goes through
9
+
* {@code DrawConstantPool.addToCache}, which is only ever called from
10
+
* {@code WebImage.toMessageInternal} on the single (per-{@code DirectDraw}-context) encode path.
11
+
* {@code toMessageInternal} resets the overflow counters and builds one proto by sequential
12
+
* {@code addToCache} calls, so serialized encoding is already a correctness requirement independent
13
+
* of this class. Do not assume any method here is safe to call concurrently.
0 commit comments