Debian Codegraph @

src/core/SkScanPriv.h

raw
1 /*
2 * Copyright 2006 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 #ifndef SkScanPriv_DEFINED
9 #define SkScanPriv_DEFINED
10
11 #include "include/core/SkPath.h"
12 #include "src/core/SkBlitter.h"
13 #include "src/core/SkScan.h"
14
15 // controls how much we super-sample (when we use that scan convertion)
16 #define SK_SUPERSAMPLE_SHIFT 2
17
18 class SkScanClipper {
19 public:
20 SkScanClipper(SkBlitter* blitter, const SkRegion* clip, const SkIRect& bounds,
21 bool skipRejectTest = false, bool boundsPreClipped = false);
22
23 SkBlitter* getBlitter() const { return fBlitter; }
24 const SkIRect* getClipRect() const { return fClipRect; }
25
26 private:
27 SkRectClipBlitter fRectBlitter;
28 SkRgnClipBlitter fRgnBlitter;
29 #ifdef SK_DEBUG
30 SkRectClipCheckBlitter fRectClipCheckBlitter;
31 #endif
32 SkBlitter* fBlitter;
33 const SkIRect* fClipRect;
34 };
35
36 // blit the rects above and below avoid, clipped to clip
37 void sk_blit_above(SkBlitter*, const SkIRect& avoid, const SkRegion& clip);
38 void sk_blit_below(SkBlitter*, const SkIRect& avoid, const SkRegion& clip);
39
40 template<class EdgeType>
41 static inline void remove_edge(EdgeType* edge) {
42 edge->fPrev->fNext = edge->fNext;
43 edge->fNext->fPrev = edge->fPrev;
44 }
45
46 template<class EdgeType>
47 static inline void insert_edge_after(EdgeType* edge, EdgeType* afterMe) {
48 edge->fPrev = afterMe;
49 edge->fNext = afterMe->fNext;
50 afterMe->fNext->fPrev = edge;
51 afterMe->fNext = edge;
52 }
53
54 template<class EdgeType>
55 void backward_insert_edge_based_on_x(EdgeType* edge) {
56 SkFixed x = edge->fX;
57 EdgeType* prev = edge->fPrev;
58 while (prev->fPrev && prev->fX > x) {
59 prev = prev->fPrev;
60 }
61 if (prev->fNext != edge) {
62 remove_edge(edge);
63 insert_edge_after(edge, prev);
64 }
65 }
66
67 // Start from the right side, searching backwards for the point to begin the new edge list
68 // insertion, marching forwards from here. The implementation could have started from the left
69 // of the prior insertion, and search to the right, or with some additional caching, binary
70 // search the starting point. More work could be done to determine optimal new edge insertion.
71 template<class EdgeType>
72 EdgeType* backward_insert_start(EdgeType* prev, SkFixed x) {
73 while (prev->fPrev && prev->fX > x) {
74 prev = prev->fPrev;
75 }
76 return prev;
77 }
78
79 #endif