Skip to content

Commit 43994ab

Browse files
authored
Use "blur_sigma" instead of "blur_radius" in Shadow. (#25760)
1 parent d96669f commit 43994ab

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

lib/ui/painting.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5010,7 +5010,7 @@ class Shadow {
50105010
// See SkBlurMask::ConvertRadiusToSigma().
50115011
// <https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23>
50125012
static double convertRadiusToSigma(double radius) {
5013-
return radius * 0.57735 + 0.5;
5013+
return radius > 0 ? radius * 0.57735 + 0.5 : 0;
50145014
}
50155015

50165016
/// The [blurRadius] in sigmas instead of logical pixels.
@@ -5147,8 +5147,9 @@ class Shadow {
51475147
shadowsData.setFloat32(_kYOffset + shadowOffset,
51485148
shadow.offset.dy, _kFakeHostEndian);
51495149

5150+
final double blurSigma = Shadow.convertRadiusToSigma(shadow.blurRadius);
51505151
shadowsData.setFloat32(_kBlurOffset + shadowOffset,
5151-
shadow.blurRadius, _kFakeHostEndian);
5152+
blurSigma, _kFakeHostEndian);
51525153
}
51535154
}
51545155

lib/web_ui/lib/src/ui/painting.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class Shadow {
614614
// See SkBlurMask::ConvertRadiusToSigma().
615615
// <https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23>
616616
static double convertRadiusToSigma(double radius) {
617-
return radius * 0.57735 + 0.5;
617+
return radius > 0 ? radius * 0.57735 + 0.5 : 0;
618618
}
619619

620620
double get blurSigma => convertRadiusToSigma(blurRadius);

third_party/txt/src/skia/paragraph_builder_skia.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ skt::TextStyle TxtToSkia(const TextStyle& txt) {
126126
for (const txt::TextShadow& txt_shadow : txt.text_shadows) {
127127
skt::TextShadow shadow;
128128
shadow.fOffset = txt_shadow.offset;
129-
shadow.fBlurSigma = txt_shadow.blur_radius;
129+
shadow.fBlurSigma = txt_shadow.blur_sigma;
130130
shadow.fColor = txt_shadow.color;
131131
skia.addShadow(shadow);
132132
}

third_party/txt/src/skia/paragraph_skia.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ TextStyle SkiaToTxt(const skt::TextStyle& skia) {
7575
for (const skt::TextShadow& skia_shadow : skia.getShadows()) {
7676
txt::TextShadow shadow;
7777
shadow.offset = skia_shadow.fOffset;
78-
shadow.blur_radius = skia_shadow.fBlurSigma;
78+
shadow.blur_sigma = skia_shadow.fBlurSigma;
7979
shadow.color = skia_shadow.fColor;
8080
txt.text_shadows.emplace_back(shadow);
8181
}

third_party/txt/src/txt/paragraph_txt.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,9 +1650,9 @@ void ParagraphTxt::PaintShadow(SkCanvas* canvas,
16501650

16511651
SkPaint paint;
16521652
paint.setColor(text_shadow.color);
1653-
if (text_shadow.blur_radius != 0.0) {
1653+
if (text_shadow.blur_sigma > 0.5) {
16541654
paint.setMaskFilter(SkMaskFilter::MakeBlur(
1655-
kNormal_SkBlurStyle, text_shadow.blur_radius, false));
1655+
kNormal_SkBlurStyle, text_shadow.blur_sigma, false));
16561656
}
16571657
canvas->drawTextBlob(record.text(), offset.x() + text_shadow.offset.x(),
16581658
offset.y() + text_shadow.offset.y(), paint);

third_party/txt/src/txt/text_shadow.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
namespace txt {
2121

2222
TextShadow::TextShadow() {}
23-
TextShadow::TextShadow(SkColor color, SkPoint offset, double blur_radius)
24-
: color(color), offset(offset), blur_radius(blur_radius) {}
23+
TextShadow::TextShadow(SkColor color, SkPoint offset, double blur_sigma)
24+
: color(color), offset(offset), blur_sigma(blur_sigma) {}
2525

2626
bool TextShadow::operator==(const TextShadow& other) const {
2727
if (color != other.color)
2828
return false;
2929
if (offset != other.offset)
3030
return false;
31-
if (blur_radius != other.blur_radius)
31+
if (blur_sigma != other.blur_sigma)
3232
return false;
3333

3434
return true;
@@ -41,7 +41,7 @@ bool TextShadow::operator!=(const TextShadow& other) const {
4141
bool TextShadow::hasShadow() const {
4242
if (!offset.isZero())
4343
return true;
44-
if (blur_radius != 0.0)
44+
if (blur_sigma > 0.5)
4545
return true;
4646

4747
return false;

third_party/txt/src/txt/text_shadow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class TextShadow {
2626
public:
2727
SkColor color = SK_ColorBLACK;
2828
SkPoint offset;
29-
double blur_radius = 0.0;
29+
double blur_sigma = 0.0;
3030

3131
TextShadow();
3232

33-
TextShadow(SkColor color, SkPoint offset, double blur_radius);
33+
TextShadow(SkColor color, SkPoint offset, double blur_sigma);
3434

3535
bool operator==(const TextShadow& other) const;
3636

0 commit comments

Comments
 (0)