-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRasterizerImpl.h
79 lines (65 loc) · 1.75 KB
/
RasterizerImpl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
// RasterizerImpl.h
//
// Classes for rasterization
// Copyright (c) 2015 by Kronosaur Productions, LLC. All Rights Reserved.
#pragma once
struct SEdgeState
{
SEdgeState *pNextEdge;
int x;
int yStart;
int xWholePixelMove;
int xDirection;
int iErrorTerm;
int iErrorTermAdjUp;
int iErrorTermAdjDown;
int iCount;
};
class CSortedEdgeList
{
public:
CSortedEdgeList (void) :
m_pFirst(NULL),
m_pNext(NULL)
{ }
void Advance (void);
inline SEdgeState *GetFirst (void) const { return m_pFirst; }
inline CSortedEdgeList *GetNext (void) const { return m_pNext; }
void Insert (SEdgeState *pEdge);
void Insert (CSortedEdgeList &EdgeList);
inline bool IsEmpty (void) const { return (m_pFirst == NULL); }
inline void SetNext (CSortedEdgeList *pNext) { m_pNext = pNext; }
void Sort (void);
private:
SEdgeState *m_pFirst;
CSortedEdgeList *m_pNext;
};
class CGlobalEdgeTable
{
public:
CGlobalEdgeTable (void) :
m_pFirst(NULL),
m_pLast(NULL)
{ }
~CGlobalEdgeTable (void);
inline CSortedEdgeList *GetFirst (void) const { return m_pFirst; }
inline CSortedEdgeList *GetLast (void) const { return m_pLast; }
void Insert (SEdgeState *pEdge);
private:
CSortedEdgeList *m_pFirst;
CSortedEdgeList *m_pLast;
};
class CPolygonRasterizer
{
public:
CPolygonRasterizer (const CGPath &Path, int iAntiAlias = 3);
~CPolygonRasterizer (void);
void Rasterize (CGRegion *retRegion);
private:
void AddPolygonToGET (const TArray<CVector> &Points);
void RasterizeLine (CGRunList &Runs);
TArray<SEdgeState *> m_Edges; // An array of allocated edge arrays
CGlobalEdgeTable m_GET; // Global Edge Table
CSortedEdgeList m_AET; // Active Edge Table
int m_iAntiAlias; // Number of sub-pixel samples per dimension
};