From 0ffbd10584a535e631334e759d51373aa775fcb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=82=AC?= Date: Thu, 22 May 2025 08:05:48 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8memcpy=5Fs=20=E4=BB=A3?= =?UTF-8?q?=E6=9B=BF=20for=E5=BE=AA=E7=8E=AF=E6=8F=90=E9=AB=98=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄悬 --- services/ui/driver/ui_rotation.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/services/ui/driver/ui_rotation.cpp b/services/ui/driver/ui_rotation.cpp index 6c805c71..2e3fb3b0 100644 --- a/services/ui/driver/ui_rotation.cpp +++ b/services/ui/driver/ui_rotation.cpp @@ -108,14 +108,22 @@ void UiRotation::RotateBuffer(const uint8_t *origBuf, uint8_t *dstBuf, uint32_t int x {}, y {}; const uint8_t *srcP = nullptr; uint8_t *dstP = nullptr; - for (int h = rect_.GetTop(); h <= rect_.GetBottom(); h++) { - for (int w = rect_.GetLeft(); w <= rect_.GetRight(); w++) { + int top = rect_.GetTop(); + int bottom = rect_.GetBottom(); + int left = rect_.GetLeft(); + int right = rect_.GetRight(); + for (int h = top; h < bottom; h++) { + for (int w = left; w < right; w++) { x = offsetX_ + w * cosR_ - h * sinR_; y = offsetY_ + h * cosR_ + w * sinR_; srcP = origBuf + h * oldRowBytes_ + w * pixelBytes_; dstP = dstBuf + y * newRowBytes_ + x * pixelBytes_; - for (int j = 0; j < pixelBytes_; j++) { - *dstP++ = *srcP++; + if (memcpy_s(dstP, pixelBytes_, srcP, pixelBytes_) != EOK) { + LOG(ERROR) << "flip memcpy_s fail " << "w = " << w << " h = " << h; + return; + } else { + srcP += pixelBytes_; + dstP += pixelBytes_; } } } -- Gitee