diff --git a/adapter/ohos/osal/drawing_lattice_ohos.cpp b/adapter/ohos/osal/drawing_lattice_ohos.cpp index 37db9fc16dd..e7ca9986bb7 100644 --- a/adapter/ohos/osal/drawing_lattice_ohos.cpp +++ b/adapter/ohos/osal/drawing_lattice_ohos.cpp @@ -37,4 +37,25 @@ void* DrawingLatticeOhos::GetDrawingLatticeSptrAddr() { return static_cast(&lattice_); } + +std::string DrawingLatticeOhos::DumpToString() +{ + if (lattice_) { + std::string drawingConfigStr; + drawingConfigStr.append("fXCount = " + std::to_string(lattice_->fXCount)); + drawingConfigStr.append("fXDivs = ["); + for (int32_t idx = 0; idx < lattice_->fXCount; ++idx) { + drawingConfigStr.append(std::to_string(lattice_->fXDivs[idx]) + " "); + } + drawingConfigStr.append("] "); + drawingConfigStr.append("fYCount = " + std::to_string(lattice_->fYCount)); + drawingConfigStr.append("fYDivs = ["); + for (int32_t idx = 0; idx < lattice_->fYCount; ++idx) { + drawingConfigStr.append(std::to_string(lattice_->fYDivs[idx]) + " "); + } + drawingConfigStr.append("] "); + return drawingConfigStr; + } + return "Lattice is null"; +} } // namespace OHOS::Ace diff --git a/adapter/ohos/osal/drawing_lattice_ohos.h b/adapter/ohos/osal/drawing_lattice_ohos.h index 47202c7ec83..85b6d11193a 100644 --- a/adapter/ohos/osal/drawing_lattice_ohos.h +++ b/adapter/ohos/osal/drawing_lattice_ohos.h @@ -29,6 +29,7 @@ public: : lattice_(std::move(lattice)) {} ~DrawingLatticeOhos() override = default; void* GetDrawingLatticeSptrAddr() override; + std::string DumpToString() override; private: std::shared_ptr lattice_; diff --git a/adapter/preview/osal/drawing_lattice_preview.cpp b/adapter/preview/osal/drawing_lattice_preview.cpp index dcfd1b23db6..ae4e8282ef0 100644 --- a/adapter/preview/osal/drawing_lattice_preview.cpp +++ b/adapter/preview/osal/drawing_lattice_preview.cpp @@ -40,4 +40,25 @@ void* DrawingLatticePreview::GetDrawingLatticeSptrAddr() { return static_cast(&lattice_); } + +std::string DrawingLatticePreview::DumpToString() +{ + if (lattice_) { + std::string drawingConfigStr; + drawingConfigStr.append("fXCount = " + std::to_string(lattice_->fXCount)); + drawingConfigStr.append("fXDivs = ["); + for (int32_t idx = 0; idx < lattice_->fXCount; ++idx) { + drawingConfigStr.append(std::to_string(lattice_->fXDivs[idx]) + " "); + } + drawingConfigStr.append("] "); + drawingConfigStr.append("fYCount = " + std::to_string(lattice_->fYCount)); + drawingConfigStr.append("fYDivs = ["); + for (int32_t idx = 0; idx < lattice_->fYCount; ++idx) { + drawingConfigStr.append(std::to_string(lattice_->fYDivs[idx]) + " "); + } + drawingConfigStr.append("] "); + return drawingConfigStr; + } + return "Lattice is null"; +} } // namespace OHOS::Ace diff --git a/adapter/preview/osal/drawing_lattice_preview.h b/adapter/preview/osal/drawing_lattice_preview.h index 4fa489a0bb8..9f96dc0ad64 100644 --- a/adapter/preview/osal/drawing_lattice_preview.h +++ b/adapter/preview/osal/drawing_lattice_preview.h @@ -27,6 +27,7 @@ public: : lattice_(std::move(lattice)) {} ~DrawingLatticePreview() override = default; void* GetDrawingLatticeSptrAddr() override; + std::string DumpToString() override; private: std::shared_ptr lattice_; diff --git a/frameworks/base/image/drawing_lattice.h b/frameworks/base/image/drawing_lattice.h index ec1ccbccef5..faea6835c64 100644 --- a/frameworks/base/image/drawing_lattice.h +++ b/frameworks/base/image/drawing_lattice.h @@ -27,6 +27,7 @@ public: static RefPtr CreateDrawingLattice(void* sptrAddr); static RefPtr CreateDrawingLatticeFromNative(void* sptrAddr); virtual void* GetDrawingLatticeSptrAddr() = 0; //define the return value as void is for tdd compilation + virtual std::string DumpToString() = 0; }; } // namespace Ace diff --git a/frameworks/core/components_ng/pattern/image/image_pattern.cpp b/frameworks/core/components_ng/pattern/image/image_pattern.cpp index 064d29ec02b..bbe83877071 100644 --- a/frameworks/core/components_ng/pattern/image/image_pattern.cpp +++ b/frameworks/core/components_ng/pattern/image/image_pattern.cpp @@ -1362,27 +1362,52 @@ void ImagePattern::DumpLayoutInfo() { auto layoutProp = GetLayoutProperty(); CHECK_NULL_VOID(layoutProp); + + DumpImageSourceInfo(layoutProp); + DumpAltSourceInfo(layoutProp); + DumpImageFit(layoutProp); + DumpFitOriginalSize(layoutProp); + DumpSourceSize(layoutProp); + DumpAutoResize(layoutProp); +} + +inline void ImagePattern::DumpImageSourceInfo(const RefPtr& layoutProp) +{ auto src = layoutProp->GetImageSourceInfo().value_or(ImageSourceInfo("")); DumpLog::GetInstance().AddDesc(std::string("url: ").append(src.ToString())); DumpLog::GetInstance().AddDesc("SrcCacheKey: " + src.GetKey()); +} +inline void ImagePattern::DumpAltSourceInfo(const RefPtr& layoutProp) +{ auto altSrc = layoutProp->GetAlt().value_or(ImageSourceInfo("")); DumpLog::GetInstance().AddDesc(std::string("altUrl: ").append(altSrc.ToString())); +} +inline void ImagePattern::DumpImageFit(const RefPtr& layoutProp) +{ auto imageFit = layoutProp->GetImageFit().value_or(ImageFit::COVER); DumpLog::GetInstance().AddDesc(std::string("objectFit: ").append(GetImageFitStr(imageFit))); +} +inline void ImagePattern::DumpFitOriginalSize(const RefPtr& layoutProp) +{ auto fitOriginalSize = layoutProp->GetFitOriginalSize().value_or(false); DumpLog::GetInstance().AddDesc(std::string("fitOriginalSize: ").append(fitOriginalSize ? "true" : "false")); +} +inline void ImagePattern::DumpSourceSize(const RefPtr& layoutProp) +{ const std::optional& sourceSize = layoutProp->GetSourceSize(); if (sourceSize.has_value()) { DumpLog::GetInstance().AddDesc(std::string("sourceSize: ").append(sourceSize.value().ToString())); } +} +inline void ImagePattern::DumpAutoResize(const RefPtr& layoutProp) +{ bool autoResize = layoutProp->GetAutoResize().value_or(autoResizeDefault_); - autoResize ? DumpLog::GetInstance().AddDesc("autoResize:true") - : DumpLog::GetInstance().AddDesc("autoResize:false"); + autoResize ? DumpLog::GetInstance().AddDesc("autoResize:true") : DumpLog::GetInstance().AddDesc("autoResize:false"); } void ImagePattern::DumpRenderInfo() @@ -1390,51 +1415,92 @@ void ImagePattern::DumpRenderInfo() auto renderProp = GetPaintProperty(); CHECK_NULL_VOID(renderProp); + DumpRenderMode(renderProp); + DumpImageRepeat(renderProp); + DumpImageColorFilter(renderProp); + DumpFillColor(renderProp); + DumpDynamicRangeMode(renderProp); + DumpMatchTextDirection(renderProp); + DumpSmoothEdge(renderProp); + DumpBorderRadiusProperties(renderProp); + DumpResizable(renderProp); +} + +inline void ImagePattern::DumpRenderMode(const RefPtr& renderProp) +{ auto imageRenderMode = renderProp->GetImageRenderMode().value_or(ImageRenderMode::ORIGINAL); DumpLog::GetInstance().AddDesc( std::string("renderMode: ").append((imageRenderMode == ImageRenderMode::ORIGINAL) ? "Original" : "Template")); +} +inline void ImagePattern::DumpImageRepeat(const RefPtr& renderProp) +{ auto imageRepeat = renderProp->GetImageRepeat().value_or(ImageRepeat::NO_REPEAT); DumpLog::GetInstance().AddDesc(std::string("objectRepeat: ").append(GetImageRepeatStr(imageRepeat))); +} +inline void ImagePattern::DumpImageColorFilter(const RefPtr& renderProp) +{ auto imageColorFilter = renderProp->GetColorFilter(); if (imageColorFilter.has_value()) { auto colorFilter = imageColorFilter.value(); DumpLog::GetInstance().AddDesc(std::string("colorFilter: ").append(GetImageColorFilterStr(colorFilter))); } +} +inline void ImagePattern::DumpFillColor(const RefPtr& renderProp) +{ auto fillColor = renderProp->GetSvgFillColor(); if (fillColor.has_value()) { auto color = fillColor.value(); DumpLog::GetInstance().AddDesc(std::string("fillColor: ").append(color.ColorToString())); } +} +inline void ImagePattern::DumpDynamicRangeMode(const RefPtr& renderProp) +{ DynamicRangeMode dynamicMode = DynamicRangeMode::STANDARD; if (renderProp->HasDynamicMode()) { dynamicMode = renderProp->GetDynamicMode().value_or(DynamicRangeMode::STANDARD); DumpLog::GetInstance().AddDesc(std::string("dynamicRangeMode: ").append(GetDynamicModeString(dynamicMode))); } +} +inline void ImagePattern::DumpMatchTextDirection(const RefPtr& renderProp) +{ auto matchTextDirection = renderProp->GetMatchTextDirection().value_or(false); matchTextDirection ? DumpLog::GetInstance().AddDesc("matchTextDirection:true") : DumpLog::GetInstance().AddDesc("matchTextDirection:false"); +} +inline void ImagePattern::DumpSmoothEdge(const RefPtr& renderProp) +{ auto smoothEdge = renderProp->GetSmoothEdge(); if (smoothEdge.has_value()) { DumpLog::GetInstance().AddDesc(std::string("edgeAntialiasing: ").append(std::to_string(smoothEdge.value()))); } +} +inline void ImagePattern::DumpResizable(const RefPtr& renderProp) +{ + if (renderProp->HasImageResizableSlice() && renderProp->GetImageResizableSliceValue({}).Valid()) { + DumpLog::GetInstance().AddDesc( + std::string("resizable slice: ").append(renderProp->GetImageResizableSliceValue({}).ToString())); + } + + auto resizableLattice = renderProp->GetImageResizableLatticeValue(nullptr); + DumpLog::GetInstance().AddDesc( + "resizableLattice:" + (resizableLattice ? resizableLattice->DumpToString() : "Lattice is null")); +} + +void ImagePattern::DumpBorderRadiusProperties(const RefPtr& renderProp) +{ auto needBorderRadius = renderProp->GetNeedBorderRadius().value_or(false); needBorderRadius ? DumpLog::GetInstance().AddDesc("needBorderRadius:true") : DumpLog::GetInstance().AddDesc("needBorderRadius:false"); auto borderRadius = renderProp->GetBorderRadius().value_or(BorderRadiusProperty()); - DumpLog::GetInstance().AddDesc(borderRadius.ToString()); - - if (renderProp && renderProp->HasImageResizableSlice() && renderProp->GetImageResizableSliceValue({}).Valid()) { - DumpLog::GetInstance().AddDesc( - std::string("resizable slice: ").append(renderProp->GetImageResizableSliceValue({}).ToString())); - } + DumpLog::GetInstance().AddDesc("ImageBorderRadius:" + borderRadius.ToString()); auto host = GetHost(); CHECK_NULL_VOID(host); @@ -1447,6 +1513,7 @@ void ImagePattern::DumpRenderInfo() DumpLog::GetInstance().AddDesc("borderRadius: null"); } } + void ImagePattern::DumpSvgInfo() { auto imageLayoutProperty = GetLayoutProperty(); diff --git a/frameworks/core/components_ng/pattern/image/image_pattern.h b/frameworks/core/components_ng/pattern/image/image_pattern.h index 08d3144c6bf..f0c060d376b 100644 --- a/frameworks/core/components_ng/pattern/image/image_pattern.h +++ b/frameworks/core/components_ng/pattern/image/image_pattern.h @@ -215,8 +215,23 @@ public: void DumpInfo(std::unique_ptr& json) override; void DumpSimplifyInfo(std::unique_ptr& json) override {} void DumpLayoutInfo(); + inline void DumpImageSourceInfo(const RefPtr& layoutProp); + inline void DumpAltSourceInfo(const RefPtr& layoutProp); + inline void DumpImageFit(const RefPtr& layoutProp); + inline void DumpFitOriginalSize(const RefPtr& layoutProp); + inline void DumpSourceSize(const RefPtr& layoutProp); + inline void DumpAutoResize(const RefPtr& layoutProp); void DumpLayoutInfo(std::unique_ptr& json); void DumpRenderInfo(); + inline void DumpRenderMode(const RefPtr& renderProp); + inline void DumpImageRepeat(const RefPtr& renderProp); + inline void DumpImageColorFilter(const RefPtr& renderProp); + inline void DumpFillColor(const RefPtr& renderProp); + inline void DumpDynamicRangeMode(const RefPtr& renderProp); + inline void DumpMatchTextDirection(const RefPtr& renderProp); + inline void DumpSmoothEdge(const RefPtr& renderProp); + inline void DumpResizable(const RefPtr& renderProp); + void DumpBorderRadiusProperties(const RefPtr& renderProp); void DumpRenderInfo(std::unique_ptr& json); void DumpAdvanceInfo() override; void DumpAdvanceInfo(std::unique_ptr& json) override;