From 1f6cb849c6675cfc58bf8864fe12680ad02533b4 Mon Sep 17 00:00:00 2001 From: zhdengc <15223574545@163.com> Date: Tue, 11 May 2021 10:06:12 +0800 Subject: [PATCH] IssueNo:#I3QPHC Description:Singleton adjustment Feature or Bugfix:Feature Binary Source:No --- BUILD.gn | 3 +++ frameworks/animator/animator_manager.cpp | 6 +++++ frameworks/animator/animator_manager.h | 6 +---- frameworks/common/image_decode_ability.cpp | 24 +++++++++++++++++ frameworks/common/input_device_manager.cpp | 6 +++++ frameworks/common/screen.cpp | 6 +++++ frameworks/components/root_view.cpp | 6 +++++ frameworks/core/render_manager.cpp | 6 +++++ frameworks/core/render_manager.h | 6 +---- frameworks/core/task_manager.cpp | 5 ++++ frameworks/dfx/event_injector.cpp | 6 +++++ frameworks/dfx/performance_task.cpp | 25 ++++++++++++++++++ frameworks/dfx/performance_task.h | 6 +---- frameworks/dfx/ui_dump_dom_tree.cpp | 6 +++++ frameworks/dfx/ui_screenshot.cpp | 6 +++++ frameworks/dock/focus_manager.cpp | 6 +++++ frameworks/dock/screen_device_proxy.cpp | 6 +++++ frameworks/dock/screen_device_proxy.h | 6 +---- frameworks/dock/vibrator_manager.cpp | 26 +++++++++++++++++++ frameworks/draw/draw_arc.cpp | 5 ++++ frameworks/draw/draw_arc.h | 6 +---- frameworks/draw/draw_utils.cpp | 6 +++++ frameworks/draw/draw_utils.h | 6 +---- frameworks/font/ui_line_break.cpp | 7 ++++- frameworks/font/ui_line_break.h | 9 +------ frameworks/font/ui_multi_font_manager.cpp | 6 +++++ frameworks/font/ui_multi_font_manager.h | 7 +---- frameworks/font/ui_text_shaping.cpp | 6 +++++ frameworks/font/ui_text_shaping.h | 6 +---- frameworks/imgdecode/cache_manager.cpp | 6 +++++ frameworks/imgdecode/cache_manager.h | 6 +---- frameworks/imgdecode/file_img_decoder.cpp | 6 +++++ frameworks/imgdecode/file_img_decoder.h | 6 +---- frameworks/themes/theme_manager.cpp | 6 +++++ .../innerkits/common/image_decode_ability.h | 6 +---- .../innerkits/common/input_device_manager.h | 6 +---- interfaces/innerkits/common/task_manager.h | 6 +---- interfaces/innerkits/dock/focus_manager.h | 6 +---- interfaces/innerkits/dock/vibrator_manager.h | 6 +---- interfaces/kits/common/screen.h | 6 +---- interfaces/kits/components/root_view.h | 6 +---- interfaces/kits/dfx/event_injector.h | 6 +---- interfaces/kits/dfx/ui_dump_dom_tree.h | 6 +---- interfaces/kits/dfx/ui_screenshot.h | 6 +---- interfaces/kits/themes/theme_manager.h | 6 +---- test/framework/include/ui_test_app.h | 12 ++------- test/framework/src/ui_test_app.cpp | 12 +++++++++ .../qt/simulator/drivers/display/monitor.cpp | 6 +++++ tools/qt/simulator/drivers/display/monitor.h | 6 +---- .../qt/simulator/drivers/indev/key_input.cpp | 6 +++++ tools/qt/simulator/drivers/indev/key_input.h | 6 +---- .../simulator/drivers/indev/mouse_input.cpp | 6 +++++ .../qt/simulator/drivers/indev/mouse_input.h | 6 +---- .../drivers/indev/mousewheel_input.cpp | 6 +++++ .../drivers/indev/mousewheel_input.h | 6 +---- tools/qt/simulator/uitest/UITest.pro | 4 +++ ui.gni | 3 +++ 57 files changed, 261 insertions(+), 145 deletions(-) create mode 100644 frameworks/common/image_decode_ability.cpp create mode 100644 frameworks/dfx/performance_task.cpp create mode 100644 frameworks/dock/vibrator_manager.cpp diff --git a/BUILD.gn b/BUILD.gn index 9873e73..160d4dd 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -61,6 +61,7 @@ shared_library("ui") { "frameworks/animator/easing_equation.cpp", "frameworks/animator/interpolation.cpp", "frameworks/common/graphic_startup.cpp", + "frameworks/common/image_decode_ability.cpp", "frameworks/common/image.cpp", "frameworks/common/input_device_manager.cpp", "frameworks/common/screen.cpp", @@ -108,6 +109,7 @@ shared_library("ui") { "frameworks/default_resource/check_box_res.cpp", "frameworks/dfx/event_injector.cpp", "frameworks/dfx/key_event_injector.cpp", + "frameworks/dfx/performance_task.cpp", "frameworks/dfx/point_event_injector.cpp", "frameworks/dfx/ui_dump_dom_tree.cpp", "frameworks/dfx/ui_screenshot.cpp", @@ -118,6 +120,7 @@ shared_library("ui") { "frameworks/dock/pointer_input_device.cpp", "frameworks/dock/rotate_input_device.cpp", "frameworks/dock/screen_device_proxy.cpp", + "frameworks/dock/vibrator_manager.cpp", "frameworks/dock/virtual_input_device.cpp", "frameworks/draw/draw_arc.cpp", "frameworks/draw/draw_curve.cpp", diff --git a/frameworks/animator/animator_manager.cpp b/frameworks/animator/animator_manager.cpp index 9c168a1..f2af9c2 100644 --- a/frameworks/animator/animator_manager.cpp +++ b/frameworks/animator/animator_manager.cpp @@ -19,6 +19,12 @@ #include "hal_tick.h" namespace OHOS { +AnimatorManager* AnimatorManager::GetInstance() +{ + static AnimatorManager animatorManager; + return &animatorManager; +} + void AnimatorManager::Init() { Task::Init(); diff --git a/frameworks/animator/animator_manager.h b/frameworks/animator/animator_manager.h index 78150d5..a822368 100644 --- a/frameworks/animator/animator_manager.h +++ b/frameworks/animator/animator_manager.h @@ -58,11 +58,7 @@ public: * @since 1.0 * @version 1.0 */ - static AnimatorManager* GetInstance() - { - static AnimatorManager animatorManager; - return &animatorManager; - } + static AnimatorManager* GetInstance(); void Init() override; diff --git a/frameworks/common/image_decode_ability.cpp b/frameworks/common/image_decode_ability.cpp new file mode 100644 index 0000000..912b994 --- /dev/null +++ b/frameworks/common/image_decode_ability.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "common/image_decode_ability.h" + +namespace OHOS { +ImageDecodeAbility& ImageDecodeAbility::GetInstance() +{ + static ImageDecodeAbility instance; + return instance; +} +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/common/input_device_manager.cpp b/frameworks/common/input_device_manager.cpp index abeac0e..5672eb1 100755 --- a/frameworks/common/input_device_manager.cpp +++ b/frameworks/common/input_device_manager.cpp @@ -18,6 +18,12 @@ #include "gfx_utils/graphic_log.h" namespace OHOS { +InputDeviceManager* InputDeviceManager::GetInstance() +{ + static InputDeviceManager instance; + return &instance; +} + void InputDeviceManager::Init() { if (INDEV_READ_PERIOD > 0) { diff --git a/frameworks/common/screen.cpp b/frameworks/common/screen.cpp index b07f9ad..77ab244 100755 --- a/frameworks/common/screen.cpp +++ b/frameworks/common/screen.cpp @@ -20,6 +20,12 @@ #include "gfx_utils/mem_api.h" namespace OHOS { +Screen& Screen::GetInstance() +{ + static Screen instance; + return instance; +} + uint16_t Screen::GetWidth() { return ScreenDeviceProxy::GetInstance()->GetScreenWidth(); diff --git a/frameworks/components/root_view.cpp b/frameworks/components/root_view.cpp index ff04fb5..b0188c1 100755 --- a/frameworks/components/root_view.cpp +++ b/frameworks/components/root_view.cpp @@ -41,6 +41,12 @@ RootView::RootView() #endif } +RootView* RootView::GetInstance() +{ + static RootView instance; + return &instance; +} + #if ENABLE_WINDOW Window* RootView::GetBoundWindow() const { diff --git a/frameworks/core/render_manager.cpp b/frameworks/core/render_manager.cpp index 6e86722..b575f4d 100755 --- a/frameworks/core/render_manager.cpp +++ b/frameworks/core/render_manager.cpp @@ -29,6 +29,12 @@ RenderManager::RenderManager() : fps_(0.f), needResetFPS_(true), onFPSChangedLis RenderManager::~RenderManager() {} +RenderManager& RenderManager::GetInstance() +{ + static RenderManager instance; + return instance; +} + void RenderManager::Init() { Task::Init(); diff --git a/frameworks/core/render_manager.h b/frameworks/core/render_manager.h index 7460bbb..591785e 100755 --- a/frameworks/core/render_manager.h +++ b/frameworks/core/render_manager.h @@ -35,11 +35,7 @@ static constexpr uint16_t MILLISECONDS_PER_SECOND = 1000; class RenderManager : public Task { public: - static RenderManager& GetInstance() - { - static RenderManager instance; - return instance; - } + static RenderManager& GetInstance(); void Init() override; diff --git a/frameworks/core/task_manager.cpp b/frameworks/core/task_manager.cpp index 98ffe05..cede580 100755 --- a/frameworks/core/task_manager.cpp +++ b/frameworks/core/task_manager.cpp @@ -19,6 +19,11 @@ #include "hal_tick.h" namespace OHOS { +TaskManager* TaskManager::GetInstance() +{ + static TaskManager taskManager; + return &taskManager; +} void TaskManager::Add(Task* task) { if (task == nullptr) { diff --git a/frameworks/dfx/event_injector.cpp b/frameworks/dfx/event_injector.cpp index 3579a5e..4f181b2 100755 --- a/frameworks/dfx/event_injector.cpp +++ b/frameworks/dfx/event_injector.cpp @@ -35,6 +35,12 @@ EventInjector::~EventInjector() } } +EventInjector* EventInjector::GetInstance() +{ + static EventInjector instance; + return &instance; +} + bool EventInjector::RegisterEventInjector(EventDataType type) { switch (type) { diff --git a/frameworks/dfx/performance_task.cpp b/frameworks/dfx/performance_task.cpp new file mode 100644 index 0000000..16a6d04 --- /dev/null +++ b/frameworks/dfx/performance_task.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dfx/performance_task.h" +#if ENABLE_DEBUG && ENABLE_DEBUG_PERFORMANCE_TRACE +namespace OHOS { +PerformanceTask* PerformanceTask::GetInstance() +{ + static PerformanceTask instance; + return &instance; +} +} +#endif diff --git a/frameworks/dfx/performance_task.h b/frameworks/dfx/performance_task.h index cbc62aa..7450c1b 100755 --- a/frameworks/dfx/performance_task.h +++ b/frameworks/dfx/performance_task.h @@ -24,11 +24,7 @@ namespace OHOS { class PerformanceTask : public Task { public: - static PerformanceTask* GetInstance() - { - static PerformanceTask instance; - return &instance; - } + static PerformanceTask* GetInstance(); void Init() override { diff --git a/frameworks/dfx/ui_dump_dom_tree.cpp b/frameworks/dfx/ui_dump_dom_tree.cpp index 88cb013..bc5c805 100755 --- a/frameworks/dfx/ui_dump_dom_tree.cpp +++ b/frameworks/dfx/ui_dump_dom_tree.cpp @@ -36,6 +36,12 @@ #endif // ENABLE_DEBUG namespace OHOS { #if ENABLE_DEBUG +UIDumpDomTree* UIDumpDomTree::GetInstance() +{ + static UIDumpDomTree instance; + return &instance; +} + void UIDumpDomTree::AddNameField(UIViewType type, cJSON* usr) const { if (usr == nullptr) { diff --git a/frameworks/dfx/ui_screenshot.cpp b/frameworks/dfx/ui_screenshot.cpp index ee04e81..13d93fc 100755 --- a/frameworks/dfx/ui_screenshot.cpp +++ b/frameworks/dfx/ui_screenshot.cpp @@ -135,6 +135,12 @@ UIScreenshot::~UIScreenshot() } } +UIScreenshot* UIScreenshot::GetInstance() +{ + static UIScreenshot instance; + return &instance; +} + bool UIScreenshot::ScreenshotToFile(const char* path) { if (screenshotListener_ == nullptr) { diff --git a/frameworks/dock/focus_manager.cpp b/frameworks/dock/focus_manager.cpp index 507e332..89bf0a5 100755 --- a/frameworks/dock/focus_manager.cpp +++ b/frameworks/dock/focus_manager.cpp @@ -19,6 +19,12 @@ #include "gfx_utils/graphic_math.h" namespace OHOS { +FocusManager* FocusManager::GetInstance() +{ + static FocusManager instance; + return &instance; +} + bool FocusManager::RequestFocus(UIView* view) { if (view == nullptr || view == focusView_ || !view->IsFocusable() || diff --git a/frameworks/dock/screen_device_proxy.cpp b/frameworks/dock/screen_device_proxy.cpp index 12d16ca..acf5b3d 100755 --- a/frameworks/dock/screen_device_proxy.cpp +++ b/frameworks/dock/screen_device_proxy.cpp @@ -19,6 +19,12 @@ #include "securec.h" namespace OHOS { +ScreenDeviceProxy* ScreenDeviceProxy::GetInstance() +{ + static ScreenDeviceProxy instance; + return &instance; +} + void ScreenDeviceProxy::Flush() {} void ScreenDeviceProxy::OnFlushReady() diff --git a/frameworks/dock/screen_device_proxy.h b/frameworks/dock/screen_device_proxy.h index 0bf3c41..acebea6 100755 --- a/frameworks/dock/screen_device_proxy.h +++ b/frameworks/dock/screen_device_proxy.h @@ -31,11 +31,7 @@ namespace OHOS { /** @brief A display device proxy */ class ScreenDeviceProxy : public HeapBase { public: - static ScreenDeviceProxy* GetInstance() - { - static ScreenDeviceProxy instance; - return &instance; - } + static ScreenDeviceProxy* GetInstance(); void SetDevice(ScreenDevice* device) { diff --git a/frameworks/dock/vibrator_manager.cpp b/frameworks/dock/vibrator_manager.cpp new file mode 100644 index 0000000..21f37da --- /dev/null +++ b/frameworks/dock/vibrator_manager.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dock/vibrator_manager.h" + +#if ENABLE_VIBRATOR +namespace OHOS { +VibratorManager* VibratorManager::GetInstance() +{ + static VibratorManager instance; + return &instance; +} +} // namespace OHOS +#endif diff --git a/frameworks/draw/draw_arc.cpp b/frameworks/draw/draw_arc.cpp index b093472..48dc80d 100755 --- a/frameworks/draw/draw_arc.cpp +++ b/frameworks/draw/draw_arc.cpp @@ -19,6 +19,11 @@ namespace OHOS { #define IS_IN_DEGREERANE(d, s, e) ((s) <= (e)) ? (((d) >= (s)) && ((d) <= (e))) : (((d) >= (s)) || ((d) <= (e))) +DrawArc* DrawArc::GetInstance() +{ + static DrawArc drawArc; + return &drawArc; +} void DrawArc::DrawImg(const Point& imgPos, Rect& area, diff --git a/frameworks/draw/draw_arc.h b/frameworks/draw/draw_arc.h index ce9e302..5223c5f 100755 --- a/frameworks/draw/draw_arc.h +++ b/frameworks/draw/draw_arc.h @@ -35,11 +35,7 @@ struct ArcInfo { class DrawArc : public HeapBase { public: - static DrawArc* GetInstance() - { - static DrawArc drawArc; - return &drawArc; - } + static DrawArc* GetInstance(); void GetDrawRange(int16_t& start, int16_t& end); diff --git a/frameworks/draw/draw_utils.cpp b/frameworks/draw/draw_utils.cpp index 3f2ef3a..a41cb84 100755 --- a/frameworks/draw/draw_utils.cpp +++ b/frameworks/draw/draw_utils.cpp @@ -168,6 +168,12 @@ TriangleEdge::TriangleEdge(int16_t x1, int16_t y1, int16_t x2, int16_t y2) TriangleEdge::~TriangleEdge() {} +DrawUtils* DrawUtils::GetInstance() +{ + static DrawUtils instance; + return &instance; +} + void DrawUtils::DrawColorAreaBySides(const Rect& mask, const ColorType& color, OpacityType opa, diff --git a/frameworks/draw/draw_utils.h b/frameworks/draw/draw_utils.h index adb0286..003e649 100755 --- a/frameworks/draw/draw_utils.h +++ b/frameworks/draw/draw_utils.h @@ -168,11 +168,7 @@ enum { class DrawUtils : public HeapBase { public: - static DrawUtils* GetInstance() - { - static DrawUtils instance; - return &instance; - } + static DrawUtils* GetInstance(); void DrawColorArea(const Rect& area, const Rect& mask, const ColorType& color, OpacityType opa) const; diff --git a/frameworks/font/ui_line_break.cpp b/frameworks/font/ui_line_break.cpp index aa7a3ed..0b54899 100755 --- a/frameworks/font/ui_line_break.cpp +++ b/frameworks/font/ui_line_break.cpp @@ -22,7 +22,6 @@ using namespace U_ICU_NAMESPACE; namespace OHOS { -UILineBreakEngine* UILineBreakEngine::instance_ = nullptr; static void* MemAlloc(const void* context, size_t size) { return UIMalloc(size); @@ -41,6 +40,12 @@ static void* MemRealloc(const void* context, void* mem, size_t size) return UIRealloc(mem, size); } +UILineBreakEngine& UILineBreakEngine::GetInstance() +{ + static UILineBreakEngine instance; + return instance; +} + uint16_t UILineBreakEngine::GetNextBreakPos(UILineBreakProxy& record) { const UChar* str = reinterpret_cast(record.GetStr()); diff --git a/frameworks/font/ui_line_break.h b/frameworks/font/ui_line_break.h index 60ecdcd..f896afa 100755 --- a/frameworks/font/ui_line_break.h +++ b/frameworks/font/ui_line_break.h @@ -40,13 +40,7 @@ public: * @since 3.0 * @version 5.0 */ - static UILineBreakEngine& GetInstance() - { - if (instance_ == nullptr) { - instance_ = new UILineBreakEngine(); - } - return *instance_; - } + static UILineBreakEngine& GetInstance(); /** * @brief 初始化换行引擎,加载换行规则文件 @@ -142,7 +136,6 @@ private: void LoadRule(); static constexpr const int32_t LINE_BREAK_STATE_START = 1; static constexpr const int32_t LINE_BREAK_STATE_STOP = 0; - static UILineBreakEngine* instance_; bool initSuccess_; char* addr_; int32_t size_; diff --git a/frameworks/font/ui_multi_font_manager.cpp b/frameworks/font/ui_multi_font_manager.cpp index 360e67f..65c829e 100755 --- a/frameworks/font/ui_multi_font_manager.cpp +++ b/frameworks/font/ui_multi_font_manager.cpp @@ -119,6 +119,12 @@ void UIMultiFontManager::UpdateScript(UITextLanguageFontParam& fonts) } } +UIMultiFontManager* UIMultiFontManager::GetInstance() +{ + static UIMultiFontManager instance; + return &instance; +} + void UIMultiFontManager::ClearSearchFontList() { uint8_t totalFontId = GetTotalFontId(); diff --git a/frameworks/font/ui_multi_font_manager.h b/frameworks/font/ui_multi_font_manager.h index 05a3964..5fe79ae 100755 --- a/frameworks/font/ui_multi_font_manager.h +++ b/frameworks/font/ui_multi_font_manager.h @@ -32,12 +32,7 @@ public: * * @return UIMultiFontManager* */ - static UIMultiFontManager *GetInstance() - { - static UIMultiFontManager instance; - return &instance; - } - + static UIMultiFontManager* GetInstance(); void ClearSearchFontList(); int8_t SetSearchFontList(uint8_t fontListId, uint8_t *fontIds, uint8_t size); int8_t GetSearchFontList(uint8_t fontListId, uint8_t **fontIds); diff --git a/frameworks/font/ui_text_shaping.cpp b/frameworks/font/ui_text_shaping.cpp index 8f1f701..1c942a5 100755 --- a/frameworks/font/ui_text_shaping.cpp +++ b/frameworks/font/ui_text_shaping.cpp @@ -17,6 +17,12 @@ #include "font/ui_text_shaping.h" namespace OHOS { +UITextShaping* UITextShaping::GetInstance() +{ + static UITextShaping instance; + return &instance; +} + bool UITextShaping::IsSameTTFId(uint8_t fontId, uint32_t unicode) { // Need to be implemented diff --git a/frameworks/font/ui_text_shaping.h b/frameworks/font/ui_text_shaping.h index 5eb7c6f..0718fb7 100755 --- a/frameworks/font/ui_text_shaping.h +++ b/frameworks/font/ui_text_shaping.h @@ -48,11 +48,7 @@ public: * @brief Get the Instance object * @return UITextShaping* the static instance */ - static UITextShaping* GetInstance() - { - static UITextShaping instance; - return &instance; - } + static UITextShaping* GetInstance(); static bool IsSameTTFId(uint8_t fontId, uint32_t unicode); }; // class UITextShaping diff --git a/frameworks/imgdecode/cache_manager.cpp b/frameworks/imgdecode/cache_manager.cpp index 3de0dd9..0cbaff7 100755 --- a/frameworks/imgdecode/cache_manager.cpp +++ b/frameworks/imgdecode/cache_manager.cpp @@ -83,6 +83,12 @@ RetCode CacheEntry::SetSrc(const char* path) return RetCode::OK; } +CacheManager& CacheManager::GetInstance() +{ + static CacheManager instance; + return instance; +} + RetCode CacheManager::Init(uint16_t size) { if ((size == 0) || (size > MAX_CACHE_ENTRY_NUM)) { diff --git a/frameworks/imgdecode/cache_manager.h b/frameworks/imgdecode/cache_manager.h index a7258f3..10d6728 100755 --- a/frameworks/imgdecode/cache_manager.h +++ b/frameworks/imgdecode/cache_manager.h @@ -64,11 +64,7 @@ private: class CacheManager : public HeapBase { public: - static CacheManager& GetInstance() - { - static CacheManager instance; - return instance; - } + static CacheManager& GetInstance(); RetCode Init(uint16_t size); diff --git a/frameworks/imgdecode/file_img_decoder.cpp b/frameworks/imgdecode/file_img_decoder.cpp index edfe075..d964a2b 100755 --- a/frameworks/imgdecode/file_img_decoder.cpp +++ b/frameworks/imgdecode/file_img_decoder.cpp @@ -19,6 +19,12 @@ #include "imgdecode/image_load.h" namespace OHOS { +FileImgDecoder& FileImgDecoder::GetInstance() +{ + static FileImgDecoder instance; + return instance; +} + RetCode FileImgDecoder::Open(ImgResDsc& dsc) { #ifdef _WIN32 diff --git a/frameworks/imgdecode/file_img_decoder.h b/frameworks/imgdecode/file_img_decoder.h index 0e25f93..0e64842 100755 --- a/frameworks/imgdecode/file_img_decoder.h +++ b/frameworks/imgdecode/file_img_decoder.h @@ -33,11 +33,7 @@ enum class RetCode { class FileImgDecoder : public HeapBase { public: - static FileImgDecoder& GetInstance() - { - static FileImgDecoder instance; - return instance; - } + static FileImgDecoder& GetInstance(); struct ImgResDsc { FileImgDecoder* decoder; diff --git a/frameworks/themes/theme_manager.cpp b/frameworks/themes/theme_manager.cpp index b69879a..19a3529 100755 --- a/frameworks/themes/theme_manager.cpp +++ b/frameworks/themes/theme_manager.cpp @@ -16,6 +16,12 @@ #include "themes/theme_manager.h" namespace OHOS { +ThemeManager& ThemeManager::GetInstance() +{ + static ThemeManager instance; + return instance; +} + void ThemeManager::SetCurrent(Theme* theme) { if (theme_ != nullptr) { diff --git a/interfaces/innerkits/common/image_decode_ability.h b/interfaces/innerkits/common/image_decode_ability.h index 8241e8a..95042af 100755 --- a/interfaces/innerkits/common/image_decode_ability.h +++ b/interfaces/innerkits/common/image_decode_ability.h @@ -26,11 +26,7 @@ enum { }; class ImageDecodeAbility : public HeapBase { public: - static ImageDecodeAbility& GetInstance() - { - static ImageDecodeAbility instance; - return instance; - } + static ImageDecodeAbility& GetInstance(); void SetImageDecodeAbility(uint32_t imageType) { diff --git a/interfaces/innerkits/common/input_device_manager.h b/interfaces/innerkits/common/input_device_manager.h index 515aaf8..64a6647 100755 --- a/interfaces/innerkits/common/input_device_manager.h +++ b/interfaces/innerkits/common/input_device_manager.h @@ -30,11 +30,7 @@ public: * @brief Get instance of InputDeviceManager. * @returns Instance of InputDeviceManager */ - static InputDeviceManager* GetInstance() - { - static InputDeviceManager instance; - return &instance; - } + static InputDeviceManager* GetInstance(); void Init() override; diff --git a/interfaces/innerkits/common/task_manager.h b/interfaces/innerkits/common/task_manager.h index 90f9a9f..8d48253 100755 --- a/interfaces/innerkits/common/task_manager.h +++ b/interfaces/innerkits/common/task_manager.h @@ -28,11 +28,7 @@ public: * @brief return TaskManager's singleton * @return TaskManager* */ - static TaskManager* GetInstance() - { - static TaskManager taskManager; - return &taskManager; - } + static TaskManager* GetInstance(); /** * @brief add task to task manager diff --git a/interfaces/innerkits/dock/focus_manager.h b/interfaces/innerkits/dock/focus_manager.h index d2f5808..c09bc74 100755 --- a/interfaces/innerkits/dock/focus_manager.h +++ b/interfaces/innerkits/dock/focus_manager.h @@ -42,11 +42,7 @@ public: * @since 5.0 * @version 3.0 */ - static FocusManager* GetInstance() - { - static FocusManager instance; - return &instance; - } + static FocusManager* GetInstance(); /** * @brief Clear the focus. diff --git a/interfaces/innerkits/dock/vibrator_manager.h b/interfaces/innerkits/dock/vibrator_manager.h index a50ab48..e725b2a 100644 --- a/interfaces/innerkits/dock/vibrator_manager.h +++ b/interfaces/innerkits/dock/vibrator_manager.h @@ -47,11 +47,7 @@ public: * @since 5.0 * @version 3.0 */ - static VibratorManager* GetInstance() - { - static VibratorManager instance; - return &instance; - } + static VibratorManager* GetInstance(); void RegisterVibratorFunc(VibratorFunc vibratorFunc) { diff --git a/interfaces/kits/common/screen.h b/interfaces/kits/common/screen.h index b597927..cc7f0b3 100755 --- a/interfaces/kits/common/screen.h +++ b/interfaces/kits/common/screen.h @@ -51,11 +51,7 @@ public: * @brief Obtains a singleton Screen instance. * @return Returns the Screen instance. */ - static Screen& GetInstance() - { - static Screen instance; - return instance; - } + static Screen& GetInstance(); /** * @brief Obtains the width of this screen. diff --git a/interfaces/kits/components/root_view.h b/interfaces/kits/components/root_view.h index e986ed1..afe487e 100755 --- a/interfaces/kits/components/root_view.h +++ b/interfaces/kits/components/root_view.h @@ -74,11 +74,7 @@ public: * @since 1.0 * @version 1.0 */ - static RootView* GetInstance() - { - static RootView instance; - return &instance; - } + static RootView* GetInstance(); #if ENABLE_WINDOW /** diff --git a/interfaces/kits/dfx/event_injector.h b/interfaces/kits/dfx/event_injector.h index 7cdaa79..bb67377 100755 --- a/interfaces/kits/dfx/event_injector.h +++ b/interfaces/kits/dfx/event_injector.h @@ -70,11 +70,7 @@ public: * @since 1.0 * @version 1.0 */ - static EventInjector* GetInstance() - { - static EventInjector instance; - return &instance; - } + static EventInjector* GetInstance(); /** * @brief Registers an event injector of a specified type. diff --git a/interfaces/kits/dfx/ui_dump_dom_tree.h b/interfaces/kits/dfx/ui_dump_dom_tree.h index bd7f2c1..0435579 100755 --- a/interfaces/kits/dfx/ui_dump_dom_tree.h +++ b/interfaces/kits/dfx/ui_dump_dom_tree.h @@ -70,11 +70,7 @@ public: * @since 1.0 * @version 1.0 */ - static UIDumpDomTree* GetInstance() - { - static UIDumpDomTree instance; - return &instance; - } + static UIDumpDomTree* GetInstance(); /** * @brief Exports information about a DOM tree starting from a specified DOM node and saves the information to diff --git a/interfaces/kits/dfx/ui_screenshot.h b/interfaces/kits/dfx/ui_screenshot.h index 084a61d..6d35b6a 100755 --- a/interfaces/kits/dfx/ui_screenshot.h +++ b/interfaces/kits/dfx/ui_screenshot.h @@ -64,11 +64,7 @@ public: * @since 1.0 * @version 1.0 */ - static UIScreenshot* GetInstance() - { - static UIScreenshot instance; - return &instance; - } + static UIScreenshot* GetInstance(); /** * @brief Takes a screenshot and saves it to a file. diff --git a/interfaces/kits/themes/theme_manager.h b/interfaces/kits/themes/theme_manager.h index e3c29d4..3dca85f 100755 --- a/interfaces/kits/themes/theme_manager.h +++ b/interfaces/kits/themes/theme_manager.h @@ -51,11 +51,7 @@ public: * * @return Returns the singleton instance of the ThemeManager class. */ - static ThemeManager& GetInstance() - { - static ThemeManager instance; - return instance; - } + static ThemeManager& GetInstance(); /** * @brief Sets the current screen theme for this application. diff --git a/test/framework/include/ui_test_app.h b/test/framework/include/ui_test_app.h index d6001cf..93a534a 100755 --- a/test/framework/include/ui_test_app.h +++ b/test/framework/include/ui_test_app.h @@ -29,11 +29,7 @@ namespace { } class UITestApp { public: - static UITestApp* GetInstance() - { - static UITestApp instance; - return &instance; - } + static UITestApp* GetInstance(); void Start(); void Init(); @@ -56,11 +52,7 @@ private: class UIAutoTestApp { public: - static UIAutoTestApp* GetInstance() - { - static UIAutoTestApp instance; - return &instance; - } + static UIAutoTestApp* GetInstance(); void Start(); private: UIAutoTestApp() {} diff --git a/test/framework/src/ui_test_app.cpp b/test/framework/src/ui_test_app.cpp index 122d86b..ded3891 100755 --- a/test/framework/src/ui_test_app.cpp +++ b/test/framework/src/ui_test_app.cpp @@ -27,6 +27,12 @@ #endif namespace OHOS { +UITestApp* UITestApp::GetInstance() +{ + static UITestApp instance; + return &instance; +} + void UITestApp::Start() { if (rootView_ == nullptr) { @@ -107,6 +113,12 @@ UITestApp::~UITestApp() } } +UIAutoTestApp* UIAutoTestApp::GetInstance() +{ + static UIAutoTestApp instance; + return &instance; +} + void UIAutoTestApp::Start() { EventInjector::GetInstance()->RegisterEventInjector(EventDataType::POINT_TYPE); diff --git a/tools/qt/simulator/drivers/display/monitor.cpp b/tools/qt/simulator/drivers/display/monitor.cpp index 3c0a05c..9396b4e 100755 --- a/tools/qt/simulator/drivers/display/monitor.cpp +++ b/tools/qt/simulator/drivers/display/monitor.cpp @@ -27,6 +27,12 @@ #include "mousewheel_input.h" namespace OHOS { +Monitor* Monitor::GetInstance() +{ + static Monitor instance; + return &instance; +} + void Monitor::InitHal() { ScreenDeviceProxy::GetInstance()->SetScreenSize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); diff --git a/tools/qt/simulator/drivers/display/monitor.h b/tools/qt/simulator/drivers/display/monitor.h index c453b42..76c5eaa 100755 --- a/tools/qt/simulator/drivers/display/monitor.h +++ b/tools/qt/simulator/drivers/display/monitor.h @@ -26,11 +26,7 @@ class Monitor : public QObject, public ScreenDevice { public: Monitor() : defaultColor_ (0x44) {} virtual ~Monitor() {} - static Monitor* GetInstance() - { - static Monitor instance; - return &instance; - } + static Monitor* GetInstance(); void InitHal(); void InitFontEngine(); void InitImageDecodeAbility(); diff --git a/tools/qt/simulator/drivers/indev/key_input.cpp b/tools/qt/simulator/drivers/indev/key_input.cpp index b1c9467..5b069fc 100644 --- a/tools/qt/simulator/drivers/indev/key_input.cpp +++ b/tools/qt/simulator/drivers/indev/key_input.cpp @@ -27,6 +27,12 @@ static uint16_t g_lastKeyId = 0; static uint16_t g_lastKeyState = INVALID_KEY_STATE; } // namespace +KeyInput* KeyInput::GetInstance() +{ + static KeyInput keyInput; + return &keyInput; +} + bool KeyInput::Read(DeviceData& data) { data.keyId = g_lastKeyId; diff --git a/tools/qt/simulator/drivers/indev/key_input.h b/tools/qt/simulator/drivers/indev/key_input.h index d53635b..98a0681 100644 --- a/tools/qt/simulator/drivers/indev/key_input.h +++ b/tools/qt/simulator/drivers/indev/key_input.h @@ -27,11 +27,7 @@ class KeyInput : public KeyInputDevice { public: KeyInput() {} virtual ~KeyInput() {} - static KeyInput* GetInstance() - { - static KeyInput keyInput; - return &keyInput; - } + static KeyInput* GetInstance(); bool Read(DeviceData& data) override; void KeyHandler(QKeyEvent* event); diff --git a/tools/qt/simulator/drivers/indev/mouse_input.cpp b/tools/qt/simulator/drivers/indev/mouse_input.cpp index 54480b7..a6c7b03 100755 --- a/tools/qt/simulator/drivers/indev/mouse_input.cpp +++ b/tools/qt/simulator/drivers/indev/mouse_input.cpp @@ -19,6 +19,12 @@ namespace OHOS { #if USE_MOUSE +MouseInput* MouseInput::GetInstance() +{ + static MouseInput mouseInput; + return &mouseInput; +} + bool MouseInput::Read(DeviceData& data) { data.point.x = lastX_; diff --git a/tools/qt/simulator/drivers/indev/mouse_input.h b/tools/qt/simulator/drivers/indev/mouse_input.h index be4651f..abcec16 100755 --- a/tools/qt/simulator/drivers/indev/mouse_input.h +++ b/tools/qt/simulator/drivers/indev/mouse_input.h @@ -27,11 +27,7 @@ class MouseInput : public PointerInputDevice { public: MouseInput() : leftButtonDown_(false), lastX_(0), lastY_(0) {} virtual ~MouseInput() {} - static MouseInput* GetInstance() - { - static MouseInput mouseInput; - return &mouseInput; - } + static MouseInput* GetInstance(); bool Read(DeviceData& data) override; void MouseHandler(QMouseEvent* event); diff --git a/tools/qt/simulator/drivers/indev/mousewheel_input.cpp b/tools/qt/simulator/drivers/indev/mousewheel_input.cpp index 55d3b84..9585480 100755 --- a/tools/qt/simulator/drivers/indev/mousewheel_input.cpp +++ b/tools/qt/simulator/drivers/indev/mousewheel_input.cpp @@ -22,6 +22,12 @@ static int16_t g_rotate = 0; namespace OHOS { #if USE_MOUSEWHEEL #if ENABLE_ROTATE_INPUT +MousewheelInput* MousewheelInput::GetInstance() +{ + static MousewheelInput mousewheelInput; + return &mousewheelInput; +} + bool MousewheelInput::Read(DeviceData &data) { data.rotate = g_rotate; diff --git a/tools/qt/simulator/drivers/indev/mousewheel_input.h b/tools/qt/simulator/drivers/indev/mousewheel_input.h index 0553eca..d0176a9 100755 --- a/tools/qt/simulator/drivers/indev/mousewheel_input.h +++ b/tools/qt/simulator/drivers/indev/mousewheel_input.h @@ -26,11 +26,7 @@ class MousewheelInput : public RotateInputDevice { public: MousewheelInput() {} virtual ~MousewheelInput() {} - static MousewheelInput* GetInstance() - { - static MousewheelInput mousewheelInput; - return &mousewheelInput; - } + static MousewheelInput* GetInstance(); bool Read(DeviceData& data) override; void MousewheelHandler(QWheelEvent* event); }; diff --git a/tools/qt/simulator/uitest/UITest.pro b/tools/qt/simulator/uitest/UITest.pro index 32ab8ed..b035305 100755 --- a/tools/qt/simulator/uitest/UITest.pro +++ b/tools/qt/simulator/uitest/UITest.pro @@ -36,6 +36,7 @@ SOURCES += \ ../../../../frameworks/animator/easing_equation.cpp \ ../../../../frameworks/animator/interpolation.cpp \ ../../../../frameworks/common/graphic_startup.cpp \ + ../../../../frameworks/common/image_decode_ability.cpp \ ../../../../frameworks/common/image.cpp \ ../../../../frameworks/common/input_device_manager.cpp \ ../../../../frameworks/common/screen.cpp \ @@ -82,6 +83,7 @@ SOURCES += \ ../../../../frameworks/default_resource/check_box_res.cpp \ ../../../../frameworks/dfx/event_injector.cpp \ ../../../../frameworks/dfx/key_event_injector.cpp \ + ../../../../frameworks/dfx/performance_task.cpp \ ../../../../frameworks/dfx/point_event_injector.cpp \ ../../../../frameworks/dfx/ui_dump_dom_tree.cpp \ ../../../../frameworks/dock/input_device.cpp \ @@ -89,6 +91,7 @@ SOURCES += \ ../../../../frameworks/dock/pointer_input_device.cpp \ ../../../../frameworks/dock/rotate_input_device.cpp \ ../../../../frameworks/dock/screen_device_proxy.cpp \ + ../../../../frameworks/dock/vibrator_manager.cpp \ ../../../../frameworks/dock/virtual_input_device.cpp \ ../../../../frameworks/draw/draw_arc.cpp \ ../../../../frameworks/draw/draw_curve.cpp \ @@ -120,6 +123,7 @@ SOURCES += \ ../../../../../utils/frameworks/color.cpp \ ../../../../../utils/frameworks/geometry2d.cpp \ ../../../../../utils/frameworks/graphic_math.cpp \ + ../../../../../utils/frameworks/graphic_performance.cpp \ ../../../../../utils/frameworks/hal_tick.cpp \ ../../../../../utils/frameworks/mem_api.cpp \ ../../../../../utils/frameworks/style.cpp \ diff --git a/ui.gni b/ui.gni index 6f25a52..3e9d300 100755 --- a/ui.gni +++ b/ui.gni @@ -22,6 +22,7 @@ graphic_ui_sources = [ "$GRAPHIC_UI_PATH/frameworks/animator/easing_equation.cpp", "$GRAPHIC_UI_PATH/frameworks/animator/interpolation.cpp", "$GRAPHIC_UI_PATH/frameworks/common/graphic_startup.cpp", + "$GRAPHIC_UI_PATH/frameworks/common/image_decode_ability.cpp", "$GRAPHIC_UI_PATH/frameworks/common/image.cpp", "$GRAPHIC_UI_PATH/frameworks/common/input_device_manager.cpp", "$GRAPHIC_UI_PATH/frameworks/common/screen.cpp", @@ -67,12 +68,14 @@ graphic_ui_sources = [ "$GRAPHIC_UI_PATH/frameworks/default_resource/check_box_res.cpp", "$GRAPHIC_UI_PATH/frameworks/dfx/event_injector.cpp", "$GRAPHIC_UI_PATH/frameworks/dfx/key_event_injector.cpp", + "$GRAPHIC_UI_PATH/frameworks/dfx/performance_task.cpp", "$GRAPHIC_UI_PATH/frameworks/dfx/point_event_injector.cpp", "$GRAPHIC_UI_PATH/frameworks/dfx/ui_dump_dom_tree.cpp", "$GRAPHIC_UI_PATH/frameworks/dock/input_device.cpp", "$GRAPHIC_UI_PATH/frameworks/dock/key_input_device.cpp", "$GRAPHIC_UI_PATH/frameworks/dock/pointer_input_device.cpp", "$GRAPHIC_UI_PATH/frameworks/dock/screen_device_proxy.cpp", + "$GRAPHIC_UI_PATH/frameworks/dock/vibrator_manager.cpp", "$GRAPHIC_UI_PATH/frameworks/dock/virtual_input_device.cpp", "$GRAPHIC_UI_PATH/frameworks/draw/draw_arc.cpp", "$GRAPHIC_UI_PATH/frameworks/draw/draw_curve.cpp", -- GitLab