OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkAntiRun_DEFINED | 9 #ifndef SkAntiRun_DEFINED |
10 #define SkAntiRun_DEFINED | 10 #define SkAntiRun_DEFINED |
11 | 11 |
12 #include "SkBlitter.h" | 12 #include "SkBlitter.h" |
13 | 13 |
14 /** Sparse array of run-length-encoded alpha (supersampling coverage) values. | 14 /** Sparse array of run-length-encoded alpha (supersampling coverage) values. |
15 Sparseness allows us to independently compose several paths into the | 15 Sparseness allows us to independently compose several paths into the |
16 same SkAlphaRuns buffer. | 16 same SkAlphaRuns buffer. |
17 */ | 17 */ |
18 | 18 |
19 class SkAlphaRuns { | 19 class SkAlphaRuns { |
20 public: | 20 public: |
21 int16_t* fRuns; | 21 int16_t* fRuns; |
22 uint8_t* fAlpha; | 22 uint8_t* fAlpha; |
23 | 23 |
24 // Return 0-255 given 0-256 | 24 // Return 0-255 given 0-256 |
25 static inline SkAlpha CatchOverflow(int alpha) { | 25 static inline SkAlpha CatchOverflow(int alpha) { |
| 26 SkASSERT(alpha >= 0 && alpha <= 256); |
26 return alpha - (alpha >> 8); | 27 return alpha - (alpha >> 8); |
27 } | 28 } |
28 | 29 |
29 /// Returns true if the scanline contains only a single run, | 30 /// Returns true if the scanline contains only a single run, |
30 /// of alpha value 0. | 31 /// of alpha value 0. |
31 bool empty() const { | 32 bool empty() const { |
32 SkASSERT(fRuns[0] > 0); | 33 SkASSERT(fRuns[0] > 0); |
33 return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0; | 34 return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0; |
34 } | 35 } |
35 | 36 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 x -= n; | 187 x -= n; |
187 } | 188 } |
188 } | 189 } |
189 | 190 |
190 private: | 191 private: |
191 SkDEBUGCODE(int fWidth;) | 192 SkDEBUGCODE(int fWidth;) |
192 SkDEBUGCODE(void validate() const;) | 193 SkDEBUGCODE(void validate() const;) |
193 }; | 194 }; |
194 | 195 |
195 #endif | 196 #endif |
OLD | NEW |