Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/core/SkScan.h
Line
Count
Source
1
/*
2
 * Copyright 2011 The Android Open Source Project
3
 *
4
 * Use of this source code is governed by a BSD-style license that can be
5
 * found in the LICENSE file.
6
 */
7
8
9
#ifndef SkScan_DEFINED
10
#define SkScan_DEFINED
11
12
#include "include/core/SkRect.h"
13
#include "include/private/SkFixed.h"
14
#include <atomic>
15
16
class SkRasterClip;
17
class SkRegion;
18
class SkBlitter;
19
class SkPath;
20
21
/** Defines a fixed-point rectangle, identical to the integer SkIRect, but its
22
    coordinates are treated as SkFixed rather than int32_t.
23
*/
24
typedef SkIRect SkXRect;
25
26
extern std::atomic<bool> gSkUseAnalyticAA;
27
extern std::atomic<bool> gSkForceAnalyticAA;
28
29
class AdditiveBlitter;
30
31
class SkScan {
32
public:
33
    /*
34
     *  Draws count-1 line segments, one at a time:
35
     *      line(pts[0], pts[1])
36
     *      line(pts[1], pts[2])
37
     *      line(......, pts[count - 1])
38
     */
39
    typedef void (*HairRgnProc)(const SkPoint[], int count, const SkRegion*, SkBlitter*);
40
    typedef void (*HairRCProc)(const SkPoint[], int count, const SkRasterClip&, SkBlitter*);
41
42
    static void FillPath(const SkPath&, const SkIRect&, SkBlitter*);
43
44
    ///////////////////////////////////////////////////////////////////////////
45
    // rasterclip
46
47
    static void FillIRect(const SkIRect&, const SkRasterClip&, SkBlitter*);
48
    static void FillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*);
49
    static void FillRect(const SkRect&, const SkRasterClip&, SkBlitter*);
50
    static void AntiFillRect(const SkRect&, const SkRasterClip&, SkBlitter*);
51
    static void AntiFillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*);
52
    static void FillPath(const SkPath&, const SkRasterClip&, SkBlitter*);
53
    static void AntiFillPath(const SkPath&, const SkRasterClip&, SkBlitter*);
54
    static void FrameRect(const SkRect&, const SkPoint& strokeSize,
55
                          const SkRasterClip&, SkBlitter*);
56
    static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize,
57
                              const SkRasterClip&, SkBlitter*);
58
    static void FillTriangle(const SkPoint pts[], const SkRasterClip&, SkBlitter*);
59
    static void HairLine(const SkPoint[], int count, const SkRasterClip&, SkBlitter*);
60
    static void AntiHairLine(const SkPoint[], int count, const SkRasterClip&, SkBlitter*);
61
    static void HairRect(const SkRect&, const SkRasterClip&, SkBlitter*);
62
    static void AntiHairRect(const SkRect&, const SkRasterClip&, SkBlitter*);
63
    static void HairPath(const SkPath&, const SkRasterClip&, SkBlitter*);
64
    static void AntiHairPath(const SkPath&, const SkRasterClip&, SkBlitter*);
65
    static void HairSquarePath(const SkPath&, const SkRasterClip&, SkBlitter*);
66
    static void AntiHairSquarePath(const SkPath&, const SkRasterClip&, SkBlitter*);
67
    static void HairRoundPath(const SkPath&, const SkRasterClip&, SkBlitter*);
68
    static void AntiHairRoundPath(const SkPath&, const SkRasterClip&, SkBlitter*);
69
70
    // Needed by do_fill_path in SkScanPriv.h
71
    static void FillPath(const SkPath&, const SkRegion& clip, SkBlitter*);
72
73
private:
74
    friend class SkAAClip;
75
    friend class SkRegion;
76
77
    static void FillIRect(const SkIRect&, const SkRegion* clip, SkBlitter*);
78
    static void FillXRect(const SkXRect&, const SkRegion* clip, SkBlitter*);
79
    static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
80
    static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
81
    static void AntiFillXRect(const SkXRect&, const SkRegion*, SkBlitter*);
82
    static void AntiFillPath(const SkPath&, const SkRegion& clip, SkBlitter*, bool forceRLE);
83
    static void FillTriangle(const SkPoint pts[], const SkRegion*, SkBlitter*);
84
85
    static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize,
86
                              const SkRegion*, SkBlitter*);
87
    static void HairLineRgn(const SkPoint[], int count, const SkRegion*, SkBlitter*);
88
    static void AntiHairLineRgn(const SkPoint[], int count, const SkRegion*, SkBlitter*);
89
    static void AAAFillPath(const SkPath& path, SkBlitter* blitter, const SkIRect& pathIR,
90
                            const SkIRect& clipBounds, bool forceRLE);
91
    static void SAAFillPath(const SkPath& path, SkBlitter* blitter, const SkIRect& pathIR,
92
                            const SkIRect& clipBounds, bool forceRLE);
93
};
94
95
/** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates
96
    from int to SkFixed. Does not check for overflow if the src coordinates
97
    exceed 32K
98
*/
99
3.29k
static inline void XRect_set(SkXRect* xr, const SkIRect& src) {
100
1.64k
    xr->fLeft = SkIntToFixed(src.fLeft);
101
1.64k
    xr->fTop = SkIntToFixed(src.fTop);
102
1.64k
    xr->fRight = SkIntToFixed(src.fRight);
103
1.64k
    xr->fBottom = SkIntToFixed(src.fBottom);
104
3.29k
}
Unexecuted instantiation: SkRegion_path.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkScan_Path.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkAAClip.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkDraw.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkDraw_atlas.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkDraw_vertices.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkScan.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkScan_AntiPath.cpp:XRect_set(SkIRect*, SkIRect const&)
SkScan_Antihair.cpp:XRect_set(SkIRect*, SkIRect const&)
Line
Count
Source
99
1.64k
static inline void XRect_set(SkXRect* xr, const SkIRect& src) {
100
1.64k
    xr->fLeft = SkIntToFixed(src.fLeft);
101
1.64k
    xr->fTop = SkIntToFixed(src.fTop);
102
1.64k
    xr->fRight = SkIntToFixed(src.fRight);
103
1.64k
    xr->fBottom = SkIntToFixed(src.fBottom);
104
1.64k
}
Unexecuted instantiation: SkScan_Hairline.cpp:XRect_set(SkIRect*, SkIRect const&)
Unexecuted instantiation: SkScan_AAAPath.cpp:XRect_set(SkIRect*, SkIRect const&)
SkScan_Antihair.cpp:XRect_set(SkIRect*, SkIRect const&)
Line
Count
Source
99
1.64k
static inline void XRect_set(SkXRect* xr, const SkIRect& src) {
100
1.64k
    xr->fLeft = SkIntToFixed(src.fLeft);
101
1.64k
    xr->fTop = SkIntToFixed(src.fTop);
102
1.64k
    xr->fRight = SkIntToFixed(src.fRight);
103
1.64k
    xr->fBottom = SkIntToFixed(src.fBottom);
104
1.64k
}
105
106
/** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates
107
    from SkScalar to SkFixed. Does not check for overflow if the src coordinates
108
    exceed 32K
109
*/
110
2.06k
static inline void XRect_set(SkXRect* xr, const SkRect& src) {
111
2.06k
    xr->fLeft = SkScalarToFixed(src.fLeft);
112
2.06k
    xr->fTop = SkScalarToFixed(src.fTop);
113
2.06k
    xr->fRight = SkScalarToFixed(src.fRight);
114
2.06k
    xr->fBottom = SkScalarToFixed(src.fBottom);
115
2.06k
}
Unexecuted instantiation: SkRegion_path.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkScan_Path.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkAAClip.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkDraw.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkDraw_atlas.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkDraw_vertices.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkScan.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkScan_AntiPath.cpp:XRect_set(SkIRect*, SkRect const&)
SkScan_Antihair.cpp:XRect_set(SkIRect*, SkRect const&)
Line
Count
Source
110
2.06k
static inline void XRect_set(SkXRect* xr, const SkRect& src) {
111
2.06k
    xr->fLeft = SkScalarToFixed(src.fLeft);
112
2.06k
    xr->fTop = SkScalarToFixed(src.fTop);
113
2.06k
    xr->fRight = SkScalarToFixed(src.fRight);
114
2.06k
    xr->fBottom = SkScalarToFixed(src.fBottom);
115
2.06k
}
Unexecuted instantiation: SkScan_Hairline.cpp:XRect_set(SkIRect*, SkRect const&)
Unexecuted instantiation: SkScan_AAAPath.cpp:XRect_set(SkIRect*, SkRect const&)
116
117
/** Round the SkXRect coordinates, and store the result in the SkIRect.
118
*/
119
100
static inline void XRect_round(const SkXRect& xr, SkIRect* dst) {
120
100
    dst->fLeft = SkFixedRoundToInt(xr.fLeft);
121
100
    dst->fTop = SkFixedRoundToInt(xr.fTop);
122
100
    dst->fRight = SkFixedRoundToInt(xr.fRight);
123
100
    dst->fBottom = SkFixedRoundToInt(xr.fBottom);
124
100
}
Unexecuted instantiation: SkRegion_path.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_Path.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkAAClip.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkDraw.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkDraw_atlas.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkDraw_vertices.cpp:XRect_round(SkIRect const&, SkIRect*)
SkScan.cpp:XRect_round(SkIRect const&, SkIRect*)
Line
Count
Source
119
100
static inline void XRect_round(const SkXRect& xr, SkIRect* dst) {
120
100
    dst->fLeft = SkFixedRoundToInt(xr.fLeft);
121
100
    dst->fTop = SkFixedRoundToInt(xr.fTop);
122
100
    dst->fRight = SkFixedRoundToInt(xr.fRight);
123
100
    dst->fBottom = SkFixedRoundToInt(xr.fBottom);
124
100
}
Unexecuted instantiation: SkScan_AntiPath.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_Antihair.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_Hairline.cpp:XRect_round(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_AAAPath.cpp:XRect_round(SkIRect const&, SkIRect*)
125
126
/** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling
127
    for right/bottom), and store the result in the SkIRect.
128
*/
129
815
static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) {
130
815
    dst->fLeft = SkFixedFloorToInt(xr.fLeft);
131
815
    dst->fTop = SkFixedFloorToInt(xr.fTop);
132
815
    dst->fRight = SkFixedCeilToInt(xr.fRight);
133
815
    dst->fBottom = SkFixedCeilToInt(xr.fBottom);
134
815
}
Unexecuted instantiation: SkRegion_path.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_Path.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkAAClip.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkDraw.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkDraw_atlas.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkDraw_vertices.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_AntiPath.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
SkScan_Antihair.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Line
Count
Source
129
815
static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) {
130
815
    dst->fLeft = SkFixedFloorToInt(xr.fLeft);
131
815
    dst->fTop = SkFixedFloorToInt(xr.fTop);
132
815
    dst->fRight = SkFixedCeilToInt(xr.fRight);
133
815
    dst->fBottom = SkFixedCeilToInt(xr.fBottom);
134
815
}
Unexecuted instantiation: SkScan_Hairline.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
Unexecuted instantiation: SkScan_AAAPath.cpp:XRect_roundOut(SkIRect const&, SkIRect*)
135
136
#endif