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" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #include "SkDevice.h" | 13 #include "SkDevice.h" |
14 #include "SkDeviceLooper.h" | 14 #include "SkDeviceLooper.h" |
15 #include "SkFixed.h" | 15 #include "SkFixed.h" |
16 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
17 #include "SkPaint.h" | 17 #include "SkPaint.h" |
18 #include "SkPathEffect.h" | 18 #include "SkPathEffect.h" |
19 #include "SkRasterClip.h" | 19 #include "SkRasterClip.h" |
20 #include "SkRasterizer.h" | 20 #include "SkRasterizer.h" |
| 21 #include "SkRRect.h" |
21 #include "SkScan.h" | 22 #include "SkScan.h" |
22 #include "SkShader.h" | 23 #include "SkShader.h" |
23 #include "SkString.h" | 24 #include "SkString.h" |
24 #include "SkStroke.h" | 25 #include "SkStroke.h" |
25 #include "SkTemplatesPriv.h" | 26 #include "SkTemplatesPriv.h" |
26 #include "SkTLazy.h" | 27 #include "SkTLazy.h" |
27 #include "SkUtils.h" | 28 #include "SkUtils.h" |
28 | 29 |
29 #include "SkAutoKern.h" | 30 #include "SkAutoKern.h" |
30 #include "SkBitmapProcShader.h" | 31 #include "SkBitmapProcShader.h" |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 matrix.mapVectors(dst, src, 2); | 1016 matrix.mapVectors(dst, src, 2); |
1016 SkScalar len0 = fast_len(dst[0]); | 1017 SkScalar len0 = fast_len(dst[0]); |
1017 SkScalar len1 = fast_len(dst[1]); | 1018 SkScalar len1 = fast_len(dst[1]); |
1018 if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) { | 1019 if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) { |
1019 *coverage = SkScalarAve(len0, len1); | 1020 *coverage = SkScalarAve(len0, len1); |
1020 return true; | 1021 return true; |
1021 } | 1022 } |
1022 return false; | 1023 return false; |
1023 } | 1024 } |
1024 | 1025 |
| 1026 void SkDraw::drawRRect(const SkRRect& rrect, const SkPaint& paint) const { |
| 1027 SkDEBUGCODE(this->validate()); |
| 1028 |
| 1029 if (fRC->isEmpty()) { |
| 1030 return; |
| 1031 } |
| 1032 |
| 1033 { |
| 1034 // TODO: Investigate optimizing these options. They are in the same |
| 1035 // order as SkDraw::drawPath, which handles each case. It may be |
| 1036 // that there is no way to optimize for these using the SkRRect path. |
| 1037 SkScalar coverage; |
| 1038 if (SkDrawTreatAsHairline(paint, *fMatrix, &coverage)) { |
| 1039 goto DRAW_PATH; |
| 1040 } |
| 1041 |
| 1042 if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) { |
| 1043 goto DRAW_PATH; |
| 1044 } |
| 1045 |
| 1046 if (paint.getRasterizer()) { |
| 1047 goto DRAW_PATH; |
| 1048 } |
| 1049 } |
| 1050 |
| 1051 if (paint.getMaskFilter()) { |
| 1052 // Transform the rrect into device space. |
| 1053 SkRRect devRRect; |
| 1054 if (rrect.transform(*fMatrix, &devRRect)) { |
| 1055 SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint); |
| 1056 if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, |
| 1057 fBounder, blitter.get(), |
| 1058 SkPaint::kFill_Style)) { |
| 1059 return; // filterRRect() called the blitter, so we're done |
| 1060 } |
| 1061 } |
| 1062 } |
| 1063 |
| 1064 DRAW_PATH: |
| 1065 // Now fall back to the default case of using a path. |
| 1066 SkPath path; |
| 1067 path.addRRect(rrect); |
| 1068 this->drawPath(path, paint, NULL, true); |
| 1069 } |
| 1070 |
1025 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, | 1071 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, |
1026 const SkMatrix* prePathMatrix, bool pathIsMutable) const { | 1072 const SkMatrix* prePathMatrix, bool pathIsMutable) const { |
1027 SkDEBUGCODE(this->validate();) | 1073 SkDEBUGCODE(this->validate();) |
1028 | 1074 |
1029 // nothing to draw | 1075 // nothing to draw |
1030 if (fRC->isEmpty()) { | 1076 if (fRC->isEmpty()) { |
1031 return; | 1077 return; |
1032 } | 1078 } |
1033 | 1079 |
1034 SkPath* pathPtr = (SkPath*)&origSrcPath; | 1080 SkPath* pathPtr = (SkPath*)&origSrcPath; |
(...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 mask->fImage = SkMask::AllocImage(size); | 2872 mask->fImage = SkMask::AllocImage(size); |
2827 memset(mask->fImage, 0, mask->computeImageSize()); | 2873 memset(mask->fImage, 0, mask->computeImageSize()); |
2828 } | 2874 } |
2829 | 2875 |
2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2876 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2831 draw_into_mask(*mask, devPath, style); | 2877 draw_into_mask(*mask, devPath, style); |
2832 } | 2878 } |
2833 | 2879 |
2834 return true; | 2880 return true; |
2835 } | 2881 } |
OLD | NEW |