提交 2e962594 编写于 作者: O openharmony_ci 提交者: Gitee

!409 多线程模式下字体可能存在渲染花屏问题

Merge pull request !409 from wangtiantian/bug_bitmap_m
......@@ -374,7 +374,7 @@ int16_t GlyphsManager::GetFontWidth(uint32_t unicode)
return node->advance;
}
int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap)
int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode)
{
if (bitmap == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap invalid parameter");
......@@ -385,7 +385,10 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap)
return INVALID_RET_VALUE;
}
const GlyphNode* node = GetGlyphNode(unicode);
const GlyphNode* node = glyphNode;
if (glyphNode == nullptr) {
node = GetGlyphNode(unicode);
}
if (node == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap node not found");
return INVALID_RET_VALUE;
......
......@@ -41,7 +41,7 @@ public:
const GlyphNode* GetGlyphNode(uint32_t unicode);
int8_t GetBitmap(uint32_t unicode, uint8_t* bitmap);
int8_t GetBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode = nullptr);
void SetRamBuffer(uintptr_t ramAddr);
......
......@@ -215,9 +215,9 @@ uint32_t UIFontBitmap::GetRamUsedLen(uint32_t textManagerRamUsed, uint32_t langF
return dynamicFontRamUsed_ + textManagerRamUsed + bitmapRamUsed_ + langFontRamUsed;
}
int8_t UIFontBitmap::GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap)
int8_t UIFontBitmap::GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode)
{
return dynamicFont_.GetBitmap(unicode, bitmap);
return dynamicFont_.GetBitmap(unicode, bitmap, glyphNode);
}
uint8_t* UIFontBitmap::GetCacheBitmap(uint8_t fontId, uint32_t unicode)
......@@ -262,6 +262,9 @@ int16_t UIFontBitmap::GetDynamicFontWidth(uint32_t unicode, uint8_t fontId)
uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId)
{
if (bitmapCache_ == nullptr) {
return nullptr;
}
if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) {
GRAPHIC_LOGE("UIFontBitmap::GetWidthInFontId fontId and unicode not match");
return nullptr;
......@@ -269,26 +272,24 @@ uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint
if (fontId != GetBaseFontId()) {
SetCurrentFontId(fontId);
}
if (bitmapCache_ == nullptr) {
int8_t ret = GetGlyphNode(unicode, glyphNode);
while ((ret == RET_VALUE_OK) && (glyphNode.reserve != fontId)) {
SetCurrentFontId(fontId);
ret = GetGlyphNode(unicode, glyphNode);
}
if (ret != RET_VALUE_OK) {
return nullptr;
}
uint8_t* bitmap = bitmapCache_->GetBitmap(GetBaseFontId(), unicode);
uint8_t* bitmap = bitmapCache_->GetBitmap(fontId, unicode);
if (bitmap != nullptr) {
GetGlyphNode(unicode, glyphNode);
return bitmap;
}
int8_t ret = GetGlyphNode(unicode, glyphNode);
if (ret != RET_VALUE_OK) {
return nullptr;
}
if (glyphNode.kernOff <= glyphNode.dataOff) {
return nullptr;
}
uint32_t bitmapSize = glyphNode.kernOff - glyphNode.dataOff;
bitmap = bitmapCache_->GetSpace(GetBaseFontId(), unicode, bitmapSize);
ret = dynamicFont_.GetBitmap(unicode, bitmap);
bitmap = bitmapCache_->GetSpace(fontId, unicode, bitmapSize);
ret = dynamicFont_.GetBitmap(unicode, bitmap, &glyphNode);
if (ret == RET_VALUE_OK) {
return bitmap;
}
......
......@@ -47,7 +47,7 @@ protected:
uint32_t GetBitmapRamUsed();
uint32_t GetDynamicFontRamUsed();
uint32_t GetRamUsedLen(uint32_t textManagerRamUsed, uint32_t langFontRamUsed);
int8_t GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap);
int8_t GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode = nullptr);
uint8_t* GetCacheBitmap(uint8_t fontId, uint32_t unicode);
uint8_t* GetCacheSpace(uint8_t fontId, uint32_t unicode, uint32_t size);
void PutCacheSpace(uint8_t* addr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册