Line data Source code
1 : /*
2 : * Copyright 2011 Google Inc.
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 : #ifndef SkEdgeBuilder_DEFINED
8 : #define SkEdgeBuilder_DEFINED
9 :
10 : #include "SkArenaAlloc.h"
11 : #include "SkRect.h"
12 : #include "SkTDArray.h"
13 :
14 : struct SkEdge;
15 : struct SkAnalyticEdge;
16 : class SkEdgeClipper;
17 : class SkPath;
18 :
19 226 : class SkEdgeBuilder {
20 : public:
21 : SkEdgeBuilder();
22 :
23 : // returns the number of built edges. The array of those edge pointers
24 : // is returned from edgeList().
25 : int build(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToTheRight,
26 : bool analyticAA = false);
27 :
28 42 : SkEdge** edgeList() { return (SkEdge**)fEdgeList; }
29 184 : SkAnalyticEdge** analyticEdgeList() { return (SkAnalyticEdge**)fEdgeList; }
30 :
31 : private:
32 : enum Combine {
33 : kNo_Combine,
34 : kPartial_Combine,
35 : kTotal_Combine
36 : };
37 :
38 : Combine CombineVertical(const SkEdge* edge, SkEdge* last);
39 : Combine CombineVertical(const SkAnalyticEdge* edge, SkAnalyticEdge* last);
40 : Combine checkVertical(const SkEdge* edge, SkEdge** edgePtr);
41 : Combine checkVertical(const SkAnalyticEdge* edge, SkAnalyticEdge** edgePtr);
42 : bool vertical_line(const SkEdge* edge);
43 : bool vertical_line(const SkAnalyticEdge* edge);
44 :
45 : SkArenaAlloc fAlloc;
46 : SkTDArray<void*> fList;
47 :
48 : /*
49 : * If we're in general mode, we allcoate the pointers in fList, and this
50 : * will point at fList.begin(). If we're in polygon mode, fList will be
51 : * empty, as we will have preallocated room for the pointers in fAlloc's
52 : * block, and fEdgeList will point into that.
53 : */
54 : void** fEdgeList;
55 :
56 : int fShiftUp;
57 : bool fAnalyticAA;
58 :
59 : public:
60 : void addLine(const SkPoint pts[]);
61 : void addQuad(const SkPoint pts[]);
62 : void addCubic(const SkPoint pts[]);
63 : void addClipper(SkEdgeClipper*);
64 :
65 : int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToTheRight);
66 : };
67 :
68 : #endif
|