#include "flutter/flow/ohos_layers/clip_path_layer.h"
#include "flutter/flow/ohos_layers/paint_context.h"
namespace flutter::OHOS {
void ClipPathLayer::Prepare(const SkMatrix& matrix)
{
SkRect clipPathBounds = clipPath_.getBounds();
SkRect childPaintBounds = SkRect::MakeEmpty();
PrepareChildren(matrix, childPaintBounds);
if (childPaintBounds.intersect(clipPathBounds)) {
SetPaintBounds(childPaintBounds);
}
}
void ClipPathLayer::Paint(const PaintContext& paintContext) const
{
SkAutoCanvasRestore save(paintContext.skCanvas, true);
paintContext.skCanvas->clipPath(clipPath_, clipBehavior_ != Clip::HARDEDGE);
if (clipBehavior_ == Clip::ANTIALIAS_WITH_SAVELAYER) {
paintContext.skCanvas->saveLayer(GetPaintBounds(), nullptr);
}
PaintChildren(paintContext);
if (clipBehavior_ == Clip::ANTIALIAS_WITH_SAVELAYER) {
paintContext.skCanvas->restore();
}
}
}