Skip to content

Commit

Permalink
LibGfx: Fix a bug where alpha was applied twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ananas-dev committed Dec 15, 2024
1 parent 75a1c91 commit feec29a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Libraries/LibGfx/PainterSkia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ static SkPoint to_skia_point(auto const& point)
return SkPoint::Make(point.x(), point.y());
}

static void apply_paint_style(SkPaint& paint, Gfx::PaintStyle const& style, float global_alpha)
static void apply_paint_style(SkPaint& paint, Gfx::PaintStyle const& style)
{
if (is<Gfx::SolidColorPaintStyle>(style)) {
auto const& solid_color = static_cast<Gfx::SolidColorPaintStyle const&>(style);
auto color = solid_color.sample_color(Gfx::IntPoint(0, 0));

paint.setColor(to_skia_color(color.with_opacity(global_alpha)));
paint.setColor(to_skia_color(color));
} else if (is<Gfx::CanvasLinearGradientPaintStyle>(style)) {
auto const& linear_gradient = static_cast<Gfx::CanvasLinearGradientPaintStyle const&>(style);
auto const& color_stops = linear_gradient.color_stops();
Expand Down Expand Up @@ -246,11 +246,11 @@ static void apply_filters(SkPaint& paint, Span<Gfx::Filter> filters)
}
}

static SkPaint to_skia_paint(Gfx::PaintStyle const& style, Span<Gfx::Filter> filters, float global_alpha)
static SkPaint to_skia_paint(Gfx::PaintStyle const& style, Span<Gfx::Filter> filters)
{
SkPaint paint;

apply_paint_style(paint, style, global_alpha);
apply_paint_style(paint, style);
apply_filters(paint, filters);

return paint;
Expand Down Expand Up @@ -357,7 +357,7 @@ void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& pain
return;

auto sk_path = to_skia_path(path);
auto paint = to_skia_paint(paint_style, filters, global_alpha);
auto paint = to_skia_paint(paint_style, filters);
paint.setAntiAlias(true);
paint.setAlphaf(global_alpha);
paint.setStyle(SkPaint::Style::kStroke_Style);
Expand Down Expand Up @@ -390,7 +390,7 @@ void PainterSkia::fill_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_
{
auto sk_path = to_skia_path(path);
sk_path.setFillType(to_skia_path_fill_type(winding_rule));
auto paint = to_skia_paint(paint_style, filters, global_alpha);
auto paint = to_skia_paint(paint_style, filters);
paint.setAntiAlias(true);
paint.setAlphaf(global_alpha);
impl().canvas()->drawPath(sk_path, paint);
Expand Down

0 comments on commit feec29a

Please sign in to comment.