From 18fa7af7a28d184b4bdf92529c265bc0fc8c7c7b Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 14 Aug 2025 20:27:01 +0800 Subject: [PATCH] opt code Signed-off-by: liufei --- m133/include/core/SkTypeface.h | 2 +- m133/modules/skparagraph/include/Paragraph.h | 2 +- m133/modules/skparagraph/src/Decorations.cpp | 4 ++-- m133/modules/skparagraph/src/OneLineShaper.cpp | 2 -- m133/modules/skparagraph/src/ParagraphCache.cpp | 2 +- m133/modules/skparagraph/src/Run.cpp | 3 ++- m133/modules/skparagraph/src/TextLine.cpp | 3 ++- m133/src/ports/skia_ohos/FontConfig_ohos.h | 1 + m133/src/ports/skia_ohos/SkFontMgr_ohos.h | 11 +++-------- 9 files changed, 13 insertions(+), 17 deletions(-) diff --git a/m133/include/core/SkTypeface.h b/m133/include/core/SkTypeface.h index 4f38452105..62f0c610ea 100644 --- a/m133/include/core/SkTypeface.h +++ b/m133/include/core/SkTypeface.h @@ -113,7 +113,7 @@ public: /** Creates a new reference to the typeface that most closely matches the requested familyName and fontStyle. This method allows extended font - face specifiers as in the SkFontStyle type. Will never return null. + face specifiers as in the SkFontStyle type. @param familyName May be NULL. The name of the font family. @param fontStyle The style of the typeface. diff --git a/m133/modules/skparagraph/include/Paragraph.h b/m133/modules/skparagraph/include/Paragraph.h index 9cf2cd9c09..0bcc0d5b62 100644 --- a/m133/modules/skparagraph/include/Paragraph.h +++ b/m133/modules/skparagraph/include/Paragraph.h @@ -34,7 +34,7 @@ enum InternalState { kDrawn = 7 }; -enum UtfEncodeType { +enum class UtfEncodeType { kUtf8, kUtf16 }; diff --git a/m133/modules/skparagraph/src/Decorations.cpp b/m133/modules/skparagraph/src/Decorations.cpp index af89b32ebf..4d3d0ebfa7 100644 --- a/m133/modules/skparagraph/src/Decorations.cpp +++ b/m133/modules/skparagraph/src/Decorations.cpp @@ -41,7 +41,8 @@ void Decorations::updateDecorationPosition(TextDecoration decorationMode, SkScal break; case TextVerticalAlign::CENTER: if (decorationMode == TextDecoration::kLineThrough) { - // Line through is in the middle of the line + // Postion the line-through decoration at the vertical center of the line + // The division by 2 places it in the middle between the line positionY = fDecorationContext.lineHeight / 2 - baselineShift; } break; @@ -484,7 +485,6 @@ void Decorations::calculatePosition(TextDecoration decoration, SkScalar ascent) } void Decorations::calculateWaves(const TextStyle& textStyle, SkRect clip) { - fPath.reset(); int wave_count = 0; SkScalar x_start = 0; diff --git a/m133/modules/skparagraph/src/OneLineShaper.cpp b/m133/modules/skparagraph/src/OneLineShaper.cpp index ce0b62fbd3..fa6eda6219 100644 --- a/m133/modules/skparagraph/src/OneLineShaper.cpp +++ b/m133/modules/skparagraph/src/OneLineShaper.cpp @@ -7,8 +7,6 @@ #ifdef ENABLE_TEXT_ENHANCE #include "src/Run.h" #include "include/TextGlobalConfig.h" -#include "include/TextStyle.h" -#include "SkScalar.h" #include "trace.h" #endif diff --git a/m133/modules/skparagraph/src/ParagraphCache.cpp b/m133/modules/skparagraph/src/ParagraphCache.cpp index 2944b6cfd9..7e35661dae 100644 --- a/m133/modules/skparagraph/src/ParagraphCache.cpp +++ b/m133/modules/skparagraph/src/ParagraphCache.cpp @@ -473,7 +473,7 @@ void ParagraphCache::SetStoredLayoutImpl(ParagraphImpl& paragraph, ParagraphCach paragraph.getIntrinsicSize(value->fMaxIntrinsicWidth, value->fMinIntrinsicWidth, value->fAlphabeticBaseline, value->fIdeographicBaseline, value->fExceededMaxLines); - for (auto& indent : value->indents) { + for (auto& indent : paragraph.fIndents) { value->indents.push_back(indent); } value->linebreakStrategy = paragraph.getLineBreakStrategy(); diff --git a/m133/modules/skparagraph/src/Run.cpp b/m133/modules/skparagraph/src/Run.cpp index 0569131e4a..7596fb61c4 100644 --- a/m133/modules/skparagraph/src/Run.cpp +++ b/m133/modules/skparagraph/src/Run.cpp @@ -692,7 +692,8 @@ void Run::updateMetrics(InternalLineMetrics* endlineMetrics) { fFontMetrics.fLeading = 0; - updatePlaceholderAlignmentIfNeeded(placeholderStyle->fAlignment, fOwner->getParagraphStyle().getVerticalAlignment()); + updatePlaceholderAlignmentIfNeeded(placeholderStyle->fAlignment, + fOwner->getParagraphStyle().getVerticalAlignment()); switch (placeholderStyle->fAlignment) { case PlaceholderAlignment::kBaseline: diff --git a/m133/modules/skparagraph/src/TextLine.cpp b/m133/modules/skparagraph/src/TextLine.cpp index d02c063e71..6a849f3c04 100644 --- a/m133/modules/skparagraph/src/TextLine.cpp +++ b/m133/modules/skparagraph/src/TextLine.cpp @@ -1364,7 +1364,8 @@ void TextLine::middleEllipsisUpdateLine(ClusterIndex& startIndex, ClusterIndex& { const Cluster& startCluster = fOwner->cluster(startIndex); const Cluster& endCluster = fOwner->cluster(endIndex); - fEllipsis->fTextRange = TextRange(startCluster.textRange().start, startCluster.textRange().start + fEllipsis->size()); + fEllipsis->fTextRange = TextRange(startCluster.textRange().start, + startCluster.textRange().start + fEllipsis->size()); fEllipsis->setOwner(fOwner); fEllipsis->fClusterStart = startCluster.textRange().start; fEllipsisIndex = startCluster.runIndex(); diff --git a/m133/src/ports/skia_ohos/FontConfig_ohos.h b/m133/src/ports/skia_ohos/FontConfig_ohos.h index 4823844200..46c6d2990d 100644 --- a/m133/src/ports/skia_ohos/FontConfig_ohos.h +++ b/m133/src/ports/skia_ohos/FontConfig_ohos.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "FontInfo_ohos.h" #include "HmSymbolConfig_ohos.h" diff --git a/m133/src/ports/skia_ohos/SkFontMgr_ohos.h b/m133/src/ports/skia_ohos/SkFontMgr_ohos.h index 6c58ed2e87..153786fe69 100644 --- a/m133/src/ports/skia_ohos/SkFontMgr_ohos.h +++ b/m133/src/ports/skia_ohos/SkFontMgr_ohos.h @@ -1,11 +1,6 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * 2023.4.23 SkFontMgr on ohos. - * Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. - */ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef SKFONTMGR_OHOS_H #define SKFONTMGR_OHOS_H -- Gitee