From 98e2ca8faec484a67a9d7044cb6993f9694dfd5b Mon Sep 17 00:00:00 2001 From: z00847066 Date: Sat, 9 Aug 2025 15:49:48 +0800 Subject: [PATCH 1/3] modify review comments Signed-off-by: z00847066 --- modules/skparagraph/include/Paragraph.h | 2 + modules/skparagraph/src/ParagraphImpl.cpp | 54 +++++++++++++++++++++++ modules/skparagraph/src/ParagraphImpl.h | 6 +++ 3 files changed, 62 insertions(+) diff --git a/modules/skparagraph/include/Paragraph.h b/modules/skparagraph/include/Paragraph.h index 420bdeb2cf..4c44a07b83 100644 --- a/modules/skparagraph/include/Paragraph.h +++ b/modules/skparagraph/include/Paragraph.h @@ -76,6 +76,8 @@ public: virtual void setState(InternalState state) = 0; virtual InternalState getState() const = 0; + + virtual std::string GetDumpInfo() const = 0; #endif virtual void layout(SkScalar width) = 0; diff --git a/modules/skparagraph/src/ParagraphImpl.cpp b/modules/skparagraph/src/ParagraphImpl.cpp index 0c3cd812aa..4924544d06 100644 --- a/modules/skparagraph/src/ParagraphImpl.cpp +++ b/modules/skparagraph/src/ParagraphImpl.cpp @@ -2426,5 +2426,59 @@ std::unique_ptr ParagraphImpl::CloneSelf() return paragraph; } +#ifdef OHOS_SUPPORT +std::string_view ParagraphImpl::GetState() const +{ + static std::unordered_map state = { + {kUnknown, "Unknow"}, + {kIndexed, "Indexed"}, + {kShaped, "Shaped"}, + {kLineBroken, "LineBroken"}, + {kFormatted, "Formatted"}, + {kDrawn, "Drawn"}, + }; + return state[fState]; +} + +std::string ParagraphImpl::GetDumpInfo() const +{ + std::ostringstream paragraphInfo; + paragraphInfo << "This is paragraph dump info:\n"; + paragraphInfo << "Text size: " << fText.size() << " fState: " << GetState() + << " fSkipTextBlobDrawing: " << (fSkipTextBlobDrawing ? "true" : "false") << "\n"; + uint32_t glyphSize = 0; + uint32_t runIndex = 0; + for (auto& run : fRuns) { + paragraphInfo << "Run[" << runIndex << "]" << " glyph size: " << run.size() + << " text range: [" << run.textRange().start << "-" << run.textRange().end << ")\n"; + runIndex++; + glyphSize += run.size(); + } + uint32_t blockIndex = 0; + for (auto& block : fTextStyles) { + paragraphInfo << "Block[" << blockIndex << "]" + << " text range[" << block.fRange.start << "-"<< block.fRange.end << ")" + << " font size: " << block.fStyle.getFontSize() + << " font color: " << std::hex << block.fStyle.getColor() << std::dec + << " font height: " << block.fStyle.getHeight() + << " font weight: " << block.fStyle.getFontStyle().GetWeight() + << " font width: " << block.fStyle.getFontStyle().GetWidth() + << " font slant: " << block.fStyle.getFontStyle().GetSlant() << "\n"; + blockIndex++; + } + paragraphInfo << "Paragraph glyph size: " << glyphSize << "\n"; + uint32_t lineIndex = 0; + for (auto& line : fLines) { + auto runs = line.getLineAllRuns(); + auto runSize = runs.size(); + if (runSize !=0 ) { + paragraphInfo << "Line[" << lineIndex << "] run range: [" << runs[0] << "-" << runs[runSize - 1] << "]\n"; + } + lineIndex++; + } + return paragraphInfo.str(); +} +#endif + } // namespace textlayout } // namespace skia diff --git a/modules/skparagraph/src/ParagraphImpl.h b/modules/skparagraph/src/ParagraphImpl.h index fe00f7ad2a..a1803e2d4f 100644 --- a/modules/skparagraph/src/ParagraphImpl.h +++ b/modules/skparagraph/src/ParagraphImpl.h @@ -136,6 +136,11 @@ public: #ifdef OHOS_SUPPORT TextRange getEllipsisTextRange() override; +<<<<<<< HEAD +======= + bool isRunCombinated() const override { return fRuns.size() < fTextStyles.size(); } + std::string GetDumpInfo() const override; +>>>>>>> c3f198ccba (modify review comments) #endif TextLine& addLine(SkVector offset, SkVector advance, @@ -407,6 +412,7 @@ private: TextBox getEmptyTextRect(RectHeightStyle rectHeightStyle) const; size_t prefixByteCountUntilChar(size_t index); void copyProperties(const ParagraphImpl& source); + std::string_view GetState() const; #endif // Input -- Gitee From ada461a8d0ff8f4474482de67cf8a7423cb20219 Mon Sep 17 00:00:00 2001 From: z00847066 Date: Wed, 13 Aug 2025 10:55:52 +0800 Subject: [PATCH 2/3] add paragraph dump info Signed-off-by: z00847066 --- modules/skparagraph/src/ParagraphImpl.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/skparagraph/src/ParagraphImpl.cpp b/modules/skparagraph/src/ParagraphImpl.cpp index 4924544d06..6a34be2331 100644 --- a/modules/skparagraph/src/ParagraphImpl.cpp +++ b/modules/skparagraph/src/ParagraphImpl.cpp @@ -2442,15 +2442,16 @@ std::string_view ParagraphImpl::GetState() const std::string ParagraphImpl::GetDumpInfo() const { + // 由于arkui那边要求dump信息只能一行,这里将应该换行的地方用逗号代替,方便定位时统一用工具替换 std::ostringstream paragraphInfo; - paragraphInfo << "This is paragraph dump info:\n"; + paragraphInfo << "This is paragraph dump info:,"; paragraphInfo << "Text size: " << fText.size() << " fState: " << GetState() - << " fSkipTextBlobDrawing: " << (fSkipTextBlobDrawing ? "true" : "false") << "\n"; + << " fSkipTextBlobDrawing: " << (fSkipTextBlobDrawing ? "true" : "false") << ","; uint32_t glyphSize = 0; uint32_t runIndex = 0; for (auto& run : fRuns) { paragraphInfo << "Run[" << runIndex << "]" << " glyph size: " << run.size() - << " text range: [" << run.textRange().start << "-" << run.textRange().end << ")\n"; + << " text range: [" << run.textRange().start << "-" << run.textRange().end << "),"; runIndex++; glyphSize += run.size(); } @@ -2463,16 +2464,16 @@ std::string ParagraphImpl::GetDumpInfo() const << " font height: " << block.fStyle.getHeight() << " font weight: " << block.fStyle.getFontStyle().GetWeight() << " font width: " << block.fStyle.getFontStyle().GetWidth() - << " font slant: " << block.fStyle.getFontStyle().GetSlant() << "\n"; + << " font slant: " << block.fStyle.getFontStyle().GetSlant() << ","; blockIndex++; } - paragraphInfo << "Paragraph glyph size: " << glyphSize << "\n"; + paragraphInfo << "Paragraph glyph size: " << glyphSize << ","; uint32_t lineIndex = 0; for (auto& line : fLines) { auto runs = line.getLineAllRuns(); auto runSize = runs.size(); if (runSize !=0 ) { - paragraphInfo << "Line[" << lineIndex << "] run range: [" << runs[0] << "-" << runs[runSize - 1] << "]\n"; + paragraphInfo << "Line[" << lineIndex << "] run range: [" << runs[0] << "-" << runs[runSize - 1] << "],"; } lineIndex++; } -- Gitee From d5d2fc9d1807252f43e23a996e7261fc56cb4034 Mon Sep 17 00:00:00 2001 From: z00847066 Date: Thu, 14 Aug 2025 11:14:29 +0800 Subject: [PATCH 3/3] add paragraph dump info Signed-off-by: z00847066 --- modules/skparagraph/src/ParagraphImpl.cpp | 43 ++++++++++++++--------- modules/skparagraph/src/ParagraphImpl.h | 4 --- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/modules/skparagraph/src/ParagraphImpl.cpp b/modules/skparagraph/src/ParagraphImpl.cpp index 6a34be2331..1d7002ef53 100644 --- a/modules/skparagraph/src/ParagraphImpl.cpp +++ b/modules/skparagraph/src/ParagraphImpl.cpp @@ -28,6 +28,7 @@ #include #ifdef OHOS_SUPPORT +#include #include "log.h" #include "modules/skparagraph/src/TextLineBaseImpl.h" #include "TextParameter.h" @@ -646,17 +647,26 @@ void ParagraphImpl::layout(SkScalar rawWidth) { } void ParagraphImpl::paint(SkCanvas* canvas, SkScalar x, SkScalar y) { +#ifdef OHOS_SUPPORT + fState = kDrawn; +#endif CanvasParagraphPainter painter(canvas); paint(&painter, x, y); } void ParagraphImpl::paint(ParagraphPainter* painter, SkScalar x, SkScalar y) { +#ifdef OHOS_SUPPORT + fState = kDrawn; +#endif for (auto& line : fLines) { line.paint(painter, x, y); } } void ParagraphImpl::paint(ParagraphPainter* painter, RSPath* path, SkScalar hOffset, SkScalar vOffset) { +#ifdef OHOS_SUPPORT + fState = kDrawn; +#endif auto& style = fTextStyles[0].fStyle; float align = 0.0f; switch (paragraphStyle().getTextAlign()) { @@ -2442,38 +2452,39 @@ std::string_view ParagraphImpl::GetState() const std::string ParagraphImpl::GetDumpInfo() const { - // 由于arkui那边要求dump信息只能一行,这里将应该换行的地方用逗号代替,方便定位时统一用工具替换 std::ostringstream paragraphInfo; - paragraphInfo << "This is paragraph dump info:,"; - paragraphInfo << "Text size: " << fText.size() << " fState: " << GetState() - << " fSkipTextBlobDrawing: " << (fSkipTextBlobDrawing ? "true" : "false") << ","; + paragraphInfo << "Paragraph dump:"; + paragraphInfo << "Text sz:" << fText.size() << ",State:" << GetState() << ","; uint32_t glyphSize = 0; uint32_t runIndex = 0; for (auto& run : fRuns) { - paragraphInfo << "Run[" << runIndex << "]" << " glyph size: " << run.size() - << " text range: [" << run.textRange().start << "-" << run.textRange().end << "),"; + paragraphInfo << "Run" << runIndex << " glyph sz:" << run.size() + << ",rng[" << run.textRange().start << "-" << run.textRange().end << "),"; runIndex++; glyphSize += run.size(); } uint32_t blockIndex = 0; for (auto& block : fTextStyles) { - paragraphInfo << "Block[" << blockIndex << "]" - << " text range[" << block.fRange.start << "-"<< block.fRange.end << ")" - << " font size: " << block.fStyle.getFontSize() - << " font color: " << std::hex << block.fStyle.getColor() << std::dec - << " font height: " << block.fStyle.getHeight() - << " font weight: " << block.fStyle.getFontStyle().GetWeight() - << " font width: " << block.fStyle.getFontStyle().GetWidth() - << " font slant: " << block.fStyle.getFontStyle().GetSlant() << ","; + paragraphInfo << "Blk" << blockIndex + << " rng[" << block.fRange.start << "-"<< block.fRange.end << ")" + << ",sz:" << block.fStyle.getFontSize() + << ",clr:" << std::hex << block.fStyle.getColor() << std::dec + << ",ht:" << block.fStyle.getHeight() + << ",wt:" << block.fStyle.getFontStyle().GetWeight() + << ",wd:" << block.fStyle.getFontStyle().GetWidth() + << ",slt:" << block.fStyle.getFontStyle().GetSlant() << ","; blockIndex++; } - paragraphInfo << "Paragraph glyph size: " << glyphSize << ","; + paragraphInfo << "Paragraph glyph sz:" << glyphSize << ","; uint32_t lineIndex = 0; for (auto& line : fLines) { + if (lineIndex > 0) { + paragraphInfo << ","; + } auto runs = line.getLineAllRuns(); auto runSize = runs.size(); if (runSize !=0 ) { - paragraphInfo << "Line[" << lineIndex << "] run range: [" << runs[0] << "-" << runs[runSize - 1] << "],"; + paragraphInfo << "L" << lineIndex << " run rng:" << runs[0] << "-" << runs[runSize - 1]; } lineIndex++; } diff --git a/modules/skparagraph/src/ParagraphImpl.h b/modules/skparagraph/src/ParagraphImpl.h index a1803e2d4f..c2c33705b9 100644 --- a/modules/skparagraph/src/ParagraphImpl.h +++ b/modules/skparagraph/src/ParagraphImpl.h @@ -136,11 +136,7 @@ public: #ifdef OHOS_SUPPORT TextRange getEllipsisTextRange() override; -<<<<<<< HEAD -======= - bool isRunCombinated() const override { return fRuns.size() < fTextStyles.size(); } std::string GetDumpInfo() const override; ->>>>>>> c3f198ccba (modify review comments) #endif TextLine& addLine(SkVector offset, SkVector advance, -- Gitee