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); | |
27 return alpha - (alpha >> 8); | 26 return alpha - (alpha >> 8); |
28 } | 27 } |
29 | 28 |
30 /// Returns true if the scanline contains only a single run, | 29 /// Returns true if the scanline contains only a single run, |
31 /// of alpha value 0. | 30 /// of alpha value 0. |
32 bool empty() const { | 31 bool empty() const { |
33 SkASSERT(fRuns[0] > 0); | 32 SkASSERT(fRuns[0] > 0); |
34 return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0; | 33 return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0; |
35 } | 34 } |
36 | 35 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 x -= n; | 186 x -= n; |
188 } | 187 } |
189 } | 188 } |
190 | 189 |
191 private: | 190 private: |
192 SkDEBUGCODE(int fWidth;) | 191 SkDEBUGCODE(int fWidth;) |
193 SkDEBUGCODE(void validate() const;) | 192 SkDEBUGCODE(void validate() const;) |
194 }; | 193 }; |
195 | 194 |
196 #endif | 195 #endif |
OLD | NEW |