From 8a734f0b7792ea8ef71e0ed73303e355ece85341 Mon Sep 17 00:00:00 2001 From: youbing Date: Tue, 18 Oct 2022 16:51:07 +0800 Subject: [PATCH] Description: Code alarm processing#5 IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I5WD6I Feature or Bugfix: Bugfix Binary Source:No Signed-off-by: youbing54 --- frameworks/draw/draw_label.cpp | 2 +- frameworks/draw/draw_utils.cpp | 4 ++-- frameworks/font/ui_font_bitmap.cpp | 11 ++++++----- frameworks/font/ui_font_vector.cpp | 13 ++++++++----- interfaces/kits/components/ui_picker.h | 2 +- test/uitest/test_button/ui_test_button.cpp | 10 ++++++---- test/uitest/test_clip/ui_test_clip.cpp | 2 -- test/uitest/test_screenshot/ui_test_screenshot.h | 2 +- .../components/ui_abstract_clock_unit_test.cpp | 2 +- 9 files changed, 26 insertions(+), 22 deletions(-) diff --git a/frameworks/draw/draw_label.cpp b/frameworks/draw/draw_label.cpp index 02120b5..cfd9563 100644 --- a/frameworks/draw/draw_label.cpp +++ b/frameworks/draw/draw_label.cpp @@ -82,7 +82,7 @@ uint16_t DrawLabel::DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInf labelLine.style.lineSpace_, havebackgroundColor, backgroundColor}; -#if ENABLE_VECTOR_FONT +#if defined(ENABLE_VECTOR_FONT) && ENABLE_VECTOR_FONT glyphNode.textStyle = letterInfo.textStyle; #endif glyphNode.advance = 0; diff --git a/frameworks/draw/draw_utils.cpp b/frameworks/draw/draw_utils.cpp index 977da59..4cd0b9e 100644 --- a/frameworks/draw/draw_utils.cpp +++ b/frameworks/draw/draw_utils.cpp @@ -91,12 +91,12 @@ namespace OHOS { (r1) = static_cast((Alpha2 * (r2) + (1 - Alpha2) * Alpha1 * (r1)) / Alpha3); \ (g1) = static_cast((Alpha2 * (g2) + (1 - Alpha2) * Alpha1 * (g1)) / Alpha3); \ (b1) = static_cast((Alpha2 * (b2) + (1 - Alpha2) * Alpha1 * (b1)) / Alpha3); \ - (a1) = static_cast(Alpha3 * OPA_OPAQUE); + (a1) = static_cast(Alpha3 * OPA_OPAQUE) #define COLOR_BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \ (r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \ (g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \ - (b1) = (((b2) * (a2)) / OPA_OPAQUE) + (((b1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); + (b1) = (((b2) * (a2)) / OPA_OPAQUE) + (((b1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE) // 565 #define COLOR_FILL_BLEND(d, dm, s, sm, a) \ diff --git a/frameworks/font/ui_font_bitmap.cpp b/frameworks/font/ui_font_bitmap.cpp index 8b2ac2f..f5af518 100644 --- a/frameworks/font/ui_font_bitmap.cpp +++ b/frameworks/font/ui_font_bitmap.cpp @@ -23,10 +23,10 @@ #include "gfx_utils/file.h" #include "gfx_utils/graphic_log.h" #include "graphic_config.h" -#if ENABLE_MULTI_FONT +#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT #include "font/ui_multi_font_manager.h" #endif -#if ENABLE_SHAPING +#if defined(ENABLE_SHAPING) && ENABLE_SHAPING #include "font/ui_text_shaping.h" #endif @@ -60,9 +60,10 @@ bool UIFontBitmap::IsVectorFont() const return false; } -uint8_t UIFontBitmap::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& script, uint16_t fontId, uint8_t size) const +uint8_t UIFontBitmap::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& script, + uint16_t fontId, uint8_t size) const { -#if ENABLE_MULTI_FONT +#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT return UIMultiFontManager::GetInstance()->GetShapingFontId(text, fontId, ttfId, script); #else UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId); @@ -157,7 +158,7 @@ int8_t UIFontBitmap::GetFontHeader(FontHeader& fontHeader, uint16_t fontId, uint return INVALID_RET_VALUE; } -#if ENABLE_MULTI_FONT +#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT int8_t UIFontBitmap::GetMultiGlyphNode(uint32_t unicode, GlyphNode& glyphNode, uint16_t fontId) { int8_t ret = GetGlyphNode(unicode, glyphNode, fontId); diff --git a/frameworks/font/ui_font_vector.cpp b/frameworks/font/ui_font_vector.cpp index d25e777..736bbcc 100644 --- a/frameworks/font/ui_font_vector.cpp +++ b/frameworks/font/ui_font_vector.cpp @@ -24,7 +24,7 @@ #include "gfx_utils/graphic_log.h" #include "graphic_config.h" #include "securec.h" -#if ENABLE_MULTI_FONT +#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT #include "font/ui_multi_font_manager.h" #endif @@ -118,7 +118,7 @@ uint8_t UIFontVector::RegisterFontInfo(const char* ttfName, uint8_t shaping) if (IsColorEmojiFont(ftFaces_[j])) { SetupColorFont(ftFaces_[j]); } -#if ENABLE_MULTI_FONT +#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT UIMultiFontManager::GetInstance()->UpdateScript(fontInfo_[j]); #endif return j; @@ -337,9 +337,10 @@ uint16_t UIFontVector::GetHeight(uint16_t fontId, uint8_t fontSize) return static_cast(faceInfo.face->size->metrics.height / FONT_PIXEL_IN_POINT); } -uint8_t UIFontVector::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& script, uint16_t fontId, uint8_t size) const +uint8_t UIFontVector::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& script, + uint16_t fontId, uint8_t size) const { -#if ENABLE_MULTI_FONT +#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT const UITextLanguageFontParam* fontParam1 = GetFontInfo(fontId); if (fontParam1 == nullptr) { return 0; @@ -364,7 +365,7 @@ uint8_t UIFontVector::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& scr } ttfId = fontParam1->ttfId; -#if ENABLE_SHAPING +#if defined(ENABLE_SHAPING) && ENABLE_SHAPING script = UIMultiFontManager::GetInstance()->GetScriptByTtfId(ttfId); #endif return fontParam1->shaping; @@ -377,6 +378,7 @@ uint8_t UIFontVector::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& scr return fontInfo->shaping; #endif } + uint16_t UIFontVector::GetFontId(const char* ttfName, uint8_t fontSize) const { if (ttfName != nullptr) { @@ -568,6 +570,7 @@ void UIFontVector::SetItaly(FT_GlyphSlot slot) FT_Outline outline = slot->outline; FT_Outline_Transform(&outline, &matrix); } + void UIFontVector::SetBold(uint16_t fontId) { int32_t error; diff --git a/interfaces/kits/components/ui_picker.h b/interfaces/kits/components/ui_picker.h index 76da186..875149a 100644 --- a/interfaces/kits/components/ui_picker.h +++ b/interfaces/kits/components/ui_picker.h @@ -339,7 +339,7 @@ public: */ virtual void OnPickerStoped(UIPicker& picker) {} /** - * @brief Called when an item is selected during sliding. This function is implemented by applications. + * @brief Called when an item is selected during sliding. This function is implemented by applications. * * @param picker Indicates the picker instance. * @since 1.0 diff --git a/test/uitest/test_button/ui_test_button.cpp b/test/uitest/test_button/ui_test_button.cpp index 15f62f9..cb7bfc4 100644 --- a/test/uitest/test_button/ui_test_button.cpp +++ b/test/uitest/test_button/ui_test_button.cpp @@ -576,7 +576,7 @@ private: bool touchable_; }; -#if DEFAULT_ANIMATION +#if defined(DEFAULT_ANIMATION) && DEFAULT_ANIMATION class TestBtnAnimationListener : public UIView::OnClickListener { public: TestBtnAnimationListener(UIView* uiView, bool enableAnimation) : uiView_(uiView), enableAnimation_(enableAnimation) @@ -708,8 +708,9 @@ void UITestBUTTON::UIKitButtonTest002(UIScrollView* container, UIButton* button) container->Add(button14); container->Add(button15); -#if DEFAULT_ANIMATION - UILabelButton* button16 = GetTestUIButton("开启动效", 340, 1040, button); // 340: x-coordinate, 1040: y-coordinate +#if defined(DEFAULT_ANIMATION) && DEFAULT_ANIMATION + // 340: x-coordinate, 1040: y-coordinate + UILabelButton* button16 = GetTestUIButton("开启动效", 340, 1040, button); if (enableAnimationListener_ == nullptr) { enableAnimationListener_ = static_cast( @@ -717,7 +718,8 @@ void UITestBUTTON::UIKitButtonTest002(UIScrollView* container, UIButton* button) } button16->SetOnClickListener(enableAnimationListener_); - UILabelButton* button17 = GetTestUIButton("关闭动效", 340, 1090, button); // 340: x-coordinate, 1090: y-coordinate + // 340: x-coordinate, 1090: y-coordinate + UILabelButton* button17 = GetTestUIButton("关闭动效", 340, 1090, button); if (disableAnimationListener_ == nullptr) { disableAnimationListener_ = static_cast( new TestBtnAnimationListener(reinterpret_cast(button), false)); diff --git a/test/uitest/test_clip/ui_test_clip.cpp b/test/uitest/test_clip/ui_test_clip.cpp index 72a8181..fb80dcf 100644 --- a/test/uitest/test_clip/ui_test_clip.cpp +++ b/test/uitest/test_clip/ui_test_clip.cpp @@ -267,7 +267,6 @@ void UITestClip::UIKitClipTest004() CreateTitleLabel("贝塞尔曲线裁剪 "); ClipPath path; - // {50, 50}, {100, 50}, {100, 100}, {50, 100}: path points; {60, 110}, {80, 10}: control points of curve path.MoveTo({50, 50}).CurveTo({60, 110}, {80, 10}, {100, 50}).LineTo({100, 100}).LineTo({50, 100}); UIImageView* imageView = CreateImageView(); @@ -282,7 +281,6 @@ void UITestClip::UIKitClipTest005() CreateTitleLabel("多边形裁剪 "); ClipPath path; - // {20, 70}, {50, 60}, {110, 80}, {110, 130}, {50, 100}, {20, 120}: path points path.MoveTo({20, 70}).LineTo({50, 60}).LineTo({110, 80}).LineTo({110, 130}).LineTo({50, 100}).LineTo({20, 120}); UIImageView* imageView = CreateImageView(); diff --git a/test/uitest/test_screenshot/ui_test_screenshot.h b/test/uitest/test_screenshot/ui_test_screenshot.h index e29f7eb..fe4b759 100644 --- a/test/uitest/test_screenshot/ui_test_screenshot.h +++ b/test/uitest/test_screenshot/ui_test_screenshot.h @@ -17,7 +17,7 @@ #define UI_TEST_SCREENSHOT_H #include "graphic_config.h" -#if ENABLE_DEBUG +#if defined(ENABLE_DEBUG) && ENABLE_DEBUG #include "components/ui_scroll_view.h" #include "components/ui_label.h" #include "components/ui_label_button.h" diff --git a/test/unittest/components/ui_abstract_clock_unit_test.cpp b/test/unittest/components/ui_abstract_clock_unit_test.cpp index 3ce710a..220be21 100644 --- a/test/unittest/components/ui_abstract_clock_unit_test.cpp +++ b/test/unittest/components/ui_abstract_clock_unit_test.cpp @@ -27,7 +27,7 @@ namespace { const uint8_t INIT_HOUR = 24; const uint8_t INIT_MINUTE = 60; const uint8_t INIT_SECOND = 60; - const bool clockInit = 1; + const bool CLOCK_INT = 1; } class UIAbstractClockUnitTest : public testing::Test { -- GitLab