1 :
2 : /*
3 : * Copyright 2006 The Android Open Source Project
4 : *
5 : * Use of this source code is governed by a BSD-style license that can be
6 : * found in the LICENSE file.
7 : */
8 :
9 :
10 : #ifndef SkEdge_DEFINED
11 : #define SkEdge_DEFINED
12 :
13 : #include "SkRect.h"
14 :
15 : struct SkEdge {
16 : enum Type {
17 : kLine_Type,
18 : kQuad_Type,
19 : kCubic_Type
20 : };
21 :
22 : SkEdge* fNext;
23 : SkEdge* fPrev;
24 :
25 : SkFixed fX;
26 : SkFixed fDX;
27 : int32_t fFirstY;
28 : int32_t fLastY;
29 : int8_t fCurveCount; // only used by kQuad(+) and kCubic(-)
30 : uint8_t fCurveShift; // appled to all Dx/DDx/DDDx except for fCubicDShift exception
31 : uint8_t fCubicDShift; // applied to fCDx and fCDy only in cubic
32 : int8_t fWinding; // 1 or -1
33 :
34 : int setLine(const SkPoint& p0, const SkPoint& p1, const SkIRect* clip,
35 : int shiftUp);
36 : inline int updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by);
37 : void chopLineWithClip(const SkIRect& clip);
38 :
39 0 : inline bool intersectsClip(const SkIRect& clip) const {
40 0 : SkASSERT(fFirstY < clip.fBottom);
41 0 : return fLastY >= clip.fTop;
42 : }
43 :
44 : #ifdef SK_DEBUG
45 : void dump() const {
46 : #ifdef SK_CAN_USE_FLOAT
47 : SkDebugf("edge: firstY:%d lastY:%d x:%g dx:%g w:%d\n", fFirstY, fLastY, SkFixedToFloat(fX), SkFixedToFloat(fDX), fWinding);
48 : #else
49 : SkDebugf("edge: firstY:%d lastY:%d x:%x dx:%x w:%d\n", fFirstY, fLastY, fX, fDX, fWinding);
50 : #endif
51 : }
52 :
53 0 : void validate() const {
54 0 : SkASSERT(fPrev && fNext);
55 0 : SkASSERT(fPrev->fNext == this);
56 0 : SkASSERT(fNext->fPrev == this);
57 :
58 0 : SkASSERT(fFirstY <= fLastY);
59 0 : SkASSERT(SkAbs32(fWinding) == 1);
60 0 : }
61 : #endif
62 : };
63 :
64 : struct SkQuadraticEdge : public SkEdge {
65 : SkFixed fQx, fQy;
66 : SkFixed fQDx, fQDy;
67 : SkFixed fQDDx, fQDDy;
68 : SkFixed fQLastX, fQLastY;
69 :
70 : int setQuadratic(const SkPoint pts[3], int shiftUp);
71 : int updateQuadratic();
72 : };
73 :
74 : struct SkCubicEdge : public SkEdge {
75 : SkFixed fCx, fCy;
76 : SkFixed fCDx, fCDy;
77 : SkFixed fCDDx, fCDDy;
78 : SkFixed fCDDDx, fCDDDy;
79 : SkFixed fCLastX, fCLastY;
80 :
81 : int setCubic(const SkPoint pts[4], const SkIRect* clip, int shiftUp);
82 : int updateCubic();
83 : };
84 :
85 : #endif
|