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_rrect_layer.h" 9 10 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkRRect.h" 12 13 #include "flutter/flow/ohos_layers/paint_context.h" 14 15 namespace flutter::OHOS { 16 Prepare(const SkMatrix & matrix)17void ClipRRectLayer::Prepare(const SkMatrix& matrix) 18 { 19 SkRect clipRrectBounds = clipRrect_.getBounds(); 20 SkRect childPaintBounds = SkRect::MakeEmpty(); 21 PrepareChildren(matrix, childPaintBounds); 22 23 if (childPaintBounds.intersect(clipRrectBounds)) { 24 SetPaintBounds(clipRrectBounds); 25 } 26 } 27 Paint(const PaintContext & paintContext) const28void ClipRRectLayer::Paint(const PaintContext& paintContext) const 29 { 30 SkAutoCanvasRestore save(paintContext.skCanvas, true); 31 paintContext.skCanvas->clipRRect(clipRrect_, clipBehavior_ != Clip::HARDEDGE); 32 33 if (clipBehavior_ == Clip::ANTIALIAS_WITH_SAVELAYER) { 34 paintContext.skCanvas->saveLayer(GetPaintBounds(), nullptr); 35 } 36 PaintChildren(paintContext); 37 if (clipBehavior_ == Clip::ANTIALIAS_WITH_SAVELAYER) { 38 paintContext.skCanvas->restore(); 39 } 40 } 41 42 } // namespace flutter::OHOS