GlyphLayoutEngine: cleanup, no functional change.
Change-Id: I688d4a5f1c93de10f15bd34045cf342ea03fa984 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2766 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
cdd33d8e61
commit
c0e0ba1fd8
@@ -82,7 +82,7 @@ public:
|
|||||||
static FontCacheEntry* FontCacheEntryFor(const ServerFont& font,
|
static FontCacheEntry* FontCacheEntryFor(const ServerFont& font,
|
||||||
bool forceVector,
|
bool forceVector,
|
||||||
const FontCacheEntry* disallowedEntry,
|
const FontCacheEntry* disallowedEntry,
|
||||||
const char* utf8String, int32 length,
|
uint32 glyphCode,
|
||||||
FontCacheReference& cacheReference,
|
FontCacheReference& cacheReference,
|
||||||
bool needsWriteLock);
|
bool needsWriteLock);
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ private:
|
|||||||
FontCacheReference& cacheReference,
|
FontCacheReference& cacheReference,
|
||||||
FontCacheEntry* entry,
|
FontCacheEntry* entry,
|
||||||
const ServerFont& font, bool needsVector,
|
const ServerFont& font, bool needsVector,
|
||||||
const char* utf8String, int32 length,
|
uint32 glyphCode,
|
||||||
FontCacheReference& fallbackCacheReference,
|
FontCacheReference& fallbackCacheReference,
|
||||||
FontCacheEntry*& fallbackEntry);
|
FontCacheEntry*& fallbackEntry);
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ GlyphLayoutEngine::IsWhiteSpace(uint32 charCode)
|
|||||||
|
|
||||||
inline FontCacheEntry*
|
inline FontCacheEntry*
|
||||||
GlyphLayoutEngine::FontCacheEntryFor(const ServerFont& font, bool forceVector,
|
GlyphLayoutEngine::FontCacheEntryFor(const ServerFont& font, bool forceVector,
|
||||||
const FontCacheEntry* disallowedEntry, const char* utf8String, int32 length,
|
const FontCacheEntry* disallowedEntry, uint32 glyphCode,
|
||||||
FontCacheReference& cacheReference, bool needsWriteLock)
|
FontCacheReference& cacheReference, bool needsWriteLock)
|
||||||
{
|
{
|
||||||
ASSERT(cacheReference.Entry() == NULL);
|
ASSERT(cacheReference.Entry() == NULL);
|
||||||
@@ -192,8 +192,8 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
entry = FontCacheEntryFor(font, consumer.NeedsVector(), NULL,
|
entry = FontCacheEntryFor(font, consumer.NeedsVector(), NULL, 0,
|
||||||
utf8String, length, cacheReference, false);
|
cacheReference, false);
|
||||||
|
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -240,7 +240,7 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
|
|||||||
// we only have to do this switch once for the whole string.
|
// we only have to do this switch once for the whole string.
|
||||||
if (!writeLocked) {
|
if (!writeLocked) {
|
||||||
writeLocked = _WriteLockAndAcquireFallbackEntry(cacheReference,
|
writeLocked = _WriteLockAndAcquireFallbackEntry(cacheReference,
|
||||||
entry, font, consumer.NeedsVector(), utf8String, length,
|
entry, font, consumer.NeedsVector(), charCode,
|
||||||
fallbackCacheReference, fallbackEntry);
|
fallbackCacheReference, fallbackEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,8 +301,8 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
|
|||||||
inline bool
|
inline bool
|
||||||
GlyphLayoutEngine::_WriteLockAndAcquireFallbackEntry(
|
GlyphLayoutEngine::_WriteLockAndAcquireFallbackEntry(
|
||||||
FontCacheReference& cacheReference, FontCacheEntry* entry,
|
FontCacheReference& cacheReference, FontCacheEntry* entry,
|
||||||
const ServerFont& font, bool forceVector, const char* utf8String,
|
const ServerFont& font, bool forceVector, uint32 charCode,
|
||||||
int32 length, FontCacheReference& fallbackCacheReference,
|
FontCacheReference& fallbackCacheReference,
|
||||||
FontCacheEntry*& fallbackEntry)
|
FontCacheEntry*& fallbackEntry)
|
||||||
{
|
{
|
||||||
// We need a fallback font, since potentially, we have to obtain missing
|
// We need a fallback font, since potentially, we have to obtain missing
|
||||||
@@ -331,33 +331,39 @@ GlyphLayoutEngine::_WriteLockAndAcquireFallbackEntry(
|
|||||||
};
|
};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
fallbackEntry = NULL;
|
||||||
|
|
||||||
// Try to get the glyph from the fallback fonts
|
// Try to get the glyph from the fallback fonts
|
||||||
while (fallbacks[i] != NULL) {
|
for (i = 0; fallbacks[i] != NULL; i++) {
|
||||||
if (gFontManager->Lock()) {
|
if (gFontManager->Lock()) {
|
||||||
FontStyle* fallbackStyle = gFontManager->GetStyle(
|
FontStyle* fallbackStyle = gFontManager->GetStyle(fallbacks[i],
|
||||||
fallbacks[i], font.Style());
|
font.Style());
|
||||||
|
|
||||||
if (fallbackStyle != NULL) {
|
if (fallbackStyle == NULL) {
|
||||||
ServerFont fallbackFont(*fallbackStyle, font.Size());
|
|
||||||
gFontManager->Unlock();
|
gFontManager->Unlock();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Force the write-lock on the fallback entry, since we
|
ServerFont fallbackFont(*fallbackStyle, font.Size());
|
||||||
// don't transfer or copy GlyphCache objects from one cache
|
gFontManager->Unlock();
|
||||||
// to the other, but create new glyphs which are stored in
|
|
||||||
// "entry" in any case, which requires the write cache for
|
|
||||||
// sure (used FontEngine of fallbackEntry).
|
|
||||||
fallbackEntry = FontCacheEntryFor(fallbackFont, forceVector,
|
|
||||||
entry, utf8String, length, fallbackCacheReference, true);
|
|
||||||
|
|
||||||
if (fallbackEntry != NULL)
|
// Force the write-lock on the fallback entry, since we
|
||||||
break;
|
// don't transfer or copy GlyphCache objects from one cache
|
||||||
} else
|
// to the other, but create new glyphs which are stored in
|
||||||
gFontManager->Unlock();
|
// "entry" in any case, which requires the write cache for
|
||||||
|
// sure (used FontEngine of fallbackEntry).
|
||||||
|
FontCacheEntry* candidateFallbackEntry = FontCacheEntryFor(
|
||||||
|
fallbackFont, forceVector, entry, charCode,
|
||||||
|
fallbackCacheReference, true);
|
||||||
|
|
||||||
|
// Stop when we find a font that indeed has the glyph we need.
|
||||||
|
if (candidateFallbackEntry != NULL) {
|
||||||
|
fallbackEntry = candidateFallbackEntry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: We don't care if fallbackEntry is still NULL, fetching
|
// NOTE: We don't care if fallbackEntry is still NULL, fetching
|
||||||
// alternate glyphs will simply not work.
|
// alternate glyphs will simply not work.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user