IssueNo:#I423M9

Description:modify graphic timer for cmsis
Sig:graphic
Feature or Bugfix:Bugfix
Binary Source:No

Signed-off-by: YueBiang <suyue7@huawei.com>
This commit is contained in:
YueBiang
2021-07-26 10:22:34 +08:00
parent b6e4f72e23
commit 750b9b247f
3 changed files with 74 additions and 3 deletions
+64
View File
@@ -17,6 +17,7 @@
#include "gfx_utils/graphic_log.h"
#ifdef _WIN32
#include "windows.h"
#elif defined(_LITEOS)
#else
#include <cerrno>
#include <csignal>
@@ -131,6 +132,69 @@ void GraphicTimer::Stop()
}
}
#elif defined(_LITEOS)
static void TimerCallback(void* args)
{
GraphicTimer* timer = reinterpret_cast<GraphicTimer*>(args);
if (timer != nullptr) {
timer->Callback();
}
}
GraphicTimer::GraphicTimer(int32_t periodMs, GraphicTimerCb cb, void* arg, bool isPeriodic)
: cb_(cb), arg_(arg), isPeriodic_(isPeriodic)
{
if ((periodMs > MAX_PERIOD_MS) || (periodMs <= 0)) {
GRAPHIC_LOGE("Timer create failed, period should be within (0, %d].(period=%d)", MAX_PERIOD_MS, periodMs);
return;
}
osTimerType_t timerType = isPeriodic ? osTimerPeriodic : osTimerOnce;
timer_ = osTimerNew(reinterpret_cast<osTimerFunc_t>(TimerCallback), timerType, this, nullptr);
if (timer_ == nullptr) {
GRAPHIC_LOGE("Timer create failed");
return;
}
periodMs_ = periodMs;
}
GraphicTimer::~GraphicTimer()
{
if (periodMs_ >= 0) {
osStatus_t ret = osTimerDelete(timer_);
if (ret != osStatus_t::osOK) {
GRAPHIC_LOGE("Timer delete failed.");
}
}
}
bool GraphicTimer::Start()
{
if (periodMs_ < 0) {
GRAPHIC_LOGE("Timer start failed, timer should be created first.");
return false;
}
osStatus_t ret = osTimerStart(timer_, periodMs_);
if (ret != osStatus_t::osOK) {
GRAPHIC_LOGE("Timer start failed.");
return false;
}
return true;
}
void GraphicTimer::Stop()
{
if (periodMs_ < 0) {
return;
}
osStatus_t ret = osTimerStop(timer_);
bool isRunning = osTimerIsRunning(timer_);
if ((ret != osStatus_t::osOK) || (isRunning)) {
GRAPHIC_LOGE("Timer stop failed.");
return;
}
}
#else
static void TimerCallback(union sigval v)
{
+2 -2
View File
@@ -295,12 +295,12 @@ void StyleDefault::InitScrollBarStyle()
scrollBarBackgroundStyle_.SetStyle(STYLE_LINE_COLOR,
Color::GetColorFromRGB(0x7f, 0x7f, 0x7f).full); // 0x7f: default color
scrollBarBackgroundStyle_.SetStyle(STYLE_LINE_OPA, 128); // 128: default opa
scrollBarBackgroundStyle_.SetStyle(STYLE_LINE_WIDTH, 4); // 4: default width
scrollBarBackgroundStyle_.SetStyle(STYLE_LINE_WIDTH, 8); // 8: default width
scrollBarForegroundStyle_.SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
scrollBarForegroundStyle_.SetStyle(STYLE_BACKGROUND_OPA, 168); // 168: default opa
scrollBarForegroundStyle_.SetStyle(STYLE_LINE_COLOR, Color::White().full);
scrollBarForegroundStyle_.SetStyle(STYLE_LINE_OPA, 168); // 168: default opa
scrollBarForegroundStyle_.SetStyle(STYLE_LINE_WIDTH, 3); // 3: default width
scrollBarForegroundStyle_.SetStyle(STYLE_LINE_WIDTH, 6); // 6: default width
}
} // namespace OHOS
+8 -1
View File
@@ -17,7 +17,10 @@
#define GRAPHIC_LITE_TIMER_H
#include <cstdint>
#ifndef _WIN32
#ifdef _WIN32
#elif defined(_LITEOS)
#include "cmsis_os2.h"
#else
#include <ctime>
#endif
@@ -37,6 +40,8 @@ public:
#ifdef _WIN32
void* GetNativeTimer()
#elif defined(_LITEOS)
osTimerId_t GetNativeTimer()
#else
timer_t GetNativeTimer()
#endif
@@ -67,6 +72,8 @@ private:
#ifdef _WIN32
void* timer_ = nullptr;
#elif defined(_LITEOS)
osTimerId_t timer_;
#else
timer_t timer_;
#endif