From 9a275a325b025f1978932467631f2e27d34d0aa8 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 11 May 2026 16:43:16 +0800 Subject: [PATCH] =?utf8?q?n9=20=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= =?utf8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../BackToCrossShapedTransition.cpp | 4 +- .../transition/BackToHexagonsTransition.cpp | 6 +- .../transition/BackToWaterfallTransition.cpp | 4 +- .../src/transition/CrossShapedTransition.cpp | 4 +- .../services/gui/uikit/sample/sample_ui.h | 4 +- .../ui_test_clock_dial/ui_test_clock_dial.h | 4 +- .../ui_test_lottie/ui_test_trim_path.cpp | 167 ++++++++++++++++++ .../ui_test_lottie/ui_test_trim_path.h | 55 ++++++ .../common/input_device_manager.cpp | 2 +- .../ui/frameworks/core/render_manager.cpp | 2 +- 10 files changed, 232 insertions(+), 20 deletions(-) create mode 100644 code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.cpp create mode 100644 code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.h diff --git a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToCrossShapedTransition.cpp b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToCrossShapedTransition.cpp index 6cc07e37b..f5b47dadf 100644 --- a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToCrossShapedTransition.cpp +++ b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToCrossShapedTransition.cpp @@ -3,9 +3,7 @@ * Description: BackToCrossShapedTransition * Create: 2025-04 */ -#if 0 // 1201patch 为编译过屏蔽 -#include "applist/AppItemView.h" -#endif +#include "applist/include/AppItemView.h" #include "animator/easing_equation.h" #include "common/screen.h" #include "components/root_view.h" diff --git a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp index 3b96ee494..703c76ed7 100644 --- a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp +++ b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp @@ -9,9 +9,7 @@ #include "TransitionManager.h" #include "NativeAbility.h" #include "components/root_view.h" -#if 0 // 1201patch 为编译过屏蔽 -#include "applist/HexagonsDesktopFragment.h" -#endif +#include "applist/include/HexagonsDesktopFragment.h" #include "hal_tick.h" #include "wearable_log.h" #ifdef JS_ENABLE @@ -26,7 +24,6 @@ static const float TARGET_SCALE_END = 1.0f; void BackToHexagonsTransition::OnTransitionStart(UIImageView* current, UIViewGroup* target) { -#if 0 // 1201patch 为编译过屏蔽 current_ = current; target_ = dynamic_cast(TransitionUtils::GetViewAndTransparentizePath(target, UI_HEXAGONS_LIST)); if ((target_ == nullptr) || (current_ == nullptr)) { @@ -75,7 +72,6 @@ void BackToHexagonsTransition::OnTransitionStart(UIImageView* current, UIViewGro float yScale = current->GetHeight() * 1.0f / rect.GetHeight(); tarScaleStart_ = FloatLessEqual(xScale, yScale) ? xScale : yScale; curScaleEnd_ = 1.0f / tarScaleStart_; -#endif } void BackToHexagonsTransition::TransitionAlg(uint32_t time) diff --git a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToWaterfallTransition.cpp b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToWaterfallTransition.cpp index c047df4fd..7907cfc75 100644 --- a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToWaterfallTransition.cpp +++ b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/BackToWaterfallTransition.cpp @@ -9,7 +9,7 @@ #include "TransitionManager.h" #include "NativeAbility.h" #include "components/root_view.h" -// #include "applist/WaterfallDesktopFragment.h" +#include "applist/include/WaterfallDesktopFragment.h" #include "hal_tick.h" #include "wearable_log.h" #ifdef JS_ENABLE @@ -24,7 +24,6 @@ static const float TARGET_SCALE_END = 1.0f; void BackToWaterfallTransition::OnTransitionStart(UIImageView* current, UIViewGroup* target) { -#if 0 // 1201patch 为编译过屏蔽 current_ = current; target_ = dynamic_cast(TransitionUtils::GetViewAndTransparentizePath(target, UI_WATERFALL_LIST)); if ((target_ == nullptr) || (current_ == nullptr)) { @@ -80,7 +79,6 @@ void BackToWaterfallTransition::OnTransitionStart(UIImageView* current, UIViewGr float yScale = current->GetHeight() * 1.0f / rect.GetHeight(); tarScaleStart_ = FloatLessEqual(xScale, yScale) ? xScale : yScale; curScaleEnd_ = 1.0f / tarScaleStart_; -#endif } void BackToWaterfallTransition::TransitionAlg(uint32_t time) diff --git a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/CrossShapedTransition.cpp b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/CrossShapedTransition.cpp index d8244324f..b178b68ad 100644 --- a/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/CrossShapedTransition.cpp +++ b/code/sdk/application/wearable/n9/nativeabilityfwk/src/transition/CrossShapedTransition.cpp @@ -4,9 +4,7 @@ * Create: 2025-04 */ -#if 0 // 1201patch 为编译过屏蔽 -#include "applist/AppItemView.h" -#endif +#include "applist/include/AppItemView.h" #include "animator/easing_equation.h" #include "common/screen.h" #include "components/root_view.h" diff --git a/code/sdk/middleware/services/gui/uikit/sample/sample_ui.h b/code/sdk/middleware/services/gui/uikit/sample/sample_ui.h index 194f1f0dd..22021e94e 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/sample_ui.h +++ b/code/sdk/middleware/services/gui/uikit/sample/sample_ui.h @@ -15,8 +15,8 @@ extern "C" { int SampleUi(void); /* - $)A9&D\ChJv : Ft6/V86(SC@} - $)A2NJ}DZH] : 2NJ}N*SC@}C{3F + 功能描述 : 启动指定用例 + 参数内容 : 参数为用例名称 */ int StartCaseUi(const char* testCaseId); diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h index 52dbc30bc..fd52908ab 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h @@ -65,7 +65,7 @@ public: AppGroupView *InitWatchFacePage(void); AppGroupView *InitHeartRatePage(void); AppGroupView *InitActivityPage(void); - bool OnClick(UIView& view, const ClickEvent& event) override; // Çл»ÌØÐÔ + bool OnClick(UIView& view, const ClickEvent& event) override; // 切换特性 AppGroupView *InitCompassPage(void); void AnimatorStart(int pageIndex); void AnimatorStop(void); @@ -93,7 +93,7 @@ private: UICrossView *mainSwipeGroup{nullptr}; SwipeListener *listener{nullptr}; CardSwipe* callback{nullptr}; - UILabelButton* controlButton {nullptr}; // Çл»°´Å¥ + UILabelButton* controlButton {nullptr}; // 切换按钮 bool HorizontalViewInit(void); void VerticalViewInit(void); void VertViewLoad(void); diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.cpp new file mode 100644 index 000000000..0a8f938d1 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025. All rights reserved. + * Description: Trim path Test + * Author: Hisi Graphic Team + * Created: 2025-6 + */ + +#include "ui_test_trim_path.h" +#include "lottie/lott_trim_path.h" +#include "draw/hw_draw_utils.h" +#include "engines/gfx/lite_m_gfx_engine.h" +#include "gfx_utils/mem_check.h" + +namespace OHOS { +static const int32_t TRIM_RANGE_MIN = 0; +static const int32_t TRIM_RANGE_MAX = 100; +static const int16_t SLIDER_WIDTH = 130; +static const int16_t SLIDER_HEIGHT = 30; +static const int16_t SLIDER_VALID_HEIGHT = 4; +static const int16_t KNOB_WIDTH = 8; + +void UITestTrimPath::InitPath() +{ + Path sectorPath = {0}; + ArcInfo arcInfo = {{100, 150}, {0, 0}, 100, 0, 90, nullptr}; // 100, 15, 90: arc info paramters + if (!HWDrawUtils::GetInstance()->ObtainSectorPath(arcInfo, sectorPath.cmdNum, sectorPath.cmds, + sectorPath.dataNum, sectorPath.data)) { + GRAPHIC_LOGE("alloc data failed"); + return; + } + + Path cirlePath = {0}; + arcInfo = {{270, 80}, {0, 0}, 50, 0, 0, nullptr}; // 270, 80, 50: arc info paramters + if (!HWDrawUtils::GetInstance()->ObtainCirclePath(arcInfo, cirlePath.cmdNum, cirlePath.cmds, + cirlePath.dataNum, cirlePath.data)) { + GRAPHIC_LOGE("alloc data failed"); + HWDrawUtils::GetInstance()->FreeBufferForPath(§orPath); + return; + } + + path_.cmdNum = sectorPath.cmdNum + cirlePath.cmdNum; + path_.dataNum = sectorPath.dataNum + cirlePath.dataNum; + const uint8_t fSize = sizeof(float); + HWDrawUtils::GetInstance()->AllocBufferForPath(&path_, path_.cmdNum, path_.dataNum); + memcpy_s(path_.cmds, path_.cmdNum, sectorPath.cmds, sectorPath.cmdNum); + memcpy_s(path_.cmds + sectorPath.cmdNum, cirlePath.cmdNum, cirlePath.cmds, cirlePath.cmdNum); + memcpy_s(path_.data, path_.dataNum * fSize, sectorPath.data, sectorPath.dataNum * fSize); + memcpy_s(path_.data + sectorPath.dataNum, cirlePath.dataNum * fSize, cirlePath.data, cirlePath.dataNum * fSize); + HWDrawUtils::GetInstance()->FreeBufferForPath(§orPath); + HWDrawUtils::GetInstance()->FreeBufferForPath(&cirlePath); + + paint_.SetStyle(Paint::PaintStyle::STROKE_STYLE); + paint_.SetStrokeColor(Color::Green()); + paint_.SetStrokeWidth(5); // 5: stroke width + canvas_->BeginPath(paint_); + canvas_->SetPathData(path_.cmdNum, path_.cmds, path_.dataNum, path_.data); + canvas_->DrawPath(); +} + +void UITestTrimPath::InitSlider(UISlider*& slider, int16_t x, int16_t y) +{ + slider = new UISlider(); + if (slider == nullptr) { + GRAPHIC_LOGE("new UISlider failed\n"); + return; + } + slider->SetPosition(x, y, SLIDER_WIDTH, SLIDER_HEIGHT); + slider->SetRange(TRIM_RANGE_MIN, TRIM_RANGE_MAX); + slider->SetValidHeight(SLIDER_VALID_HEIGHT); + slider->SetValidWidth(SLIDER_WIDTH - 10); // 10, reserve width + slider->SetKnobWidth(KNOB_WIDTH); + slider->SetSliderRadius(5, 5); // 5:background radius, 5:foreground radius + slider->SetKnobStyle(STYLE_BACKGROUND_COLOR, Color::Yellow().full); + slider->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, Color::White().full); + slider->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 90); // 90: opa + slider->SetDirection(UISlider::Direction::DIR_LEFT_TO_RIGHT); + slider->SetSliderEventListener(this); + container_->Add(slider); +} + +void UITestTrimPath::InitLabel(UILabel*& label, const Rect& rect, const char* str) +{ + label = new UILabel(); + if (label == nullptr) { + GRAPHIC_LOGE("new UILabel failed\n"); + return; + } + label->SetPosition(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetText(str); + container_->Add(label); +} + +void UITestTrimPath::SetUp() +{ + MemCheck::GetInstance()->DumpMemInfo(); + if (container_ != nullptr) { + return; + } + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + + canvas_ = new UICanvasExt(); + canvas_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), 250); // 250: canvas height + canvas_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + container_->Add(canvas_); + + InitLabel(startLabel_, Rect(20, 280, 70, 310), "Start:"); // 20, 280, 70, 310: coordinate + InitSlider(startSlider_, 70, 280); // 70, 280: coordinate + + InitLabel(endLabel_, Rect(220, 280, 270, 310), "End:"); // 220, 280, 270, 310: coordinate + InitSlider(endSlider_, 270, 280); // 260, 280: coordinate + endSlider_->SetValue(TRIM_RANGE_MAX); + + InitLabel(offsetLabel_, Rect(110, 330, 170, 360), "Offset:"); // 110, 330, 170, 360: coordinate + InitSlider(offsetSlider_, 170, 330); // 180, 330: coordinate + + InitLabel(parallelLabel_, Rect(200, 380, 260, 440), "Parallel:"); // 200, 380, 260, 440: coordinate + parallelCheckBox_ = new UICheckBox(); + parallelCheckBox_->SetPosition(260, 380, 50, 50); // 260, 380, 50, 50: coordinate + parallelCheckBox_->SetState(UICheckBox::UICheckBoxState::UNSELECTED); + parallelCheckBox_->SetOnChangeListener(this); + container_->Add(parallelCheckBox_); + + InitPath(); +} + +void UITestTrimPath::TearDown() +{ + UIViewGroup::RemoveAndDeleteAllRecursively(container_); + HWDrawUtils::GetInstance()->FreeBufferForPath(&path_); + lottTrimPath_.ClearPath(); + MemCheck::GetInstance()->DumpMemInfo(); +} + +void UITestTrimPath::TrimPath() +{ + canvas_->Clear(); + canvas_->BeginPath(paint_); + lottTrimPath_.SetPath(path_); + Path trimedPath = lottTrimPath_.TrimPath(startValue_, endValue_, offsetValue_, isParallel_); + // sync because trimed path is drawing and needs to be updated + LiteMGfxEngine::GetInstance()->SyncHwDraw(); + canvas_->SetPathData(trimedPath.cmdNum, trimedPath.cmds, trimedPath.dataNum, trimedPath.data); + canvas_->DrawPath(); +} + +bool UITestTrimPath::OnChange(UICheckBox::UICheckBoxState state) +{ + isParallel_ = (state == UICheckBox::UICheckBoxState::SELECTED); + TrimPath(); + return true; +} + +void UITestTrimPath::OnChange(int32_t value) +{ + startValue_ = startSlider_->GetValue() * 1.0f / TRIM_RANGE_MAX; + endValue_ = endSlider_->GetValue() * 1.0f / TRIM_RANGE_MAX; + offsetValue_ = offsetSlider_->GetValue() * 1.0f / TRIM_RANGE_MAX; + TrimPath(); +} + +const UIView* UITestTrimPath::GetTestView() +{ + return container_; +} +} \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.h new file mode 100644 index 000000000..17aa7c76c --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_lottie/ui_test_trim_path.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025. All rights reserved. + * Description: Lottie Test + * Author: Hisi Graphic Team + * Created: 2025-6 + */ + +#ifndef UI_TEST_TRIM_PATH_H +#define UI_TEST_TRIM_PATH_H + +#include "ui_test.h" +#include "components/ui_canvas_ext.h" +#include "components/ui_label.h" +#include "components/ui_slider.h" +#include "components/ui_checkbox.h" +#include "lottie/lott_trim_path.h" + +namespace OHOS { +class UITestTrimPath : public UITest, public UISlider::UISliderEventListener, public UICheckBox::OnChangeListener { +public: + void SetUp() override; + void TearDown() override; + const UIView* GetTestView() override; + void OnChange(int32_t value) override; + bool OnChange(UICheckBox::UICheckBoxState state) override; + +private: + void InitPath(); + void TrimPath(); + void InitSlider(UISlider*& slider, int16_t x, int16_t y); + void InitLabel(UILabel*& label, const Rect& position, const char* str); + UILabel* startLabel_{nullptr}; + UISlider* startSlider_{nullptr}; + float startValue_{0.0f}; + + UILabel* endLabel_{nullptr}; + UISlider* endSlider_{nullptr}; + float endValue_{1.0f}; + + UILabel* offsetLabel_{nullptr}; + UISlider* offsetSlider_{nullptr}; + float offsetValue_{0.0f}; + + UILabel* parallelLabel_{nullptr}; + UICheckBox* parallelCheckBox_{nullptr}; + bool isParallel_{false}; + + UIViewGroup* container_ = nullptr; + PaintExt paint_{}; + LottTrimPath lottTrimPath_{}; + Path path_{0}; + UICanvasExt* canvas_{nullptr}; +}; +} +#endif \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/input_device_manager.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/input_device_manager.cpp index 24f68be2c..cebd68381 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/input_device_manager.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/input_device_manager.cpp @@ -30,7 +30,7 @@ InputDeviceManager* InputDeviceManager::GetInstance() void InputDeviceManager::Init() { - SetPeriod(0); + SetPeriod(0); // Input的默认处理周期受RTC/TE刷新周期控制 TaskManager::GetInstance()->Add(this); } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/render_manager.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/render_manager.cpp index 8ea6dd03f..2be30e100 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/render_manager.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/render_manager.cpp @@ -36,7 +36,7 @@ RenderManager& RenderManager::GetInstance() void RenderManager::Init() { - SetPeriod(0); + SetPeriod(0); // 防止波动场景下的Draw Task的遗漏处理 Task::Init(); } -- 2.17.1