NDK C-Api backgroundBlurStyle

Signed-off-by: aryawang <wangcaihui@huawei.com>
Change-Id: I20488fc6e086a7edd9d83ffcc857ab9c5fe917a4
This commit is contained in:
aryawang 2024-05-28 08:25:32 +00:00
parent 58f3ebbdf1
commit 4c2dbe8adf

View File

@ -109,6 +109,8 @@ constexpr int32_t BLUR_STYLE_INDEX = 0;
constexpr int32_t COLOR_MODE_INDEX = 1;
constexpr int32_t ADAPTIVE_COLOR_INDEX = 2;
constexpr int32_t SCALE_INDEX = 3;
constexpr int32_t GRAY_SCALE_START = 4;
constexpr int32_t GRAY_SCALE_END = 5;
constexpr int32_t DECORATION_COLOR_INDEX = 1;
constexpr int32_t DECORATION_STYLE_INDEX = 2;
constexpr int32_t PROGRESS_TYPE_LINEAR = 1;
@ -8067,11 +8069,31 @@ int32_t SetBackgroundBlurStyle(ArkUI_NodeHandle node, const ArkUI_AttributeItem*
if (SCALE_INDEX < actualSize) {
scale = item->value[SCALE_INDEX].f32;
}
uint32_t grayScaleStart = 0;
if (GRAY_SCALE_START < actualSize) {
if (GreatOrEqual(item->value[GRAY_SCALE_START].f32, 0.0f)) {
grayScaleStart = static_cast<uint32_t>(item->value[GRAY_SCALE_START].f32);
} else {
return ERROR_CODE_PARAM_INVALID;
}
}
uint32_t grayScaleEnd = 0;
if (GRAY_SCALE_END < actualSize) {
if (GreatOrEqual(item->value[GRAY_SCALE_END].f32, 0.0f)
&& GreatOrEqual(item->value[GRAY_SCALE_END].f32, item->value[GRAY_SCALE_START].f32)) {
grayScaleEnd = static_cast<uint32_t>(item->value[GRAY_SCALE_END].f32);
} else {
return ERROR_CODE_PARAM_INVALID;
}
}
BlurOption blurOption;
int32_t intArray[NUM_3];
intArray[NUM_0] = blurStyle;
intArray[NUM_1] = colorMode;
intArray[NUM_2] = adaptiveColor;
std::vector<float> greyVector(NUM_2);
greyVector[NUM_0] = grayScaleStart;
greyVector[NUM_1] = grayScaleEnd;
fullImpl->getNodeModifiers()->getCommonModifier()->setBackgroundBlurStyle(
node->uiNodeHandle, intArray, scale, blurOption.grayscale.data(), blurOption.grayscale.size());
return ERROR_CODE_NO_ERROR;