提交 508e7ffd 编写于 作者: O openharmony_ci 提交者: Gitee

!451 字体绘制出现花屏问题

Merge pull request !451 from wangtiantian/bug_m
......@@ -92,15 +92,15 @@ int8_t GlyphsManager::GlyphNodeCacheInit()
return RET_VALUE_OK;
}
GlyphNode* GlyphsManager::GetNodeFromCache(uint32_t unicode)
GlyphNode* GlyphsManager::GetNodeFromCache(uint32_t unicode, uint8_t fontId)
{
GlyphNode* node = nullptr;
uint8_t font = fontId_ & FONT_HASH_MASK;
uint8_t font = fontId & FONT_HASH_MASK;
uint8_t uc = unicode & UNICODE_HASH_MASK;
for (uint8_t i = 0; i < NODE_HASH_NR; i++) {
GlyphNode* p = &((*nodeCache_)[font][uc][i]);
if ((p->unicode == unicode) && (p->reserve == fontId_)) {
if ((p->unicode == unicode) && (p->reserve == fontId)) {
node = p;
break;
}
......@@ -108,12 +108,12 @@ GlyphNode* GlyphsManager::GetNodeFromCache(uint32_t unicode)
return node;
}
GlyphNode* GlyphsManager::GetNodeCacheSpace(uint32_t unicode)
GlyphNode* GlyphsManager::GetNodeCacheSpace(uint32_t unicode, uint8_t fontId)
{
uint8_t font, uc, i;
GlyphNode* node = nullptr;
font = fontId_ & FONT_HASH_MASK;
font = fontId & FONT_HASH_MASK;
uc = unicode & UNICODE_HASH_MASK;
i = (*cacheStatus_)[font][uc];
node = &((*nodeCache_)[font][uc][i]);
......@@ -127,30 +127,39 @@ GlyphNode* GlyphsManager::GetNodeCacheSpace(uint32_t unicode)
return node;
}
GlyphNode* GlyphsManager::GetNodeFromFile(uint32_t unicode)
GlyphNode* GlyphsManager::GetNodeFromFile(uint32_t unicode, uint8_t fontId)
{
uint16_t idx = 0;
uint8_t key;
uint32_t offset;
uint8_t* tmpIndexCache = curIndexCache_;
uint32_t tmpGlyphNodeSectionStart = curGlyphNodeSectionStart_;
while (fontId_ != fontId) {
SetCurrentFontId(fontId);
if (!isFontIdSet_) {
return nullptr;
}
tmpIndexCache = curIndexCache_;
tmpGlyphNodeSectionStart = curGlyphNodeSectionStart_;
}
for (int32_t i = RADIX_SHIFT_START; i >= 0; i -= RADIX_TREE_BITS) {
offset = idx * sizeof(IndexNode);
key = static_cast<uint8_t>((unicode >> static_cast<uint8_t>(i)) & RADIX_TREE_MASK);
offset += key * sizeof(uint16_t);
idx = *(reinterpret_cast<uint16_t*>(curIndexCache_ + offset));
idx = *(reinterpret_cast<uint16_t*>(tmpIndexCache + offset));
if (idx == 0) {
GRAPHIC_LOGE("GlyphsManager::GetNodeFromFile unicode not found");
return nullptr;
}
}
offset = curGlyphNodeSectionStart_ + (idx - 1) * sizeof(GlyphNode);
offset = tmpGlyphNodeSectionStart + (idx - 1) * sizeof(GlyphNode);
int32_t ret = lseek(fp_, offset, SEEK_SET);
if (ret != static_cast<int32_t>(offset)) {
GRAPHIC_LOGE("GlyphsManager::GetNodeFromFile lseek failed");
return nullptr;
}
GlyphNode* node = GetNodeCacheSpace(unicode);
GlyphNode* node = GetNodeCacheSpace(unicode, fontId);
ret = read(fp_, node, sizeof(GlyphNode));
if (ret < 0) {
GRAPHIC_LOGE("GlyphsManager::GetNodeFromFile read failed");
......@@ -325,20 +334,19 @@ const GlyphNode* GlyphsManager::GetGlyphNode(uint32_t unicode)
if (!isFontIdSet_) {
return nullptr;
}
uint8_t fontId = fontId_;
if (curGlyphNode_ != nullptr) {
if ((curGlyphNode_->unicode == unicode) && (curGlyphNode_->reserve == fontId_)) {
if ((curGlyphNode_->unicode == unicode) && (curGlyphNode_->reserve == fontId)) {
return curGlyphNode_;
}
}
GlyphNode* node = GetNodeFromCache(unicode);
GlyphNode* node = GetNodeFromCache(unicode, fontId);
if (node == nullptr) {
node = GetNodeFromFile(unicode);
node = GetNodeFromFile(unicode, fontId);
if (node != nullptr) {
node->reserve = fontId_;
node->reserve = fontId;
}
}
curGlyphNode_ = node;
return node;
}
......@@ -385,19 +393,17 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontI
return INVALID_RET_VALUE;
}
const GlyphNode* node = GetGlyphNode(unicode);
uint32_t tmpBitMapSectionStart = curBitMapSectionStart_;
while ((fontId != 0) && (node != nullptr) && (node->reserve != fontId)) {
SetCurrentFontId(fontId);
node = GetGlyphNode(unicode);
tmpBitMapSectionStart = curBitMapSectionStart_;
}
if (node == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap node not found");
return INVALID_RET_VALUE;
}
if ((fontId != 0) && (fontId_ != fontId)) {
SetCurrentFontId(fontId);
}
uint32_t offset = curBitMapSectionStart_ + node->dataOff;
uint32_t offset = tmpBitMapSectionStart + node->dataOff;
uint32_t size = node->kernOff - node->dataOff;
int32_t ret = lseek(fp_, offset, SEEK_SET);
if (ret != static_cast<int32_t>(offset)) {
......
......@@ -72,9 +72,9 @@ private:
};
int8_t GlyphNodeCacheInit();
GlyphNode* GetNodeFromCache(uint32_t unicode);
GlyphNode* GetNodeCacheSpace(uint32_t unicode);
GlyphNode* GetNodeFromFile(uint32_t unicode);
GlyphNode* GetNodeFromCache(uint32_t unicode, uint8_t fontId);
GlyphNode* GetNodeCacheSpace(uint32_t unicode, uint8_t fontId);
GlyphNode* GetNodeFromFile(uint32_t unicode, uint8_t fontId);
uint32_t AlignUp(uint32_t addr, uint32_t align)
{
return (((addr + (1 << align)) >> align) << align);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册