diff options
author | Nikita Gubarkov <nikita.gubarkov@jetbrains.com> | 2024-04-23 15:51:23 +0200 |
---|---|---|
committer | Nikita Gubarkov <764610@gmail.com> | 2024-04-25 20:56:51 +0200 |
commit | 54a7172299117b1ba528d4282f6c3fb852c255fe (patch) | |
tree | a4bbd9d2efc195f8ed8e1f23979bc95f8f595df1 | |
parent | 03912794abbb34f84a5bdb3d605ccd738701328a (diff) | |
download | JetBrainsRuntime-54a7172299117b1ba528d4282f6c3fb852c255fe.tar.gz |
JBR-7020 Reorder LCD glyph cache freeing and validationjb17.0.11-b1286
1. As we started committing the command buffer on glyph cache flush, this invalidates the current encoder. We need to `MTLTR_ValidateGlyphCache` after the flush, not before.
2. There's no reason to maintain separate glyph cache invalidation logic for this singe case (which is a no-op in reality), so just free the cache instead.
-rw-r--r-- | src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGlyphCache.m | 31 | ||||
-rw-r--r-- | src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m | 10 |
2 files changed, 5 insertions, 36 deletions
diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGlyphCache.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGlyphCache.m index 7ff7410fabb..4808092dbd4 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGlyphCache.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGlyphCache.m @@ -215,37 +215,6 @@ } return JNI_FALSE; } -/** - * Invalidates all cells in the cache. Note that this method does not - * attempt to compact the cache in any way; it just invalidates any cells - * that already exist. - */ -- (void) invalidate -{ - MTLCacheCellInfo *cellinfo; - - J2dTraceLn(J2D_TRACE_INFO, "MTLGlyphCache.invalidate"); - - if (_cacheInfo == NULL) { - return; - } - - // flush any pending vertices that may be depending on the current - // glyph cache layout - if (_cacheInfo->Flush != NULL) { - _cacheInfo->Flush(_cacheInfo->mtlc); - } - - cellinfo = _cacheInfo->head; - while (cellinfo != NULL) { - if (cellinfo->glyphInfo != NULL) { - // if the cell is occupied, notify the base glyph that its - // cached version for this cache is about to be invalidated - MTLGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo); - } - cellinfo = cellinfo->next; - } -} /** * Invalidates and frees all cells and the cache itself. The "cache" pointer diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m index 3e78ed5a9c9..1aa57e25b89 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m @@ -372,17 +372,17 @@ MTLTR_DrawLCDGlyphViaCache(MTLContext *mtlc, BMTLSDOps *dstOps, DisableColorGlyphPainting(mtlc); } - if (!MTLTR_ValidateGlyphCache(mtlc, dstOps, JNI_TRUE)) { - return JNI_FALSE; - } - if (rgbOrder != lastRGBOrder) { // need to invalidate the cache in this case; see comments // for lastRGBOrder above - [mtlc.glyphCacheLCD invalidate]; + [mtlc.glyphCacheLCD free]; lastRGBOrder = rgbOrder; } + if (!MTLTR_ValidateGlyphCache(mtlc, dstOps, JNI_TRUE)) { + return JNI_FALSE; + } + glyphMode = MODE_USE_CACHE_LCD; } |