!9858 HMSymbol 适配资源接口的修改,增加动效类型

Merge pull request !9858 from dengyanfang23/master
This commit is contained in:
openharmony_ci 2024-04-10 01:57:13 +00:00 committed by Gitee
commit ec15df631e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 134 additions and 94 deletions

View File

@ -118,6 +118,7 @@ void CopyTextStyleSymbol(const TextStyle& style, SPText::TextStyle& textStyle)
textStyle.symbol.SetAnimationMode(style.symbol.GetAnimationMode());
textStyle.symbol.SetRepeatCount(style.symbol.GetRepeatCount());
textStyle.symbol.SetAminationStart(style.symbol.GetAminationStart());
textStyle.symbol.SetCommonSubType(style.symbol.GetCommonSubType());
for (auto [tag, value] : style.symbol.GetVisualMap()) {
textStyle.fontFeatures.SetFeature(RemoveQuotes(tag), value);
}

View File

@ -35,7 +35,9 @@ static const std::map<uint32_t, Drawing::DrawingEffectStrategy> EFFECT_TYPES = {
{2, Drawing::DrawingEffectStrategy::VARIABLE_COLOR},
{3, Drawing::DrawingEffectStrategy::APPEAR},
{4, Drawing::DrawingEffectStrategy::DISAPPEAR},
{5, Drawing::DrawingEffectStrategy::BOUNCE}};
{5, Drawing::DrawingEffectStrategy::BOUNCE},
{6, Drawing::DrawingEffectStrategy::PULSE},
{7, Drawing::DrawingEffectStrategy::REPLACE_APPEAR}};
enum VisualMode {
VISUAL_MEDIUM = 0,
@ -160,6 +162,16 @@ public:
return visualMap_;
}
void SetCommonSubType(Drawing::DrawingCommonSubType commonSubType)
{
commonSubType_ = commonSubType;
}
Drawing::DrawingCommonSubType GetCommonSubType() const
{
return commonSubType_;
}
private:
std::vector<Drawing::DrawingSColor> colorList_;
Drawing::DrawingSymbolRenderingStrategy renderMode_ = Drawing::DrawingSymbolRenderingStrategy::SINGLE;
@ -172,6 +184,7 @@ private:
int repeatCount_ = 1;
bool aminationStart_ = true;
std::map<std::string, int> visualMap_;
Drawing::DrawingCommonSubType commonSubType_ = Drawing::DrawingCommonSubType::UP;
};
}
}

View File

@ -32,7 +32,9 @@ enum SymbolAnimationEffectStrategy {
SYMBOL_VARIABLE_COLOR = 2,
SYMBOL_APPEAR = 3,
SYMBOL_DISAPPEAR = 4,
SYMBOL_BOUNCE = 5
SYMBOL_BOUNCE = 5,
SYMBOL_PULSE = 6,
SYMBOL_REPLACE_APPEAR = 7
};
using SymbolNode = struct SymbolNode {
@ -51,6 +53,7 @@ using SymbolAnimationConfig = struct SymbolAnimationConfig {
uint16_t animationMode = 0;
int repeatCount = 1;
bool aminationStart = false;
Drawing::DrawingCommonSubType commonSubType = Drawing::DrawingCommonSubType::UP;
};
}
}

View File

@ -282,6 +282,7 @@ void ParagraphBuilderImpl::CopyTextStylePaint(const TextStyle& txt, skia::textla
paint.symbol.SetAnimationMode(txt.symbol.GetAnimationMode());
paint.symbol.SetRepeatCount(txt.symbol.GetRepeatCount());
paint.symbol.SetAminationStart(txt.symbol.GetAminationStart());
paint.symbol.SetCommonSubType(txt.symbol.GetCommonSubType());
skStyle.setForegroundPaintID(AllocPaintID(paint));
}
}

View File

@ -25,7 +25,9 @@ static const std::map<RSEffectStrategy, TextEngine::SymbolAnimationEffectStrateg
{RSEffectStrategy::VARIABLE_COLOR, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_VARIABLE_COLOR},
{RSEffectStrategy::APPEAR, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_APPEAR},
{RSEffectStrategy::DISAPPEAR, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_DISAPPEAR},
{RSEffectStrategy::BOUNCE, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_BOUNCE}};
{RSEffectStrategy::BOUNCE, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_BOUNCE},
{RSEffectStrategy::PULSE, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_PULSE},
{RSEffectStrategy::REPLACE_APPEAR, TextEngine::SymbolAnimationEffectStrategy::SYMBOL_REPLACE_APPEAR}};
static void MergePath(RSPath& multPath, const std::vector<RSGroupInfo>& groupInfos, std::vector<RSPath>& pathLayers)
{
@ -136,6 +138,7 @@ bool SymbolNodeBuild::DecomposeSymbolAndDraw()
symbolAnimationConfig->animationMode = animationMode_;
symbolAnimationConfig->aminationStart = aminationStart_;
symbolAnimationConfig->symbolSpanId = symblSpanId_;
symbolAnimationConfig->commonSubType = commonSubType_;
animationFunc_(symbolAnimationConfig);
return true;
}

View File

@ -71,6 +71,11 @@ public:
aminationStart_ = aminationStart;
}
void SetCommonSubType(Drawing::DrawingCommonSubType commonSubType)
{
commonSubType_ = commonSubType;
}
private:
RSAnimationSetting animationSetting_;
RSHMSymbolData symbolData_;
@ -80,6 +85,7 @@ private:
uint16_t animationMode_ = 0;
int repeatCount_ = 1;
bool aminationStart_ = false;
Drawing::DrawingCommonSubType commonSubType_ = Drawing::DrawingCommonSubType::UP;
std::function<bool(const std::shared_ptr<OHOS::Rosen::TextEngine::SymbolAnimationConfig>&)>
animationFunc_ = nullptr;

View File

@ -26,20 +26,20 @@ RSSymbolLayers HMSymbolRun::GetSymbolLayers(const uint16_t& glyphId, const HMSym
RSSymbolLayers symbolInfo;
symbolInfo.symbolGlyphId = glyphId;
uint32_t symbolId = static_cast<uint32_t>(glyphId);
std::shared_ptr<RSSymbolLayersGroups> symbolInfoOrign = RSHmSymbolConfig_OHOS::GetSymbolLayersGroups(symbolId);
if (symbolInfoOrign == nullptr || symbolInfoOrign->symbolGlyphId == 0) {
RSSymbolLayersGroups symbolInfoOrign = RSHmSymbolConfig_OHOS::GetSymbolLayersGroups(symbolId);
if (symbolInfoOrign.renderModeGroups.empty() || symbolInfoOrign.symbolGlyphId == 0) {
return symbolInfo;
}
RSSymbolRenderingStrategy renderMode = symbolText.GetRenderMode();
if (symbolInfoOrign->renderModeGroups.find(renderMode) == symbolInfoOrign->renderModeGroups.end()) {
if (symbolInfoOrign.renderModeGroups.find(renderMode) == symbolInfoOrign.renderModeGroups.end()) {
renderMode = RSSymbolRenderingStrategy::SINGLE;
}
symbolInfo.layers = symbolInfoOrign->layers;
if (symbolInfoOrign->renderModeGroups.find(renderMode) != symbolInfoOrign->renderModeGroups.end()) {
symbolInfo.renderGroups = symbolInfoOrign->renderModeGroups[renderMode];
symbolInfo.symbolGlyphId = symbolInfoOrign->symbolGlyphId;
symbolInfo.layers = symbolInfoOrign.layers;
if (symbolInfoOrign.renderModeGroups.find(renderMode) != symbolInfoOrign.renderModeGroups.end()) {
symbolInfo.renderGroups = symbolInfoOrign.renderModeGroups[renderMode];
symbolInfo.symbolGlyphId = symbolInfoOrign.symbolGlyphId;
}
std::vector<RSSColor> colorList = symbolText.GetRenderColor();
@ -161,6 +161,7 @@ bool HMSymbolRun::SymbolAnimation(const RSHMSymbolData symbol, const uint32_t gl
symbolNode.SetAnimationMode(animationMode);
symbolNode.SetRepeatCount(symbolTxt.GetRepeatCount());
symbolNode.SetAminationStart(symbolTxt.GetAminationStart());
symbolNode.SetCommonSubType(symbolTxt.GetCommonSubType());
if (!symbolNode.DecomposeSymbolAndDraw()) {
return false;
}
@ -183,10 +184,7 @@ bool HMSymbolRun::GetAnimationGroups(const uint32_t glyphid, const RSEffectStrat
RSAnimationSetting& animationOut)
{
auto symbolInfoOrigin = RSHmSymbolConfig_OHOS::GetSymbolLayersGroups(glyphid);
if (symbolInfoOrigin == nullptr) {
return false;
}
std::vector<RSAnimationSetting> animationSettings = symbolInfoOrigin->animationSettings;
std::vector<RSAnimationSetting> animationSettings = symbolInfoOrigin.animationSettings;
RSAnimationType animationType = static_cast<RSAnimationType>(effectStrategy);
for (size_t i = 0; i < animationSettings.size(); i++) {

View File

@ -96,6 +96,16 @@ public:
{
return aminationStart_;
}
void SetCommonSubType(Drawing::DrawingCommonSubType commonSubType)
{
commonSubType_ = commonSubType;
}
Drawing::DrawingCommonSubType GetCommonSubType() const
{
return commonSubType_;
}
private:
std::vector<RSSColor> colorList_;
@ -104,6 +114,7 @@ private:
uint16_t animationMode_ = 0;
int repeatCount_ = 1;
bool aminationStart_ = false;
Drawing::DrawingCommonSubType commonSubType_ = Drawing::DrawingCommonSubType::UP;
};
}
}

View File

@ -34,13 +34,23 @@ enum DrawingAnimationType {
VARIABLE_COLOR_TYPE = 2,
APPEAR_TYPE = 3,
DISAPPEAR_TYPE = 4,
BOUNCE_TYPE = 5
BOUNCE_TYPE = 5,
PULSE_TYPE = 6,
REPLACE_APPEAR_TYPE = 7,
REPLACE_DISAPPEAR_TYPE
};
enum DrawingCurveType {
INVALID_CURVE_TYPE = 0,
SPRING = 1,
LINEAR = 2,
FRICTION = 3,
SHARP = 4,
};
enum DrawingCommonSubType {
UP = 0,
DOWN = 1,
};
struct DrawingPiecewiseParameter {
@ -52,7 +62,8 @@ struct DrawingPiecewiseParameter {
};
struct DrawingAnimationPara {
uint32_t animationMode;
uint32_t animationMode = 0; // 0 is default value, is byLayer effect
DrawingCommonSubType commonSubType = DrawingCommonSubType::UP;
std::vector<std::vector<DrawingPiecewiseParameter>> groupParameters;
};
@ -75,7 +86,7 @@ struct DrawingGroupInfo {
struct DrawingGroupSetting {
std::vector<DrawingGroupInfo> groupInfos;
int animationIndex;
int animationIndex = -1; // -1 is default value, the level has no effecet
};
struct DrawingAnimationSetting {
@ -94,7 +105,10 @@ enum DrawingEffectStrategy {
VARIABLE_COLOR = 2,
APPEAR = 3,
DISAPPEAR = 4,
BOUNCE = 5
BOUNCE = 5,
PULSE = 6,
REPLACE_APPEAR = 7,
REPLACE_DISAPPEAR
};
struct DrawingSymbolLayers {

View File

@ -27,10 +27,11 @@ class HmSymbolConfigOhosImpl;
class DRAWING_API HmSymbolConfigOhos {
public:
static std::shared_ptr<DrawingSymbolLayersGroups> GetSymbolLayersGroups(uint32_t glyphId);
static DrawingSymbolLayersGroups GetSymbolLayersGroups(uint32_t glyphId);
static std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode);
static std::vector<std::vector<DrawingPiecewiseParameter>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode = 0,
DrawingCommonSubType commonSubType = DrawingCommonSubType::UP);
};
} // namespace Drawing

View File

@ -21,20 +21,17 @@ namespace OHOS {
namespace Rosen {
namespace Drawing {
std::shared_ptr<DrawingSymbolLayersGroups> SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(uint32_t glyphId)
DrawingSymbolLayersGroups SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(uint32_t glyphId)
{
SymbolLayersGroups* groups = HmSymbolConfig_OHOS::getInstance()->getSymbolLayersGroups(glyphId);
if (!groups) {
return nullptr;
}
SymbolLayersGroups groups = HmSymbolConfig_OHOS::GetInstance()->GetSymbolLayersGroups(glyphId);
std::shared_ptr<DrawingSymbolLayersGroups> drawingGroups = std::make_shared<DrawingSymbolLayersGroups>();
drawingGroups->symbolGlyphId = groups->symbolGlyphId;
drawingGroups->layers = groups->layers;
DrawingSymbolLayersGroups drawingGroups;
drawingGroups.symbolGlyphId = groups.symbolGlyphId;
drawingGroups.layers = groups.layers;
std::vector<DrawingAnimationSetting> drawingSettings;
auto settings = groups->animationSettings;
auto settings = groups.animationSettings;
std::map<DrawingSymbolRenderingStrategy, std::vector<DrawingRenderGroup>> drawingRenderModeGroups;
auto renderModeGroups = groups->renderModeGroups;
auto renderModeGroups = groups.renderModeGroups;
for (size_t i = 0; i < settings.size(); i++) {
drawingSettings.push_back(ConvertToDrawingAnimationSetting(settings.at(i)));
}
@ -51,8 +48,8 @@ std::shared_ptr<DrawingSymbolLayersGroups> SkiaHmSymbolConfigOhos::GetSymbolLaye
iter++;
}
drawingGroups->animationSettings = drawingSettings;
drawingGroups->renderModeGroups = drawingRenderModeGroups;
drawingGroups.animationSettings = drawingSettings;
drawingGroups.renderModeGroups = drawingRenderModeGroups;
return drawingGroups;
}
@ -123,20 +120,17 @@ static std::vector<DrawingPiecewiseParameter> ConvertPiecewiseParametersVec(cons
return out;
}
std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> SkiaHmSymbolConfigOhos::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode)
std::vector<std::vector<DrawingPiecewiseParameter>> SkiaHmSymbolConfigOhos::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode, DrawingCommonSubType commonSubType)
{
auto animationType = static_cast<AnimationType>(type);
auto parametersPtr = HmSymbolConfig_OHOS::getInstance()->getGroupParameters(
animationType, groupSum, animationMode);
if (parametersPtr == nullptr) {
return nullptr;
}
auto subType = static_cast<CommonSubType>(commonSubType);
auto parametersPtr = HmSymbolConfig_OHOS::GetInstance()->GetGroupParameters(
animationType, groupSum, animationMode, subType);
std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> parameters =
std::make_shared<std::vector<std::vector<DrawingPiecewiseParameter>>>();
for (auto& paraTmp : (*parametersPtr)) {
parameters->push_back(ConvertPiecewiseParametersVec(paraTmp));
std::vector<std::vector<DrawingPiecewiseParameter>> parameters;
for (auto& paraTmp : parametersPtr) {
parameters.push_back(ConvertPiecewiseParametersVec(paraTmp));
}
return parameters;
}

View File

@ -26,10 +26,11 @@ namespace Drawing {
class SkiaHmSymbolConfigOhos {
public:
static std::shared_ptr<DrawingSymbolLayersGroups> GetSymbolLayersGroups(uint32_t glyphId);
static DrawingSymbolLayersGroups GetSymbolLayersGroups(uint32_t glyphId);
static std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode);
static std::vector<std::vector<DrawingPiecewiseParameter>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode = 0,
DrawingCommonSubType commonSubType = DrawingCommonSubType::UP);
private:
static DrawingAnimationSetting ConvertToDrawingAnimationSetting(AnimationSetting setting);

View File

@ -179,15 +179,15 @@ void SkiaStaticFactory::GetDrawingPointsForTextBlob(const TextBlob* blob, std::v
return SkiaTextBlob::GetDrawingPointsForTextBlob(blob, points);
}
std::shared_ptr<DrawingSymbolLayersGroups> SkiaStaticFactory::GetSymbolLayersGroups(uint32_t glyphId)
DrawingSymbolLayersGroups SkiaStaticFactory::GetSymbolLayersGroups(uint32_t glyphId)
{
return SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(glyphId);
}
std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> SkiaStaticFactory::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode)
std::vector<std::vector<DrawingPiecewiseParameter>> SkiaStaticFactory::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode, DrawingCommonSubType commonSubType)
{
return SkiaHmSymbolConfigOhos::GetGroupParameters(type, groupSum, animationMode);
return SkiaHmSymbolConfigOhos::GetGroupParameters(type, groupSum, animationMode, commonSubType);
}
FontStyleSet* SkiaStaticFactory::CreateEmpty()

View File

@ -74,9 +74,10 @@ public:
static void GetDrawingGlyphIDforTextBlob(const TextBlob* blob, std::vector<uint16_t>& glyphIds);
static Path GetDrawingPathforTextBlob(uint16_t glyphId, const TextBlob* blob);
static void GetDrawingPointsForTextBlob(const TextBlob* blob, std::vector<Point>& points);
static std::shared_ptr<DrawingSymbolLayersGroups> GetSymbolLayersGroups(uint32_t glyphId);
static std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode);
static DrawingSymbolLayersGroups GetSymbolLayersGroups(uint32_t glyphId);
static std::vector<std::vector<DrawingPiecewiseParameter>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode = 0,
DrawingCommonSubType commonSubType = DrawingCommonSubType::UP);
static FontStyleSet* CreateEmpty();
};
} // namespace Drawing

View File

@ -299,7 +299,7 @@ void StaticFactory::GetDrawingPointsForTextBlob(const TextBlob* blob, std::vecto
return EngineStaticFactory::GetDrawingPointsForTextBlob(blob, points);
}
std::shared_ptr<DrawingSymbolLayersGroups> StaticFactory::GetSymbolLayersGroups(uint32_t glyphId)
DrawingSymbolLayersGroups StaticFactory::GetSymbolLayersGroups(uint32_t glyphId)
{
#ifdef ENABLE_DDGR_OPTIMIZE
if (SystemProperties::GetGpuApiType() == GpuApiType::DDGR) {
@ -309,10 +309,10 @@ std::shared_ptr<DrawingSymbolLayersGroups> StaticFactory::GetSymbolLayersGroups(
return EngineStaticFactory::GetSymbolLayersGroups(glyphId);
}
std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> StaticFactory::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode)
std::vector<std::vector<DrawingPiecewiseParameter>> StaticFactory::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode, DrawingCommonSubType commonSubType)
{
return EngineStaticFactory::GetGroupParameters(type, groupSum, animationMode);
return EngineStaticFactory::GetGroupParameters(type, groupSum, animationMode, commonSubType);
}
FontStyleSet* StaticFactory::CreateEmpty()

View File

@ -74,9 +74,10 @@ public:
static void GetDrawingGlyphIDforTextBlob(const TextBlob* blob, std::vector<uint16_t>& glyphIds);
static Path GetDrawingPathforTextBlob(uint16_t glyphId, const TextBlob* blob);
static void GetDrawingPointsForTextBlob(const TextBlob* blob, std::vector<Point>& points);
static std::shared_ptr<DrawingSymbolLayersGroups> GetSymbolLayersGroups(uint32_t glyphId);
static std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode);
static DrawingSymbolLayersGroups GetSymbolLayersGroups(uint32_t glyphId);
static std::vector<std::vector<DrawingPiecewiseParameter>> GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode = 0,
DrawingCommonSubType commonSubType = DrawingCommonSubType::UP);
static FontStyleSet* CreateEmpty();
};
} // namespace Drawing

View File

@ -20,15 +20,15 @@
namespace OHOS {
namespace Rosen {
namespace Drawing {
std::shared_ptr<DrawingSymbolLayersGroups> HmSymbolConfigOhos::GetSymbolLayersGroups(uint32_t glyphId)
DrawingSymbolLayersGroups HmSymbolConfigOhos::GetSymbolLayersGroups(uint32_t glyphId)
{
return StaticFactory::GetSymbolLayersGroups(glyphId);
}
std::shared_ptr<std::vector<std::vector<DrawingPiecewiseParameter>>> HmSymbolConfigOhos::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode)
std::vector<std::vector<DrawingPiecewiseParameter>> HmSymbolConfigOhos::GetGroupParameters(
DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode, DrawingCommonSubType commonSubType)
{
return StaticFactory::GetGroupParameters(type, groupSum, animationMode);
return StaticFactory::GetGroupParameters(type, groupSum, animationMode, commonSubType);
}
} // namespace Drawing

View File

@ -58,7 +58,7 @@ void CreateAnimationTimingCurve(OHOS::Rosen::Drawing::DrawingCurveType type, std
}
bool GetAnimationGroupParameters(const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig,
std::shared_ptr<std::vector<std::vector<Drawing::DrawingPiecewiseParameter>>>& parameters)
std::vector<std::vector<Drawing::DrawingPiecewiseParameter>>& parameters)
{
// count animation levels
int animationLevelNum = -1;
@ -79,7 +79,7 @@ bool GetAnimationGroupParameters(const std::shared_ptr<TextEngine::SymbolAnimati
parameters = Drawing::HmSymbolConfigOhos::GetGroupParameters(
Drawing::DrawingAnimationType(symbolAnimationConfig->effectStrategy), uint16_t(animationLevelNum),
uint16_t(animationMode));
if (parameters == nullptr) {
if (parameters.empty()) {
return false;
}
return true;
@ -184,7 +184,7 @@ bool RSSymbolAnimation::SetPublicAnimation(
Vector4f offsets = CalculateOffset(symbolFirstNode.symbolData.path_, symbolFirstNode.nodeBoundary[0],
symbolFirstNode.nodeBoundary[1]); // index 0 offsetX and 1 offsetY of layout
std::shared_ptr<std::vector<std::vector<Drawing::DrawingPiecewiseParameter>>> parameters = nullptr;
std::vector<std::vector<Drawing::DrawingPiecewiseParameter>> parameters;
bool res = GetAnimationGroupParameters(symbolAnimationConfig, parameters);
for (uint32_t n = 0; n < nodeNum; n++) {
@ -209,11 +209,11 @@ bool RSSymbolAnimation::SetPublicAnimation(
continue;
}
if (parameters->size() <= symbolNode.animationIndex || parameters->at(symbolNode.animationIndex).empty()) {
if (parameters.size() <= symbolNode.animationIndex || parameters[symbolNode.animationIndex].empty()) {
ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__);
continue;
}
auto oneGroupParas = (*parameters)[int(symbolNode.animationIndex)];
auto oneGroupParas = parameters[int(symbolNode.animationIndex)];
if (oneGroupParas.empty()) {
ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__);
continue;
@ -360,11 +360,11 @@ bool RSSymbolAnimation::GetScaleUnitAnimationParas(
{
// AnimationType, Animation groups, animation_mode; animation_mode is 1 when Animation groups is 1
auto scaleParas = Drawing::HmSymbolConfigOhos::GetGroupParameters(Drawing::SCALE_TYPE, 1, 1);
if (scaleParas == nullptr || scaleParas->empty() || scaleParas->at(UNIT_GROUP).empty()) {
if (scaleParas.empty() || scaleParas[UNIT_GROUP].empty()) {
ROSEN_LOGD("[%{public}s] can not get scaleParas \n", __func__);
return false;
}
scaleUnitParas = (*scaleParas)[UNIT_GROUP][UNIT_PERIOD];
scaleUnitParas = scaleParas[UNIT_GROUP][UNIT_PERIOD];
auto scaleProperties = scaleUnitParas.properties;
if (!ElementInMap(SCALE_PROP_X, scaleProperties) || !ElementInMap(SCALE_PROP_Y, scaleProperties)) {
@ -563,11 +563,11 @@ bool RSSymbolAnimation::GetVariableColorAnimationParas(
{
// AnimationType, Animation groups, animation_mode; the variable color groups is 3 , animation_mode is 1
auto multiGroupParas = Drawing::HmSymbolConfigOhos::GetGroupParameters(Drawing::VARIABLE_COLOR_TYPE, 3, 1);
if (multiGroupParas == nullptr || multiGroupParas->size() <= index || multiGroupParas->at(index).empty()) {
if (multiGroupParas.size() <= index || multiGroupParas[index].empty()) {
ROSEN_LOGD("[%{public}s] can not get multiGroupParas \n", __func__);
return false;
}
auto oneGroupParas = (*multiGroupParas)[index]; // index means the sequence number of node or animation layer
auto oneGroupParas = multiGroupParas[index]; // index means the sequence number of node or animation layer
if (oneGroupParas.empty()) {
return false;
}

View File

@ -27,20 +27,20 @@ RSSymbolLayers HMSymbolRun::GetSymbolLayers(const uint16_t& glyphId, const HMSym
RSSymbolLayers symbolInfo;
symbolInfo.symbolGlyphId = glyphId;
uint32_t symbolId = static_cast<uint32_t>(glyphId);
std::shared_ptr<RSSymbolLayersGroups> symbolInfoOrign = RSHmSymbolConfig_OHOS::GetSymbolLayersGroups(symbolId);
if (symbolInfoOrign == nullptr || symbolInfoOrign->symbolGlyphId == 0) {
RSSymbolLayersGroups symbolInfoOrign = RSHmSymbolConfig_OHOS::GetSymbolLayersGroups(symbolId);
if (symbolInfoOrign.renderModeGroups.empty() || symbolInfoOrign.symbolGlyphId == 0) {
return symbolInfo;
}
RSSymbolRenderingStrategy renderMode = symbolText.GetRenderMode();
if (symbolInfoOrign->renderModeGroups.find(renderMode) == symbolInfoOrign->renderModeGroups.end()) {
if (symbolInfoOrign.renderModeGroups.find(renderMode) == symbolInfoOrign.renderModeGroups.end()) {
renderMode = RSSymbolRenderingStrategy::SINGLE;
}
symbolInfo.layers = symbolInfoOrign->layers;
if (symbolInfoOrign->renderModeGroups.find(renderMode) != symbolInfoOrign->renderModeGroups.end()) {
symbolInfo.renderGroups = symbolInfoOrign->renderModeGroups[renderMode];
symbolInfo.symbolGlyphId = symbolInfoOrign->symbolGlyphId;
symbolInfo.layers = symbolInfoOrign.layers;
if (symbolInfoOrign.renderModeGroups.find(renderMode) != symbolInfoOrign.renderModeGroups.end()) {
symbolInfo.renderGroups = symbolInfoOrign.renderModeGroups[renderMode];
symbolInfo.symbolGlyphId = symbolInfoOrign.symbolGlyphId;
}
std::vector<RSSColor> colorList = symbolText.GetRenderColor();
@ -179,10 +179,7 @@ bool HMSymbolRun::GetAnimationGroups(const uint32_t glyohId, const RSEffectStrat
RSAnimationSetting& animationOut)
{
auto symbolInfoOrigin = RSHmSymbolConfig_OHOS::GetSymbolLayersGroups(glyohId);
if (symbolInfoOrigin == nullptr) {
return false;
}
std::vector<RSAnimationSetting> animationSettings = symbolInfoOrigin->animationSettings;
std::vector<RSAnimationSetting> animationSettings = symbolInfoOrigin.animationSettings;
RSAnimationType animationType = static_cast<RSAnimationType>(effectStrategy);
for (size_t i = 0; i < animationSettings.size(); i++) {

View File

@ -45,15 +45,10 @@ void SkiaHmSymbolConfigOhosTest::TearDown() {}
*/
HWTEST_F(SkiaHmSymbolConfigOhosTest, GetSymbolLayersGroups001, TestSize.Level1)
{
RenderGroup renderGroup;
std::map<SymbolRenderingStrategy, std::vector<RenderGroup>> renderModeGroups {
{ SymbolRenderingStrategy::SINGLE, { renderGroup } }
};
AnimationSetting animationSetting;
SymbolLayersGroups group {1, {}, renderModeGroups, { animationSetting } };
HmSymbolConfig_OHOS::getInstance()->getHmSymbolConfig()->insert({1, group});
auto groups = SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(1);
ASSERT_TRUE(groups != nullptr);
HmSymbolConfig_OHOS::GetInstance()->ParseConfigOfHmSymbol("hm_symbol_config_next.json",
SkString("/system/fonts/"));
auto groups = SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(3); // 3 is an existing GlyphID
ASSERT_TRUE(groups.symbolGlyphId != 0);
}
} // namespace Drawing
} // namespace Rosen