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 #include "SkDraw.h" | 8 #include "SkDraw.h" |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "SkBounder.h" | 10 #include "SkBounder.h" |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 switch (dc) { | 980 switch (dc) { |
981 case SkXfermode::kOne_Coeff: | 981 case SkXfermode::kOne_Coeff: |
982 case SkXfermode::kISA_Coeff: | 982 case SkXfermode::kISA_Coeff: |
983 case SkXfermode::kISC_Coeff: | 983 case SkXfermode::kISC_Coeff: |
984 return true; | 984 return true; |
985 default: | 985 default: |
986 return false; | 986 return false; |
987 } | 987 } |
988 } | 988 } |
989 | 989 |
990 bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix& matrix, | 990 bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, |
991 SkScalar* coverage) { | 991 SkScalar* coverage) { |
992 SkASSERT(coverage); | 992 SkASSERT(coverage); |
993 SkASSERT(strokeWidth > 0); | 993 if (SkPaint::kStroke_Style != paint.getStyle()) { |
994 // We need to try to fake a thick-stroke with a modulated hairline. | 994 return false; |
| 995 } |
| 996 SkScalar strokeWidth = paint.getStrokeWidth(); |
| 997 if (0 == strokeWidth) { |
| 998 *coverage = SK_Scalar1; |
| 999 return true; |
| 1000 } |
995 | 1001 |
| 1002 // if we get here, we need to try to fake a thick-stroke with a modulated |
| 1003 // hairline |
| 1004 |
| 1005 if (!paint.isAntiAlias()) { |
| 1006 return false; |
| 1007 } |
996 if (matrix.hasPerspective()) { | 1008 if (matrix.hasPerspective()) { |
997 return false; | 1009 return false; |
998 } | 1010 } |
999 | 1011 |
1000 SkVector src[2], dst[2]; | 1012 SkVector src[2], dst[2]; |
1001 src[0].set(strokeWidth, 0); | 1013 src[0].set(strokeWidth, 0); |
1002 src[1].set(0, strokeWidth); | 1014 src[1].set(0, strokeWidth); |
1003 matrix.mapVectors(dst, src, 2); | 1015 matrix.mapVectors(dst, src, 2); |
1004 SkScalar len0 = fast_len(dst[0]); | 1016 SkScalar len0 = fast_len(dst[0]); |
1005 SkScalar len1 = fast_len(dst[1]); | 1017 SkScalar len1 = fast_len(dst[1]); |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 mask->fImage = SkMask::AllocImage(size); | 2827 mask->fImage = SkMask::AllocImage(size); |
2816 memset(mask->fImage, 0, mask->computeImageSize()); | 2828 memset(mask->fImage, 0, mask->computeImageSize()); |
2817 } | 2829 } |
2818 | 2830 |
2819 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2831 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2820 draw_into_mask(*mask, devPath, style); | 2832 draw_into_mask(*mask, devPath, style); |
2821 } | 2833 } |
2822 | 2834 |
2823 return true; | 2835 return true; |
2824 } | 2836 } |
OLD | NEW |