OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkAAClip_DEFINED | 9 #ifndef SkAAClip_DEFINED |
10 #define SkAAClip_DEFINED | 10 #define SkAAClip_DEFINED |
11 | 11 |
12 #include "SkBlitter.h" | 12 #include "SkBlitter.h" |
13 #include "SkRegion.h" | 13 #include "SkRegion.h" |
14 | 14 |
15 class SkAAClip { | 15 class SkAAClip { |
16 public: | 16 public: |
17 SkAAClip(); | 17 SkAAClip(); |
18 SkAAClip(const SkAAClip&); | 18 SkAAClip(const SkAAClip&); |
19 ~SkAAClip(); | 19 ~SkAAClip(); |
20 | 20 |
21 SkAAClip& operator=(const SkAAClip&); | 21 SkAAClip& operator=(const SkAAClip&); |
22 friend bool operator==(const SkAAClip&, const SkAAClip&); | 22 friend bool operator==(const SkAAClip&, const SkAAClip&); |
23 friend bool operator!=(const SkAAClip& a, const SkAAClip& b) { | 23 friend bool operator!=(const SkAAClip& a, const SkAAClip& b) { |
24 return !(a == b); | 24 return !(a == b); |
25 } | 25 } |
26 | 26 |
27 void swap(SkAAClip&); | 27 void swap(SkAAClip&); |
28 | 28 |
29 bool isEmpty() const { return NULL == fRunHead; } | 29 bool isEmpty() const { return nullptr == fRunHead; } |
30 const SkIRect& getBounds() const { return fBounds; } | 30 const SkIRect& getBounds() const { return fBounds; } |
31 | 31 |
32 // Returns true iff the clip is not empty, and is just a hard-edged rect (no
partial alpha). | 32 // Returns true iff the clip is not empty, and is just a hard-edged rect (no
partial alpha). |
33 // If true, getBounds() can be used in place of this clip. | 33 // If true, getBounds() can be used in place of this clip. |
34 bool isRect() const; | 34 bool isRect() const; |
35 | 35 |
36 bool setEmpty(); | 36 bool setEmpty(); |
37 bool setRect(const SkIRect&); | 37 bool setRect(const SkIRect&); |
38 bool setRect(const SkRect&, bool doAA = true); | 38 bool setRect(const SkRect&, bool doAA = true); |
39 bool setPath(const SkPath&, const SkRegion* clip = NULL, bool doAA = true); | 39 bool setPath(const SkPath&, const SkRegion* clip = nullptr, bool doAA = true
); |
40 bool setRegion(const SkRegion&); | 40 bool setRegion(const SkRegion&); |
41 bool set(const SkAAClip&); | 41 bool set(const SkAAClip&); |
42 | 42 |
43 bool op(const SkAAClip&, const SkAAClip&, SkRegion::Op); | 43 bool op(const SkAAClip&, const SkAAClip&, SkRegion::Op); |
44 | 44 |
45 // Helpers for op() | 45 // Helpers for op() |
46 bool op(const SkIRect&, SkRegion::Op); | 46 bool op(const SkIRect&, SkRegion::Op); |
47 bool op(const SkRect&, SkRegion::Op, bool doAA); | 47 bool op(const SkRect&, SkRegion::Op, bool doAA); |
48 bool op(const SkAAClip&, SkRegion::Op); | 48 bool op(const SkAAClip&, SkRegion::Op); |
49 | 49 |
50 bool translate(int dx, int dy, SkAAClip* dst) const; | 50 bool translate(int dx, int dy, SkAAClip* dst) const; |
51 bool translate(int dx, int dy) { | 51 bool translate(int dx, int dy) { |
52 return this->translate(dx, dy, this); | 52 return this->translate(dx, dy, this); |
53 } | 53 } |
54 | 54 |
55 /** | 55 /** |
56 * Allocates a mask the size of the aaclip, and expands its data into | 56 * Allocates a mask the size of the aaclip, and expands its data into |
57 * the mask, using kA8_Format | 57 * the mask, using kA8_Format |
58 */ | 58 */ |
59 void copyToMask(SkMask*) const; | 59 void copyToMask(SkMask*) const; |
60 | 60 |
61 // called internally | 61 // called internally |
62 | 62 |
63 bool quickContains(int left, int top, int right, int bottom) const; | 63 bool quickContains(int left, int top, int right, int bottom) const; |
64 bool quickContains(const SkIRect& r) const { | 64 bool quickContains(const SkIRect& r) const { |
65 return this->quickContains(r.fLeft, r.fTop, r.fRight, r.fBottom); | 65 return this->quickContains(r.fLeft, r.fTop, r.fRight, r.fBottom); |
66 } | 66 } |
67 | 67 |
68 const uint8_t* findRow(int y, int* lastYForRow = NULL) const; | 68 const uint8_t* findRow(int y, int* lastYForRow = nullptr) const; |
69 const uint8_t* findX(const uint8_t data[], int x, int* initialCount = NULL)
const; | 69 const uint8_t* findX(const uint8_t data[], int x, int* initialCount = nullpt
r) const; |
70 | 70 |
71 class Iter; | 71 class Iter; |
72 struct RunHead; | 72 struct RunHead; |
73 struct YOffset; | 73 struct YOffset; |
74 class Builder; | 74 class Builder; |
75 | 75 |
76 #ifdef SK_DEBUG | 76 #ifdef SK_DEBUG |
77 void validate() const; | 77 void validate() const; |
78 void debug(bool compress_y=false) const; | 78 void debug(bool compress_y=false) const; |
79 #else | 79 #else |
(...skipping 12 matching lines...) Expand all Loading... |
92 | 92 |
93 friend class Builder; | 93 friend class Builder; |
94 class BuilderBlitter; | 94 class BuilderBlitter; |
95 friend class BuilderBlitter; | 95 friend class BuilderBlitter; |
96 }; | 96 }; |
97 | 97 |
98 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
99 | 99 |
100 class SkAAClipBlitter : public SkBlitter { | 100 class SkAAClipBlitter : public SkBlitter { |
101 public: | 101 public: |
102 SkAAClipBlitter() : fScanlineScratch(NULL) {} | 102 SkAAClipBlitter() : fScanlineScratch(nullptr) {} |
103 virtual ~SkAAClipBlitter(); | 103 virtual ~SkAAClipBlitter(); |
104 | 104 |
105 void init(SkBlitter* blitter, const SkAAClip* aaclip) { | 105 void init(SkBlitter* blitter, const SkAAClip* aaclip) { |
106 SkASSERT(aaclip && !aaclip->isEmpty()); | 106 SkASSERT(aaclip && !aaclip->isEmpty()); |
107 fBlitter = blitter; | 107 fBlitter = blitter; |
108 fAAClip = aaclip; | 108 fAAClip = aaclip; |
109 fAAClipBounds = aaclip->getBounds(); | 109 fAAClipBounds = aaclip->getBounds(); |
110 } | 110 } |
111 | 111 |
112 void blitH(int x, int y, int width) override; | 112 void blitH(int x, int y, int width) override; |
(...skipping 15 matching lines...) Expand all Loading... |
128 enum { | 128 enum { |
129 kSize = 32 * 32 | 129 kSize = 32 * 32 |
130 }; | 130 }; |
131 SkAutoSMalloc<kSize> fGrayMaskScratch; // used for blitMask | 131 SkAutoSMalloc<kSize> fGrayMaskScratch; // used for blitMask |
132 void* fScanlineScratch; // enough for a mask at 32bit, or runs+aa | 132 void* fScanlineScratch; // enough for a mask at 32bit, or runs+aa |
133 | 133 |
134 void ensureRunsAndAA(); | 134 void ensureRunsAndAA(); |
135 }; | 135 }; |
136 | 136 |
137 #endif | 137 #endif |
OLD | NEW |