From 0c7670b226b89066618dbe6a2c28793824d28e4c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 5 Jul 2024 10:40:29 +0200 Subject: [PATCH] LibGfx: Rename Painter => DeprecatedPainter --- .../main/cpp/WebViewImplementationNative.cpp | 4 +- Ladybird/Qt/TVGIconEngine.cpp | 4 +- Ladybird/Qt/Tab.cpp | 2 +- Ladybird/Qt/WebContentView.cpp | 2 +- .../Userland/Libraries/LibGfx/BUILD.gn | 2 +- Tests/LibGfx/BenchmarkGfxPainter.cpp | 8 +- Tests/LibGfx/TestPainter.cpp | 6 +- Tests/LibGfx/TestScalingFunctions.cpp | 4 +- .../Libraries/LibGfx/AntiAliasingPainter.cpp | 6 +- .../Libraries/LibGfx/AntiAliasingPainter.h | 6 +- Userland/Libraries/LibGfx/CMakeLists.txt | 2 +- .../{Painter.cpp => DeprecatedPainter.cpp} | 78 +++++++++---------- .../LibGfx/{Painter.h => DeprecatedPainter.h} | 14 ++-- .../LibGfx/EdgeFlagPathRasterizer.cpp | 18 ++--- .../Libraries/LibGfx/EdgeFlagPathRasterizer.h | 8 +- .../Libraries/LibGfx/Font/OpenType/Glyf.cpp | 2 +- .../LibGfx/Font/OpenType/Typeface.cpp | 2 +- Userland/Libraries/LibGfx/Forward.h | 2 +- .../Libraries/LibGfx/GradientPainting.cpp | 12 +-- .../LibGfx/ImageFormats/PNGLoader.cpp | 4 +- .../LibGfx/ImageFormats/TinyVGLoader.cpp | 4 +- .../LibGfx/ImageFormats/TinyVGLoader.h | 2 +- Userland/Libraries/LibGfx/Path.cpp | 6 +- Userland/Libraries/LibGfx/PathClipper.cpp | 6 +- Userland/Libraries/LibGfx/PathClipper.h | 8 +- Userland/Libraries/LibGfx/VectorGraphic.cpp | 6 +- Userland/Libraries/LibGfx/VectorGraphic.h | 4 +- .../LibWeb/HTML/CanvasRenderingContext2D.cpp | 8 +- .../LibWeb/HTML/CanvasRenderingContext2D.h | 4 +- .../LibWeb/Painting/PaintableBox.cpp | 4 +- .../LibWeb/Painting/ShadowPainting.cpp | 1 - 31 files changed, 119 insertions(+), 120 deletions(-) rename Userland/Libraries/LibGfx/{Painter.cpp => DeprecatedPainter.cpp} (91%) rename Userland/Libraries/LibGfx/{Painter.h => DeprecatedPainter.h} (95%) diff --git a/Ladybird/Android/src/main/cpp/WebViewImplementationNative.cpp b/Ladybird/Android/src/main/cpp/WebViewImplementationNative.cpp index c4cb12e7595..50809a75fcd 100644 --- a/Ladybird/Android/src/main/cpp/WebViewImplementationNative.cpp +++ b/Ladybird/Android/src/main/cpp/WebViewImplementationNative.cpp @@ -8,7 +8,7 @@ #include "JNIHelpers.h" #include #include -#include +#include #include #include #include @@ -70,7 +70,7 @@ void WebViewImplementationNative::paint_into_bitmap(void* android_bitmap_raw, An VERIFY((info.flags & ANDROID_BITMAP_FLAGS_IS_HARDWARE) == 0); auto android_bitmap = MUST(Gfx::Bitmap::create_wrapper(to_gfx_bitmap_format(info.format), Gfx::AlphaType::Premultiplied, { info.width, info.height }, info.stride, android_bitmap_raw)); - Gfx::Painter painter(android_bitmap); + Gfx::DeprecatedPainter painter(android_bitmap); if (auto* bitmap = m_client_state.has_usable_bitmap ? m_client_state.front_bitmap.bitmap.ptr() : m_backup_bitmap.ptr()) painter.blit({ 0, 0 }, *bitmap, bitmap->rect()); else diff --git a/Ladybird/Qt/TVGIconEngine.cpp b/Ladybird/Qt/TVGIconEngine.cpp index d13bbbcc87d..d3978940f53 100644 --- a/Ladybird/Qt/TVGIconEngine.cpp +++ b/Ladybird/Qt/TVGIconEngine.cpp @@ -8,7 +8,7 @@ #include "StringUtils.h" #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ QPixmap TVGIconEngine::pixmap(QSize const& size, QIcon::Mode mode, QIcon::State if (QPixmapCache::find(key, &pixmap)) return pixmap; auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { size.width(), size.height() })); - Gfx::Painter painter { *bitmap }; + Gfx::DeprecatedPainter painter { *bitmap }; m_image_data->draw_into(painter, bitmap->rect()); for (auto const& filter : m_filters) { if (filter->mode() == mode) { diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index 56231fb8dd0..2871f28d165 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -12,8 +12,8 @@ #include "Settings.h" #include "StringUtils.h" #include +#include #include -#include #include #include #include diff --git a/Ladybird/Qt/WebContentView.cpp b/Ladybird/Qt/WebContentView.cpp index 86165c026e5..5b97c1d8ba4 100644 --- a/Ladybird/Qt/WebContentView.cpp +++ b/Ladybird/Qt/WebContentView.cpp @@ -20,9 +20,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn index ca4b36afb09..6603c0f1f60 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn @@ -30,6 +30,7 @@ shared_library("LibGfx") { "CMYKBitmap.cpp", "Color.cpp", "DeltaE.cpp", + "DeprecatedPainter.cpp", "EdgeFlagPathRasterizer.cpp", "Filters/ColorBlindnessFilter.cpp", "Filters/FastBoxBlurFilter.cpp", @@ -78,7 +79,6 @@ shared_library("LibGfx") { "ImageFormats/WebPWriter.cpp", "ImageFormats/WebPWriterLossless.cpp", "ImmutableBitmap.cpp", - "Painter.cpp", "Palette.cpp", "Path.cpp", "PathClipper.cpp", diff --git a/Tests/LibGfx/BenchmarkGfxPainter.cpp b/Tests/LibGfx/BenchmarkGfxPainter.cpp index 17dce4494d3..1747bd86809 100644 --- a/Tests/LibGfx/BenchmarkGfxPainter.cpp +++ b/Tests/LibGfx/BenchmarkGfxPainter.cpp @@ -7,8 +7,8 @@ #include #include +#include #include -#include #include BENCHMARK_CASE(diagonal_lines) @@ -17,7 +17,7 @@ BENCHMARK_CASE(diagonal_lines) int const bitmap_size = 2000; auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size })); - Gfx::Painter painter(bitmap); + Gfx::DeprecatedPainter painter(bitmap); for (int run = 0; run < run_count; run++) { for (int i = 0; i < bitmap_size; i++) { @@ -33,7 +33,7 @@ BENCHMARK_CASE(fill) int const bitmap_size = 2000; auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size })); - Gfx::Painter painter(bitmap); + Gfx::DeprecatedPainter painter(bitmap); for (int run = 0; run < run_count; run++) { painter.fill_rect(bitmap->rect(), Color::Blue); @@ -46,7 +46,7 @@ BENCHMARK_CASE(fill_with_gradient) int const bitmap_size = 2000; auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size })); - Gfx::Painter painter(bitmap); + Gfx::DeprecatedPainter painter(bitmap); for (int run = 0; run < run_count; run++) { painter.fill_rect_with_gradient(bitmap->rect(), Color::Blue, Color::Red); diff --git a/Tests/LibGfx/TestPainter.cpp b/Tests/LibGfx/TestPainter.cpp index a520861b822..d8dcc9f6e95 100644 --- a/Tests/LibGfx/TestPainter.cpp +++ b/Tests/LibGfx/TestPainter.cpp @@ -6,13 +6,13 @@ #include -#include +#include TEST_CASE(draw_scaled_bitmap_with_transform) { auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 40, 30 })); bitmap->fill(Gfx::Color::White); - Gfx::Painter painter(bitmap); + Gfx::DeprecatedPainter painter(bitmap); auto source_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 1, 1 })); source_bitmap->fill(Gfx::Color::Black); @@ -49,7 +49,7 @@ TEST_CASE(draw_scaled_bitmap_with_transform) TEST_CASE(draw_rect_rough_bounds) { auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 10, 10 })); - Gfx::Painter painter(*bitmap); + Gfx::DeprecatedPainter painter(*bitmap); painter.draw_rect(Gfx::IntRect(0, 0, 1, 1), Color::Black, true); painter.draw_rect(Gfx::IntRect(9, 9, 1, 1), Color::Black, true); } diff --git a/Tests/LibGfx/TestScalingFunctions.cpp b/Tests/LibGfx/TestScalingFunctions.cpp index aa5a41941a0..f074c024f49 100644 --- a/Tests/LibGfx/TestScalingFunctions.cpp +++ b/Tests/LibGfx/TestScalingFunctions.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include // Scaling modes which use linear interpolation should use premultiplied alpha. @@ -22,7 +22,7 @@ TEST_CASE(test_painter_scaling_uses_premultiplied_alpha) auto scaled_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { 5, 5 })); scaled_bitmap->fill(Color::Transparent); - Gfx::Painter painter(scaled_bitmap); + Gfx::DeprecatedPainter painter(scaled_bitmap); painter.draw_scaled_bitmap(scaled_bitmap->rect(), src_bitmap, src_bitmap->rect(), 1.0f, scaling_mode); auto top_left_pixel = scaled_bitmap->get_pixel(0, 0); diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp index a7e1deb489b..552985d4a23 100644 --- a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp +++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp @@ -13,8 +13,8 @@ #include #include #include +#include #include -#include namespace Gfx { @@ -279,7 +279,7 @@ void AntiAliasingPainter::draw_ellipse(IntRect const& a_rect, Color color, int t auto outer_rect = a_rect; outer_rect.set_location({ 0, 0 }); auto inner_rect = outer_rect.shrunken(thickness * 2, thickness * 2); - Painter painter { outline_ellipse_bitmap }; + DeprecatedPainter painter { outline_ellipse_bitmap }; AntiAliasingPainter aa_painter { painter }; aa_painter.fill_ellipse(outer_rect, color_no_alpha); aa_painter.fill_ellipse(inner_rect, color_no_alpha, BlendMode::AlphaSubtract); @@ -580,7 +580,7 @@ void AntiAliasingPainter::fill_rect_with_rounded_corners(IntRect const& a_rect, } auto fill_corner = [&](auto const& ellipse_center, auto const& corner_point, CornerRadius const& corner) { - PainterStateSaver save { m_underlying_painter }; + DeprecatedPainterStateSaver save { m_underlying_painter }; m_underlying_painter.add_clip_rect(IntRect::from_two_points(ellipse_center, corner_point)); fill_ellipse(IntRect::centered_at(ellipse_center, { corner.horizontal_radius * 2, corner.vertical_radius * 2 }), color, blend_mode); }; diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.h b/Userland/Libraries/LibGfx/AntiAliasingPainter.h index d21fe5c52b4..3f85a55796d 100644 --- a/Userland/Libraries/LibGfx/AntiAliasingPainter.h +++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.h @@ -18,7 +18,7 @@ namespace Gfx { class AntiAliasingPainter { public: - explicit AntiAliasingPainter(Painter& painter) + explicit AntiAliasingPainter(DeprecatedPainter& painter) : m_underlying_painter(painter) { } @@ -78,7 +78,7 @@ public: void fill_rect_with_rounded_corners(IntRect const&, Color, CornerRadius top_left, CornerRadius top_right, CornerRadius bottom_right, CornerRadius bottom_left, BlendMode blend_mode = BlendMode::Normal); - Gfx::Painter& underlying_painter() { return m_underlying_painter; } + Gfx::DeprecatedPainter& underlying_painter() { return m_underlying_painter; } private: struct Range { @@ -96,7 +96,7 @@ private: void draw_anti_aliased_line(FloatPoint, FloatPoint, Color, float thickness, LineStyle, Color, LineLengthMode); void draw_dotted_line(IntPoint, IntPoint, Gfx::Color, int thickness); - Painter& m_underlying_painter; + DeprecatedPainter& m_underlying_painter; AffineTransform m_transform; }; diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 8d0b49d6fb5..a9ca50b0b13 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -7,6 +7,7 @@ set(SOURCES CMYKBitmap.cpp Color.cpp DeltaE.cpp + DeprecatedPainter.cpp EdgeFlagPathRasterizer.cpp FontCascadeList.cpp Font/Emoji.cpp @@ -54,7 +55,6 @@ set(SOURCES ImageFormats/AVIFLoader.cpp ImmutableBitmap.cpp MedianCut.cpp - Painter.cpp Palette.cpp Path.cpp PathClipper.cpp diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/DeprecatedPainter.cpp similarity index 91% rename from Userland/Libraries/LibGfx/Painter.cpp rename to Userland/Libraries/LibGfx/DeprecatedPainter.cpp index 07b1ee42469..786dcfc04cf 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/DeprecatedPainter.cpp @@ -10,7 +10,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include "Painter.h" +#include "DeprecatedPainter.h" #include "Bitmap.h" #include "Font/Font.h" #include @@ -42,7 +42,7 @@ ALWAYS_INLINE Color get_pixel(Gfx::Bitmap const& bitmap, int x, int y) return bitmap.get_pixel(x, y); } -Painter::Painter(Gfx::Bitmap& bitmap) +DeprecatedPainter::DeprecatedPainter(Gfx::Bitmap& bitmap) : m_target(bitmap) { VERIFY(bitmap.format() == Gfx::BitmapFormat::BGRx8888 || bitmap.format() == Gfx::BitmapFormat::BGRA8888); @@ -51,7 +51,7 @@ Painter::Painter(Gfx::Bitmap& bitmap) m_clip_origin = state().clip_rect; } -void Painter::clear_rect(IntRect const& a_rect, Color color) +void DeprecatedPainter::clear_rect(IntRect const& a_rect, Color color) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -68,7 +68,7 @@ void Painter::clear_rect(IntRect const& a_rect, Color color) } } -void Painter::fill_physical_rect(IntRect const& physical_rect, Color color) +void DeprecatedPainter::fill_physical_rect(IntRect const& physical_rect, Color color) { // Callers must do clipping. ARGB32* dst = target().scanline(physical_rect.top()) + physical_rect.left(); @@ -82,7 +82,7 @@ void Painter::fill_physical_rect(IntRect const& physical_rect, Color color) } } -void Painter::fill_rect(IntRect const& a_rect, Color color) +void DeprecatedPainter::fill_rect(IntRect const& a_rect, Color color) { if (color.alpha() == 0) return; @@ -100,7 +100,7 @@ void Painter::fill_rect(IntRect const& a_rect, Color color) fill_physical_rect(rect, color); } -void Painter::fill_rect(IntRect const& rect, PaintStyle const& paint_style) +void DeprecatedPainter::fill_rect(IntRect const& rect, PaintStyle const& paint_style) { auto a_rect = rect.translated(translation()); auto clipped_rect = a_rect.intersected(clip_rect()); @@ -117,7 +117,7 @@ void Painter::fill_rect(IntRect const& rect, PaintStyle const& paint_style) }); } -void Painter::fill_rect_with_gradient(Orientation orientation, IntRect const& a_rect, Color gradient_start, Color gradient_end) +void DeprecatedPainter::fill_rect_with_gradient(Orientation orientation, IntRect const& a_rect, Color gradient_start, Color gradient_end) { if (gradient_start == gradient_end) { fill_rect(a_rect, gradient_start); @@ -126,17 +126,17 @@ void Painter::fill_rect_with_gradient(Orientation orientation, IntRect const& a_ return fill_rect_with_linear_gradient(a_rect, Array { ColorStop { gradient_start, 0 }, ColorStop { gradient_end, 1 } }, orientation == Orientation::Horizontal ? 90.0f : 0.0f); } -void Painter::fill_rect_with_gradient(IntRect const& a_rect, Color gradient_start, Color gradient_end) +void DeprecatedPainter::fill_rect_with_gradient(IntRect const& a_rect, Color gradient_start, Color gradient_end) { return fill_rect_with_gradient(Orientation::Horizontal, a_rect, gradient_start, gradient_end); } -void Painter::fill_rect_with_rounded_corners(IntRect const& a_rect, Color color, int radius) +void DeprecatedPainter::fill_rect_with_rounded_corners(IntRect const& a_rect, Color color, int radius) { return fill_rect_with_rounded_corners(a_rect, color, radius, radius, radius, radius); } -void Painter::fill_rect_with_rounded_corners(IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius) +void DeprecatedPainter::fill_rect_with_rounded_corners(IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius) { // Fasttrack for rects without any border radii if (!top_left_radius && !top_right_radius && !bottom_right_radius && !bottom_left_radius) @@ -220,7 +220,7 @@ void Painter::fill_rect_with_rounded_corners(IntRect const& a_rect, Color color, fill_rounded_corner(bottom_right_corner, bottom_right_radius, color, CornerOrientation::BottomRight); } -void Painter::fill_rounded_corner(IntRect const& a_rect, int radius, Color color, CornerOrientation orientation) +void DeprecatedPainter::fill_rounded_corner(IntRect const& a_rect, int radius, Color color, CornerOrientation orientation) { // Care about clipping auto translated_a_rect = a_rect.translated(translation()); @@ -323,7 +323,7 @@ static void on_each_ellipse_point(IntRect const& rect, Function& } } -void Painter::fill_ellipse(IntRect const& a_rect, Color color) +void DeprecatedPainter::fill_ellipse(IntRect const& a_rect, Color color) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -356,7 +356,7 @@ static void for_each_pixel_around_rect_clockwise(RectType const& rect, Callback callback(rect.left(), y); } -void Painter::draw_rect(IntRect const& a_rect, Color color, bool rough) +void DeprecatedPainter::draw_rect(IntRect const& a_rect, Color color, bool rough) { IntRect rect = a_rect.translated(translation()); auto clipped_rect = rect.intersected(clip_rect()); @@ -460,7 +460,7 @@ static void do_blit_with_opacity(BlitState& state) } } -void Painter::blit_with_opacity(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, float opacity, bool apply_alpha) +void DeprecatedPainter::blit_with_opacity(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, float opacity, bool apply_alpha) { if (opacity >= 1.0f && !(source.has_alpha_channel() && apply_alpha)) return blit(position, source, src_rect); @@ -501,7 +501,7 @@ void Painter::blit_with_opacity(IntPoint position, Gfx::Bitmap const& source, In } } -void Painter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, Function const& filter, bool apply_alpha) +void DeprecatedPainter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, Function const& filter, bool apply_alpha) { IntRect safe_src_rect = src_rect.intersected(source.rect()); auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation()); @@ -537,14 +537,14 @@ void Painter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRec } } -void Painter::blit(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, float opacity, bool apply_alpha) +void DeprecatedPainter::blit(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, float opacity, bool apply_alpha) { if (opacity < 1.0f || (source.has_alpha_channel() && apply_alpha)) return blit_with_opacity(position, source, src_rect, opacity, apply_alpha); auto safe_src_rect = src_rect.intersected(source.rect()); - // If we get here, the Painter might have a scale factor, but the source bitmap has the same scale factor. + // If we get here, the DeprecatedPainter might have a scale factor, but the source bitmap has the same scale factor. // We need to transform from logical to physical coordinates, but we can just copy pixels without resampling. auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); @@ -790,12 +790,12 @@ ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, IntRect con } } -void Painter::draw_scaled_bitmap(IntRect const& a_dst_rect, Gfx::Bitmap const& source, IntRect const& a_src_rect, float opacity, ScalingMode scaling_mode) +void DeprecatedPainter::draw_scaled_bitmap(IntRect const& a_dst_rect, Gfx::Bitmap const& source, IntRect const& a_src_rect, float opacity, ScalingMode scaling_mode) { draw_scaled_bitmap(a_dst_rect, source, FloatRect { a_src_rect }, opacity, scaling_mode); } -void Painter::draw_scaled_bitmap(IntRect const& a_dst_rect, Gfx::Bitmap const& source, FloatRect const& a_src_rect, float opacity, ScalingMode scaling_mode) +void DeprecatedPainter::draw_scaled_bitmap(IntRect const& a_dst_rect, Gfx::Bitmap const& source, FloatRect const& a_src_rect, float opacity, ScalingMode scaling_mode) { IntRect int_src_rect = enclosing_int_rect(a_src_rect); if (a_src_rect == int_src_rect && a_dst_rect.size() == int_src_rect.size()) @@ -836,7 +836,7 @@ void Painter::draw_scaled_bitmap(IntRect const& a_dst_rect, Gfx::Bitmap const& s } } -void Painter::set_pixel(IntPoint p, Color color, bool blend) +void DeprecatedPainter::set_pixel(IntPoint p, Color color, bool blend) { auto point = p; point.translate_by(state().translation); @@ -847,7 +847,7 @@ void Painter::set_pixel(IntPoint p, Color color, bool blend) set_physical_pixel(point, color, blend); } -void Painter::set_physical_pixel(IntPoint physical_point, Color color, bool blend) +void DeprecatedPainter::set_physical_pixel(IntPoint physical_point, Color color, bool blend) { // This function should only be called after translation, clipping, etc has been handled elsewhere // if not use set_pixel(). @@ -858,7 +858,7 @@ void Painter::set_physical_pixel(IntPoint physical_point, Color color, bool blen dst = color_for_format(target().format(), dst).blend(color).value(); } -Optional Painter::get_pixel(IntPoint p) +Optional DeprecatedPainter::get_pixel(IntPoint p) { auto point = p; point.translate_by(state().translation); @@ -867,7 +867,7 @@ Optional Painter::get_pixel(IntPoint p) return target().get_pixel(point); } -ErrorOr> Painter::get_region_bitmap(IntRect const& region, BitmapFormat format, Optional actual_region) +ErrorOr> DeprecatedPainter::get_region_bitmap(IntRect const& region, BitmapFormat format, Optional actual_region) { auto bitmap_region = region.translated(state().translation).intersected(target().rect()); if (actual_region.has_value()) @@ -875,21 +875,21 @@ ErrorOr> Painter::get_region_bitmap(IntRect const& region, return target().cropped(bitmap_region, format); } -ALWAYS_INLINE void Painter::set_physical_pixel(u32& pixel, Color color) +ALWAYS_INLINE void DeprecatedPainter::set_physical_pixel(u32& pixel, Color color) { // This always sets a single physical pixel, independent of scale(). // This should only be called by routines that already handle scale. pixel = color.value(); } -ALWAYS_INLINE void Painter::fill_physical_scanline(int y, int x, int width, Color color) +ALWAYS_INLINE void DeprecatedPainter::fill_physical_scanline(int y, int x, int width, Color color) { // This always draws a single physical scanline, independent of scale(). // This should only be called by routines that already handle scale. fast_u32_fill(target().scanline(y) + x, color.value(), width); } -void Painter::draw_physical_pixel(IntPoint physical_position, Color color, int thickness) +void DeprecatedPainter::draw_physical_pixel(IntPoint physical_position, Color color, int thickness) { // This always draws a single physical pixel, independent of scale(). // This should only be called by routines that already handle scale @@ -907,7 +907,7 @@ void Painter::draw_physical_pixel(IntPoint physical_position, Color color, int t fill_physical_rect(rect, color); } -void Painter::draw_line(IntPoint a_p1, IntPoint a_p2, Color color, int thickness, LineStyle style, Color alternate_color) +void DeprecatedPainter::draw_line(IntPoint a_p1, IntPoint a_p2, Color color, int thickness, LineStyle style, Color alternate_color) { if (clip_rect().is_empty()) return; @@ -1059,7 +1059,7 @@ void Painter::draw_line(IntPoint a_p1, IntPoint a_p2, Color color, int thickness } } -void Painter::draw_triangle_wave(IntPoint a_p1, IntPoint a_p2, Color color, int amplitude, int thickness) +void DeprecatedPainter::draw_triangle_wave(IntPoint a_p1, IntPoint a_p2, Color color, int amplitude, int thickness) { // FIXME: Support more than horizontal waves VERIFY(a_p1.y() == a_p2.y()); @@ -1099,7 +1099,7 @@ static bool can_approximate_bezier_curve(FloatPoint p1, FloatPoint p2, FloatPoin return error <= tolerance; } -void Painter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function& callback) +void DeprecatedPainter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function& callback) { struct SegmentDescriptor { FloatPoint control_point; @@ -1133,12 +1133,12 @@ void Painter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, Fl } } -void Painter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function&& callback) +void DeprecatedPainter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function&& callback) { for_each_line_segment_on_bezier_curve(control_point, p1, p2, callback); } -void Painter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function&& callback) +void DeprecatedPainter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function&& callback) { for_each_line_segment_on_cubic_bezier_curve(control_point_0, control_point_1, p1, p2, callback); } @@ -1165,7 +1165,7 @@ static bool can_approximate_cubic_bezier_curve(FloatPoint p1, FloatPoint p2, Flo } // static -void Painter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function& callback) +void DeprecatedPainter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function& callback) { struct ControlPair { FloatPoint control_point_0; @@ -1205,36 +1205,36 @@ void Painter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_poi } } -void Painter::add_clip_rect(IntRect const& rect) +void DeprecatedPainter::add_clip_rect(IntRect const& rect) { state().clip_rect.intersect(rect.translated(translation())); state().clip_rect.intersect(target().rect()); // FIXME: This shouldn't be necessary? } -void Painter::clear_clip_rect() +void DeprecatedPainter::clear_clip_rect() { state().clip_rect = m_clip_origin; } -PainterStateSaver::PainterStateSaver(Painter& painter) +DeprecatedPainterStateSaver::DeprecatedPainterStateSaver(DeprecatedPainter& painter) : m_painter(painter) { m_painter.save(); } -PainterStateSaver::~PainterStateSaver() +DeprecatedPainterStateSaver::~DeprecatedPainterStateSaver() { m_painter.restore(); } -void Painter::stroke_path(Path const& path, Color color, int thickness) +void DeprecatedPainter::stroke_path(Path const& path, Color color, int thickness) { if (thickness <= 0) return; fill_path(path.stroke_to_fill(thickness), color); } -void Painter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap const& bitmap, FloatRect const& src_rect, AffineTransform const& transform, float opacity, ScalingMode scaling_mode) +void DeprecatedPainter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap const& bitmap, FloatRect const& src_rect, AffineTransform const& transform, float opacity, ScalingMode scaling_mode) { if (transform.is_identity_or_translation_or_scale()) { draw_scaled_bitmap(transform.map(dst_rect.to_type()).to_rounded(), bitmap, src_rect, opacity, scaling_mode); @@ -1250,7 +1250,7 @@ void Painter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap // - Set or blend (depending on alpha values) one pixel in the canvas. // - Loop. - // FIXME: Painter should have an affine transform as part of its state and handle all of this instead. + // FIXME: DeprecatedPainter should have an affine transform as part of its state and handle all of this instead. if (opacity == 0.0f) return; diff --git a/Userland/Libraries/LibGfx/Painter.h b/Userland/Libraries/LibGfx/DeprecatedPainter.h similarity index 95% rename from Userland/Libraries/LibGfx/Painter.h rename to Userland/Libraries/LibGfx/DeprecatedPainter.h index 5f154bcfc91..1619ce100f9 100644 --- a/Userland/Libraries/LibGfx/Painter.h +++ b/Userland/Libraries/LibGfx/DeprecatedPainter.h @@ -36,10 +36,10 @@ ALWAYS_INLINE static Color color_for_format(BitmapFormat format, ARGB32 value) } } -class Painter { +class DeprecatedPainter { public: - explicit Painter(Gfx::Bitmap&); - ~Painter() = default; + explicit DeprecatedPainter(Gfx::Bitmap&); + ~DeprecatedPainter() = default; void clear_rect(IntRect const&, Color); void fill_rect(IntRect const&, Color); @@ -132,13 +132,13 @@ protected: Vector m_state_stack; }; -class PainterStateSaver { +class DeprecatedPainterStateSaver { public: - explicit PainterStateSaver(Painter&); - ~PainterStateSaver(); + explicit DeprecatedPainterStateSaver(DeprecatedPainter&); + ~DeprecatedPainterStateSaver(); private: - Painter& m_painter; + DeprecatedPainter& m_painter; }; } diff --git a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp index c9ebd091355..d4e76da78e4 100644 --- a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp +++ b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #if defined(AK_COMPILER_GCC) # pragma GCC optimize("O3") @@ -99,13 +99,13 @@ EdgeFlagPathRasterizer::EdgeFlagPathRasterizer(IntSize size) } template -void EdgeFlagPathRasterizer::fill(Painter& painter, Path const& path, Color color, WindingRule winding_rule, FloatPoint offset) +void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, Path const& path, Color color, WindingRule winding_rule, FloatPoint offset) { fill_internal(painter, path, color, winding_rule, offset); } template -void EdgeFlagPathRasterizer::fill(Painter& painter, Path const& path, PaintStyle const& style, float opacity, WindingRule winding_rule, FloatPoint offset) +void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, Path const& path, PaintStyle const& style, float opacity, WindingRule winding_rule, FloatPoint offset) { style.paint(enclosing_int_rect(path.bounding_box()), [&](PaintStyle::SamplerFunction sampler) { if (opacity == 0.0f) @@ -122,7 +122,7 @@ void EdgeFlagPathRasterizer::fill(Painter& painter, Path const& } template -void EdgeFlagPathRasterizer::fill_internal(Painter& painter, Path const& path, auto color_or_function, WindingRule winding_rule, FloatPoint offset) +void EdgeFlagPathRasterizer::fill_internal(DeprecatedPainter& painter, Path const& path, auto color_or_function, WindingRule winding_rule, FloatPoint offset) { auto bounding_box = enclosing_int_rect(path.bounding_box().translated(offset)); auto dest_rect = bounding_box.translated(painter.translation()); @@ -375,7 +375,7 @@ void EdgeFlagPathRasterizer::fast_fill_solid_color_span(ARGB32* template template -FLATTEN __attribute__((hot)) void EdgeFlagPathRasterizer::write_scanline(Painter& painter, int scanline, EdgeExtent edge_extent, auto& color_or_function) +FLATTEN __attribute__((hot)) void EdgeFlagPathRasterizer::write_scanline(DeprecatedPainter& painter, int scanline, EdgeExtent edge_extent, auto& color_or_function) { // Handle scanline clipping. auto left_clip = m_clip.left() - m_blit_origin.x(); @@ -435,17 +435,17 @@ static IntSize path_bounds(Gfx::Path const& path) return enclosing_int_rect(path.bounding_box()).size(); } -// Note: The AntiAliasingPainter and Painter now perform the same antialiasing, +// Note: The AntiAliasingPainter and DeprecatedPainter now perform the same antialiasing, // since it would be harder to turn it off for the standard painter. -// The samples are reduced to 8 for Gfx::Painter though as a "speedy" option. +// The samples are reduced to 8 for Gfx::DeprecatedPainter though as a "speedy" option. -void Painter::fill_path(Path const& path, Color color, WindingRule winding_rule) +void DeprecatedPainter::fill_path(Path const& path, Color color, WindingRule winding_rule) { EdgeFlagPathRasterizer<8> rasterizer(path_bounds(path)); rasterizer.fill(*this, path, color, winding_rule); } -void Painter::fill_path(Path const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule) +void DeprecatedPainter::fill_path(Path const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule) { EdgeFlagPathRasterizer<8> rasterizer(path_bounds(path)); rasterizer.fill(*this, path, paint_style, opacity, winding_rule); diff --git a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h index 14b948906ce..3f959fcbb53 100644 --- a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h +++ b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h @@ -147,8 +147,8 @@ class EdgeFlagPathRasterizer { public: EdgeFlagPathRasterizer(IntSize); - void fill(Painter&, Path const&, Color, WindingRule, FloatPoint offset = {}); - void fill(Painter&, Path const&, PaintStyle const&, float opacity, WindingRule, FloatPoint offset = {}); + void fill(DeprecatedPainter&, Path const&, Color, WindingRule, FloatPoint offset = {}); + void fill(DeprecatedPainter&, Path const&, PaintStyle const&, float opacity, WindingRule, FloatPoint offset = {}); private: using SubpixelSample = Detail::Sample; @@ -174,11 +174,11 @@ private: } }; - void fill_internal(Painter&, Path const&, auto color_or_function, WindingRule, FloatPoint offset); + void fill_internal(DeprecatedPainter&, Path const&, auto color_or_function, WindingRule, FloatPoint offset); Detail::Edge* plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent&, Detail::Edge* active_edges = nullptr); template - FLATTEN void write_scanline(Painter&, int scanline, EdgeExtent, auto& color_or_function); + FLATTEN void write_scanline(DeprecatedPainter&, int scanline, EdgeExtent, auto& color_or_function); Color scanline_color(int scanline, int offset, u8 alpha, auto& color_or_function); void write_pixel(BitmapFormat format, ARGB32* scanline_ptr, int scanline, int offset, SampleType sample, auto& color_or_function); void fast_fill_solid_color_span(ARGB32* scanline_ptr, int start, int end, Color color); diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp index 54dd09ba3bf..904663ec8fe 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp @@ -5,8 +5,8 @@ */ #include +#include #include -#include #include #include diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp index e05fa3c88f2..9aa3c8d484c 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp @@ -14,12 +14,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include diff --git a/Userland/Libraries/LibGfx/Forward.h b/Userland/Libraries/LibGfx/Forward.h index b9d26392a70..42a8fd6eb2e 100644 --- a/Userland/Libraries/LibGfx/Forward.h +++ b/Userland/Libraries/LibGfx/Forward.h @@ -26,7 +26,7 @@ template class Line; class AntiAliasingPainter; -class Painter; +class DeprecatedPainter; class Palette; class PaletteImpl; class Path; diff --git a/Userland/Libraries/LibGfx/GradientPainting.cpp b/Userland/Libraries/LibGfx/GradientPainting.cpp index 5f221510450..31dd321308f 100644 --- a/Userland/Libraries/LibGfx/GradientPainting.cpp +++ b/Userland/Libraries/LibGfx/GradientPainting.cpp @@ -5,9 +5,9 @@ */ #include +#include #include #include -#include #if defined(AK_COMPILER_GCC) # pragma GCC optimize("O3") @@ -122,7 +122,7 @@ public: return color; } - void paint_into_physical_rect(Painter& painter, IntRect rect, auto location_transform) + void paint_into_physical_rect(DeprecatedPainter& painter, IntRect rect, auto location_transform) { auto clipped_rect = rect.intersected(painter.clip_rect()); auto start_offset = clipped_rect.location() - rect.location(); @@ -171,7 +171,7 @@ struct Gradient { { } - void paint(Painter& painter, IntRect rect) + void paint(DeprecatedPainter& painter, IntRect rect) { m_gradient_line.paint_into_physical_rect(painter, rect, m_transform_function); } @@ -271,7 +271,7 @@ static auto create_radial_gradient(IntRect const& physical_rect, ReadonlySpan color_stops, float angle, Optional repeat_length) +void DeprecatedPainter::fill_rect_with_linear_gradient(IntRect const& rect, ReadonlySpan color_stops, float angle, Optional repeat_length) { auto a_rect = to_physical(rect); if (a_rect.intersected(clip_rect()).is_empty()) @@ -285,7 +285,7 @@ static FloatPoint pixel_center(IntPoint point) return point.to_type().translated(0.5f, 0.5f); } -void Painter::fill_rect_with_conic_gradient(IntRect const& rect, ReadonlySpan color_stops, IntPoint center, float start_angle, Optional repeat_length) +void DeprecatedPainter::fill_rect_with_conic_gradient(IntRect const& rect, ReadonlySpan color_stops, IntPoint center, float start_angle, Optional repeat_length) { auto a_rect = to_physical(rect); if (a_rect.intersected(clip_rect()).is_empty()) @@ -296,7 +296,7 @@ void Painter::fill_rect_with_conic_gradient(IntRect const& rect, ReadonlySpan color_stops, IntPoint center, IntSize size, Optional repeat_length, Optional rotation_angle) +void DeprecatedPainter::fill_rect_with_radial_gradient(IntRect const& rect, ReadonlySpan color_stops, IntPoint center, IntSize size, Optional repeat_length, Optional rotation_angle) { auto a_rect = to_physical(rect); if (a_rect.intersected(clip_rect()).is_empty()) diff --git a/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp index 1f1fae48f46..4937ffff7cb 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp @@ -6,10 +6,10 @@ */ #include +#include #include #include #include -#include #include namespace Gfx { @@ -203,7 +203,7 @@ ErrorOr PNGImageDecoderPlugin::initialize() static ErrorOr> render_animation_frame(AnimationFrame const& prev_animation_frame, AnimationFrame const& animation_frame, Bitmap const& decoded_frame_bitmap) { auto rendered_bitmap = TRY(prev_animation_frame.bitmap->clone()); - Painter painter(rendered_bitmap); + DeprecatedPainter painter(rendered_bitmap); auto frame_rect = animation_frame.rect(); switch (prev_animation_frame.dispose_op) { diff --git a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp index 9d63684e240..9836c148e90 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp @@ -12,9 +12,9 @@ #include #include #include +#include #include #include -#include #include namespace Gfx { @@ -472,7 +472,7 @@ ErrorOr> TinyVGDecodedImageData::decode(St return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) TinyVGDecodedImageData({ header.width, header.height }, move(draw_commands)))); } -void TinyVGDecodedImageData::draw_transformed(Painter& painter, AffineTransform transform) const +void TinyVGDecodedImageData::draw_transformed(DeprecatedPainter& painter, AffineTransform transform) const { // FIXME: Correctly handle non-uniform scales. auto scale = max(transform.x_scale(), transform.y_scale()); diff --git a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h index 8ca323741a9..2138ed5b7c2 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h +++ b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h @@ -52,7 +52,7 @@ public: return m_size; } - virtual void draw_transformed(Painter&, AffineTransform) const override; + virtual void draw_transformed(DeprecatedPainter&, AffineTransform) const override; ReadonlySpan draw_commands() const { diff --git a/Userland/Libraries/LibGfx/Path.cpp b/Userland/Libraries/LibGfx/Path.cpp index e63a96697e6..d33cb1a0c0a 100644 --- a/Userland/Libraries/LibGfx/Path.cpp +++ b/Userland/Libraries/LibGfx/Path.cpp @@ -8,8 +8,8 @@ #include #include #include +#include #include -#include #include #include @@ -332,13 +332,13 @@ void Path::segmentize_path() break; } case PathSegment::QuadraticBezierCurveTo: { - Painter::for_each_line_segment_on_bezier_curve(segment.through(), cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) { + DeprecatedPainter::for_each_line_segment_on_bezier_curve(segment.through(), cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) { add_line(p0, p1); }); break; } case PathSegment::CubicBezierCurveTo: { - Painter::for_each_line_segment_on_cubic_bezier_curve(segment.through_0(), segment.through_1(), cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) { + DeprecatedPainter::for_each_line_segment_on_cubic_bezier_curve(segment.through_0(), segment.through_1(), cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) { add_line(p0, p1); }); break; diff --git a/Userland/Libraries/LibGfx/PathClipper.cpp b/Userland/Libraries/LibGfx/PathClipper.cpp index 226eb3e7d8b..e0c266c4a37 100644 --- a/Userland/Libraries/LibGfx/PathClipper.cpp +++ b/Userland/Libraries/LibGfx/PathClipper.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include namespace Gfx { @@ -13,7 +13,7 @@ namespace Gfx { // FIXME: This pretty naive, we should be able to cut down the allocations here // (especially for the paint style which is a bit sad). -ErrorOr PathClipper::create(Painter& painter, ClipPath const& clip_path) +ErrorOr PathClipper::create(DeprecatedPainter& painter, ClipPath const& clip_path) { auto bounding_box = enclosing_int_rect(clip_path.path.bounding_box()); IntRect actual_save_rect {}; @@ -31,7 +31,7 @@ ErrorOr PathClipper::create(Painter& painter, ClipPath const& clip_ return PathClipper(move(saved_clip_region), bounding_box, clip_path); } -ErrorOr PathClipper::apply_clip(Painter& painter) +ErrorOr PathClipper::apply_clip(DeprecatedPainter& painter) { painter.restore(); if (!m_saved_clip_region) diff --git a/Userland/Libraries/LibGfx/PathClipper.h b/Userland/Libraries/LibGfx/PathClipper.h index 0a0e9ba317a..882abe019f6 100644 --- a/Userland/Libraries/LibGfx/PathClipper.h +++ b/Userland/Libraries/LibGfx/PathClipper.h @@ -20,8 +20,8 @@ struct ClipPath { class PathClipper { public: - static ErrorOr create(Painter&, ClipPath const& clip_path); - ErrorOr apply_clip(Painter& painter); + static ErrorOr create(DeprecatedPainter&, ClipPath const& clip_path); + ErrorOr apply_clip(DeprecatedPainter& painter); private: PathClipper(RefPtr saved_clip_region, IntRect bounding_box, ClipPath const& clip_path) @@ -41,7 +41,7 @@ class ScopedPathClip { AK_MAKE_NONCOPYABLE(ScopedPathClip); public: - ScopedPathClip(Painter& painter, Optional const& clip_path) + ScopedPathClip(DeprecatedPainter& painter, Optional const& clip_path) : m_painter(painter) { if (clip_path.has_value()) { @@ -60,7 +60,7 @@ public: } private: - Painter& m_painter; + DeprecatedPainter& m_painter; Optional m_path_clipper; }; diff --git a/Userland/Libraries/LibGfx/VectorGraphic.cpp b/Userland/Libraries/LibGfx/VectorGraphic.cpp index baae04a216c..1a7ec299431 100644 --- a/Userland/Libraries/LibGfx/VectorGraphic.cpp +++ b/Userland/Libraries/LibGfx/VectorGraphic.cpp @@ -4,12 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include namespace Gfx { -void VectorGraphic::draw_into(Painter& painter, IntRect const& dest, AffineTransform transform) const +void VectorGraphic::draw_into(DeprecatedPainter& painter, IntRect const& dest, AffineTransform transform) const { // Apply the transform then center within destination rectangle (this ignores any translation from the transform): // This allows you to easily rotate or flip the image before painting. @@ -27,7 +27,7 @@ void VectorGraphic::draw_into(Painter& painter, IntRect const& dest, AffineTrans ErrorOr> VectorGraphic::bitmap(IntSize size, AffineTransform transform) const { auto bitmap = TRY(Bitmap::create(Gfx::BitmapFormat::BGRA8888, size)); - Painter painter { *bitmap }; + DeprecatedPainter painter { *bitmap }; draw_into(painter, IntRect { {}, size }, transform); return bitmap; } diff --git a/Userland/Libraries/LibGfx/VectorGraphic.h b/Userland/Libraries/LibGfx/VectorGraphic.h index 0b45f16448f..c437e3b9ba0 100644 --- a/Userland/Libraries/LibGfx/VectorGraphic.h +++ b/Userland/Libraries/LibGfx/VectorGraphic.h @@ -16,13 +16,13 @@ namespace Gfx { class VectorGraphic : public RefCounted { public: virtual IntSize intrinsic_size() const = 0; - virtual void draw_transformed(Painter&, AffineTransform) const = 0; + virtual void draw_transformed(DeprecatedPainter&, AffineTransform) const = 0; IntSize size() const { return intrinsic_size(); } IntRect rect() const { return { {}, size() }; } ErrorOr> bitmap(IntSize size, AffineTransform = {}) const; - void draw_into(Painter&, IntRect const& dest, AffineTransform = {}) const; + void draw_into(DeprecatedPainter&, IntRect const& dest, AffineTransform = {}) const; virtual ~VectorGraphic() = default; }; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 484892256d3..95c0cf3561c 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include @@ -181,13 +181,13 @@ void CanvasRenderingContext2D::did_draw(Gfx::FloatRect const&) canvas_element().paintable()->set_needs_display(); } -Gfx::Painter* CanvasRenderingContext2D::painter() +Gfx::DeprecatedPainter* CanvasRenderingContext2D::painter() { if (!canvas_element().bitmap()) { if (!canvas_element().create_bitmap()) return nullptr; canvas_element().document().invalidate_display_list(); - m_painter = make(*canvas_element().bitmap()); + m_painter = make(*canvas_element().bitmap()); } return m_painter.ptr(); } @@ -359,7 +359,7 @@ WebIDL::ExceptionOr> CanvasRenderingContext2D::get_image_da auto source_rect_intersected = source_rect.intersected(bitmap.rect()); // 6. Set the pixel values of imageData to be the pixels of this's output bitmap in the area specified by the source rectangle in the bitmap's coordinate space units, converted from this's color space to imageData's colorSpace using 'relative-colorimetric' rendering intent. - // FIXME: Can't use a Gfx::Painter + blit() here as it doesn't support ImageData bitmap's RGBA8888 format. + // FIXME: Can't use a Gfx::DeprecatedPainter + blit() here as it doesn't support ImageData bitmap's RGBA8888 format. // NOTE: Internally we must use premultiplied alpha, but ImageData should hold unpremultiplied alpha. This conversion // might result in a loss of precision, but is according to spec. // See: https://html.spec.whatwg.org/multipage/canvas.html#premultiplied-alpha-and-the-2d-rendering-context diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 152ac1c45f7..ef6d57db53f 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -135,7 +135,7 @@ private: PreparedText prepare_text(ByteString const& text, float max_width = INFINITY); - Gfx::Painter* painter(); + Gfx::DeprecatedPainter* painter(); Optional antialiased_painter(); Gfx::Path rect_path(float x, float y, float width, float height); @@ -147,7 +147,7 @@ private: void clip_internal(Gfx::Path&, Gfx::WindingRule); JS::NonnullGCPtr m_element; - OwnPtr m_painter; + OwnPtr m_painter; // https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-origin-clean bool m_origin_clean { true }; diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 5e8996bd719..d091b640c09 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -6,8 +6,8 @@ */ #include +#include #include -#include #include #include #include @@ -943,7 +943,7 @@ RefPtr PaintableBox::calculate_mask(PaintContext& context, CSSPixel if (maybe_bitmap.is_error()) return {}; auto bitmap = maybe_bitmap.release_value(); - Gfx::Painter painter(*bitmap); + Gfx::DeprecatedPainter painter(*bitmap); Gfx::AntiAliasingPainter aa_painter(painter); aa_painter.fill_path(path, Color::Black); return bitmap; diff --git a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp index fcfc5e7aa2d..97415f46e6b 100644 --- a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp @@ -7,7 +7,6 @@ */ #include -#include #include #include #include