| 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 #ifndef SkAnalyticEdge_DEFINED | 8 #ifndef SkAnalyticEdge_DEFINED |
| 9 #define SkAnalyticEdge_DEFINED | 9 #define SkAnalyticEdge_DEFINED |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // fDY is only used for blitting trapezoids. | 36 // fDY is only used for blitting trapezoids. |
| 37 | 37 |
| 38 int8_t fCurveCount; // only used by kQuad(+) and kCubic(-) | 38 int8_t fCurveCount; // only used by kQuad(+) and kCubic(-) |
| 39 uint8_t fCurveShift; // appled to all Dx/DDx/DDDx except for fCubicDShift
exception | 39 uint8_t fCurveShift; // appled to all Dx/DDx/DDDx except for fCubicDShift
exception |
| 40 uint8_t fCubicDShift; // applied to fCDx and fCDy only in cubic | 40 uint8_t fCubicDShift; // applied to fCDx and fCDy only in cubic |
| 41 int8_t fWinding; // 1 or -1 | 41 int8_t fWinding; // 1 or -1 |
| 42 | 42 |
| 43 static const int kDefaultAccuracy = 2; // default accuracy for snapping | 43 static const int kDefaultAccuracy = 2; // default accuracy for snapping |
| 44 | 44 |
| 45 static inline SkFixed snapY(SkFixed y, int accuracy = kDefaultAccuracy) { | 45 static inline SkFixed snapY(SkFixed y, int accuracy = kDefaultAccuracy) { |
| 46 return SkFixedRoundToFixed(y << accuracy) >> accuracy; | 46 // This approach is safer than left shift, round, then right shift |
| 47 return (y + (SK_Fixed1 >> (accuracy + 1))) >> (16 - accuracy) << (16 - a
ccuracy); |
| 47 } | 48 } |
| 48 | 49 |
| 49 // Update fX, fY of this edge so fY = y | 50 // Update fX, fY of this edge so fY = y |
| 50 inline void goY(SkFixed y) { | 51 inline void goY(SkFixed y) { |
| 51 if (y == fY + SK_Fixed1) { | 52 if (y == fY + SK_Fixed1) { |
| 52 fX = fX + fDX; | 53 fX = fX + fDX; |
| 53 fY = y; | 54 fY = y; |
| 54 } else if (y != fY) { | 55 } else if (y != fY) { |
| 55 // Drop lower digits as our alpha only has 8 bits | 56 // Drop lower digits as our alpha only has 8 bits |
| 56 // (fDX and y - fUpperY may be greater than SK_Fixed1) | 57 // (fDX and y - fUpperY may be greater than SK_Fixed1) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 fWinding = SkToS8(winding); | 146 fWinding = SkToS8(winding); |
| 146 fCurveShift = 0; | 147 fCurveShift = 0; |
| 147 | 148 |
| 148 if (clip) { | 149 if (clip) { |
| 149 this->chopLineWithClip(*clip); | 150 this->chopLineWithClip(*clip); |
| 150 } | 151 } |
| 151 return true; | 152 return true; |
| 152 } | 153 } |
| 153 | 154 |
| 154 #endif | 155 #endif |
| OLD | NEW |