Explorar o código

LibWeb: Remove fragment_baseline from PaintTextShadow

Translate text_rect instead, so the struct doesn't have to carry
additional member.
Aliaksandr Kalenik hai 1 ano
pai
achega
b27cf1be49

+ 0 - 1
Userland/Libraries/LibWeb/Painting/Command.h

@@ -145,7 +145,6 @@ struct PaintTextShadow {
     NonnullRefPtr<Gfx::GlyphRun> glyph_run;
     double glyph_run_scale { 1 };
     Color color;
-    int fragment_baseline;
     Gfx::IntPoint draw_location;
 
     [[nodiscard]] Gfx::IntRect bounding_rect() const { return { draw_location, shadow_bounding_rect.size() }; }

+ 1 - 1
Userland/Libraries/LibWeb/Painting/DisplayListPlayerCPU.cpp

@@ -270,7 +270,7 @@ CommandResult DisplayListPlayerCPU::paint_text_shadow(PaintTextShadow const& com
 
     Gfx::Painter shadow_painter { *shadow_bitmap };
     // FIXME: "Spread" the shadow somehow.
-    Gfx::IntPoint const baseline_start(command.text_rect.x(), command.text_rect.y() + command.fragment_baseline);
+    Gfx::IntPoint const baseline_start(command.text_rect.x(), command.text_rect.y());
     shadow_painter.translate(baseline_start);
     auto const& glyphs = command.glyph_run->glyphs();
     for (auto const& glyph_or_emoji : glyphs) {

+ 1 - 1
Userland/Libraries/LibWeb/Painting/DisplayListPlayerGPU.cpp

@@ -190,7 +190,7 @@ CommandResult DisplayListPlayerGPU::paint_text_shadow(PaintTextShadow const& com
     text_shadow_painter->clear(command.color.with_alpha(0));
 
     Gfx::FloatRect const shadow_location { command.draw_location, command.shadow_bounding_rect.size() };
-    Gfx::IntPoint const baseline_start(command.text_rect.x(), command.text_rect.y() + command.fragment_baseline);
+    Gfx::IntPoint const baseline_start(command.text_rect.x(), command.text_rect.y());
     text_shadow_painter->translate(baseline_start.to_type<float>());
     text_shadow_painter->draw_glyph_run(command.glyph_run->glyphs(), command.color);
     if (command.blur_radius == 0) {

+ 1 - 2
Userland/Libraries/LibWeb/Painting/DisplayListRecorder.cpp

@@ -344,7 +344,7 @@ void DisplayListRecorder::paint_inner_box_shadow_params(PaintBoxShadowParams par
     append(PaintInnerBoxShadow { .box_shadow_params = params });
 }
 
-void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const& glyph_run, double glyph_run_scale, Color color, int fragment_baseline, Gfx::IntPoint draw_location)
+void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const& glyph_run, double glyph_run_scale, Color color, Gfx::IntPoint draw_location)
 {
     append(PaintTextShadow {
         .blur_radius = blur_radius,
@@ -353,7 +353,6 @@ void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect boundi
         .glyph_run = glyph_run,
         .glyph_run_scale = glyph_run_scale,
         .color = color,
-        .fragment_baseline = fragment_baseline,
         .draw_location = state().translation.map(draw_location) });
 }
 

+ 1 - 1
Userland/Libraries/LibWeb/Painting/DisplayListRecorder.h

@@ -127,7 +127,7 @@ public:
 
     void paint_outer_box_shadow_params(PaintBoxShadowParams params);
     void paint_inner_box_shadow_params(PaintBoxShadowParams params);
-    void paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const&, double glyph_run_scale, Color color, int fragment_baseline, Gfx::IntPoint draw_location);
+    void paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const&, double glyph_run_scale, Color color, Gfx::IntPoint draw_location);
 
     void fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, Gfx::AntiAliasingPainter::CornerRadius top_left_radius, Gfx::AntiAliasingPainter::CornerRadius top_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_left_radius, Vector<Gfx::Path> const& clip_paths = {});
     void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius, Vector<Gfx::Path> const& clip_paths = {});

+ 1 - 1
Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp

@@ -610,7 +610,7 @@ void paint_text_shadow(PaintContext& context, PaintableFragment const& fragment,
             draw_rect.y() + offset_y - margin
         };
 
-        context.display_list_recorder().paint_text_shadow(blur_radius, bounding_rect, text_rect, fragment.glyph_run(), context.device_pixels_per_css_pixel(), layer.color, fragment_baseline, draw_location);
+        context.display_list_recorder().paint_text_shadow(blur_radius, bounding_rect, text_rect.translated(0, fragment_baseline), fragment.glyph_run(), context.device_pixels_per_css_pixel(), layer.color, draw_location);
     }
 }