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 SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, | 990 bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix& matrix, |
991 SkScalar* coverage) { | 991 SkScalar* coverage) { |
992 SkASSERT(coverage); | 992 SkASSERT(coverage); |
993 if (SkPaint::kStroke_Style != paint.getStyle()) { | 993 SkASSERT(strokeWidth > 0); |
994 return false; | 994 // We need to try to fake a thick-stroke with a modulated hairline. |
995 } | |
996 SkScalar strokeWidth = paint.getStrokeWidth(); | |
997 if (0 == strokeWidth) { | |
998 *coverage = SK_Scalar1; | |
999 return true; | |
1000 } | |
1001 | 995 |
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 } | |
1008 if (matrix.hasPerspective()) { | 996 if (matrix.hasPerspective()) { |
1009 return false; | 997 return false; |
1010 } | 998 } |
1011 | 999 |
1012 SkVector src[2], dst[2]; | 1000 SkVector src[2], dst[2]; |
1013 src[0].set(strokeWidth, 0); | 1001 src[0].set(strokeWidth, 0); |
1014 src[1].set(0, strokeWidth); | 1002 src[1].set(0, strokeWidth); |
1015 matrix.mapVectors(dst, src, 2); | 1003 matrix.mapVectors(dst, src, 2); |
1016 SkScalar len0 = fast_len(dst[0]); | 1004 SkScalar len0 = fast_len(dst[0]); |
1017 SkScalar len1 = fast_len(dst[1]); | 1005 SkScalar len1 = fast_len(dst[1]); |
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 mask->fImage = SkMask::AllocImage(size); | 2814 mask->fImage = SkMask::AllocImage(size); |
2827 memset(mask->fImage, 0, mask->computeImageSize()); | 2815 memset(mask->fImage, 0, mask->computeImageSize()); |
2828 } | 2816 } |
2829 | 2817 |
2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2818 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2831 draw_into_mask(*mask, devPath, style); | 2819 draw_into_mask(*mask, devPath, style); |
2832 } | 2820 } |
2833 | 2821 |
2834 return true; | 2822 return true; |
2835 } | 2823 } |
OLD | NEW |