OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "gm.h" | 8 #include "gm.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 p.setXfermode(nullptr); | 71 p.setXfermode(nullptr); |
72 rastBuilder->addLayer(p); | 72 rastBuilder->addLayer(p); |
73 } | 73 } |
74 | 74 |
75 #include "SkDiscretePathEffect.h" | 75 #include "SkDiscretePathEffect.h" |
76 | 76 |
77 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { | 77 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { |
78 rastBuilder->addLayer(p); | 78 rastBuilder->addLayer(p); |
79 | 79 |
80 p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->u
nref(); | 80 p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3)); |
81 p.setXfermodeMode(SkXfermode::kSrcOut_Mode); | 81 p.setXfermodeMode(SkXfermode::kSrcOut_Mode); |
82 rastBuilder->addLayer(p); | 82 rastBuilder->addLayer(p); |
83 } | 83 } |
84 | 84 |
85 static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { | 85 static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { |
86 rastBuilder->addLayer(p); | 86 rastBuilder->addLayer(p); |
87 | 87 |
88 p.setAntiAlias(false); | 88 p.setAntiAlias(false); |
89 SkLayerRasterizer::Builder rastBuilder2; | 89 SkLayerRasterizer::Builder rastBuilder2; |
90 r5(&rastBuilder2, p); | 90 r5(&rastBuilder2, p); |
91 p.setRasterizer(rastBuilder2.detachRasterizer())->unref(); | 91 p.setRasterizer(rastBuilder2.detachRasterizer())->unref(); |
92 p.setXfermodeMode(SkXfermode::kClear_Mode); | 92 p.setXfermodeMode(SkXfermode::kClear_Mode); |
93 rastBuilder->addLayer(p); | 93 rastBuilder->addLayer(p); |
94 } | 94 } |
95 | 95 |
96 #include "Sk2DPathEffect.h" | 96 #include "Sk2DPathEffect.h" |
97 | 97 |
98 static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) { | 98 static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix
) { |
99 SkPath path; | 99 SkPath path; |
100 path.addCircle(0, 0, radius); | 100 path.addCircle(0, 0, radius); |
101 return SkPath2DPathEffect::Create(matrix, path); | 101 return SkPath2DPathEffect::Make(matrix, path); |
102 } | 102 } |
103 | 103 |
104 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { | 104 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { |
105 SkMatrix lattice; | 105 SkMatrix lattice; |
106 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); | 106 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); |
107 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); | 107 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
108 p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice))->unref(); | 108 p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice)); |
109 rastBuilder->addLayer(p); | 109 rastBuilder->addLayer(p); |
110 } | 110 } |
111 | 111 |
112 static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { | 112 static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { |
113 rastBuilder->addLayer(p); | 113 rastBuilder->addLayer(p); |
114 | 114 |
115 SkMatrix lattice; | 115 SkMatrix lattice; |
116 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); | 116 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); |
117 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); | 117 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
118 p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref(); | 118 p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice)); |
119 p.setXfermodeMode(SkXfermode::kClear_Mode); | 119 p.setXfermodeMode(SkXfermode::kClear_Mode); |
120 rastBuilder->addLayer(p); | 120 rastBuilder->addLayer(p); |
121 | 121 |
122 p.setPathEffect(nullptr); | 122 p.setPathEffect(nullptr); |
123 p.setXfermode(nullptr); | 123 p.setXfermode(nullptr); |
124 p.setStyle(SkPaint::kStroke_Style); | 124 p.setStyle(SkPaint::kStroke_Style); |
125 p.setStrokeWidth(SK_Scalar1); | 125 p.setStrokeWidth(SK_Scalar1); |
126 rastBuilder->addLayer(p); | 126 rastBuilder->addLayer(p); |
127 } | 127 } |
128 | 128 |
129 static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { | 129 static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { |
130 rastBuilder->addLayer(p); | 130 rastBuilder->addLayer(p); |
131 | 131 |
132 SkMatrix lattice; | 132 SkMatrix lattice; |
133 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); | 133 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); |
134 lattice.postRotate(SkIntToScalar(30), 0, 0); | 134 lattice.postRotate(SkIntToScalar(30), 0, 0); |
135 p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref(); | 135 p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice)); |
136 p.setXfermodeMode(SkXfermode::kClear_Mode); | 136 p.setXfermodeMode(SkXfermode::kClear_Mode); |
137 rastBuilder->addLayer(p); | 137 rastBuilder->addLayer(p); |
138 | 138 |
139 p.setPathEffect(nullptr); | 139 p.setPathEffect(nullptr); |
140 p.setXfermode(nullptr); | 140 p.setXfermode(nullptr); |
141 p.setStyle(SkPaint::kStroke_Style); | 141 p.setStyle(SkPaint::kStroke_Style); |
142 p.setStrokeWidth(SK_Scalar1); | 142 p.setStrokeWidth(SK_Scalar1); |
143 rastBuilder->addLayer(p); | 143 rastBuilder->addLayer(p); |
144 } | 144 } |
145 | 145 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 381 |
382 SkScalar start = textPt.fX; | 382 SkScalar start = textPt.fX; |
383 SkScalar end = posX; | 383 SkScalar end = posX; |
384 SkScalar uPos = pos[0].fY + uWidth; | 384 SkScalar uPos = pos[0].fY + uWidth; |
385 SkPath underline = create_underline(intersections, start, end, uPos, uWi
dth, textSize); | 385 SkPath underline = create_underline(intersections, start, end, uPos, uWi
dth, textSize); |
386 paint.setStyle(SkPaint::kStroke_Style); | 386 paint.setStyle(SkPaint::kStroke_Style); |
387 canvas->drawPath(underline, paint); | 387 canvas->drawPath(underline, paint); |
388 canvas->translate(0, textSize * 1.3f); | 388 canvas->translate(0, textSize * 1.3f); |
389 } | 389 } |
390 } | 390 } |
OLD | NEW |