mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibGfx: Rename Painter => DeprecatedPainter
This commit is contained in:
parent
099956a7cd
commit
0c7670b226
Notes:
github-actions[bot]
2024-08-20 07:38:33 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/0c7670b226b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1024
31 changed files with 119 additions and 120 deletions
|
@ -8,7 +8,7 @@
|
|||
#include "JNIHelpers.h"
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
#include <Userland/Libraries/LibGfx/Bitmap.h>
|
||||
#include <Userland/Libraries/LibGfx/Painter.h>
|
||||
#include <Userland/Libraries/LibGfx/DeprecatedPainter.h>
|
||||
#include <Userland/Libraries/LibWeb/Crypto/Crypto.h>
|
||||
#include <Userland/Libraries/LibWebView/ViewImplementation.h>
|
||||
#include <android/bitmap.h>
|
||||
|
@ -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
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "StringUtils.h"
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <QFile>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
|
@ -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) {
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include "Settings.h"
|
||||
#include "StringUtils.h"
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/ImageFormats/BMPWriter.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/HTML/SelectedFile.h>
|
||||
#include <LibWebView/SearchEngine.h>
|
||||
#include <LibWebView/SourceHighlighter.h>
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include <LibCore/Resource.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibGfx/ImageFormats/PNGWriter.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Line.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Painter.h"
|
||||
#include "DeprecatedPainter.h"
|
||||
#include "Bitmap.h"
|
||||
#include "Font/Font.h"
|
||||
#include <AK/Assertions.h>
|
||||
|
@ -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(IntPoint)>&
|
|||
}
|
||||
}
|
||||
|
||||
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<Color(Color)> const& filter, bool apply_alpha)
|
||||
void DeprecatedPainter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, Function<Color(Color)> 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<Color> Painter::get_pixel(IntPoint p)
|
||||
Optional<Color> DeprecatedPainter::get_pixel(IntPoint p)
|
||||
{
|
||||
auto point = p;
|
||||
point.translate_by(state().translation);
|
||||
|
@ -867,7 +867,7 @@ Optional<Color> Painter::get_pixel(IntPoint p)
|
|||
return target().get_pixel(point);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Bitmap>> Painter::get_region_bitmap(IntRect const& region, BitmapFormat format, Optional<IntRect&> actual_region)
|
||||
ErrorOr<NonnullRefPtr<Bitmap>> DeprecatedPainter::get_region_bitmap(IntRect const& region, BitmapFormat format, Optional<IntRect&> actual_region)
|
||||
{
|
||||
auto bitmap_region = region.translated(state().translation).intersected(target().rect());
|
||||
if (actual_region.has_value())
|
||||
|
@ -875,21 +875,21 @@ ErrorOr<NonnullRefPtr<Bitmap>> 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<void(FloatPoint, FloatPoint)>& callback)
|
||||
void DeprecatedPainter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>& 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<void(FloatPoint, FloatPoint)>&& callback)
|
||||
void DeprecatedPainter::for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>&& 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<void(FloatPoint, FloatPoint)>&& callback)
|
||||
void DeprecatedPainter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>&& 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<void(FloatPoint, FloatPoint)>& callback)
|
||||
void DeprecatedPainter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>& 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<float>()).to_rounded<int>(), 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;
|
|
@ -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<State, 4> m_state_stack;
|
||||
};
|
||||
|
||||
class PainterStateSaver {
|
||||
class DeprecatedPainterStateSaver {
|
||||
public:
|
||||
explicit PainterStateSaver(Painter&);
|
||||
~PainterStateSaver();
|
||||
explicit DeprecatedPainterStateSaver(DeprecatedPainter&);
|
||||
~DeprecatedPainterStateSaver();
|
||||
|
||||
private:
|
||||
Painter& m_painter;
|
||||
DeprecatedPainter& m_painter;
|
||||
};
|
||||
|
||||
}
|
|
@ -9,8 +9,8 @@
|
|||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/EdgeFlagPathRasterizer.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
|
||||
#if defined(AK_COMPILER_GCC)
|
||||
# pragma GCC optimize("O3")
|
||||
|
@ -99,13 +99,13 @@ EdgeFlagPathRasterizer<SamplesPerPixel>::EdgeFlagPathRasterizer(IntSize size)
|
|||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(Painter& painter, Path const& path, Color color, WindingRule winding_rule, FloatPoint offset)
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(DeprecatedPainter& painter, Path const& path, Color color, WindingRule winding_rule, FloatPoint offset)
|
||||
{
|
||||
fill_internal(painter, path, color, winding_rule, offset);
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(Painter& painter, Path const& path, PaintStyle const& style, float opacity, WindingRule winding_rule, FloatPoint offset)
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::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<SamplesPerPixel>::fill(Painter& painter, Path const&
|
|||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill_internal(Painter& painter, Path const& path, auto color_or_function, WindingRule winding_rule, FloatPoint offset)
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::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<SamplesPerPixel>::fast_fill_solid_color_span(ARGB32*
|
|||
|
||||
template<unsigned SamplesPerPixel>
|
||||
template<WindingRule WindingRule>
|
||||
FLATTEN __attribute__((hot)) void EdgeFlagPathRasterizer<SamplesPerPixel>::write_scanline(Painter& painter, int scanline, EdgeExtent edge_extent, auto& color_or_function)
|
||||
FLATTEN __attribute__((hot)) void EdgeFlagPathRasterizer<SamplesPerPixel>::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);
|
||||
|
|
|
@ -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<SamplesPerPixel>;
|
||||
|
@ -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<WindingRule>
|
||||
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);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/OpenType/Glyf.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/OpenType/Cmap.h>
|
||||
#include <LibGfx/Font/OpenType/Glyf.h>
|
||||
#include <LibGfx/Font/OpenType/Tables.h>
|
||||
#include <LibGfx/Font/OpenType/Typeface.h>
|
||||
#include <LibGfx/ImageFormats/PNGLoader.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <math.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ template<typename T>
|
|||
class Line;
|
||||
|
||||
class AntiAliasingPainter;
|
||||
class Painter;
|
||||
class DeprecatedPainter;
|
||||
class Palette;
|
||||
class PaletteImpl;
|
||||
class Path;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <AK/Math.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Gradients.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
|
||||
#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<Co
|
|||
};
|
||||
}
|
||||
|
||||
void Painter::fill_rect_with_linear_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, float angle, Optional<float> repeat_length)
|
||||
void DeprecatedPainter::fill_rect_with_linear_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, float angle, Optional<float> 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<float>().translated(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
void Painter::fill_rect_with_conic_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, float start_angle, Optional<float> repeat_length)
|
||||
void DeprecatedPainter::fill_rect_with_conic_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, float start_angle, Optional<float> 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<Co
|
|||
conic_gradient.paint(*this, a_rect);
|
||||
}
|
||||
|
||||
void Painter::fill_rect_with_radial_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, IntSize size, Optional<float> repeat_length, Optional<float> rotation_angle)
|
||||
void DeprecatedPainter::fill_rect_with_radial_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, IntSize size, Optional<float> repeat_length, Optional<float> rotation_angle)
|
||||
{
|
||||
auto a_rect = to_physical(rect);
|
||||
if (a_rect.intersected(clip_rect()).is_empty())
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/ImageFormats/PNGLoader.h>
|
||||
#include <LibGfx/ImageFormats/TIFFLoader.h>
|
||||
#include <LibGfx/ImageFormats/TIFFMetadata.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <png.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -203,7 +203,7 @@ ErrorOr<bool> PNGImageDecoderPlugin::initialize()
|
|||
static ErrorOr<NonnullRefPtr<Bitmap>> 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) {
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <AK/Variant.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/ImageFormats/TinyVGLoader.h>
|
||||
#include <LibGfx/Line.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -472,7 +472,7 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> 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());
|
||||
|
|
|
@ -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<DrawCommand> draw_commands() const
|
||||
{
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibGfx/BoundingBox.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibGfx/TextLayout.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/PathClipper.h>
|
||||
|
||||
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> PathClipper::create(Painter& painter, ClipPath const& clip_path)
|
||||
ErrorOr<PathClipper> 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> PathClipper::create(Painter& painter, ClipPath const& clip_
|
|||
return PathClipper(move(saved_clip_region), bounding_box, clip_path);
|
||||
}
|
||||
|
||||
ErrorOr<void> PathClipper::apply_clip(Painter& painter)
|
||||
ErrorOr<void> PathClipper::apply_clip(DeprecatedPainter& painter)
|
||||
{
|
||||
painter.restore();
|
||||
if (!m_saved_clip_region)
|
||||
|
|
|
@ -20,8 +20,8 @@ struct ClipPath {
|
|||
|
||||
class PathClipper {
|
||||
public:
|
||||
static ErrorOr<PathClipper> create(Painter&, ClipPath const& clip_path);
|
||||
ErrorOr<void> apply_clip(Painter& painter);
|
||||
static ErrorOr<PathClipper> create(DeprecatedPainter&, ClipPath const& clip_path);
|
||||
ErrorOr<void> apply_clip(DeprecatedPainter& painter);
|
||||
|
||||
private:
|
||||
PathClipper(RefPtr<Bitmap const> 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<ClipPath> const& clip_path)
|
||||
ScopedPathClip(DeprecatedPainter& painter, Optional<ClipPath> const& clip_path)
|
||||
: m_painter(painter)
|
||||
{
|
||||
if (clip_path.has_value()) {
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
Painter& m_painter;
|
||||
DeprecatedPainter& m_painter;
|
||||
Optional<PathClipper> m_path_clipper;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/VectorGraphic.h>
|
||||
|
||||
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<NonnullRefPtr<Gfx::Bitmap>> 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;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace Gfx {
|
|||
class VectorGraphic : public RefCounted<VectorGraphic> {
|
||||
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<NonnullRefPtr<Gfx::Bitmap>> 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;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Quad.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibUnicode/Segmenter.h>
|
||||
|
@ -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<Gfx::Painter>(*canvas_element().bitmap());
|
||||
m_painter = make<Gfx::DeprecatedPainter>(*canvas_element().bitmap());
|
||||
}
|
||||
return m_painter.ptr();
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ WebIDL::ExceptionOr<JS::GCPtr<ImageData>> 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
|
||||
|
|
|
@ -135,7 +135,7 @@ private:
|
|||
|
||||
PreparedText prepare_text(ByteString const& text, float max_width = INFINITY);
|
||||
|
||||
Gfx::Painter* painter();
|
||||
Gfx::DeprecatedPainter* painter();
|
||||
Optional<Gfx::AntiAliasingPainter> 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<HTMLCanvasElement> m_element;
|
||||
OwnPtr<Gfx::Painter> m_painter;
|
||||
OwnPtr<Gfx::DeprecatedPainter> m_painter;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-origin-clean
|
||||
bool m_origin_clean { true };
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibUnicode/CharacterTypes.h>
|
||||
#include <LibWeb/CSS/SystemColor.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
@ -943,7 +943,7 @@ RefPtr<Gfx::Bitmap> 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;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
#include <LibGfx/DisjointRectSet.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/Painting/BorderPainting.h>
|
||||
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
||||
#include <LibWeb/Painting/PaintBoxShadowParams.h>
|
||||
|
|
Loading…
Reference in a new issue