diff --git a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp index ca35a4cb85cb69a9335ecad23c8abfedb2ab8544..3ec5665a49b5fd1916968915b948be757193595d 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp @@ -193,7 +193,9 @@ void CanvasPaintMethod::DrawPixelMap(RefPtr pixelMap, const Ace::Canva InitPaintBlend(compositeOperationpBrush); RSRect rec = RSRect(0, 0, lastLayoutSize_.Width(), lastLayoutSize_.Height()); RSSaveLayerOps layerOps(&rec, &compositeOperationpBrush); - + if (state_.globalState.GetType() != CompositeOperation::SOURCE_OVER) { + rsCanvas_->SaveLayer(layerOps); + } if (state_.globalState.HasGlobalAlpha()) { imageBrush_.SetAlphaF(state_.globalState.GetAlpha()); } @@ -205,13 +207,13 @@ void CanvasPaintMethod::DrawPixelMap(RefPtr pixelMap, const Ace::Canva canvasImage.dx + canvasImage.dWidth, canvasImage.dy + canvasImage.dHeight); RSPath path; path.AddRect(rec); - PaintShadow(path, state_.shadow, rsCanvas, &imageBrush_, nullptr, &layerOps); + PaintImageShadow(path, state_.shadow, rsCanvas, &imageBrush_, nullptr, + (state_.globalState.GetType() != CompositeOperation::SOURCE_OVER) ? &layerOps : nullptr); } auto recordingCanvas = static_cast(rsCanvas); CHECK_NULL_VOID(recordingCanvas); const std::shared_ptr tempPixelMap = pixelMap->GetPixelMapSharedPtr(); CHECK_NULL_VOID(tempPixelMap); - rsCanvas_->SaveLayer(layerOps); switch (canvasImage.flag) { case 0: { RSRect srcRect = RSRect(0, 0, tempPixelMap->GetWidth(), tempPixelMap->GetHeight()); @@ -245,7 +247,9 @@ void CanvasPaintMethod::DrawPixelMap(RefPtr pixelMap, const Ace::Canva default: break; } - rsCanvas_->Restore(); + if (state_.globalState.GetType() != CompositeOperation::SOURCE_OVER) { + rsCanvas_->Restore(); + } #endif } @@ -738,6 +742,21 @@ void CanvasPaintMethod::PaintShadow(const RSPath& path, const Shadow& shadow, RS #endif } +void CanvasPaintMethod::PaintImageShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, + const RSBrush* brush, const RSPen* pen, RSSaveLayerOps* slo) +{ +#ifndef ACE_UNITTEST + CHECK_NULL_VOID(rsCanvas_); + if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE) && slo != nullptr) { + RosenDecorationPainter::PaintShadow(path, shadow, canvas, brush, pen); + rsCanvas_->Restore(); + rsCanvas_->SaveLayer(*slo); + } else { + RosenDecorationPainter::PaintShadow(path, shadow, canvas, brush, pen); + } +#endif +} + void CanvasPaintMethod::Path2DRect(const PathArgs& args) { double left = args.para1; diff --git a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h index 835b1edf0586a61b7b46645123fffc86f30573be..7e7a7e762f6f17b48c4aca085efe7c26bf2d5ff4 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h +++ b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h @@ -100,6 +100,8 @@ private: void UpdateTextStyleForeground(bool isStroke, RSTextStyle& txtStyle, bool hasShadow); void PaintShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, const RSBrush* brush = nullptr, const RSPen* pen = nullptr, RSSaveLayerOps* slo = nullptr) override; + void PaintImageShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, const RSBrush* brush = nullptr, + const RSPen* pen = nullptr, RSSaveLayerOps* slo = nullptr) override; void Path2DRect(const PathArgs& args) override; RSCanvas* GetRawPtrOfRSCanvas() override { diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp index 3a9f0147d9dba21759349121801545418653f462..081122002e3cf91b44f985efeea4b976639c0497 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp @@ -568,6 +568,9 @@ void CustomPaintPaintMethod::DrawImageInternal( InitPaintBlend(compositeOperationpBrush); auto rect = RSRect(0, 0, lastLayoutSize_.Width(), lastLayoutSize_.Height()); RSSaveLayerOps slo(&rect, &compositeOperationpBrush); + if (state_.globalState.GetType() != CompositeOperation::SOURCE_OVER) { + rsCanvas_->SaveLayer(slo); + } InitImagePaint(nullptr, &imageBrush_, sampleOptions_); if (state_.globalState.HasGlobalAlpha()) { imageBrush_.SetAlphaF(state_.globalState.GetAlpha()); @@ -577,10 +580,9 @@ void CustomPaintPaintMethod::DrawImageInternal( canvasImage.dx, canvasImage.dy, canvasImage.dWidth + canvasImage.dx, canvasImage.dHeight + canvasImage.dy); RSPath path; path.AddRect(rsRect); - PaintShadow(path, state_.shadow, rsCanvas, &imageBrush_, nullptr, &slo); + PaintImageShadow(path, state_.shadow, rsCanvas, &imageBrush_, nullptr, + (state_.globalState.GetType() != CompositeOperation::SOURCE_OVER) ? &slo : nullptr); } - - rsCanvas_->SaveLayer(slo); rsCanvas->AttachBrush(imageBrush_); switch (canvasImage.flag) { case DrawImageType::THREE_PARAMS: @@ -605,7 +607,9 @@ void CustomPaintPaintMethod::DrawImageInternal( break; } rsCanvas->DetachBrush(); - rsCanvas_->Restore(); + if (state_.globalState.GetType() != CompositeOperation::SOURCE_OVER) { + rsCanvas_->Restore(); + } } void CustomPaintPaintMethod::DrawImage(const Ace::CanvasImage& canvasImage, double width, double height) diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h index 9176a5856ccecf8af7d3aefc4ed1a3c2f8dda866..588c3c75f5dc25e3bbe82cdd0795086e24118333 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h @@ -363,6 +363,8 @@ protected: virtual RSCanvas* GetRawPtrOfRSCanvas() = 0; virtual void PaintShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, const RSBrush* brush = nullptr, const RSPen* pen = nullptr, RSSaveLayerOps* slo = nullptr) = 0; + virtual void PaintImageShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, + const RSBrush* brush = nullptr, const RSPen* pen = nullptr, RSSaveLayerOps* slo = nullptr) = 0; double GetAlignOffset(TextAlign align, std::unique_ptr& paragraph); RSTextAlign GetEffectiveAlign(RSTextAlign align, RSTextDirection direction) const; #ifndef ACE_UNITTEST diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp index 613decb3fc6d3d8117b93e125c6b83f464523fca..ba8778a05691af7b037714aca01a92056375a369 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp @@ -530,6 +530,21 @@ void OffscreenCanvasPaintMethod::PaintShadow(const RSPath& path, const Shadow& s #endif } +void OffscreenCanvasPaintMethod::PaintImageShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, + const RSBrush* brush, const RSPen* pen, RSSaveLayerOps* slo) +{ +#ifndef ACE_UNITTEST + CHECK_NULL_VOID(rsCanvas_); + if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE) && slo != nullptr) { + RosenDecorationPainter::PaintShadow(path, shadow, canvas, brush, pen); + rsCanvas_->Restore(); + rsCanvas_->SaveLayer(*slo); + } else { + RosenDecorationPainter::PaintShadow(path, shadow, canvas, brush, pen); + } +#endif +} + void OffscreenCanvasPaintMethod::Path2DRect(const PathArgs& args) { double left = args.para1; diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h index 0d7eeea5788d6992461e56c2abebd6c1edbf0f98..121111e5dc062ba5b5374d74ecbd034acb5c2c97 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h @@ -70,6 +70,8 @@ private: void UpdateTextStyleForeground(bool isStroke, RSTextStyle& txtStyle, bool hasShadow); void PaintShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, const RSBrush* brush = nullptr, const RSPen* pen = nullptr, RSSaveLayerOps* slo = nullptr) override; + void PaintImageShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, + const RSBrush* brush = nullptr, const RSPen* pen = nullptr, RSSaveLayerOps* slo = nullptr) override; void Path2DRect(const PathArgs& args) override; RSCanvas* GetRawPtrOfRSCanvas() override {