1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_DEBUG_BOUNDARY_PAINTER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_DEBUG_BOUNDARY_PAINTER_H
18 
19 #include <optional>
20 
21 #include "base/geometry/ng/offset_t.h"
22 #include "base/geometry/ng/point_t.h"
23 #include "base/geometry/ng/size_t.h"
24 #include "core/components/common/layout/constants.h"
25 #include "core/components/common/properties/color.h"
26 #include "core/components_ng/render/drawing.h"
27 
28 namespace OHOS::Ace::NG {
29 class DebugBoundaryPainter {
30 public:
31     DebugBoundaryPainter() = default;
DebugBoundaryPainter(const SizeF & content,const SizeF & frame)32     DebugBoundaryPainter(const SizeF& content, const SizeF& frame) : contentSize_(content), frameMarginSize_(frame) {}
33     ~DebugBoundaryPainter() = default;
34 
DrawDebugBoundaries(RSCanvas & canvas,const OffsetF & offset)35     void DrawDebugBoundaries(RSCanvas& canvas, const OffsetF& offset) const
36     {
37         PaintDebugBoundary(canvas, offset);
38         PaintDebugCorner(canvas, offset);
39         PaintDebugMargin(canvas, offset);
40     }
41 
SetFrameOffset(const OffsetF & offset)42     void SetFrameOffset(const OffsetF& offset)
43     {
44         contentOffset_ = offset;
45     }
46 
47 private:
48     void PaintDebugBoundary(RSCanvas& canvas, const OffsetF& offset) const;
49     void PaintDebugMargin(RSCanvas& canvas, const OffsetF& offset) const;
50     void PaintDebugCorner(RSCanvas& canvas, const OffsetF& offset) const;
51 
52     SizeF contentSize_;
53     SizeF frameMarginSize_;
54     OffsetF contentOffset_;
55 };
56 } // namespace OHOS::Ace::NG
57 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_DEBUG_BOUNDARY_PAINTER_H