Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5010,7 +5010,7 @@ class Shadow {
// See SkBlurMask::ConvertRadiusToSigma().
// <https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23>
static double convertRadiusToSigma(double radius) {
return radius * 0.57735 + 0.5;
return radius > 0 ? radius * 0.57735 + 0.5 : 0;
}

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

final double blurSigma = Shadow.convertRadiusToSigma(shadow.blurRadius);
shadowsData.setFloat32(_kBlurOffset + shadowOffset,
shadow.blurRadius, _kFakeHostEndian);
blurSigma, _kFakeHostEndian);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ class Shadow {
// See SkBlurMask::ConvertRadiusToSigma().
// <https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23>
static double convertRadiusToSigma(double radius) {
return radius * 0.57735 + 0.5;
return radius > 0 ? radius * 0.57735 + 0.5 : 0;
}

double get blurSigma => convertRadiusToSigma(blurRadius);
Expand Down
2 changes: 1 addition & 1 deletion third_party/txt/src/skia/paragraph_builder_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ skt::TextStyle TxtToSkia(const TextStyle& txt) {
for (const txt::TextShadow& txt_shadow : txt.text_shadows) {
skt::TextShadow shadow;
shadow.fOffset = txt_shadow.offset;
shadow.fBlurSigma = txt_shadow.blur_radius;
shadow.fBlurSigma = txt_shadow.blur_sigma;
shadow.fColor = txt_shadow.color;
skia.addShadow(shadow);
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/txt/src/skia/paragraph_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TextStyle SkiaToTxt(const skt::TextStyle& skia) {
for (const skt::TextShadow& skia_shadow : skia.getShadows()) {
txt::TextShadow shadow;
shadow.offset = skia_shadow.fOffset;
shadow.blur_radius = skia_shadow.fBlurSigma;
shadow.blur_sigma = skia_shadow.fBlurSigma;
shadow.color = skia_shadow.fColor;
txt.text_shadows.emplace_back(shadow);
}
Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/paragraph_txt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,9 @@ void ParagraphTxt::PaintShadow(SkCanvas* canvas,

SkPaint paint;
paint.setColor(text_shadow.color);
if (text_shadow.blur_radius != 0.0) {
if (text_shadow.blur_sigma > 0.5) {
paint.setMaskFilter(SkMaskFilter::MakeBlur(
kNormal_SkBlurStyle, text_shadow.blur_radius, false));
kNormal_SkBlurStyle, text_shadow.blur_sigma, false));
}
canvas->drawTextBlob(record.text(), offset.x() + text_shadow.offset.x(),
offset.y() + text_shadow.offset.y(), paint);
Expand Down
8 changes: 4 additions & 4 deletions third_party/txt/src/txt/text_shadow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
namespace txt {

TextShadow::TextShadow() {}
TextShadow::TextShadow(SkColor color, SkPoint offset, double blur_radius)
: color(color), offset(offset), blur_radius(blur_radius) {}
TextShadow::TextShadow(SkColor color, SkPoint offset, double blur_sigma)
: color(color), offset(offset), blur_sigma(blur_sigma) {}

bool TextShadow::operator==(const TextShadow& other) const {
if (color != other.color)
return false;
if (offset != other.offset)
return false;
if (blur_radius != other.blur_radius)
if (blur_sigma != other.blur_sigma)
return false;

return true;
Expand All @@ -41,7 +41,7 @@ bool TextShadow::operator!=(const TextShadow& other) const {
bool TextShadow::hasShadow() const {
if (!offset.isZero())
return true;
if (blur_radius != 0.0)
if (blur_sigma > 0.5)
return true;

return false;
Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/text_shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class TextShadow {
public:
SkColor color = SK_ColorBLACK;
SkPoint offset;
double blur_radius = 0.0;
double blur_sigma = 0.0;

TextShadow();

TextShadow(SkColor color, SkPoint offset, double blur_radius);
TextShadow(SkColor color, SkPoint offset, double blur_sigma);

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

Expand Down