JBR-7020 Reorder LCD glyph cache freeing and validation

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.

(cherry picked from commit 891a9c6c52)
This commit is contained in:
Nikita Gubarkov
2024-04-23 15:51:23 +02:00
committed by jbrbot
parent 09e82dcb66
commit e989b902b1
2 changed files with 5 additions and 36 deletions

View File

@@ -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

View File

@@ -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;
}