diff --git a/services/ui/driver/graphic_engine.cpp b/services/ui/driver/graphic_engine.cpp index ba95193db9d7c5a9e64899a120cb100536e398b6..1ec595f3a0fad3c59ab51f859bb1f62d28b4f601 100644 --- a/services/ui/driver/graphic_engine.cpp +++ b/services/ui/driver/graphic_engine.cpp @@ -102,6 +102,11 @@ __attribute__((weak)) void InitFlushBatteryStatusExt(void) { } +__attribute__((weak)) void SetBrightness(int value) +{ + LOG(INFO) << "not set backlight"; +} + void GraphicEngine::FlushThreadLoop() const { while (!flushStop_) { @@ -109,19 +114,28 @@ void GraphicEngine::FlushThreadLoop() const InitFlushBatteryStatusExt(); Utils::UsSleep(sleepTime_); } - // clear screen after stop - UiRotation::GetInstance().SetDegree(UI_ROTATION_DEGREE::UI_ROTATION_0); - uint8_t pixelBytes = OHOS::DrawUtils::GetByteSizeByColorMode(colorMode_); - uint32_t picSize = 0; - if (__builtin_mul_overflow(width_ * height_, pixelBytes, &picSize)) { - return; + LOG(INFO) << "disable clear stop stopClear_ = " << stopClear_; + if (stopClear_) { + // clear screen after stop + UiRotation::GetInstance().SetDegree(UI_ROTATION_DEGREE::UI_ROTATION_0); + uint8_t pixelBytes = OHOS::DrawUtils::GetByteSizeByColorMode(colorMode_); + uint32_t picSize = 0; + if (__builtin_mul_overflow(width_ * height_, pixelBytes, &picSize)) { + return; + } + (void)memset_s(buffInfo_->virAddr, picSize, 0, picSize); + sfDev_->Flip(reinterpret_cast(buffInfo_->virAddr)); } - (void)memset_s(buffInfo_->virAddr, picSize, 0, picSize); - sfDev_->Flip(reinterpret_cast(buffInfo_->virAddr)); +} + +void GraphicEngine::DisableClearStop(void) +{ + stopClear_ = false; } void GraphicEngine::StopEngine(void) { + SetBrightness(0); flushStop_ = true; Utils::UsSleep(THREAD_USLEEP_TIME * 10); // 10: wait for stop 100ms } diff --git a/services/ui/driver/graphic_engine.h b/services/ui/driver/graphic_engine.h index c80dba19878dfab33f29f578479a5a064e918cca..b7719db877d72edda49ce7b09baf183f33351e1d 100644 --- a/services/ui/driver/graphic_engine.h +++ b/services/ui/driver/graphic_engine.h @@ -39,6 +39,7 @@ public: void StopEngine(void); void SetSleepTime(uint32_t sleepTime); void HandleScreenPowerDown(bool blank); + void DisableClearStop(void); private: void FlushThreadLoop() const; void InitFontEngine(const char *fontPath) const; @@ -53,6 +54,7 @@ private: uint16_t width_ = 0; uint8_t colorMode_ = 0; bool flushStop_ = true; + bool stopClear_ = true; uint32_t sleepTime_ = THREAD_USLEEP_TIME; std::mutex mtx_ {}; }; @@ -64,6 +66,7 @@ extern "C" { #endif /* __cplusplus */ void InitFlushBatteryStatusExt(void); void PostInitSurfDev(std::unique_ptr &surfDev, GrSurface &surface); +void SetBrightness(int value); #ifdef __cplusplus #if __cplusplus }