diff --git a/BUILD.gn b/BUILD.gn index 9873e73bf32ab413e6b8a5701a0a306ea405d0c4..160d4dd58883964ac71170f6979bd9ce501cc69d 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 9c168a1e01db72674f0ce95433edaa223057c62c..f2af9c26a871c34df33b3dc02cc6bac2d8f56c82 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 78150d51126c58f8c47e1dfae756c31ad93496a4..a822368ec664bafb425ee48105a7b25893121228 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 0000000000000000000000000000000000000000..912b994e7c4eb9a3a7fc7a44db1e6279087b891a --- /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 abeac0e7c6c53c48c4e52f42e3b22ff9cad2cee2..5672eb112be91c8d76627109b507a885b6c47f29 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 b07f9ad9bdfb1ac989faf34bbb3bdf9e59b29761..77ab24477ef53cb9b475a16c5bcb2c6a769d9587 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 ff04fb5432583ffde2f85f23cb59dff711922c54..b0188c17350c2ab50a79ba0ce08c9ff03be26053 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 6e867229277c49789513d8448f15cbe29937b9cc..b575f4d5b587ac7936183fcc6f999a7c2aab614f 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 7460bbb3859e4c88f36a8ee97abb581abd46d3d1..591785ea30da881cb80ef6c945a440207cc8b44d 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 98ffe05b3d8736e5e5be1ec95e6fc9baedff2e0a..cede580efcbd1a6faaa8a9ff346d7ba2096c41f8 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 3579a5e9fe32e413a7fbb6afff2f29ea819800f3..4f181b27a131c9346ccb97ca4f10c316f234eeef 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 0000000000000000000000000000000000000000..16a6d043edc703c47b878b3d901c7b2ad77a6fe2 --- /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 cbc62aafe7da86cb828feb84dc50c2a6a6cb4d1e..7450c1bfc71c6f4004677b658d947bdb862af70e 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 88cb013f5d0cf5eccc76924ecfdc6429b988fdfb..bc5c805b52ff52fb6b06e5f88959654d57e35741 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 ee04e81ceb955353eec75702bd529921b38e1a19..13d93fc1416a7b8ada18d199bb3f95a569658729 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 507e332f9f656fb209c43229018cdfeb33f6b025..89bf0a568f7a28a6c5cfa80c55c1d873ea1be8d2 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 12d16ca99770c52f4dbacb16f5c2b3a2303a1b75..acf5b3d42219b33861775b6c9094becf26f857a4 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 0bf3c417397184774cdb967588ed069c820c24b0..acebea6e1457919ebb116014bedc05e67efb1a31 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 0000000000000000000000000000000000000000..21f37da44fa293e8ceebdbb2e3979026761ca57f --- /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 b09347230a45bab19efdd52f41926bb7b1d4e1b1..48dc80ded62b88a5e9100b8d0faf9f226ae8878f 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 ce9e302697367e6e3e19cc0cd8d2510b5e35cf07..5223c5f16f68c54f50d9be550fc01d5fc811f43d 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 3f2ef3a154732ad6b186eb8f1e601fa9c8dbc9f9..a41cb84ca0c17d8009aac75cffa281d24dc21cfb 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 adb0286ba5f810ee74b3f999bf2535b2d5f65501..003e649a23df0030b0baa290a267d4d0f2c03a3e 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 aa7a3ed3b8cbad61ca9d710378fd272f7de66e54..0b54899443f8f23b2d1f961df201467fd1ab4342 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 60ecdcd951a88afac6498cba5925e9619f6e9b04..f896afabefe9c669f8a049e65e4b5cf66cee6e64 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 360e67f86a8d5f5ed1f235579c254b5df6a5645a..65c829e069f254bd0e6ee50d4952c261285dd096 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 05a3964e6f5feec376e00027273f2ec68ac81a45..5fe79ae2735679f227082ed94a1b4198632a0840 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 8f1f7019a174a5f7df1bd58ffc328096dae49ed1..1c942a56aed40038166112f8656ee3215c8443ff 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 5eb7c6f1855eca2c387ae1d7271ba24dc0c2c340..0718fb7cdff138d7dd1fc7c646b4ce7b67925434 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 3de0dd913f3e3211cea89444fa4f8853ea32daec..0cbaff73715c3ad838bb9df3fdeddacd86ff13d5 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 a7258f3f35698b2f4897e27a0f5fcda0c46a3d59..10d67286684814843796b17d7c18c8a9aaaa053d 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 edfe075814077e556eab9d1cc27841f7542c6fbc..d964a2bfee2be74489059b98cc5ea591a8503c97 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 0e25f934013a688020478b0c5f2ef5f2864d658c..0e648427153aabcf470f57552f992d1720feb573 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 b69879a94a75b488cb22eb2b56c4a2aa4812ad45..19a35293d0858330dcd595200d41c1e43402ff8d 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 8241e8a6a680248b416175cb48da3fed6ed09bd1..95042af3dacd0bc51e2c58589657d5e37497aeef 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 515aaf829dff79d6b27354b42eaec8665eb18e7c..64a6647ec132260806e604eb2d8139d1083ba2ca 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 90f9a9ffaa708fbda4c715944fd6d4f7f3449f2b..8d482538e2a6cd0798b536944a9a7ae55f2e4718 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 d2f5808d9c525d82ac7dad7a387411ff11a3c3ec..c09bc743a90aebf2b39fb595a06027c469138c3e 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 a50ab4844b67cf05e283c8f1cb31dad7d9b569f6..e725b2ac44349666f56f89b3df2635253e3bbdca 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 b59792769fcfa9c534fa45a5d76b254fe796d766..cc7f0b3eeb0d6d18570cd81c8c2d64ebbeeb29bf 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 e986ed159bec8c4e677fab67d9ec3ce80fa5a0ab..afe487ef4984eaec273302b0a2ac145af7f4b5f6 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 7cdaa7936a27e15f926c555ce0ceea9b533b210b..bb6737748e810d3f35c477d55a9e31abc0a2b1ce 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 bd7f2c1f9b2145451a19ce987734fe2be792f2e3..0435579e7f3a3a3b696bf7861d91f63b35d6c261 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 084a61dc3027727eeea8427e1d5a64e529306787..6d35b6ab853c8787dd01f4989331f2c1a9a54c36 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 e3c29d42b75b3c6ffa642f8ae5688c281a06a985..3dca85f543c7956d7896b444434b841c9dbef066 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 d6001cfe7a44b306f0f3541ffccdb001f9873a7e..93a534a1f93c851750472a19630f4612b4942f8a 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 122d86b99549e129ef7c01bb602314a0e98634fb..ded38913e78edb71f3567fe656649ba4983f53a8 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 3c0a05c6d18f8607eafb5d5e20a3a3eb726dd48c..9396b4ecefdc9f9ab3f2d6a73744fa851d4b5549 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 c453b420289b96acc30307e46589741896db78fb..76c5eaa582979006e9bb30c5084ff754cbe5db24 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 b1c94678e3bcff95676495bc104d3c42ad966cc2..5b069fc48c3a378001ccc21eeeef27ccb25780a1 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 d53635b582c62e274d6a0c0d4f008afd07364db5..98a0681f88cef782a470ec7d7ad31c7aa93c5473 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 54480b7cf242d5ad0aafe1e6dd39fefc19164f1d..a6c7b031a4f50e105fc26c04bee5421c9abdd6b4 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 be4651fe58c6a715bbb70c75edb632112b6c60bf..abcec160fa613b9ec99d472e4e2439aa7f152ec8 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 55d3b8485549621692f59d7ef431464475b2716b..9585480a6ef72698ed63fc511d50271ce39b77a9 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 0553ecaf5997a6f65533756674dcdfdd3e27d36c..d0176a92733f1ae0775f791116e27bf09a85c18b 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 32ab8ed0cfb4d255251d0c3a3f31a4b158af0fba..b035305ea4389fb400adacd096e54736cad738b0 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 6f25a523e53aac99112cf127fa01e133ea907eff..3e9d3008886061fed9ff3ef786685184235e63ee 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",