未验证 提交 5476da58 编写于 作者: O openharmony_ci 提交者: Gitee

!584 修改编译告警

Merge pull request !584 from niulihua/master
...@@ -33,16 +33,9 @@ Image::~Image() ...@@ -33,16 +33,9 @@ Image::~Image()
if (srcType_ == IMG_SRC_FILE) { if (srcType_ == IMG_SRC_FILE) {
CacheManager::GetInstance().Close(path_); CacheManager::GetInstance().Close(path_);
} }
if (imageInfo_ != nullptr) {
if (mallocFlag_) { ReInitImageInfo(nullptr, false);
if (imageInfo_->data != nullptr) {
UIFree(reinterpret_cast<void*>(const_cast<uint8_t*>(imageInfo_->data)));
}
mallocFlag_ = false;
}
UIFree(reinterpret_cast<void*>(const_cast<ImageInfo*>(imageInfo_)));
imageInfo_ = nullptr;
}
if (path_ != nullptr) { if (path_ != nullptr) {
UIFree(reinterpret_cast<void*>(const_cast<char*>(path_))); UIFree(reinterpret_cast<void*>(const_cast<char*>(path_)));
path_ = nullptr; path_ = nullptr;
...@@ -92,9 +85,10 @@ bool Image::SetStandardSrc(const char* src) ...@@ -92,9 +85,10 @@ bool Image::SetStandardSrc(const char* src)
if (src == nullptr) { if (src == nullptr) {
return false; return false;
} }
srcType_ = IMG_SRC_UNKNOWN;
const char* ptr = strrchr(src, '.'); const char* ptr = strrchr(src, '.');
if (ptr == nullptr) { if (ptr == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
...@@ -110,14 +104,12 @@ bool Image::SetStandardSrc(const char* src) ...@@ -110,14 +104,12 @@ bool Image::SetStandardSrc(const char* src)
size_t strLen = strlen(src) + 1; size_t strLen = strlen(src) + 1;
char* imagePath = static_cast<char*>(UIMalloc(static_cast<uint32_t>(strLen))); char* imagePath = static_cast<char*>(UIMalloc(static_cast<uint32_t>(strLen)));
if (imagePath == nullptr) { if (imagePath == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
if (strcpy_s(imagePath, strLen, src) != EOK) { if (strcpy_s(imagePath, strLen, src) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath)); UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr; imagePath = nullptr;
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
path_ = imagePath; path_ = imagePath;
...@@ -130,16 +122,16 @@ bool Image::SetLiteSrc(const char* src) ...@@ -130,16 +122,16 @@ bool Image::SetLiteSrc(const char* src)
if (src == nullptr) { if (src == nullptr) {
return false; return false;
} }
srcType_ = IMG_SRC_UNKNOWN;
const char* ptr = strrchr(src, '.'); const char* ptr = strrchr(src, '.');
if (ptr == nullptr) { if (ptr == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
size_t strLen = strlen(src) + 1; size_t strLen = strlen(src) + 1;
char* imagePath = static_cast<char*>(UIMalloc(static_cast<uint32_t>(strLen))); char* imagePath = static_cast<char*>(UIMalloc(static_cast<uint32_t>(strLen)));
if (imagePath == nullptr) { if (imagePath == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
if (IsImgValid(ptr)) { if (IsImgValid(ptr)) {
...@@ -147,21 +139,18 @@ bool Image::SetLiteSrc(const char* src) ...@@ -147,21 +139,18 @@ bool Image::SetLiteSrc(const char* src)
if (memcpy_s(imagePath, strLen, src, strLen) != EOK) { if (memcpy_s(imagePath, strLen, src, strLen) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath)); UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr; imagePath = nullptr;
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
(ptr - src + imagePath)[1] = '\0'; // remove suffix (ptr - src + imagePath)[1] = '\0'; // remove suffix
if (strcat_s(imagePath, strLen, suffixName) != EOK) { if (strcat_s(imagePath, strLen, suffixName) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath)); UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr; imagePath = nullptr;
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
} else { } else {
if (memcpy_s(imagePath, strLen, src, strLen) != EOK) { if (memcpy_s(imagePath, strLen, src, strLen) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath)); UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr; imagePath = nullptr;
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
} }
...@@ -184,43 +173,30 @@ bool Image::SetSrc(const char* src) ...@@ -184,43 +173,30 @@ bool Image::SetSrc(const char* src)
return SetStandardSrc(src); return SetStandardSrc(src);
} }
return SetLiteSrc(src); return SetLiteSrc(src);
} else {
path_ = src;
srcType_ = IMG_SRC_UNKNOWN;
} }
srcType_ = IMG_SRC_UNKNOWN;
return true; return true;
} }
bool Image::SetSrc(const ImageInfo* src) bool Image::SetSrc(const ImageInfo* src)
{ {
if (imageInfo_ != nullptr) { ReInitImageInfo(nullptr, false);
if (mallocFlag_) { srcType_ = IMG_SRC_UNKNOWN;
if (imageInfo_->data != nullptr) { imageInfo_ = nullptr;
UIFree(reinterpret_cast<void*>(const_cast<uint8_t*>(imageInfo_->data)));
}
mallocFlag_ = false;
}
UIFree(reinterpret_cast<void*>(const_cast<ImageInfo*>(imageInfo_)));
imageInfo_ = nullptr;
}
if (src != nullptr) { if (src != nullptr) {
imageInfo_ = static_cast<ImageInfo*>(UIMalloc(static_cast<uint32_t>(sizeof(ImageInfo)))); imageInfo_ = static_cast<ImageInfo*>(UIMalloc(static_cast<uint32_t>(sizeof(ImageInfo))));
if (imageInfo_ == nullptr) { if (imageInfo_ == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
if (memcpy_s(const_cast<ImageInfo*>(imageInfo_), sizeof(ImageInfo), src, sizeof(ImageInfo)) != EOK) { if (memcpy_s(const_cast<ImageInfo*>(imageInfo_), sizeof(ImageInfo), src, sizeof(ImageInfo)) != EOK) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
srcType_ = IMG_SRC_VARIABLE; srcType_ = IMG_SRC_VARIABLE;
} else {
imageInfo_ = src;
srcType_ = IMG_SRC_UNKNOWN;
} }
return true; return true;
} }
...@@ -240,24 +216,50 @@ void Image::DrawImage(BufferInfo& gfxDstBuffer, ...@@ -240,24 +216,50 @@ void Image::DrawImage(BufferInfo& gfxDstBuffer,
} }
#if ENABLE_JPEG_AND_PNG #if ENABLE_JPEG_AND_PNG
static inline void FreePngBytep(png_bytep** rowPointer, uint16_t size)
{
png_bytep* tmpRowPointer = *rowPointer;
for (uint16_t i = 0; i < size; i++) {
UIFree(tmpRowPointer[i]);
tmpRowPointer[i] = nullptr;
}
UIFree(*rowPointer);
*rowPointer = nullptr;
}
static inline png_bytep* MallocPngBytep(uint16_t height, uint32_t rowBytes)
{
png_bytep* rowPointer = static_cast<png_bytep*>(UIMalloc(sizeof(png_bytep) * height));
if (rowPointer == nullptr) {
return nullptr;
}
for (uint16_t y = 0; y < height; y++) {
rowPointer[y] = static_cast<png_byte*>(UIMalloc(rowBytes));
if (rowPointer[y] == nullptr) {
FreePngBytep(&rowPointer, y);
return nullptr;
}
}
return rowPointer;
}
bool Image::SetPNGSrc(const char* src) bool Image::SetPNGSrc(const char* src)
{ {
srcType_ = IMG_SRC_UNKNOWN;
FILE* infile = nullptr; FILE* infile = nullptr;
png_bytep* rowPointer = nullptr; png_bytep* rowPointer = nullptr;
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (png == nullptr) { if (png == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
png_infop info = png_create_info_struct(png); png_infop info = png_create_info_struct(png);
if (info == nullptr) { if (info == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
png_destroy_read_struct(&png, &info, nullptr); png_destroy_read_struct(&png, &info, nullptr);
return false; return false;
} }
if ((infile = fopen(src, "rb")) == nullptr) { if ((infile = fopen(src, "rb")) == nullptr) {
GRAPHIC_LOGE("can't open %s\n", src); GRAPHIC_LOGE("can't open %s\n", src);
srcType_ = IMG_SRC_UNKNOWN;
png_destroy_read_struct(&png, &info, nullptr); png_destroy_read_struct(&png, &info, nullptr);
return false; return false;
} }
...@@ -292,49 +294,26 @@ bool Image::SetPNGSrc(const char* src) ...@@ -292,49 +294,26 @@ bool Image::SetPNGSrc(const char* src)
png_set_interlace_handling(png); png_set_interlace_handling(png);
png_read_update_info(png, info); png_read_update_info(png, info);
rowPointer = static_cast<png_bytep*>(UIMalloc(sizeof(png_bytep) * height)); rowPointer = MallocPngBytep(height, png_get_rowbytes(png, info));
if (rowPointer == nullptr) { if (rowPointer == nullptr) {
srcType_ = IMG_SRC_UNKNOWN;
fclose(infile); fclose(infile);
png_destroy_read_struct(&png, &info, nullptr); png_destroy_read_struct(&png, &info, nullptr);
return false; return false;
} }
for (uint16_t y = 0; y < height; y++) {
rowPointer[y] = static_cast<png_byte*>(UIMalloc(png_get_rowbytes(png, info)));
if (rowPointer[y] == nullptr) {
for (uint16_t i = 0; i < y; i++) {
UIFree(rowPointer[i]);
rowPointer[i] = nullptr;
}
fclose(infile);
UIFree(rowPointer);
srcType_ = IMG_SRC_UNKNOWN;
png_destroy_read_struct(&png, &info, nullptr);
return false;
}
}
png_read_image(png, rowPointer); png_read_image(png, rowPointer);
fclose(infile); fclose(infile);
png_destroy_read_struct(&png, &info, nullptr); png_destroy_read_struct(&png, &info, nullptr);
ImageInfo* imgInfo = static_cast<ImageInfo*>(UIMalloc(sizeof(ImageInfo))); ImageInfo* imgInfo = static_cast<ImageInfo*>(UIMalloc(sizeof(ImageInfo)));
if (imgInfo == nullptr) { if (imgInfo == nullptr) {
for (uint16_t i = 0; i < height; i++) { FreePngBytep(&rowPointer, height);
UIFree(rowPointer[i]);
rowPointer[i] = nullptr;
}
UIFree(rowPointer);
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
uint8_t* srcData = static_cast<uint8_t*>(UIMalloc(dataSize)); uint8_t* srcData = static_cast<uint8_t*>(UIMalloc(dataSize));
if (srcData == nullptr) { if (srcData == nullptr) {
for (uint16_t i = 0; i < height; i++) { FreePngBytep(&rowPointer, height);
UIFree(rowPointer[i]);
rowPointer[i] = nullptr;
}
UIFree(rowPointer);
UIFree(imgInfo); UIFree(imgInfo);
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
uint32_t n = 0; uint32_t n = 0;
...@@ -346,10 +325,8 @@ bool Image::SetPNGSrc(const char* src) ...@@ -346,10 +325,8 @@ bool Image::SetPNGSrc(const char* src)
srcData[n++] = row[x + 0]; // 0: R channel srcData[n++] = row[x + 0]; // 0: R channel
srcData[n++] = row[x + 3]; // 3: Alpha channel srcData[n++] = row[x + 3]; // 3: Alpha channel
} }
UIFree(row);
row = nullptr;
} }
UIFree(rowPointer); FreePngBytep(&rowPointer, height);
imgInfo->header.width = width; imgInfo->header.width = width;
imgInfo->header.height = height; imgInfo->header.height = height;
...@@ -357,18 +334,7 @@ bool Image::SetPNGSrc(const char* src) ...@@ -357,18 +334,7 @@ bool Image::SetPNGSrc(const char* src)
imgInfo->dataSize = dataSize; imgInfo->dataSize = dataSize;
imgInfo->data = srcData; imgInfo->data = srcData;
if (imageInfo_ != nullptr) { ReInitImageInfo(imgInfo, true);
if (mallocFlag_) {
if (imageInfo_->data != nullptr) {
UIFree(reinterpret_cast<void*>(const_cast<uint8_t*>(imageInfo_->data)));
}
mallocFlag_ = false;
}
UIFree(reinterpret_cast<void*>(const_cast<ImageInfo*>(imageInfo_)));
imageInfo_ = nullptr;
}
imageInfo_ = imgInfo;
mallocFlag_ = true;
srcType_ = IMG_SRC_VARIABLE; srcType_ = IMG_SRC_VARIABLE;
return true; return true;
} }
...@@ -378,10 +344,10 @@ bool Image::SetJPEGSrc(const char* src) ...@@ -378,10 +344,10 @@ bool Image::SetJPEGSrc(const char* src)
struct jpeg_decompress_struct cinfo; struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
FILE* infile = nullptr; FILE* infile = nullptr;
srcType_ = IMG_SRC_UNKNOWN;
if ((infile = fopen(src, "rb")) == nullptr) { if ((infile = fopen(src, "rb")) == nullptr) {
GRAPHIC_LOGE("can't open %s\n", src); GRAPHIC_LOGE("can't open %s\n", src);
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
...@@ -402,7 +368,6 @@ bool Image::SetJPEGSrc(const char* src) ...@@ -402,7 +368,6 @@ bool Image::SetJPEGSrc(const char* src)
jpeg_finish_decompress(&cinfo); jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
fclose(infile); fclose(infile);
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
uint8_t* srcData = static_cast<uint8_t*>(UIMalloc(dataSize)); uint8_t* srcData = static_cast<uint8_t*>(UIMalloc(dataSize));
...@@ -411,7 +376,6 @@ bool Image::SetJPEGSrc(const char* src) ...@@ -411,7 +376,6 @@ bool Image::SetJPEGSrc(const char* src)
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
fclose(infile); fclose(infile);
UIFree(imgInfo); UIFree(imgInfo);
srcType_ = IMG_SRC_UNKNOWN;
return false; return false;
} }
uint32_t n = 0; uint32_t n = 0;
...@@ -434,20 +398,22 @@ bool Image::SetJPEGSrc(const char* src) ...@@ -434,20 +398,22 @@ bool Image::SetJPEGSrc(const char* src)
imgInfo->dataSize = dataSize; imgInfo->dataSize = dataSize;
imgInfo->data = srcData; imgInfo->data = srcData;
if (imageInfo_ != nullptr) { ReInitImageInfo(imgInfo, true);
if (mallocFlag_) {
if (imageInfo_->data != nullptr) {
UIFree(reinterpret_cast<void*>(const_cast<uint8_t*>(imageInfo_->data)));
}
mallocFlag_ = false;
}
UIFree(reinterpret_cast<void*>(const_cast<ImageInfo*>(imageInfo_)));
imageInfo_ = nullptr;
}
imageInfo_ = imgInfo;
mallocFlag_ = true;
srcType_ = IMG_SRC_VARIABLE; srcType_ = IMG_SRC_VARIABLE;
return true; return true;
} }
#endif #endif
void Image::ReInitImageInfo(ImageInfo* imgInfo, bool mallocFlag)
{
if (mallocFlag_) {
if (imageInfo_->data != nullptr) {
UIFree(reinterpret_cast<void*>(const_cast<uint8_t*>(imageInfo_->data)));
}
}
UIFree(reinterpret_cast<void*>(const_cast<ImageInfo*>(imageInfo_)));
imageInfo_ = imgInfo;
mallocFlag_ = mallocFlag;
}
} // namespace OHOS } // namespace OHOS
\ No newline at end of file
...@@ -92,7 +92,7 @@ void UIArcScrollBar::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invali ...@@ -92,7 +92,7 @@ void UIArcScrollBar::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invali
if ((startAngle > endAngle_) || (endAngle < startAngle_)) { if ((startAngle > endAngle_) || (endAngle < startAngle_)) {
return; return;
} }
ArcInfo arcInfo = {0}; ArcInfo arcInfo = {{0, 0}, {0, 0}, 0, 0, 0, nullptr};
arcInfo.radius = (radius_ > 0) ? (radius_ - 1) : 0; arcInfo.radius = (radius_ > 0) ? (radius_ - 1) : 0;
arcInfo.center = center_; arcInfo.center = center_;
arcInfo.startAngle = MATH_MAX(startAngle, startAngle_); arcInfo.startAngle = MATH_MAX(startAngle, startAngle_);
...@@ -103,7 +103,7 @@ void UIArcScrollBar::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invali ...@@ -103,7 +103,7 @@ void UIArcScrollBar::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invali
void UIArcScrollBar::DrawBackground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, uint8_t backgroundOpa) void UIArcScrollBar::DrawBackground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, uint8_t backgroundOpa)
{ {
ArcInfo arcInfo = {0}; ArcInfo arcInfo = {{0, 0}, {0, 0}, 0, 0, 0, nullptr};
arcInfo.radius = radius_; arcInfo.radius = radius_;
arcInfo.center = center_; arcInfo.center = center_;
arcInfo.startAngle = startAngle_; arcInfo.startAngle = startAngle_;
......
...@@ -41,15 +41,6 @@ void ScreenDeviceProxy::OnRenderFinish(const Rect& mask) ...@@ -41,15 +41,6 @@ void ScreenDeviceProxy::OnRenderFinish(const Rect& mask)
void ScreenDeviceProxy::DrawAnimatorBuffer(const Rect& invalidatedArea) void ScreenDeviceProxy::DrawAnimatorBuffer(const Rect& invalidatedArea)
{ {
Rect invalidRect = curViewRect_;
transMap_.SetTransMapRect(curViewRect_);
invalidRect.Join(invalidRect, transMap_.GetBoxRect());
if (invalidRect.Intersect(invalidRect, invalidatedArea)) {
uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(animatorImageInfo_.header.colorMode);
TransformDataInfo imageTranDataInfo = {animatorImageInfo_.header, animatorImageInfo_.data, pxSize, LEVEL0,
BILINEAR};
}
} }
void ScreenDeviceProxy::SetAnimatorRect(const Rect& rect) void ScreenDeviceProxy::SetAnimatorRect(const Rect& rect)
......
...@@ -146,10 +146,6 @@ namespace OHOS { ...@@ -146,10 +146,6 @@ namespace OHOS {
ASSERT(0); \ ASSERT(0); \
} }
#ifdef VERSION_STANDARD
const int16_t HARDWARE_ACC_SIZE_LIMIT = 50 * 50;
#endif
namespace { namespace {
static constexpr uint8_t OPACITY_STEP_A1 = 255; static constexpr uint8_t OPACITY_STEP_A1 = 255;
static constexpr uint8_t OPACITY_STEP_A2 = 85; static constexpr uint8_t OPACITY_STEP_A2 = 85;
......
...@@ -169,6 +169,7 @@ private: ...@@ -169,6 +169,7 @@ private:
!strcmp(suffix, ".JPG") || !strcmp(suffix, ".jpeg") || !strcmp(suffix, ".JPEG") || !strcmp(suffix, ".JPG") || !strcmp(suffix, ".jpeg") || !strcmp(suffix, ".JPEG") ||
!strcmp(suffix, ".BMP") || !strcmp(suffix, ".bmp")); !strcmp(suffix, ".BMP") || !strcmp(suffix, ".bmp"));
} }
void ReInitImageInfo(ImageInfo* imgInfo, bool mallocFlag);
}; };
} // namespace OHOS } // namespace OHOS
#endif // GRAPHIC_LITE_IMAGE_H #endif // GRAPHIC_LITE_IMAGE_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册