You need to sign in or sign up before continuing.
draw_arc.h 5.2 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GRAPHIC_LITE_DRAW_ARC_H
#define GRAPHIC_LITE_DRAW_ARC_H
#include "common/image.h"
#include "draw_image.h"
#include "draw_utils.h"
Z
zhangguyuan 已提交
21 22
#include "gfx_utils/graphic_math.h"
#include "gfx_utils/heap_base.h"
M
mamingshuai 已提交
23
#include "imgdecode/cache_manager.h"
Z
zhangguyuan 已提交
24
#include "gfx_utils/style.h"
M
mamingshuai 已提交
25 26 27 28

namespace OHOS {
class DrawArc : public HeapBase {
public:
Z
zhdengc 已提交
29
    static DrawArc* GetInstance();
M
mamingshuai 已提交
30 31 32

    void GetDrawRange(int16_t& start, int16_t& end);

N
niulihua 已提交
33 34
    void Draw(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask,
              const Style& style, uint8_t opaScale, uint8_t cap);
M
mamingshuai 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

private:
    static constexpr uint8_t DRAW_ARC_QUADRANT_NUM = 4;
    static constexpr uint8_t ARC_QUADRANT_ONE = 0;
    static constexpr uint8_t ARC_QUADRANT_TWO = 1;
    static constexpr uint8_t ARC_QUADRANT_THREE = 2;
    static constexpr uint8_t ARC_QUADRANT_FOUR = 3;
    static constexpr int16_t IN_DEGREE_RANG = 0;
    static constexpr int16_t OUT_DEGREE_RANG = 1;
    static constexpr int16_t INTERSECT = 2;
    static constexpr int16_t DOUBLE_INTERSECT = 3;

    int16_t lineStart_;
    int16_t lineEnd_;
    int16_t outAntiStart_;
    int16_t outAntiEnd_;
    int16_t inAntiStart_;
    int16_t inAntiEnd_;
    int16_t y_;
    int16_t outRadius_;
    int16_t inRadius_;
    uint32_t ySqr_;
    uint32_t outRadiusSqr_;
    uint32_t inRadiusSqr_;
    bool isCircle_;
    uint32_t antiOutRadiusSqr_;
    uint32_t antiInRadiusSqr_;

    DrawArc()
        : lineStart_(0),
          lineEnd_(0),
          outAntiStart_(0),
          outAntiEnd_(0),
          inAntiStart_(0),
          inAntiEnd_(0),
          y_(0),
          outRadius_(0),
          inRadius_(0),
          ySqr_(0),
          outRadiusSqr_(0),
          inRadiusSqr_(0),
          isCircle_(false),
          antiOutRadiusSqr_(0),
          antiInRadiusSqr_(0)
    {
    }
N
niulihua 已提交
81

M
mamingshuai 已提交
82
    ~DrawArc() {}
N
niulihua 已提交
83 84 85

    void DrawVerLine(BufferInfo& gfxDstBuffer,
                     const Point& begin,
M
mamingshuai 已提交
86 87 88 89 90 91 92
                     const Point& imgPos,
                     const Rect& mask,
                     int16_t len,
                     const Style& style,
                     uint8_t opaScale,
                     const Image* imgSrc);

N
niulihua 已提交
93 94
    void DrawHorLine(BufferInfo& gfxDstBuffer,
                     const Point& begin,
M
mamingshuai 已提交
95 96 97 98 99 100 101
                     const Point& imgPos,
                     const Rect& mask,
                     int16_t len,
                     const Style& style,
                     uint8_t opaScale,
                     const Image* imgSrc);

N
niulihua 已提交
102 103
    void DrawImg(BufferInfo& gfxDstBuffer,
                 const Point& imgPos,
M
mamingshuai 已提交
104 105 106 107 108 109 110
                 Rect& area,
                 const Rect& invalidatedArea,
                 const Style& style,
                 uint8_t opaScale,
                 const Image* imgSrc);

    int16_t GetDegreeRangeIntersectState(uint16_t degreeStart, uint16_t degreeEnd, uint16_t start, uint16_t end);
N
niulihua 已提交
111

M
mamingshuai 已提交
112
    uint16_t CalculateTanDegree(uint16_t x, uint16_t y);
N
niulihua 已提交
113

M
mamingshuai 已提交
114
    int16_t GetDrawAngle(int16_t angle);
N
niulihua 已提交
115

W
wangtiantian 已提交
116 117
    void DrawCircleNoEndpoint(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style,
                              uint8_t opa, bool anti);
N
niulihua 已提交
118 119 120 121 122

    void DrawAxisLine(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa);

    void DrawLineWithDegree(BufferInfo& gfxDstBuffer,
                            ArcInfo& arcInfo,
M
mamingshuai 已提交
123 124 125 126 127 128 129
                            int16_t start,
                            int16_t end,
                            int16_t y,
                            const Rect& mask,
                            const Style& style,
                            uint8_t opaScale,
                            uint8_t quadrant);
N
niulihua 已提交
130 131 132

    int16_t DrawLineWithDegreeInner(BufferInfo& gfxDstBuffer,
                                    ArcInfo& arcInfo,
M
mamingshuai 已提交
133 134 135 136 137 138 139 140
                                    int16_t start,
                                    int16_t end,
                                    int16_t y,
                                    const Rect& mask,
                                    const Style& style,
                                    uint8_t opaScale,
                                    uint8_t quadrant);
#if ENABLE_ANTIALIAS
N
niulihua 已提交
141
    void DrawLineAnti(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa);
N
niulihua 已提交
142 143 144 145 146 147
    void DrawPointAnti(BufferInfo& gfxDstBuffer,
                       ArcInfo& arcInfo,
                       int16_t x,
                       const Rect& mask,
                       const Style& style,
                       uint8_t antiOpa);
M
mamingshuai 已提交
148 149 150 151 152 153
#endif
    uint16_t GetDegreeInQuadrant(uint16_t degree, uint8_t quadrant);
    void SetArcInfo(ArcInfo& arcInfo, const Style& style);
};
} // namespace OHOS
#endif // GRAPHIC_LITE_DRAW_ARC_H