提交 f0b53172 编写于 作者: O openharmony_ci 提交者: Gitee

!562 GlypyManager操作获取bitmap过程加锁保护,不允许中途修改fontId

Merge pull request !562 from benb365/master
......@@ -236,14 +236,15 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId)
{
uint16_t fontIdx = 0;
if (!isFileSet_) {
GRAPHIC_LOGE("GlyphsManager::SetCurrentFontId file not set");
return INVALID_RET_VALUE;
}
if (fontId > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) {
GRAPHIC_LOGE("GlyphsManager::SetCurrentFontId fontId need less than max fontId");
return INVALID_RET_VALUE;
}
GraphicLockGuard guard(lock_);
if (!isFileSet_) {
GRAPHIC_LOGE("GlyphsManager::SetCurrentFontId file not set");
return INVALID_RET_VALUE;
}
if (fontId_ == fontId) {
return RET_VALUE_OK;
}
......@@ -385,6 +386,8 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontI
GRAPHIC_LOGE("GlyphsManager::GetBitmap invalid parameter");
return INVALID_RET_VALUE;
}
GraphicLockGuard guard(lock_);
if (!isFontIdSet_) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap fontId not set");
return INVALID_RET_VALUE;
......@@ -396,6 +399,7 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontI
node = GetGlyphNode(unicode);
tmpBitMapSectionStart = curBitMapSectionStart_;
}
guard.Unlock();
if (node == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap node not found");
return INVALID_RET_VALUE;
......
......@@ -17,6 +17,7 @@
#define GLYPHS_MANAGER_FONT_H
#include "font/ui_font_header.h"
#include "graphic_locker.h"
namespace OHOS {
class GlyphsManager {
......@@ -100,6 +101,7 @@ private:
CacheType* nodeCache_;
CacheState* cacheStatus_;
GraphicMutex lock_;
int32_t fp_;
uint8_t fontId_;
FontHeader* curFontHeader_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册