Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: src/core/SkDraw.cpp

Issue 48623006: Add ability to ninepatch blurred rounded rectangle (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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()
robertphillips 2013/10/31 00:24:58 will this fit on the prior line?
scroggo 2013/11/01 21:45:46 It is 81 chars, so it falls within our hard limit
1043 || paint.getStyle() != SkPaint::kFill_Style) {
1044 goto DRAW_PATH;
1045 }
1046
1047 if (paint.getRasterizer()) {
1048 goto DRAW_PATH;
1049 }
1050 }
1051
1052 if (paint.getMaskFilter()) {
1053 // Transform the rrect into device space.
1054 SkRRect devRRect;
1055 if (rrect.transform(*fMatrix, &devRRect)) {
1056 SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
1057 if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC,
1058 fBounder, blitter.get(),
1059 SkPaint::kFill_Style)) {
1060 return; // filterRRect() called the blitter, so we're done
1061 }
1062 }
1063 }
1064
1065 DRAW_PATH:
1066 // Now fall back to the default case of using a path.
1067 SkPath path;
1068 path.addRRect(rrect);
1069 this->drawPath(path, paint, NULL, true);
1070 }
1071
1025 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, 1072 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
1026 const SkMatrix* prePathMatrix, bool pathIsMutable) const { 1073 const SkMatrix* prePathMatrix, bool pathIsMutable) const {
1027 SkDEBUGCODE(this->validate();) 1074 SkDEBUGCODE(this->validate();)
1028 1075
1029 // nothing to draw 1076 // nothing to draw
1030 if (fRC->isEmpty()) { 1077 if (fRC->isEmpty()) {
1031 return; 1078 return;
1032 } 1079 }
1033 1080
1034 SkPath* pathPtr = (SkPath*)&origSrcPath; 1081 SkPath* pathPtr = (SkPath*)&origSrcPath;
(...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 mask->fImage = SkMask::AllocImage(size); 2873 mask->fImage = SkMask::AllocImage(size);
2827 memset(mask->fImage, 0, mask->computeImageSize()); 2874 memset(mask->fImage, 0, mask->computeImageSize());
2828 } 2875 }
2829 2876
2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2877 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2831 draw_into_mask(*mask, devPath, style); 2878 draw_into_mask(*mask, devPath, style);
2832 } 2879 }
2833 2880
2834 return true; 2881 return true;
2835 } 2882 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698