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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #define kBlitterStorageLongCount (sizeof(SkBitmapProcShader) >> 2) | 52 #define kBlitterStorageLongCount (sizeof(SkBitmapProcShader) >> 2) |
53 | 53 |
54 /** Helper for allocating small blitters on the stack. | 54 /** Helper for allocating small blitters on the stack. |
55 */ | 55 */ |
56 class SkAutoBlitterChoose : SkNoncopyable { | 56 class SkAutoBlitterChoose : SkNoncopyable { |
57 public: | 57 public: |
58 SkAutoBlitterChoose() { | 58 SkAutoBlitterChoose() { |
59 fBlitter = NULL; | 59 fBlitter = NULL; |
60 } | 60 } |
61 SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix, | 61 SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix, |
62 const SkPaint& paint) { | 62 const SkPaint& paint, bool drawCoverage = false) { |
63 fBlitter = SkBlitter::Choose(device, matrix, paint, | 63 fBlitter = SkBlitter::Choose(device, matrix, paint, |
64 fStorage, sizeof(fStorage)); | 64 fStorage, sizeof(fStorage), drawCoverage); |
65 } | 65 } |
66 | 66 |
67 ~SkAutoBlitterChoose(); | 67 ~SkAutoBlitterChoose(); |
68 | 68 |
69 SkBlitter* operator->() { return fBlitter; } | 69 SkBlitter* operator->() { return fBlitter; } |
70 SkBlitter* get() const { return fBlitter; } | 70 SkBlitter* get() const { return fBlitter; } |
71 | 71 |
72 void choose(const SkBitmap& device, const SkMatrix& matrix, | 72 void choose(const SkBitmap& device, const SkMatrix& matrix, |
73 const SkPaint& paint) { | 73 const SkPaint& paint) { |
74 SkASSERT(!fBlitter); | 74 SkASSERT(!fBlitter); |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 SkScalar len0 = fast_len(dst[0]); | 1016 SkScalar len0 = fast_len(dst[0]); |
1017 SkScalar len1 = fast_len(dst[1]); | 1017 SkScalar len1 = fast_len(dst[1]); |
1018 if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) { | 1018 if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) { |
1019 *coverage = SkScalarAve(len0, len1); | 1019 *coverage = SkScalarAve(len0, len1); |
1020 return true; | 1020 return true; |
1021 } | 1021 } |
1022 return false; | 1022 return false; |
1023 } | 1023 } |
1024 | 1024 |
1025 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, | 1025 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, |
1026 const SkMatrix* prePathMatrix, bool pathIsMutable) const { | 1026 const SkMatrix* prePathMatrix, bool pathIsMutable, |
| 1027 bool drawCoverage) const { |
1027 SkDEBUGCODE(this->validate();) | 1028 SkDEBUGCODE(this->validate();) |
1028 | 1029 |
1029 // nothing to draw | 1030 // nothing to draw |
1030 if (fRC->isEmpty()) { | 1031 if (fRC->isEmpty()) { |
1031 return; | 1032 return; |
1032 } | 1033 } |
1033 | 1034 |
1034 SkPath* pathPtr = (SkPath*)&origSrcPath; | 1035 SkPath* pathPtr = (SkPath*)&origSrcPath; |
1035 bool doFill = true; | 1036 bool doFill = true; |
1036 SkPath tmpPath; | 1037 SkPath tmpPath; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 } | 1106 } |
1106 return; | 1107 return; |
1107 } | 1108 } |
1108 | 1109 |
1109 // avoid possibly allocating a new path in transform if we can | 1110 // avoid possibly allocating a new path in transform if we can |
1110 SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath; | 1111 SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath; |
1111 | 1112 |
1112 // transform the path into device space | 1113 // transform the path into device space |
1113 pathPtr->transform(*matrix, devPathPtr); | 1114 pathPtr->transform(*matrix, devPathPtr); |
1114 | 1115 |
1115 SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, *paint); | 1116 SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, *paint, drawCoverage); |
1116 | 1117 |
1117 if (paint->getMaskFilter()) { | 1118 if (paint->getMaskFilter()) { |
1118 SkPaint::Style style = doFill ? SkPaint::kFill_Style : | 1119 SkPaint::Style style = doFill ? SkPaint::kFill_Style : |
1119 SkPaint::kStroke_Style; | 1120 SkPaint::kStroke_Style; |
1120 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, | 1121 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, |
1121 fBounder, blitter.get(), | 1122 fBounder, blitter.get(), |
1122 style)) { | 1123 style)) { |
1123 return; // filterPath() called the blitter, so we're done | 1124 return; // filterPath() called the blitter, so we're done |
1124 } | 1125 } |
1125 } | 1126 } |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 mask->fImage = SkMask::AllocImage(size); | 2827 mask->fImage = SkMask::AllocImage(size); |
2827 memset(mask->fImage, 0, mask->computeImageSize()); | 2828 memset(mask->fImage, 0, mask->computeImageSize()); |
2828 } | 2829 } |
2829 | 2830 |
2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2831 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2831 draw_into_mask(*mask, devPath, style); | 2832 draw_into_mask(*mask, devPath, style); |
2832 } | 2833 } |
2833 | 2834 |
2834 return true; | 2835 return true; |
2835 } | 2836 } |
OLD | NEW |