NDK-CAPI: fix imageAnimator getAttribute problem

Signed-off-by: wangxinqiang007 <wangxinqiang2@huawei.com>
This commit is contained in:
wangxinqiang007 2024-05-25 18:37:38 +08:00
parent f3ce830f66
commit a21c813b16
10 changed files with 37 additions and 19 deletions

View File

@ -254,6 +254,14 @@ int32_t ImageAnimatorModelNG::GetIteration(FrameNode* frameNode)
return pattern->GetIteration();
}
int32_t ImageAnimatorModelNG::GetImagesSize(FrameNode* frameNode)
{
CHECK_NULL_RETURN(frameNode, 0);
auto pattern = AceType::DynamicCast<ImageAnimatorPattern>(frameNode->GetPattern());
CHECK_NULL_RETURN(pattern, 0);
return pattern->GetImagesSize();
}
void ImageAnimatorModelNG::SetOnStart(FrameNode* frameNode, std::function<void()>&& onStart)
{
CHECK_NULL_VOID(frameNode);

View File

@ -51,6 +51,7 @@ public:
static bool IsFixedSize(FrameNode* frameNode);
static int32_t GetFillMode(FrameNode* frameNode);
static int32_t GetIteration(FrameNode* frameNode);
static int32_t GetImagesSize(FrameNode* frameNode);
static void SetOnStart(FrameNode* frameNode, std::function<void()>&& onStart);
static void SetOnPause(FrameNode* frameNode, std::function<void()>&& onPause);
static void SetOnRepeat(FrameNode* frameNode, std::function<void()>&& onRepeat);

View File

@ -136,6 +136,11 @@ public:
return animator_->GetFillMode();
}
int32_t GetImagesSize()
{
return static_cast<int32_t>(images_.size());
}
private:
RefPtr<PictureAnimation<int32_t>> CreatePictureAnimation(int32_t size);
void UpdateEventCallback();

View File

@ -3106,6 +3106,7 @@ struct ArkUIImageAnimatorModifier {
ArkUI_Bool (*getFixedSize)(ArkUINodeHandle node);
ArkUI_Int32 (*getFillMode)(ArkUINodeHandle node);
ArkUI_Int32 (*getIteration)(ArkUINodeHandle node);
ArkUI_Int32 (*getImagesSize)(ArkUINodeHandle node);
};
struct ArkUISideBarContainerModifier {

View File

@ -258,6 +258,13 @@ int32_t GetIteration(ArkUINodeHandle node)
CHECK_NULL_RETURN(frameNode, DEFAULT_ITERATION);
return ImageAnimatorModelNG::GetIteration(frameNode);
}
int32_t GetImagesSize(ArkUINodeHandle node)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, 0);
return ImageAnimatorModelNG::GetImagesSize(frameNode);
}
} // namespace ImageAnimatorModifier
namespace NodeModifier {
@ -284,7 +291,8 @@ const ArkUIImageAnimatorModifier* GetImageAnimatorModifier()
ImageAnimatorModifier::GetState,
ImageAnimatorModifier::GetIsFixedSize,
ImageAnimatorModifier::GetFillMode,
ImageAnimatorModifier::GetIteration
ImageAnimatorModifier::GetIteration,
ImageAnimatorModifier::GetImagesSize
};
return &modifier;

View File

@ -476,8 +476,10 @@ void* GetDrawingColorFilter(ArkUINodeHandle node)
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, nullptr);
auto drawingColorFilter = ImageModelNG::GetDrawingColorFilter(frameNode);
CHECK_NULL_RETURN(drawingColorFilter, nullptr);
auto filterSptr = reinterpret_cast<std::shared_ptr<OHOS::Rosen::Drawing::ColorFilter>*>(
drawingColorFilter->GetDrawingColorFilterSptrAddr());
CHECK_NULL_RETURN(filterSptr, nullptr);
return (*filterSptr).get();
}

View File

@ -34,11 +34,6 @@ struct ArkUI_ImageAnimatorFrameInfo {
std::optional<int32_t> duration;
};
struct ArkUI_ImageFrameStruct {
ArkUI_ImageAnimatorFrameInfo** imageInfos;
int32_t size;
};
#ifdef __cplusplus
};
#endif

View File

@ -220,14 +220,14 @@ void OH_ArkUI_SwiperIndicator_Dispose(ArkUI_SwiperIndicator* indicator)
delete indicator;
}
void OH_ArkUI_SwiperIndicator_SetLeftPosition(ArkUI_SwiperIndicator* indicator, float value)
void OH_ArkUI_SwiperIndicator_SetStartPosition(ArkUI_SwiperIndicator* indicator, float value)
{
CHECK_NULL_VOID(indicator);
indicator->dimLeft.isSet = 1;
indicator->dimLeft.value = value;
}
float OH_ArkUI_SwiperIndicator_GetLeftPosition(ArkUI_SwiperIndicator* indicator)
float OH_ArkUI_SwiperIndicator_GetStartPosition(ArkUI_SwiperIndicator* indicator)
{
CHECK_NULL_RETURN(indicator, 0.0f);
return indicator->dimLeft.value;
@ -246,14 +246,14 @@ float OH_ArkUI_SwiperIndicator_GetTopPosition(ArkUI_SwiperIndicator* indicator)
return indicator->dimTop.value;
}
void OH_ArkUI_SwiperIndicator_SetRightPosition(ArkUI_SwiperIndicator* indicator, float value)
void OH_ArkUI_SwiperIndicator_SetEndPosition(ArkUI_SwiperIndicator* indicator, float value)
{
CHECK_NULL_VOID(indicator);
indicator->dimRight.isSet = 1;
indicator->dimRight.value = value;
}
float OH_ArkUI_SwiperIndicator_GetRightPosition(ArkUI_SwiperIndicator* indicator)
float OH_ArkUI_SwiperIndicator_GetEndPosition(ArkUI_SwiperIndicator* indicator)
{
CHECK_NULL_RETURN(indicator, 0.0f);
return indicator->dimRight.value;

View File

@ -92,7 +92,7 @@ struct ArkUI_AlignmentRuleOption {
float biasVertical;
};
constexpr int BASIC_COMPONENT_NUM = 19;
constexpr int BASIC_COMPONENT_NUM = 20;
#ifdef __cplusplus
};

View File

@ -581,10 +581,7 @@ bool ParseImages(const ArkUI_AttributeItem* item, ArkUIImageFrameInfo* imageInfo
imageInfos[i].unit = GetDefaultUnit(node, UNIT_PX);
imageInfos[i].duration = images[i]->duration.value_or(0);
}
auto imagesPtr = std::make_shared<ArkUI_ImageFrameStruct>();
imagesPtr->size = item->size;
imagesPtr->imageInfos = images;
node->imageFrameInfos = &imagesPtr;
node->imageFrameInfos = images;
return true;
}
@ -11417,12 +11414,13 @@ void ResetImageAnimatorSrc(ArkUI_NodeHandle node)
const ArkUI_AttributeItem* GetImageAnimatorSrc(ArkUI_NodeHandle node)
{
auto imageInfos = reinterpret_cast<std::shared_ptr<ArkUI_ImageFrameStruct>*>(node->imageFrameInfos);
if (!imageInfos) {
if (!node->imageFrameInfos) {
g_attributeItem.size = 0;
} else {
g_attributeItem.size = (*imageInfos)->size;
g_attributeItem.object = (*imageInfos)->imageInfos;
auto* fullImpl = GetFullImpl();
g_attributeItem.size = fullImpl->getNodeModifiers()->getImageAnimatorModifier()->getImagesSize(
node->uiNodeHandle);
g_attributeItem.object = reinterpret_cast<ArkUI_ImageAnimatorFrameInfo**>(node->imageFrameInfos);
}
return &g_attributeItem;
}