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, bool drawCoverage = false) { | 62 const SkPaint& paint) { |
63 fBlitter = SkBlitter::Choose(device, matrix, paint, | 63 fBlitter = SkBlitter::Choose(device, matrix, paint, |
64 fStorage, sizeof(fStorage), drawCoverage); | 64 fStorage, sizeof(fStorage)); |
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, | 1026 const SkMatrix* prePathMatrix, bool pathIsMutable) const { |
1027 bool drawCoverage) const { | |
1028 SkDEBUGCODE(this->validate();) | 1027 SkDEBUGCODE(this->validate();) |
1029 | 1028 |
1030 // nothing to draw | 1029 // nothing to draw |
1031 if (fRC->isEmpty()) { | 1030 if (fRC->isEmpty()) { |
1032 return; | 1031 return; |
1033 } | 1032 } |
1034 | 1033 |
1035 SkPath* pathPtr = (SkPath*)&origSrcPath; | 1034 SkPath* pathPtr = (SkPath*)&origSrcPath; |
1036 bool doFill = true; | 1035 bool doFill = true; |
1037 SkPath tmpPath; | 1036 SkPath tmpPath; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 } | 1105 } |
1107 return; | 1106 return; |
1108 } | 1107 } |
1109 | 1108 |
1110 // avoid possibly allocating a new path in transform if we can | 1109 // avoid possibly allocating a new path in transform if we can |
1111 SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath; | 1110 SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath; |
1112 | 1111 |
1113 // transform the path into device space | 1112 // transform the path into device space |
1114 pathPtr->transform(*matrix, devPathPtr); | 1113 pathPtr->transform(*matrix, devPathPtr); |
1115 | 1114 |
1116 SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, *paint, drawCoverage); | 1115 SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, *paint); |
1117 | 1116 |
1118 if (paint->getMaskFilter()) { | 1117 if (paint->getMaskFilter()) { |
1119 SkPaint::Style style = doFill ? SkPaint::kFill_Style : | 1118 SkPaint::Style style = doFill ? SkPaint::kFill_Style : |
1120 SkPaint::kStroke_Style; | 1119 SkPaint::kStroke_Style; |
1121 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, | 1120 if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, |
1122 fBounder, blitter.get(), | 1121 fBounder, blitter.get(), |
1123 style)) { | 1122 style)) { |
1124 return; // filterPath() called the blitter, so we're done | 1123 return; // filterPath() called the blitter, so we're done |
1125 } | 1124 } |
1126 } | 1125 } |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 mask->fImage = SkMask::AllocImage(size); | 2826 mask->fImage = SkMask::AllocImage(size); |
2828 memset(mask->fImage, 0, mask->computeImageSize()); | 2827 memset(mask->fImage, 0, mask->computeImageSize()); |
2829 } | 2828 } |
2830 | 2829 |
2831 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2832 draw_into_mask(*mask, devPath, style); | 2831 draw_into_mask(*mask, devPath, style); |
2833 } | 2832 } |
2834 | 2833 |
2835 return true; | 2834 return true; |
2836 } | 2835 } |
OLD | NEW |