提交 a728270f 编写于 作者: O openharmony_ci 提交者: Gitee

!146 【图形】单例整改

Merge pull request !146 from 邓志豪/weekly_20210510
...@@ -62,6 +62,7 @@ shared_library("ui") { ...@@ -62,6 +62,7 @@ shared_library("ui") {
"frameworks/animator/easing_equation.cpp", "frameworks/animator/easing_equation.cpp",
"frameworks/animator/interpolation.cpp", "frameworks/animator/interpolation.cpp",
"frameworks/common/graphic_startup.cpp", "frameworks/common/graphic_startup.cpp",
"frameworks/common/image_decode_ability.cpp",
"frameworks/common/image.cpp", "frameworks/common/image.cpp",
"frameworks/common/input_device_manager.cpp", "frameworks/common/input_device_manager.cpp",
"frameworks/common/screen.cpp", "frameworks/common/screen.cpp",
...@@ -108,6 +109,7 @@ shared_library("ui") { ...@@ -108,6 +109,7 @@ shared_library("ui") {
"frameworks/default_resource/check_box_res.cpp", "frameworks/default_resource/check_box_res.cpp",
"frameworks/dfx/event_injector.cpp", "frameworks/dfx/event_injector.cpp",
"frameworks/dfx/key_event_injector.cpp", "frameworks/dfx/key_event_injector.cpp",
"frameworks/dfx/performance_task.cpp",
"frameworks/dfx/point_event_injector.cpp", "frameworks/dfx/point_event_injector.cpp",
"frameworks/dfx/ui_dump_dom_tree.cpp", "frameworks/dfx/ui_dump_dom_tree.cpp",
"frameworks/dfx/ui_screenshot.cpp", "frameworks/dfx/ui_screenshot.cpp",
...@@ -118,6 +120,7 @@ shared_library("ui") { ...@@ -118,6 +120,7 @@ shared_library("ui") {
"frameworks/dock/pointer_input_device.cpp", "frameworks/dock/pointer_input_device.cpp",
"frameworks/dock/rotate_input_device.cpp", "frameworks/dock/rotate_input_device.cpp",
"frameworks/dock/screen_device_proxy.cpp", "frameworks/dock/screen_device_proxy.cpp",
"frameworks/dock/vibrator_manager.cpp",
"frameworks/dock/virtual_input_device.cpp", "frameworks/dock/virtual_input_device.cpp",
"frameworks/draw/draw_arc.cpp", "frameworks/draw/draw_arc.cpp",
"frameworks/draw/draw_curve.cpp", "frameworks/draw/draw_curve.cpp",
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
#include "hal_tick.h" #include "hal_tick.h"
namespace OHOS { namespace OHOS {
AnimatorManager* AnimatorManager::GetInstance()
{
static AnimatorManager animatorManager;
return &animatorManager;
}
void AnimatorManager::Init() void AnimatorManager::Init()
{ {
Task::Init(); Task::Init();
......
...@@ -58,11 +58,7 @@ public: ...@@ -58,11 +58,7 @@ public:
* @since 1.0 * @since 1.0
* @version 1.0 * @version 1.0
*/ */
static AnimatorManager* GetInstance() static AnimatorManager* GetInstance();
{
static AnimatorManager animatorManager;
return &animatorManager;
}
void Init() override; void Init() override;
......
/*
* 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
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
namespace OHOS { namespace OHOS {
InputDeviceManager* InputDeviceManager::GetInstance()
{
static InputDeviceManager instance;
return &instance;
}
void InputDeviceManager::Init() void InputDeviceManager::Init()
{ {
if (INDEV_READ_PERIOD > 0) { if (INDEV_READ_PERIOD > 0) {
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include "securec.h" #include "securec.h"
namespace OHOS { namespace OHOS {
Screen& Screen::GetInstance()
{
static Screen instance;
return instance;
}
uint16_t Screen::GetWidth() uint16_t Screen::GetWidth()
{ {
return BaseGfxEngine::GetInstance()->GetScreenWidth(); return BaseGfxEngine::GetInstance()->GetScreenWidth();
......
...@@ -43,6 +43,12 @@ RootView::RootView() ...@@ -43,6 +43,12 @@ RootView::RootView()
InitDrawContext(); InitDrawContext();
} }
RootView* RootView::GetInstance()
{
static RootView instance;
return &instance;
}
RootView::~RootView() RootView::~RootView()
{ {
DestroyDrawContext(); DestroyDrawContext();
......
...@@ -28,6 +28,12 @@ RenderManager::RenderManager() : fps_(0.f), needResetFPS_(true), onFPSChangedLis ...@@ -28,6 +28,12 @@ RenderManager::RenderManager() : fps_(0.f), needResetFPS_(true), onFPSChangedLis
RenderManager::~RenderManager() {} RenderManager::~RenderManager() {}
RenderManager& RenderManager::GetInstance()
{
static RenderManager instance;
return instance;
}
void RenderManager::Init() void RenderManager::Init()
{ {
Task::Init(); Task::Init();
......
...@@ -35,11 +35,7 @@ static constexpr uint16_t MILLISECONDS_PER_SECOND = 1000; ...@@ -35,11 +35,7 @@ static constexpr uint16_t MILLISECONDS_PER_SECOND = 1000;
class RenderManager : public Task { class RenderManager : public Task {
public: public:
static RenderManager& GetInstance() static RenderManager& GetInstance();
{
static RenderManager instance;
return instance;
}
void Init() override; void Init() override;
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
#include "hal_tick.h" #include "hal_tick.h"
namespace OHOS { namespace OHOS {
TaskManager* TaskManager::GetInstance()
{
static TaskManager taskManager;
return &taskManager;
}
void TaskManager::Add(Task* task) void TaskManager::Add(Task* task)
{ {
if (task == nullptr) { if (task == nullptr) {
......
...@@ -35,6 +35,12 @@ EventInjector::~EventInjector() ...@@ -35,6 +35,12 @@ EventInjector::~EventInjector()
} }
} }
EventInjector* EventInjector::GetInstance()
{
static EventInjector instance;
return &instance;
}
bool EventInjector::RegisterEventInjector(EventDataType type) bool EventInjector::RegisterEventInjector(EventDataType type)
{ {
switch (type) { switch (type) {
......
/*
* 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
...@@ -24,11 +24,7 @@ ...@@ -24,11 +24,7 @@
namespace OHOS { namespace OHOS {
class PerformanceTask : public Task { class PerformanceTask : public Task {
public: public:
static PerformanceTask* GetInstance() static PerformanceTask* GetInstance();
{
static PerformanceTask instance;
return &instance;
}
void Init() override void Init() override
{ {
......
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
#endif // ENABLE_DEBUG #endif // ENABLE_DEBUG
namespace OHOS { namespace OHOS {
#if ENABLE_DEBUG #if ENABLE_DEBUG
UIDumpDomTree* UIDumpDomTree::GetInstance()
{
static UIDumpDomTree instance;
return &instance;
}
void UIDumpDomTree::AddNameField(UIViewType type, cJSON* usr) const void UIDumpDomTree::AddNameField(UIViewType type, cJSON* usr) const
{ {
if (usr == nullptr) { if (usr == nullptr) {
......
...@@ -135,6 +135,12 @@ UIScreenshot::~UIScreenshot() ...@@ -135,6 +135,12 @@ UIScreenshot::~UIScreenshot()
} }
} }
UIScreenshot* UIScreenshot::GetInstance()
{
static UIScreenshot instance;
return &instance;
}
bool UIScreenshot::ScreenshotToFile(const char* path) bool UIScreenshot::ScreenshotToFile(const char* path)
{ {
if (screenshotListener_ == nullptr) { if (screenshotListener_ == nullptr) {
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
#include "gfx_utils/graphic_math.h" #include "gfx_utils/graphic_math.h"
namespace OHOS { namespace OHOS {
FocusManager* FocusManager::GetInstance()
{
static FocusManager instance;
return &instance;
}
bool FocusManager::RequestFocus(UIView* view) bool FocusManager::RequestFocus(UIView* view)
{ {
if (view == nullptr || view == focusView_ || !view->IsFocusable() || if (view == nullptr || view == focusView_ || !view->IsFocusable() ||
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
#include "securec.h" #include "securec.h"
namespace OHOS { namespace OHOS {
ScreenDeviceProxy* ScreenDeviceProxy::GetInstance()
{
static ScreenDeviceProxy instance;
return &instance;
}
void ScreenDeviceProxy::Flush() {} void ScreenDeviceProxy::Flush() {}
void ScreenDeviceProxy::OnFlushReady() void ScreenDeviceProxy::OnFlushReady()
......
...@@ -31,11 +31,7 @@ namespace OHOS { ...@@ -31,11 +31,7 @@ namespace OHOS {
/** @brief A display device proxy */ /** @brief A display device proxy */
class ScreenDeviceProxy : public HeapBase { class ScreenDeviceProxy : public HeapBase {
public: public:
static ScreenDeviceProxy* GetInstance() static ScreenDeviceProxy* GetInstance();
{
static ScreenDeviceProxy instance;
return &instance;
}
void SetDevice(ScreenDevice* device) void SetDevice(ScreenDevice* device)
{ {
......
/*
* 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
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
namespace OHOS { namespace OHOS {
#define IS_IN_DEGREERANE(d, s, e) ((s) <= (e)) ? (((d) >= (s)) && ((d) <= (e))) : (((d) >= (s)) || ((d) <= (e))) #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(BufferInfo& gfxDstBuffer, void DrawArc::DrawImg(BufferInfo& gfxDstBuffer,
const Point& imgPos, const Point& imgPos,
......
...@@ -26,11 +26,7 @@ ...@@ -26,11 +26,7 @@
namespace OHOS { namespace OHOS {
class DrawArc : public HeapBase { class DrawArc : public HeapBase {
public: public:
static DrawArc* GetInstance() static DrawArc* GetInstance();
{
static DrawArc drawArc;
return &drawArc;
}
void GetDrawRange(int16_t& start, int16_t& end); void GetDrawRange(int16_t& start, int16_t& end);
......
...@@ -165,6 +165,12 @@ TriangleEdge::TriangleEdge(int16_t x1, int16_t y1, int16_t x2, int16_t y2) ...@@ -165,6 +165,12 @@ TriangleEdge::TriangleEdge(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
TriangleEdge::~TriangleEdge() {} TriangleEdge::~TriangleEdge() {}
DrawUtils* DrawUtils::GetInstance()
{
static DrawUtils instance;
return &instance;
}
void DrawUtils::DrawColorAreaBySides(BufferInfo& gfxDstBuffer, void DrawUtils::DrawColorAreaBySides(BufferInfo& gfxDstBuffer,
const Rect& mask, const Rect& mask,
const ColorType& color, const ColorType& color,
......
...@@ -161,11 +161,7 @@ enum { ...@@ -161,11 +161,7 @@ enum {
class DrawUtils : public HeapBase { class DrawUtils : public HeapBase {
public: public:
static DrawUtils* GetInstance() static DrawUtils* GetInstance();
{
static DrawUtils instance;
return &instance;
}
void DrawColorArea(BufferInfo& gfxDstBuffer, const Rect& area, const Rect& mask, void DrawColorArea(BufferInfo& gfxDstBuffer, const Rect& area, const Rect& mask,
const ColorType& color, OpacityType opa) const; const ColorType& color, OpacityType opa) const;
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
using namespace U_ICU_NAMESPACE; using namespace U_ICU_NAMESPACE;
namespace OHOS { namespace OHOS {
UILineBreakEngine* UILineBreakEngine::instance_ = nullptr;
static void* MemAlloc(const void* context, size_t size) static void* MemAlloc(const void* context, size_t size)
{ {
return UIMalloc(size); return UIMalloc(size);
...@@ -41,6 +40,12 @@ static void* MemRealloc(const void* context, void* mem, size_t size) ...@@ -41,6 +40,12 @@ static void* MemRealloc(const void* context, void* mem, size_t size)
return UIRealloc(mem, size); return UIRealloc(mem, size);
} }
UILineBreakEngine& UILineBreakEngine::GetInstance()
{
static UILineBreakEngine instance;
return instance;
}
uint16_t UILineBreakEngine::GetNextBreakPos(UILineBreakProxy& record) uint16_t UILineBreakEngine::GetNextBreakPos(UILineBreakProxy& record)
{ {
const UChar* str = reinterpret_cast<const UChar*>(record.GetStr()); const UChar* str = reinterpret_cast<const UChar*>(record.GetStr());
......
...@@ -40,13 +40,7 @@ public: ...@@ -40,13 +40,7 @@ public:
* @since 3.0 * @since 3.0
* @version 5.0 * @version 5.0
*/ */
static UILineBreakEngine& GetInstance() static UILineBreakEngine& GetInstance();
{
if (instance_ == nullptr) {
instance_ = new UILineBreakEngine();
}
return *instance_;
}
/** /**
* @brief 初始化换行引擎,加载换行规则文件 * @brief 初始化换行引擎,加载换行规则文件
...@@ -142,7 +136,6 @@ private: ...@@ -142,7 +136,6 @@ private:
void LoadRule(); void LoadRule();
static constexpr const int32_t LINE_BREAK_STATE_START = 1; static constexpr const int32_t LINE_BREAK_STATE_START = 1;
static constexpr const int32_t LINE_BREAK_STATE_STOP = 0; static constexpr const int32_t LINE_BREAK_STATE_STOP = 0;
static UILineBreakEngine* instance_;
bool initSuccess_; bool initSuccess_;
char* addr_; char* addr_;
int32_t size_; int32_t size_;
......
...@@ -119,6 +119,12 @@ void UIMultiFontManager::UpdateScript(UITextLanguageFontParam& fonts) ...@@ -119,6 +119,12 @@ void UIMultiFontManager::UpdateScript(UITextLanguageFontParam& fonts)
} }
} }
UIMultiFontManager* UIMultiFontManager::GetInstance()
{
static UIMultiFontManager instance;
return &instance;
}
void UIMultiFontManager::ClearSearchFontList() void UIMultiFontManager::ClearSearchFontList()
{ {
uint8_t totalFontId = UIFontBuilder::GetInstance()->GetTotalFontId(); uint8_t totalFontId = UIFontBuilder::GetInstance()->GetTotalFontId();
......
...@@ -32,12 +32,7 @@ public: ...@@ -32,12 +32,7 @@ public:
* *
* @return UIMultiFontManager* * @return UIMultiFontManager*
*/ */
static UIMultiFontManager *GetInstance() static UIMultiFontManager* GetInstance();
{
static UIMultiFontManager instance;
return &instance;
}
void ClearSearchFontList(); void ClearSearchFontList();
int8_t SetSearchFontList(uint8_t fontListId, uint8_t *fontIds, uint8_t size); int8_t SetSearchFontList(uint8_t fontListId, uint8_t *fontIds, uint8_t size);
int8_t GetSearchFontList(uint8_t fontListId, uint8_t **fontIds); int8_t GetSearchFontList(uint8_t fontListId, uint8_t **fontIds);
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
#include "font/ui_text_shaping.h" #include "font/ui_text_shaping.h"
namespace OHOS { namespace OHOS {
UITextShaping* UITextShaping::GetInstance()
{
static UITextShaping instance;
return &instance;
}
bool UITextShaping::IsSameTTFId(uint8_t fontId, uint32_t unicode) bool UITextShaping::IsSameTTFId(uint8_t fontId, uint32_t unicode)
{ {
// Need to be implemented // Need to be implemented
......
...@@ -48,11 +48,7 @@ public: ...@@ -48,11 +48,7 @@ public:
* @brief Get the Instance object * @brief Get the Instance object
* @return UITextShaping* the static instance * @return UITextShaping* the static instance
*/ */
static UITextShaping* GetInstance() static UITextShaping* GetInstance();
{
static UITextShaping instance;
return &instance;
}
static bool IsSameTTFId(uint8_t fontId, uint32_t unicode); static bool IsSameTTFId(uint8_t fontId, uint32_t unicode);
}; // class UITextShaping }; // class UITextShaping
......
...@@ -83,6 +83,12 @@ RetCode CacheEntry::SetSrc(const char* path) ...@@ -83,6 +83,12 @@ RetCode CacheEntry::SetSrc(const char* path)
return RetCode::OK; return RetCode::OK;
} }
CacheManager& CacheManager::GetInstance()
{
static CacheManager instance;
return instance;
}
RetCode CacheManager::Init(uint16_t size) RetCode CacheManager::Init(uint16_t size)
{ {
if ((size == 0) || (size > MAX_CACHE_ENTRY_NUM)) { if ((size == 0) || (size > MAX_CACHE_ENTRY_NUM)) {
......
...@@ -64,11 +64,7 @@ private: ...@@ -64,11 +64,7 @@ private:
class CacheManager : public HeapBase { class CacheManager : public HeapBase {
public: public:
static CacheManager& GetInstance() static CacheManager& GetInstance();
{
static CacheManager instance;
return instance;
}
RetCode Init(uint16_t size); RetCode Init(uint16_t size);
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
#include "imgdecode/image_load.h" #include "imgdecode/image_load.h"
namespace OHOS { namespace OHOS {
FileImgDecoder& FileImgDecoder::GetInstance()
{
static FileImgDecoder instance;
return instance;
}
RetCode FileImgDecoder::Open(ImgResDsc& dsc) RetCode FileImgDecoder::Open(ImgResDsc& dsc)
{ {
#ifdef _WIN32 #ifdef _WIN32
......
...@@ -33,11 +33,7 @@ enum class RetCode { ...@@ -33,11 +33,7 @@ enum class RetCode {
class FileImgDecoder : public HeapBase { class FileImgDecoder : public HeapBase {
public: public:
static FileImgDecoder& GetInstance() static FileImgDecoder& GetInstance();
{
static FileImgDecoder instance;
return instance;
}
struct ImgResDsc { struct ImgResDsc {
FileImgDecoder* decoder; FileImgDecoder* decoder;
......
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
#include "themes/theme_manager.h" #include "themes/theme_manager.h"
namespace OHOS { namespace OHOS {
ThemeManager& ThemeManager::GetInstance()
{
static ThemeManager instance;
return instance;
}
void ThemeManager::SetCurrent(Theme* theme) void ThemeManager::SetCurrent(Theme* theme)
{ {
if (theme_ != nullptr) { if (theme_ != nullptr) {
......
...@@ -26,11 +26,7 @@ enum { ...@@ -26,11 +26,7 @@ enum {
}; };
class ImageDecodeAbility : public HeapBase { class ImageDecodeAbility : public HeapBase {
public: public:
static ImageDecodeAbility& GetInstance() static ImageDecodeAbility& GetInstance();
{
static ImageDecodeAbility instance;
return instance;
}
void SetImageDecodeAbility(uint32_t imageType) void SetImageDecodeAbility(uint32_t imageType)
{ {
......
...@@ -30,11 +30,7 @@ public: ...@@ -30,11 +30,7 @@ public:
* @brief Get instance of InputDeviceManager. * @brief Get instance of InputDeviceManager.
* @returns Instance of InputDeviceManager * @returns Instance of InputDeviceManager
*/ */
static InputDeviceManager* GetInstance() static InputDeviceManager* GetInstance();
{
static InputDeviceManager instance;
return &instance;
}
void Init() override; void Init() override;
......
...@@ -28,11 +28,7 @@ public: ...@@ -28,11 +28,7 @@ public:
* @brief return TaskManager's singleton * @brief return TaskManager's singleton
* @return TaskManager* * @return TaskManager*
*/ */
static TaskManager* GetInstance() static TaskManager* GetInstance();
{
static TaskManager taskManager;
return &taskManager;
}
/** /**
* @brief add task to task manager * @brief add task to task manager
......
...@@ -42,11 +42,7 @@ public: ...@@ -42,11 +42,7 @@ public:
* @since 5.0 * @since 5.0
* @version 3.0 * @version 3.0
*/ */
static FocusManager* GetInstance() static FocusManager* GetInstance();
{
static FocusManager instance;
return &instance;
}
/** /**
* @brief Clear the focus. * @brief Clear the focus.
......
...@@ -47,11 +47,7 @@ public: ...@@ -47,11 +47,7 @@ public:
* @since 5.0 * @since 5.0
* @version 3.0 * @version 3.0
*/ */
static VibratorManager* GetInstance() static VibratorManager* GetInstance();
{
static VibratorManager instance;
return &instance;
}
void RegisterVibratorFunc(VibratorFunc vibratorFunc) void RegisterVibratorFunc(VibratorFunc vibratorFunc)
{ {
......
...@@ -51,11 +51,7 @@ public: ...@@ -51,11 +51,7 @@ public:
* @brief Obtains a singleton <b>Screen</b> instance. * @brief Obtains a singleton <b>Screen</b> instance.
* @return Returns the <b>Screen</b> instance. * @return Returns the <b>Screen</b> instance.
*/ */
static Screen& GetInstance() static Screen& GetInstance();
{
static Screen instance;
return instance;
}
/** /**
* @brief Obtains the width of this screen. * @brief Obtains the width of this screen.
......
...@@ -74,11 +74,7 @@ public: ...@@ -74,11 +74,7 @@ public:
* @since 1.0 * @since 1.0
* @version 1.0 * @version 1.0
*/ */
static RootView* GetInstance() static RootView* GetInstance();
{
static RootView instance;
return &instance;
}
#if ENABLE_WINDOW #if ENABLE_WINDOW
/** /**
......
...@@ -70,11 +70,7 @@ public: ...@@ -70,11 +70,7 @@ public:
* @since 1.0 * @since 1.0
* @version 1.0 * @version 1.0
*/ */
static EventInjector* GetInstance() static EventInjector* GetInstance();
{
static EventInjector instance;
return &instance;
}
/** /**
* @brief Registers an event injector of a specified type. * @brief Registers an event injector of a specified type.
......
...@@ -70,11 +70,7 @@ public: ...@@ -70,11 +70,7 @@ public:
* @since 1.0 * @since 1.0
* @version 1.0 * @version 1.0
*/ */
static UIDumpDomTree* GetInstance() static UIDumpDomTree* GetInstance();
{
static UIDumpDomTree instance;
return &instance;
}
/** /**
* @brief Exports information about a DOM tree starting from a specified DOM node and saves the information to * @brief Exports information about a DOM tree starting from a specified DOM node and saves the information to
......
...@@ -64,11 +64,7 @@ public: ...@@ -64,11 +64,7 @@ public:
* @since 1.0 * @since 1.0
* @version 1.0 * @version 1.0
*/ */
static UIScreenshot* GetInstance() static UIScreenshot* GetInstance();
{
static UIScreenshot instance;
return &instance;
}
/** /**
* @brief Takes a screenshot and saves it to a file. * @brief Takes a screenshot and saves it to a file.
......
...@@ -51,11 +51,7 @@ public: ...@@ -51,11 +51,7 @@ public:
* *
* @return Returns the singleton instance of the <b>ThemeManager</b> class. * @return Returns the singleton instance of the <b>ThemeManager</b> class.
*/ */
static ThemeManager& GetInstance() static ThemeManager& GetInstance();
{
static ThemeManager instance;
return instance;
}
/** /**
* @brief Sets the current screen theme for this application. * @brief Sets the current screen theme for this application.
......
...@@ -29,11 +29,7 @@ namespace { ...@@ -29,11 +29,7 @@ namespace {
} }
class UITestApp { class UITestApp {
public: public:
static UITestApp* GetInstance() static UITestApp* GetInstance();
{
static UITestApp instance;
return &instance;
}
void Start(); void Start();
void Init(); void Init();
...@@ -56,11 +52,7 @@ private: ...@@ -56,11 +52,7 @@ private:
class UIAutoTestApp { class UIAutoTestApp {
public: public:
static UIAutoTestApp* GetInstance() static UIAutoTestApp* GetInstance();
{
static UIAutoTestApp instance;
return &instance;
}
void Start(); void Start();
private: private:
UIAutoTestApp() {} UIAutoTestApp() {}
......
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
#endif #endif
namespace OHOS { namespace OHOS {
UITestApp* UITestApp::GetInstance()
{
static UITestApp instance;
return &instance;
}
void UITestApp::Start() void UITestApp::Start()
{ {
if (rootView_ == nullptr) { if (rootView_ == nullptr) {
...@@ -107,6 +113,12 @@ UITestApp::~UITestApp() ...@@ -107,6 +113,12 @@ UITestApp::~UITestApp()
} }
} }
UIAutoTestApp* UIAutoTestApp::GetInstance()
{
static UIAutoTestApp instance;
return &instance;
}
void UIAutoTestApp::Start() void UIAutoTestApp::Start()
{ {
EventInjector::GetInstance()->RegisterEventInjector(EventDataType::POINT_TYPE); EventInjector::GetInstance()->RegisterEventInjector(EventDataType::POINT_TYPE);
......
/* /*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -35,6 +35,16 @@ ...@@ -35,6 +35,16 @@
namespace OHOS { namespace OHOS {
bool Monitor::isRegister_ = false; bool Monitor::isRegister_ = false;
Monitor* Monitor::GetInstance()
{
static Monitor instance;
if (!isRegister_) {
BaseGfxEngine::InitGfxEngine(&instance);
isRegister_ = true;
}
return &instance;
}
void Monitor::InitHal() void Monitor::InitHal()
{ {
#if USE_MOUSE #if USE_MOUSE
......
...@@ -26,16 +26,7 @@ class Monitor : public QObject, public BaseGfxEngine { ...@@ -26,16 +26,7 @@ class Monitor : public QObject, public BaseGfxEngine {
public: public:
Monitor() : defaultColor_ (0x44) {} Monitor() : defaultColor_ (0x44) {}
virtual ~Monitor() {} virtual ~Monitor() {}
static Monitor* GetInstance() static Monitor* GetInstance();
{
static Monitor instance;
if (!isRegister_) {
BaseGfxEngine::InitGfxEngine(&instance);
isRegister_ = true;
}
return &instance;
}
void InitHal(); void InitHal();
void InitFontEngine(); void InitFontEngine();
void InitImageDecodeAbility(); void InitImageDecodeAbility();
......
...@@ -27,6 +27,12 @@ static uint16_t g_lastKeyId = 0; ...@@ -27,6 +27,12 @@ static uint16_t g_lastKeyId = 0;
static uint16_t g_lastKeyState = INVALID_KEY_STATE; static uint16_t g_lastKeyState = INVALID_KEY_STATE;
} // namespace } // namespace
KeyInput* KeyInput::GetInstance()
{
static KeyInput keyInput;
return &keyInput;
}
bool KeyInput::Read(DeviceData& data) bool KeyInput::Read(DeviceData& data)
{ {
data.keyId = g_lastKeyId; data.keyId = g_lastKeyId;
......
...@@ -27,11 +27,7 @@ class KeyInput : public KeyInputDevice { ...@@ -27,11 +27,7 @@ class KeyInput : public KeyInputDevice {
public: public:
KeyInput() {} KeyInput() {}
virtual ~KeyInput() {} virtual ~KeyInput() {}
static KeyInput* GetInstance() static KeyInput* GetInstance();
{
static KeyInput keyInput;
return &keyInput;
}
bool Read(DeviceData& data) override; bool Read(DeviceData& data) override;
void KeyHandler(QKeyEvent* event); void KeyHandler(QKeyEvent* event);
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
namespace OHOS { namespace OHOS {
#if USE_MOUSE #if USE_MOUSE
MouseInput* MouseInput::GetInstance()
{
static MouseInput mouseInput;
return &mouseInput;
}
bool MouseInput::Read(DeviceData& data) bool MouseInput::Read(DeviceData& data)
{ {
data.point.x = lastX_; data.point.x = lastX_;
......
...@@ -27,11 +27,7 @@ class MouseInput : public PointerInputDevice { ...@@ -27,11 +27,7 @@ class MouseInput : public PointerInputDevice {
public: public:
MouseInput() : leftButtonDown_(false), lastX_(0), lastY_(0) {} MouseInput() : leftButtonDown_(false), lastX_(0), lastY_(0) {}
virtual ~MouseInput() {} virtual ~MouseInput() {}
static MouseInput* GetInstance() static MouseInput* GetInstance();
{
static MouseInput mouseInput;
return &mouseInput;
}
bool Read(DeviceData& data) override; bool Read(DeviceData& data) override;
void MouseHandler(QMouseEvent* event); void MouseHandler(QMouseEvent* event);
......
...@@ -22,6 +22,12 @@ static int16_t g_rotate = 0; ...@@ -22,6 +22,12 @@ static int16_t g_rotate = 0;
namespace OHOS { namespace OHOS {
#if USE_MOUSEWHEEL #if USE_MOUSEWHEEL
#if ENABLE_ROTATE_INPUT #if ENABLE_ROTATE_INPUT
MousewheelInput* MousewheelInput::GetInstance()
{
static MousewheelInput mousewheelInput;
return &mousewheelInput;
}
bool MousewheelInput::Read(DeviceData &data) bool MousewheelInput::Read(DeviceData &data)
{ {
data.rotate = g_rotate; data.rotate = g_rotate;
......
...@@ -26,11 +26,7 @@ class MousewheelInput : public RotateInputDevice { ...@@ -26,11 +26,7 @@ class MousewheelInput : public RotateInputDevice {
public: public:
MousewheelInput() {} MousewheelInput() {}
virtual ~MousewheelInput() {} virtual ~MousewheelInput() {}
static MousewheelInput* GetInstance() static MousewheelInput* GetInstance();
{
static MousewheelInput mousewheelInput;
return &mousewheelInput;
}
bool Read(DeviceData& data) override; bool Read(DeviceData& data) override;
void MousewheelHandler(QWheelEvent* event); void MousewheelHandler(QWheelEvent* event);
}; };
......
...@@ -36,6 +36,7 @@ SOURCES += \ ...@@ -36,6 +36,7 @@ SOURCES += \
../../../../frameworks/animator/easing_equation.cpp \ ../../../../frameworks/animator/easing_equation.cpp \
../../../../frameworks/animator/interpolation.cpp \ ../../../../frameworks/animator/interpolation.cpp \
../../../../frameworks/common/graphic_startup.cpp \ ../../../../frameworks/common/graphic_startup.cpp \
../../../../frameworks/common/image_decode_ability.cpp \
../../../../frameworks/common/image.cpp \ ../../../../frameworks/common/image.cpp \
../../../../frameworks/common/input_device_manager.cpp \ ../../../../frameworks/common/input_device_manager.cpp \
../../../../frameworks/common/screen.cpp \ ../../../../frameworks/common/screen.cpp \
...@@ -81,12 +82,15 @@ SOURCES += \ ...@@ -81,12 +82,15 @@ SOURCES += \
../../../../frameworks/default_resource/check_box_res.cpp \ ../../../../frameworks/default_resource/check_box_res.cpp \
../../../../frameworks/dfx/event_injector.cpp \ ../../../../frameworks/dfx/event_injector.cpp \
../../../../frameworks/dfx/key_event_injector.cpp \ ../../../../frameworks/dfx/key_event_injector.cpp \
../../../../frameworks/dfx/performance_task.cpp \
../../../../frameworks/dfx/point_event_injector.cpp \ ../../../../frameworks/dfx/point_event_injector.cpp \
../../../../frameworks/dfx/ui_dump_dom_tree.cpp \ ../../../../frameworks/dfx/ui_dump_dom_tree.cpp \
../../../../frameworks/dock/input_device.cpp \ ../../../../frameworks/dock/input_device.cpp \
../../../../frameworks/dock/key_input_device.cpp \ ../../../../frameworks/dock/key_input_device.cpp \
../../../../frameworks/dock/pointer_input_device.cpp \ ../../../../frameworks/dock/pointer_input_device.cpp \
../../../../frameworks/dock/rotate_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/dock/virtual_input_device.cpp \
../../../../frameworks/engines/gfx/gfx_engine_manager.cpp \ ../../../../frameworks/engines/gfx/gfx_engine_manager.cpp \
../../../../frameworks/draw/draw_arc.cpp \ ../../../../frameworks/draw/draw_arc.cpp \
...@@ -121,6 +125,7 @@ SOURCES += \ ...@@ -121,6 +125,7 @@ SOURCES += \
../../../../../utils/frameworks/color.cpp \ ../../../../../utils/frameworks/color.cpp \
../../../../../utils/frameworks/geometry2d.cpp \ ../../../../../utils/frameworks/geometry2d.cpp \
../../../../../utils/frameworks/graphic_math.cpp \ ../../../../../utils/frameworks/graphic_math.cpp \
../../../../../utils/frameworks/graphic_performance.cpp \
../../../../../utils/frameworks/hal_tick.cpp \ ../../../../../utils/frameworks/hal_tick.cpp \
../../../../../utils/frameworks/mem_api.cpp \ ../../../../../utils/frameworks/mem_api.cpp \
../../../../../utils/frameworks/style.cpp \ ../../../../../utils/frameworks/style.cpp \
......
...@@ -22,6 +22,7 @@ graphic_ui_sources = [ ...@@ -22,6 +22,7 @@ graphic_ui_sources = [
"$GRAPHIC_UI_PATH/frameworks/animator/easing_equation.cpp", "$GRAPHIC_UI_PATH/frameworks/animator/easing_equation.cpp",
"$GRAPHIC_UI_PATH/frameworks/animator/interpolation.cpp", "$GRAPHIC_UI_PATH/frameworks/animator/interpolation.cpp",
"$GRAPHIC_UI_PATH/frameworks/common/graphic_startup.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/image.cpp",
"$GRAPHIC_UI_PATH/frameworks/common/input_device_manager.cpp", "$GRAPHIC_UI_PATH/frameworks/common/input_device_manager.cpp",
"$GRAPHIC_UI_PATH/frameworks/common/screen.cpp", "$GRAPHIC_UI_PATH/frameworks/common/screen.cpp",
...@@ -67,12 +68,14 @@ graphic_ui_sources = [ ...@@ -67,12 +68,14 @@ graphic_ui_sources = [
"$GRAPHIC_UI_PATH/frameworks/default_resource/check_box_res.cpp", "$GRAPHIC_UI_PATH/frameworks/default_resource/check_box_res.cpp",
"$GRAPHIC_UI_PATH/frameworks/dfx/event_injector.cpp", "$GRAPHIC_UI_PATH/frameworks/dfx/event_injector.cpp",
"$GRAPHIC_UI_PATH/frameworks/dfx/key_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/point_event_injector.cpp",
"$GRAPHIC_UI_PATH/frameworks/dfx/ui_dump_dom_tree.cpp", "$GRAPHIC_UI_PATH/frameworks/dfx/ui_dump_dom_tree.cpp",
"$GRAPHIC_UI_PATH/frameworks/dock/input_device.cpp", "$GRAPHIC_UI_PATH/frameworks/dock/input_device.cpp",
"$GRAPHIC_UI_PATH/frameworks/dock/key_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/pointer_input_device.cpp",
"$GRAPHIC_UI_PATH/frameworks/dock/screen_device_proxy.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/dock/virtual_input_device.cpp",
"$GRAPHIC_UI_PATH/frameworks/draw/draw_arc.cpp", "$GRAPHIC_UI_PATH/frameworks/draw/draw_arc.cpp",
"$GRAPHIC_UI_PATH/frameworks/draw/draw_curve.cpp", "$GRAPHIC_UI_PATH/frameworks/draw/draw_curve.cpp",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册