epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright 2006 The Android Open Source Project |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #ifndef SkAntiRun_DEFINED |
| 11 | #define SkAntiRun_DEFINED |
| 12 | |
| 13 | #include "SkBlitter.h" |
| 14 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 15 | class SkAlphaRuns { |
| 16 | public: |
| 17 | int16_t* fRuns; |
| 18 | uint8_t* fAlpha; |
| 19 | |
mike@reedtribe.org | d11f0e0 | 2011-04-09 19:39:25 +0000 | [diff] [blame] | 20 | bool empty() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | SkASSERT(fRuns[0] > 0); |
| 22 | return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0; |
| 23 | } |
mike@reedtribe.org | d11f0e0 | 2011-04-09 19:39:25 +0000 | [diff] [blame] | 24 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 25 | void reset(int width); |
reed@google.com | fa57ae7 | 2011-05-31 19:18:02 +0000 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Returns the offsetX value that should be passed on the next call, |
| 29 | * assuming we're on the same scanline. If the caller is switching |
| 30 | * scanlines, then offsetX should be 0 when this is called. |
| 31 | */ |
| 32 | int add(int x, U8CPU startAlpha, int middleCount, U8CPU stopAlpha, |
| 33 | U8CPU maxValue, int offsetX); |
| 34 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 35 | SkDEBUGCODE(void assertValid(int y, int maxStep) const;) |
| 36 | SkDEBUGCODE(void dump() const;) |
| 37 | |
| 38 | static void Break(int16_t runs[], uint8_t alpha[], int x, int count); |
mike@reedtribe.org | d11f0e0 | 2011-04-09 19:39:25 +0000 | [diff] [blame] | 39 | |
| 40 | static void BreakAt(int16_t runs[], uint8_t alpha[], int x) { |
| 41 | while (x > 0) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | int n = runs[0]; |
| 43 | SkASSERT(n > 0); |
| 44 | |
mike@reedtribe.org | d11f0e0 | 2011-04-09 19:39:25 +0000 | [diff] [blame] | 45 | if (x < n) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | alpha[x] = alpha[0]; |
| 47 | runs[0] = SkToS16(x); |
| 48 | runs[x] = SkToS16(n - x); |
| 49 | break; |
| 50 | } |
| 51 | runs += n; |
| 52 | alpha += n; |
| 53 | x -= n; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | private: |
| 58 | SkDEBUGCODE(int fWidth;) |
| 59 | SkDEBUGCODE(void validate() const;) |
| 60 | }; |
| 61 | |
| 62 | #endif |
| 63 | |