• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 // 2021.2.10 Increase the process used in native_view mode.
6 //           Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved.
7 
8 #include "flutter/flow/ohos_layers/clip_path_layer.h"
9 
10 #include "flutter/flow/ohos_layers/paint_context.h"
11 
12 namespace flutter::OHOS {
13 
Prepare(const SkMatrix & matrix)14 void ClipPathLayer::Prepare(const SkMatrix& matrix)
15 {
16     SkRect clipPathBounds = clipPath_.getBounds();
17     SkRect childPaintBounds = SkRect::MakeEmpty();
18     PrepareChildren(matrix, childPaintBounds);
19 
20     if (childPaintBounds.intersect(clipPathBounds)) {
21         SetPaintBounds(childPaintBounds);
22     }
23 }
24 
Paint(const PaintContext & paintContext) const25 void ClipPathLayer::Paint(const PaintContext& paintContext) const
26 {
27     SkAutoCanvasRestore save(paintContext.skCanvas, true);
28     paintContext.skCanvas->clipPath(clipPath_, clipBehavior_ != Clip::HARDEDGE);
29 
30     if (clipBehavior_ == Clip::ANTIALIAS_WITH_SAVELAYER) {
31         paintContext.skCanvas->saveLayer(GetPaintBounds(), nullptr);
32     }
33     PaintChildren(paintContext);
34     if (clipBehavior_ == Clip::ANTIALIAS_WITH_SAVELAYER) {
35         paintContext.skCanvas->restore();
36     }
37 }
38 
39 } //  namespace flutter::OHOS