| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 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 | 9 |
| 10 #include "SkScanPriv.h" | 10 #include "SkScanPriv.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 We have two techniques for capturing the output of the supersampler: | 22 We have two techniques for capturing the output of the supersampler: |
| 23 - SUPERMASK, which records a large mask-bitmap | 23 - SUPERMASK, which records a large mask-bitmap |
| 24 this is often faster for small, complex objects | 24 this is often faster for small, complex objects |
| 25 - RLE, which records a rle-encoded scanline | 25 - RLE, which records a rle-encoded scanline |
| 26 this is often faster for large objects with big spans | 26 this is often faster for large objects with big spans |
| 27 | 27 |
| 28 These blitters use two coordinate systems: | 28 These blitters use two coordinate systems: |
| 29 - destination coordinates, scale equal to the output - often | 29 - destination coordinates, scale equal to the output - often |
| 30 abbreviated with 'i' or 'I' in variable names | 30 abbreviated with 'i' or 'I' in variable names |
| 31 - supersampled coordinates, scale equal to the output * SCALE | 31 - supersampled coordinates, scale equal to the output * SCALE |
| 32 | |
| 33 Enabling SK_USE_LEGACY_AA_COVERAGE keeps the aa coverage calculations as | |
| 34 they were before the fix that unified the output of the RLE and MASK | |
| 35 supersamplers. | |
| 36 */ | 32 */ |
| 37 | 33 |
| 38 //#define FORCE_SUPERMASK | 34 //#define FORCE_SUPERMASK |
| 39 //#define FORCE_RLE | 35 //#define FORCE_RLE |
| 40 //#define SK_USE_LEGACY_AA_COVERAGE | |
| 41 | 36 |
| 42 /////////////////////////////////////////////////////////////////////////////// | 37 /////////////////////////////////////////////////////////////////////////////// |
| 43 | 38 |
| 44 /// Base class for a single-pass supersampled blitter. | 39 /// Base class for a single-pass supersampled blitter. |
| 45 class BaseSuperBlitter : public SkBlitter { | 40 class BaseSuperBlitter : public SkBlitter { |
| 46 public: | 41 public: |
| 47 BaseSuperBlitter(SkBlitter* realBlitter, const SkIRect& ir, | 42 BaseSuperBlitter(SkBlitter* realBlitter, const SkIRect& ir, |
| 48 const SkRegion& clip, bool isInverse); | 43 const SkRegion& clip, bool isInverse); |
| 49 | 44 |
| 50 /// Must be explicitly defined on subclasses. | 45 /// Must be explicitly defined on subclasses. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 178 } |
| 184 | 179 |
| 185 /** coverage_to_partial_alpha() is being used by SkAlphaRuns, which | 180 /** coverage_to_partial_alpha() is being used by SkAlphaRuns, which |
| 186 *accumulates* SCALE pixels worth of "alpha" in [0,(256/SCALE)] | 181 *accumulates* SCALE pixels worth of "alpha" in [0,(256/SCALE)] |
| 187 to produce a final value in [0, 255] and handles clamping 256->255 | 182 to produce a final value in [0, 255] and handles clamping 256->255 |
| 188 itself, with the same (alpha - (alpha >> 8)) correction as | 183 itself, with the same (alpha - (alpha >> 8)) correction as |
| 189 coverage_to_exact_alpha(). | 184 coverage_to_exact_alpha(). |
| 190 */ | 185 */ |
| 191 static inline int coverage_to_partial_alpha(int aa) { | 186 static inline int coverage_to_partial_alpha(int aa) { |
| 192 aa <<= 8 - 2*SHIFT; | 187 aa <<= 8 - 2*SHIFT; |
| 193 #ifdef SK_USE_LEGACY_AA_COVERAGE | |
| 194 aa -= aa >> (8 - SHIFT - 1); | |
| 195 #endif | |
| 196 return aa; | 188 return aa; |
| 197 } | 189 } |
| 198 | 190 |
| 199 /** coverage_to_exact_alpha() is being used by our blitter, which wants | 191 /** coverage_to_exact_alpha() is being used by our blitter, which wants |
| 200 a final value in [0, 255]. | 192 a final value in [0, 255]. |
| 201 */ | 193 */ |
| 202 static inline int coverage_to_exact_alpha(int aa) { | 194 static inline int coverage_to_exact_alpha(int aa) { |
| 203 int alpha = (256 >> SHIFT) * aa; | 195 int alpha = (256 >> SHIFT) * aa; |
| 204 // clamp 256->255 | 196 // clamp 256->255 |
| 205 return alpha - (alpha >> 8); | 197 return alpha - (alpha >> 8); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 AntiFillPath(path, clip.bwRgn(), blitter); | 758 AntiFillPath(path, clip.bwRgn(), blitter); |
| 767 } else { | 759 } else { |
| 768 SkRegion tmp; | 760 SkRegion tmp; |
| 769 SkAAClipBlitter aaBlitter; | 761 SkAAClipBlitter aaBlitter; |
| 770 | 762 |
| 771 tmp.setRect(clip.getBounds()); | 763 tmp.setRect(clip.getBounds()); |
| 772 aaBlitter.init(blitter, &clip.aaRgn()); | 764 aaBlitter.init(blitter, &clip.aaRgn()); |
| 773 SkScan::AntiFillPath(path, tmp, &aaBlitter, true); | 765 SkScan::AntiFillPath(path, tmp, &aaBlitter, true); |
| 774 } | 766 } |
| 775 } | 767 } |
| OLD | NEW |