diff --git a/services/ui/driver/graphic_engine.cpp b/services/ui/driver/graphic_engine.cpp index ba95193db9d7c5a9e64899a120cb100536e398b6..8dc6c86eae0c0476ac78a650b9a25ca41fc1a3b1 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 pc, not set backlight"; +} + void GraphicEngine::FlushThreadLoop() const { while (!flushStop_) { @@ -110,18 +115,27 @@ void GraphicEngine::FlushThreadLoop() const 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_) { + 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..a036388ab658f01e97e307494e32aee78f01c683 100644 --- a/services/ui/driver/graphic_engine.h +++ b/services/ui/driver/graphic_engine.h @@ -38,6 +38,7 @@ public: uint16_t GetScreenHeight() override; void StopEngine(void); void SetSleepTime(uint32_t sleepTime); + void DisableClearStop(void); void HandleScreenPowerDown(bool blank); private: void FlushThreadLoop() 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 }