mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibGfx: Delete DeprecatedPainter
This commit is contained in:
parent
1e67b85571
commit
dbfe5be9ff
Notes:
github-actions[bot]
2024-11-25 20:14:51 +00:00
Author: https://github.com/shlyakpavel Commit: https://github.com/LadybirdBrowser/ladybird/commit/dbfe5be9ffa Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2570
27 changed files with 17 additions and 2068 deletions
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2022, Ben Maxwell <macdue@dueutil.tech>
|
||||
* Copyright (c) 2022, Torsten Engelmann <engelTorsten@gmx.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#if defined(AK_COMPILER_GCC)
|
||||
# pragma GCC optimize("O3")
|
||||
#endif
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
void AntiAliasingPainter::stroke_path(DeprecatedPath const& path, Color color, float thickness)
|
||||
{
|
||||
if (thickness <= 0)
|
||||
return;
|
||||
// FIXME: Cache this? Probably at a higher level such as in LibWeb?
|
||||
fill_path(path.stroke_to_fill(thickness), color);
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::stroke_path(DeprecatedPath const& path, Gfx::PaintStyle const& paint_style, float thickness, float opacity)
|
||||
{
|
||||
if (thickness <= 0)
|
||||
return;
|
||||
// FIXME: Cache this? Probably at a higher level such as in LibWeb?
|
||||
fill_path(path.stroke_to_fill(thickness), paint_style, opacity);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/DeprecatedPath.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibGfx/WindingRule.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
struct CornerRadius {
|
||||
int horizontal_radius { 0 };
|
||||
int vertical_radius { 0 };
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return horizontal_radius > 0 && vertical_radius > 0;
|
||||
}
|
||||
};
|
||||
|
||||
class AntiAliasingPainter {
|
||||
public:
|
||||
explicit AntiAliasingPainter(DeprecatedPainter& painter)
|
||||
: m_underlying_painter(painter)
|
||||
{
|
||||
}
|
||||
|
||||
void fill_path(DeprecatedPath const&, Color, WindingRule rule = WindingRule::Nonzero);
|
||||
void fill_path(DeprecatedPath const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero);
|
||||
|
||||
void stroke_path(DeprecatedPath const&, Color, float thickness);
|
||||
void stroke_path(DeprecatedPath const&, PaintStyle const& paint_style, float thickness, float opacity = 1.0f);
|
||||
|
||||
private:
|
||||
DeprecatedPainter& m_underlying_painter;
|
||||
};
|
||||
|
||||
}
|
|
@ -3,15 +3,11 @@ include(vulkan)
|
|||
|
||||
set(SOURCES
|
||||
AffineTransform.cpp
|
||||
AntiAliasingPainter.cpp
|
||||
Bitmap.cpp
|
||||
BitmapSequence.cpp
|
||||
CMYKBitmap.cpp
|
||||
Color.cpp
|
||||
DeltaE.cpp
|
||||
DeprecatedPainter.cpp
|
||||
DeprecatedPath.cpp
|
||||
EdgeFlagPathRasterizer.cpp
|
||||
FontCascadeList.cpp
|
||||
Font/Font.cpp
|
||||
Font/FontData.cpp
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/LineStyle.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/WindingRule.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
ALWAYS_INLINE static Color color_for_format(BitmapFormat format, ARGB32 value)
|
||||
{
|
||||
switch (format) {
|
||||
case BitmapFormat::BGRA8888:
|
||||
return Color::from_argb(value);
|
||||
case BitmapFormat::BGRx8888:
|
||||
return Color::from_rgb(value);
|
||||
// FIXME: Handle other formats
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
class DeprecatedPainter {
|
||||
public:
|
||||
explicit DeprecatedPainter(Gfx::Bitmap&);
|
||||
~DeprecatedPainter() = default;
|
||||
|
||||
void clear_rect(IntRect const&, Color);
|
||||
void fill_rect(IntRect const&, Color);
|
||||
void fill_rect(IntRect const&, PaintStyle const&);
|
||||
void fill_rect_with_rounded_corners(IntRect const&, Color, int radius);
|
||||
void fill_rect_with_rounded_corners(IntRect const&, Color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);
|
||||
void fill_ellipse(IntRect const&, Color);
|
||||
void draw_rect(IntRect const&, Color, bool rough = false);
|
||||
Optional<Color> get_pixel(IntPoint);
|
||||
void draw_line(IntPoint, IntPoint, Color, int thickness = 1, LineStyle style = LineStyle::Solid, Color alternate_color = Color::Transparent);
|
||||
void blit(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, float opacity = 1.0f, bool apply_alpha = true);
|
||||
void blit_filtered(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, Function<Color(Color)> const&, bool apply_alpha = true);
|
||||
|
||||
enum class CornerOrientation {
|
||||
TopLeft,
|
||||
TopRight,
|
||||
BottomRight,
|
||||
BottomLeft
|
||||
};
|
||||
void fill_rounded_corner(IntRect const&, int radius, Color, CornerOrientation);
|
||||
|
||||
static void for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>&);
|
||||
static void for_each_line_segment_on_bezier_curve(FloatPoint control_point, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>&&);
|
||||
|
||||
static void for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>&);
|
||||
static void for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function<void(FloatPoint, FloatPoint)>&&);
|
||||
|
||||
void stroke_path(DeprecatedPath const&, Color, int thickness);
|
||||
|
||||
void fill_path(DeprecatedPath const&, Color, WindingRule rule = WindingRule::Nonzero);
|
||||
void fill_path(DeprecatedPath const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero);
|
||||
|
||||
void add_clip_rect(IntRect const& rect);
|
||||
|
||||
void translate(int dx, int dy) { state().translation.translate_by({ dx, dy }); }
|
||||
|
||||
IntPoint translation() const { return state().translation; }
|
||||
|
||||
[[nodiscard]] Gfx::Bitmap& target() { return *m_target; }
|
||||
|
||||
void save() { m_state_stack.append(m_state_stack.last()); }
|
||||
void restore()
|
||||
{
|
||||
VERIFY(m_state_stack.size() > 1);
|
||||
m_state_stack.take_last();
|
||||
}
|
||||
|
||||
IntRect clip_rect() const { return state().clip_rect; }
|
||||
|
||||
protected:
|
||||
friend AntiAliasingPainter;
|
||||
template<unsigned SamplesPerPixel>
|
||||
friend class EdgeFlagPathRasterizer;
|
||||
|
||||
IntPoint to_physical(IntPoint p) const { return p.translated(translation()); }
|
||||
void set_physical_pixel(u32& pixel, Color);
|
||||
void fill_physical_scanline(int y, int x, int width, Color color);
|
||||
void blit_with_opacity(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, float opacity, bool apply_alpha = true);
|
||||
void draw_physical_pixel(IntPoint, Color, int thickness = 1);
|
||||
void set_physical_pixel(IntPoint, Color color, bool blend);
|
||||
|
||||
struct State {
|
||||
IntPoint translation;
|
||||
IntRect clip_rect;
|
||||
};
|
||||
|
||||
State& state() { return m_state_stack.last(); }
|
||||
State const& state() const { return m_state_stack.last(); }
|
||||
|
||||
void fill_physical_rect(IntRect const&, Color);
|
||||
|
||||
NonnullRefPtr<Gfx::Bitmap> m_target;
|
||||
Vector<State, 4> m_state_stack;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,468 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2024, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Memory.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/EdgeFlagPathRasterizer.h>
|
||||
|
||||
#if defined(AK_COMPILER_GCC)
|
||||
# pragma GCC optimize("O3")
|
||||
#endif
|
||||
|
||||
// This an implementation of edge-flag scanline AA, as described in:
|
||||
// https://mlab.taik.fi/~kkallio/antialiasing/EdgeFlagAA.pdf
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
static Vector<Detail::Edge> prepare_edges(ReadonlySpan<FloatLine> lines, unsigned samples_per_pixel, FloatPoint origin,
|
||||
int top_clip_scanline, int bottom_clip_scanline, int& min_edge_y, int& max_edge_y)
|
||||
{
|
||||
Vector<Detail::Edge> edges;
|
||||
edges.ensure_capacity(lines.size());
|
||||
// The first visible y value.
|
||||
auto top_clip = top_clip_scanline * int(samples_per_pixel);
|
||||
// The last visible y value.
|
||||
auto bottom_clip = (bottom_clip_scanline + 1) * int(samples_per_pixel);
|
||||
min_edge_y = bottom_clip;
|
||||
max_edge_y = top_clip;
|
||||
|
||||
for (auto& line : lines) {
|
||||
auto p0 = line.a() - origin;
|
||||
auto p1 = line.b() - origin;
|
||||
|
||||
p0.scale_by(1, samples_per_pixel);
|
||||
p1.scale_by(1, samples_per_pixel);
|
||||
|
||||
i8 winding = -1;
|
||||
if (p0.y() > p1.y()) {
|
||||
swap(p0, p1);
|
||||
} else {
|
||||
winding = 1;
|
||||
}
|
||||
|
||||
if (p0.y() == p1.y())
|
||||
continue;
|
||||
|
||||
auto min_y = static_cast<int>(p0.y());
|
||||
auto max_y = static_cast<int>(p1.y());
|
||||
|
||||
// Clip edges that start below the bottom clip...
|
||||
if (min_y > bottom_clip)
|
||||
continue;
|
||||
// ...and edges that end before the top clip.
|
||||
if (max_y < top_clip)
|
||||
continue;
|
||||
|
||||
auto start_x = p0.x();
|
||||
auto end_x = p1.x();
|
||||
auto dx = end_x - start_x;
|
||||
auto dy = max_y - min_y;
|
||||
|
||||
if (dy == 0)
|
||||
continue;
|
||||
|
||||
auto dxdy = dx / dy;
|
||||
|
||||
// Trim off the non-visible portions of the edge.
|
||||
if (min_y < top_clip) {
|
||||
start_x += dxdy * (top_clip - min_y);
|
||||
min_y = top_clip;
|
||||
}
|
||||
if (max_y > bottom_clip)
|
||||
max_y = bottom_clip;
|
||||
|
||||
min_edge_y = min(min_y, min_edge_y);
|
||||
max_edge_y = max(max_y, max_edge_y);
|
||||
|
||||
edges.unchecked_append(Detail::Edge {
|
||||
start_x,
|
||||
min_y,
|
||||
max_y,
|
||||
dxdy,
|
||||
winding,
|
||||
nullptr });
|
||||
}
|
||||
return edges;
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
EdgeFlagPathRasterizer<SamplesPerPixel>::EdgeFlagPathRasterizer(IntSize size)
|
||||
: m_size(size.width() + 1, size.height() + 1)
|
||||
{
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(DeprecatedPainter& painter, DeprecatedPath const& path, Color color, WindingRule winding_rule, FloatPoint offset)
|
||||
{
|
||||
fill_internal(painter, path, color, winding_rule, offset);
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(DeprecatedPainter& painter, DeprecatedPath 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)
|
||||
return;
|
||||
if (opacity != 1.0f) {
|
||||
return fill_internal(
|
||||
painter, path, [=, sampler = move(sampler)](IntPoint point) {
|
||||
return sampler(point).with_opacity(opacity);
|
||||
},
|
||||
winding_rule, offset);
|
||||
}
|
||||
return fill_internal(painter, path, move(sampler), winding_rule, offset);
|
||||
});
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill_internal(DeprecatedPainter& painter, DeprecatedPath 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());
|
||||
auto origin = bounding_box.top_left().to_type<float>() - offset;
|
||||
m_blit_origin = dest_rect.top_left();
|
||||
m_clip = dest_rect.intersected(painter.clip_rect());
|
||||
|
||||
// Only allocate enough to plot the parts of the scanline that could be visible.
|
||||
// Note: This can't clip the LHS.
|
||||
auto scanline_length = min(m_size.width(), m_clip.right() - m_blit_origin.x());
|
||||
if (scanline_length <= 0)
|
||||
return;
|
||||
|
||||
m_scanline.resize(scanline_length);
|
||||
|
||||
if (m_clip.is_empty())
|
||||
return;
|
||||
|
||||
auto lines = path.split_lines();
|
||||
if (lines.is_empty())
|
||||
return;
|
||||
|
||||
int min_edge_y = 0;
|
||||
int max_edge_y = 0;
|
||||
auto top_clip_scanline = m_clip.top() - m_blit_origin.y();
|
||||
auto bottom_clip_scanline = m_clip.bottom() - m_blit_origin.y() - 1;
|
||||
auto edges = prepare_edges(lines, SamplesPerPixel, origin, top_clip_scanline, bottom_clip_scanline, min_edge_y, max_edge_y);
|
||||
if (edges.is_empty())
|
||||
return;
|
||||
|
||||
int min_scanline = min_edge_y / SamplesPerPixel;
|
||||
int max_scanline = max_edge_y / SamplesPerPixel;
|
||||
m_edge_table.set_scanline_range(min_scanline, max_scanline);
|
||||
for (auto& edge : edges) {
|
||||
// Create a linked-list of edges starting on this scanline:
|
||||
int start_scanline = edge.min_y / SamplesPerPixel;
|
||||
edge.next_edge = m_edge_table[start_scanline];
|
||||
m_edge_table[start_scanline] = &edge;
|
||||
}
|
||||
|
||||
auto empty_edge_extent = [&] {
|
||||
return EdgeExtent { m_size.width() - 1, 0 };
|
||||
};
|
||||
|
||||
auto for_each_sample = [&](Detail::Edge& edge, int start_subpixel_y, int end_subpixel_y, EdgeExtent& edge_extent, auto callback) {
|
||||
for (int y = start_subpixel_y; y < end_subpixel_y; y++) {
|
||||
auto xi = static_cast<int>(edge.x + SubpixelSample::nrooks_subpixel_offsets[y]);
|
||||
if (xi >= 0 && size_t(xi) < m_scanline.size()) [[likely]] {
|
||||
SampleType sample = 1 << y;
|
||||
callback(xi, y, sample);
|
||||
} else if (xi < 0) {
|
||||
if (edge.dxdy <= 0)
|
||||
return;
|
||||
} else {
|
||||
xi = m_scanline.size() - 1;
|
||||
}
|
||||
edge.x += edge.dxdy;
|
||||
edge_extent.min_x = min(edge_extent.min_x, xi);
|
||||
edge_extent.max_x = max(edge_extent.max_x, xi);
|
||||
}
|
||||
};
|
||||
|
||||
Detail::Edge* active_edges = nullptr;
|
||||
|
||||
if (winding_rule == WindingRule::EvenOdd) {
|
||||
auto plot_edge = [&](Detail::Edge& edge, int start_subpixel_y, int end_subpixel_y, EdgeExtent& edge_extent) {
|
||||
for_each_sample(edge, start_subpixel_y, end_subpixel_y, edge_extent, [&](int xi, int, SampleType sample) {
|
||||
m_scanline[xi] ^= sample;
|
||||
});
|
||||
};
|
||||
for (int scanline = min_scanline; scanline <= max_scanline; scanline++) {
|
||||
auto edge_extent = empty_edge_extent();
|
||||
active_edges = plot_edges_for_scanline(scanline, plot_edge, edge_extent, active_edges);
|
||||
write_scanline<WindingRule::EvenOdd>(painter, scanline, edge_extent, color_or_function);
|
||||
}
|
||||
} else {
|
||||
VERIFY(winding_rule == WindingRule::Nonzero);
|
||||
// Only allocate the winding buffer if needed.
|
||||
// NOTE: non-zero fills are a fair bit less efficient. So if you can do an even-odd fill do that :^)
|
||||
if (m_windings.is_empty())
|
||||
m_windings.resize(m_scanline.size());
|
||||
|
||||
auto plot_edge = [&](Detail::Edge& edge, int start_subpixel_y, int end_subpixel_y, EdgeExtent& edge_extent) {
|
||||
for_each_sample(edge, start_subpixel_y, end_subpixel_y, edge_extent, [&](int xi, int y, SampleType sample) {
|
||||
m_scanline[xi] |= sample;
|
||||
m_windings[xi].counts[y] += edge.winding;
|
||||
});
|
||||
};
|
||||
for (int scanline = min_scanline; scanline <= max_scanline; scanline++) {
|
||||
auto edge_extent = empty_edge_extent();
|
||||
active_edges = plot_edges_for_scanline(scanline, plot_edge, edge_extent, active_edges);
|
||||
write_scanline<WindingRule::Nonzero>(painter, scanline, edge_extent, color_or_function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static auto switch_on_color_or_function(auto& color_or_function, auto color_case, auto function_case)
|
||||
{
|
||||
using ColorOrFunction = decltype(color_or_function);
|
||||
constexpr bool has_constant_color = IsSame<RemoveCVReference<ColorOrFunction>, Color>;
|
||||
if constexpr (has_constant_color) {
|
||||
return color_case(color_or_function);
|
||||
} else {
|
||||
return function_case(color_or_function);
|
||||
}
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
Color EdgeFlagPathRasterizer<SamplesPerPixel>::scanline_color(int scanline, int offset, u8 alpha, auto& color_or_function)
|
||||
{
|
||||
auto color = switch_on_color_or_function(
|
||||
color_or_function, [](Color color) { return color; },
|
||||
[&](auto& function) {
|
||||
return function({ offset, scanline });
|
||||
});
|
||||
if (color.alpha() == 255)
|
||||
return color.with_alpha(alpha, AlphaType::Premultiplied);
|
||||
return color.with_alpha(color.alpha() * alpha / 255, AlphaType::Premultiplied);
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
__attribute__((hot)) Detail::Edge* EdgeFlagPathRasterizer<SamplesPerPixel>::plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent& edge_extent, Detail::Edge* active_edges)
|
||||
{
|
||||
auto y_subpixel = [](int y) {
|
||||
return y & (SamplesPerPixel - 1);
|
||||
};
|
||||
|
||||
auto* current_edge = active_edges;
|
||||
Detail::Edge* prev_edge = nullptr;
|
||||
|
||||
// First iterate over the edge in the active edge table, these are edges added on earlier scanlines,
|
||||
// that have not yet reached their end scanline.
|
||||
while (current_edge) {
|
||||
int end_scanline = current_edge->max_y / SamplesPerPixel;
|
||||
if (scanline == end_scanline) {
|
||||
// This edge ends this scanline.
|
||||
plot_edge(*current_edge, 0, y_subpixel(current_edge->max_y), edge_extent);
|
||||
// Remove this edge from the AET
|
||||
current_edge = current_edge->next_edge;
|
||||
if (prev_edge)
|
||||
prev_edge->next_edge = current_edge;
|
||||
else
|
||||
active_edges = current_edge;
|
||||
} else {
|
||||
// This edge sticks around for a few more scanlines.
|
||||
plot_edge(*current_edge, 0, SamplesPerPixel, edge_extent);
|
||||
prev_edge = current_edge;
|
||||
current_edge = current_edge->next_edge;
|
||||
}
|
||||
}
|
||||
|
||||
// Next, iterate over new edges for this line. If active_edges was null this also becomes the new
|
||||
// AET. Edges new will be appended here.
|
||||
current_edge = m_edge_table[scanline];
|
||||
while (current_edge) {
|
||||
int end_scanline = current_edge->max_y / SamplesPerPixel;
|
||||
if (scanline == end_scanline) {
|
||||
// This edge will end this scanlines (no need to add to AET).
|
||||
plot_edge(*current_edge, y_subpixel(current_edge->min_y), y_subpixel(current_edge->max_y), edge_extent);
|
||||
} else {
|
||||
// This edge will live on for a few more scanlines.
|
||||
plot_edge(*current_edge, y_subpixel(current_edge->min_y), SamplesPerPixel, edge_extent);
|
||||
// Add this edge to the AET
|
||||
if (prev_edge)
|
||||
prev_edge->next_edge = current_edge;
|
||||
else
|
||||
active_edges = current_edge;
|
||||
prev_edge = current_edge;
|
||||
}
|
||||
current_edge = current_edge->next_edge;
|
||||
}
|
||||
|
||||
if (prev_edge)
|
||||
prev_edge->next_edge = nullptr;
|
||||
|
||||
m_edge_table[scanline] = nullptr;
|
||||
return active_edges;
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
auto EdgeFlagPathRasterizer<SamplesPerPixel>::accumulate_even_odd_scanline(EdgeExtent edge_extent, auto init, auto sample_callback)
|
||||
{
|
||||
SampleType sample = init;
|
||||
VERIFY(edge_extent.min_x >= 0);
|
||||
VERIFY(edge_extent.max_x < static_cast<int>(m_scanline.size()));
|
||||
for (int x = edge_extent.min_x; x <= edge_extent.max_x; x++) {
|
||||
sample ^= m_scanline.data()[x];
|
||||
sample_callback(x, sample);
|
||||
m_scanline.data()[x] = 0;
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
auto EdgeFlagPathRasterizer<SamplesPerPixel>::accumulate_non_zero_scanline(EdgeExtent edge_extent, auto init, auto sample_callback)
|
||||
{
|
||||
NonZeroAcc acc = init;
|
||||
VERIFY(edge_extent.min_x >= 0);
|
||||
VERIFY(edge_extent.max_x < static_cast<int>(m_scanline.size()));
|
||||
for (int x = edge_extent.min_x; x <= edge_extent.max_x; x++) {
|
||||
if (auto edges = m_scanline.data()[x]) {
|
||||
// We only need to process the windings when we hit some edges.
|
||||
for (auto y_sub = 0u; y_sub < SamplesPerPixel; y_sub++) {
|
||||
auto subpixel_bit = 1 << y_sub;
|
||||
if (edges & subpixel_bit) {
|
||||
auto winding = m_windings.data()[x].counts[y_sub];
|
||||
auto previous_winding_count = acc.winding.counts[y_sub];
|
||||
acc.winding.counts[y_sub] += winding;
|
||||
// Toggle fill on change to/from zero.
|
||||
if (bool(previous_winding_count) ^ bool(acc.winding.counts[y_sub]))
|
||||
acc.sample ^= subpixel_bit;
|
||||
}
|
||||
}
|
||||
}
|
||||
sample_callback(x, acc.sample);
|
||||
m_scanline.data()[x] = 0;
|
||||
m_windings.data()[x] = {};
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
template<WindingRule WindingRule, typename Callback>
|
||||
auto EdgeFlagPathRasterizer<SamplesPerPixel>::accumulate_scanline(EdgeExtent edge_extent, auto init, Callback callback)
|
||||
{
|
||||
if constexpr (WindingRule == WindingRule::EvenOdd)
|
||||
return accumulate_even_odd_scanline(edge_extent, init, callback);
|
||||
else
|
||||
return accumulate_non_zero_scanline(edge_extent, init, callback);
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::write_pixel(BitmapFormat format, ARGB32* scanline_ptr, int scanline, int offset, SampleType sample, auto& color_or_function)
|
||||
{
|
||||
if (!sample)
|
||||
return;
|
||||
auto dest_x = offset + m_blit_origin.x();
|
||||
auto coverage = SubpixelSample::compute_coverage(sample);
|
||||
auto paint_color = scanline_color(scanline, offset, coverage_to_alpha(coverage), color_or_function);
|
||||
scanline_ptr[dest_x] = color_for_format(format, scanline_ptr[dest_x]).blend(paint_color).value();
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fast_fill_solid_color_span(ARGB32* scanline_ptr, int start, int end, Color color)
|
||||
{
|
||||
auto start_x = start + m_blit_origin.x();
|
||||
auto end_x = end + m_blit_origin.x();
|
||||
fast_u32_fill(scanline_ptr + start_x, color.value(), end_x - start_x + 1);
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
template<WindingRule WindingRule>
|
||||
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();
|
||||
EdgeExtent clipped_extent { max(left_clip, edge_extent.min_x), edge_extent.max_x };
|
||||
if (clipped_extent.min_x > clipped_extent.max_x) {
|
||||
// Fully clipped. Unfortunately we still need to zero the scanline data.
|
||||
edge_extent.memset_extent(m_scanline.data(), 0);
|
||||
if constexpr (WindingRule == WindingRule::Nonzero)
|
||||
edge_extent.memset_extent(m_windings.data(), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Accumulate non-visible section (without plotting pixels).
|
||||
auto acc = accumulate_scanline<WindingRule>(EdgeExtent { edge_extent.min_x, left_clip - 1 }, initial_acc<WindingRule>(), [](int, SampleType) {
|
||||
// Do nothing!
|
||||
});
|
||||
|
||||
// Get pointer to current scanline pixels.
|
||||
auto dest_format = painter.target().format();
|
||||
auto dest_ptr = painter.target().scanline(scanline + m_blit_origin.y());
|
||||
|
||||
// Simple case: Handle each pixel individually.
|
||||
// Used for PaintStyle fills and semi-transparent colors.
|
||||
auto write_scanline_pixelwise = [&](auto& color_or_function) {
|
||||
accumulate_scanline<WindingRule>(clipped_extent, acc, [&](int x, SampleType sample) {
|
||||
write_pixel(dest_format, dest_ptr, scanline, x, sample, color_or_function);
|
||||
});
|
||||
};
|
||||
// Fast fill case: Track spans of solid color and set the entire span via a fast_u32_fill().
|
||||
// Used for opaque colors (i.e. alpha == 255).
|
||||
auto write_scanline_with_fast_fills = [&](Color color) {
|
||||
if (color.alpha() != 255)
|
||||
return write_scanline_pixelwise(color);
|
||||
constexpr SampleType full_coverage = NumericLimits<SampleType>::max();
|
||||
int full_coverage_count = 0;
|
||||
accumulate_scanline<WindingRule>(clipped_extent, acc, [&](int x, SampleType sample) {
|
||||
if (sample == full_coverage) {
|
||||
full_coverage_count++;
|
||||
return;
|
||||
} else {
|
||||
write_pixel(dest_format, dest_ptr, scanline, x, sample, color);
|
||||
}
|
||||
if (full_coverage_count > 0) {
|
||||
fast_fill_solid_color_span(dest_ptr, x - full_coverage_count, x - 1, color);
|
||||
full_coverage_count = 0;
|
||||
}
|
||||
});
|
||||
if (full_coverage_count > 0)
|
||||
fast_fill_solid_color_span(dest_ptr, clipped_extent.max_x - full_coverage_count + 1, clipped_extent.max_x, color);
|
||||
};
|
||||
switch_on_color_or_function(
|
||||
color_or_function, write_scanline_with_fast_fills, write_scanline_pixelwise);
|
||||
}
|
||||
|
||||
static IntSize path_bounds(Gfx::DeprecatedPath const& path)
|
||||
{
|
||||
return enclosing_int_rect(path.bounding_box()).size();
|
||||
}
|
||||
|
||||
// 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::DeprecatedPainter though as a "speedy" option.
|
||||
|
||||
void DeprecatedPainter::fill_path(DeprecatedPath const& path, Color color, WindingRule winding_rule)
|
||||
{
|
||||
EdgeFlagPathRasterizer<8> rasterizer(path_bounds(path));
|
||||
rasterizer.fill(*this, path, color, winding_rule);
|
||||
}
|
||||
|
||||
void DeprecatedPainter::fill_path(DeprecatedPath 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);
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::fill_path(DeprecatedPath const& path, Color color, WindingRule winding_rule)
|
||||
{
|
||||
EdgeFlagPathRasterizer<32> rasterizer(path_bounds(path));
|
||||
rasterizer.fill(m_underlying_painter, path, color, winding_rule, {});
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::fill_path(DeprecatedPath const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule)
|
||||
{
|
||||
EdgeFlagPathRasterizer<32> rasterizer(path_bounds(path));
|
||||
rasterizer.fill(m_underlying_painter, path, paint_style, opacity, winding_rule, {});
|
||||
}
|
||||
|
||||
template class EdgeFlagPathRasterizer<8>;
|
||||
template class EdgeFlagPathRasterizer<16>;
|
||||
template class EdgeFlagPathRasterizer<32>;
|
||||
|
||||
}
|
|
@ -1,239 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/DeprecatedPath.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibGfx/WindingRule.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
namespace Detail {
|
||||
|
||||
static auto constexpr coverage_lut = [] {
|
||||
Array<u8, 256> coverage_lut {};
|
||||
for (u32 sample = 0; sample <= 255; sample++)
|
||||
coverage_lut[sample] = AK::popcount(sample);
|
||||
return coverage_lut;
|
||||
}();
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
struct Sample {
|
||||
static_assert(!first_is_one_of(SamplesPerPixel, 8u, 16u, 32u), "EdgeFlagPathRasterizer: Invalid samples per pixel!");
|
||||
};
|
||||
|
||||
// See paper for diagrams for how these offsets work, but they allow for nicely spread out samples in each pixel.
|
||||
template<>
|
||||
struct Sample<8> {
|
||||
using Type = u8;
|
||||
static constexpr Array nrooks_subpixel_offsets {
|
||||
(5.0f / 8.0f),
|
||||
(0.0f / 8.0f),
|
||||
(3.0f / 8.0f),
|
||||
(6.0f / 8.0f),
|
||||
(1.0f / 8.0f),
|
||||
(4.0f / 8.0f),
|
||||
(7.0f / 8.0f),
|
||||
(2.0f / 8.0f),
|
||||
};
|
||||
|
||||
static u8 compute_coverage(Type sample)
|
||||
{
|
||||
return coverage_lut[sample];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Sample<16> {
|
||||
using Type = u16;
|
||||
static constexpr Array nrooks_subpixel_offsets {
|
||||
(1.0f / 16.0f),
|
||||
(8.0f / 16.0f),
|
||||
(4.0f / 16.0f),
|
||||
(15.0f / 16.0f),
|
||||
(11.0f / 16.0f),
|
||||
(2.0f / 16.0f),
|
||||
(6.0f / 16.0f),
|
||||
(14.0f / 16.0f),
|
||||
(10.0f / 16.0f),
|
||||
(3.0f / 16.0f),
|
||||
(7.0f / 16.0f),
|
||||
(12.0f / 16.0f),
|
||||
(0.0f / 16.0f),
|
||||
(9.0f / 16.0f),
|
||||
(5.0f / 16.0f),
|
||||
(13.0f / 16.0f),
|
||||
};
|
||||
|
||||
static u8 compute_coverage(Type sample)
|
||||
{
|
||||
return (
|
||||
coverage_lut[(sample >> 0) & 0xff]
|
||||
+ coverage_lut[(sample >> 8) & 0xff]);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Sample<32> {
|
||||
using Type = u32;
|
||||
static constexpr Array nrooks_subpixel_offsets {
|
||||
(28.0f / 32.0f),
|
||||
(13.0f / 32.0f),
|
||||
(6.0f / 32.0f),
|
||||
(23.0f / 32.0f),
|
||||
(0.0f / 32.0f),
|
||||
(17.0f / 32.0f),
|
||||
(10.0f / 32.0f),
|
||||
(27.0f / 32.0f),
|
||||
(4.0f / 32.0f),
|
||||
(21.0f / 32.0f),
|
||||
(14.0f / 32.0f),
|
||||
(31.0f / 32.0f),
|
||||
(8.0f / 32.0f),
|
||||
(25.0f / 32.0f),
|
||||
(18.0f / 32.0f),
|
||||
(3.0f / 32.0f),
|
||||
(12.0f / 32.0f),
|
||||
(29.0f / 32.0f),
|
||||
(22.0f / 32.0f),
|
||||
(7.0f / 32.0f),
|
||||
(16.0f / 32.0f),
|
||||
(1.0f / 32.0f),
|
||||
(26.0f / 32.0f),
|
||||
(11.0f / 32.0f),
|
||||
(20.0f / 32.0f),
|
||||
(5.0f / 32.0f),
|
||||
(30.0f / 32.0f),
|
||||
(15.0f / 32.0f),
|
||||
(24.0f / 32.0f),
|
||||
(9.0f / 32.0f),
|
||||
(2.0f / 32.0f),
|
||||
(19.0f / 32.0f),
|
||||
};
|
||||
|
||||
static u8 compute_coverage(Type sample)
|
||||
{
|
||||
return (
|
||||
coverage_lut[(sample >> 0) & 0xff]
|
||||
+ coverage_lut[(sample >> 8) & 0xff]
|
||||
+ coverage_lut[(sample >> 16) & 0xff]
|
||||
+ coverage_lut[(sample >> 24) & 0xff]);
|
||||
}
|
||||
};
|
||||
|
||||
struct Edge {
|
||||
float x;
|
||||
int min_y;
|
||||
int max_y;
|
||||
float dxdy;
|
||||
i8 winding;
|
||||
Edge* next_edge;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<unsigned SamplesPerPixel = 32>
|
||||
class EdgeFlagPathRasterizer {
|
||||
public:
|
||||
EdgeFlagPathRasterizer(IntSize);
|
||||
|
||||
void fill(DeprecatedPainter&, DeprecatedPath const&, Color, WindingRule, FloatPoint offset = {});
|
||||
void fill(DeprecatedPainter&, DeprecatedPath const&, PaintStyle const&, float opacity, WindingRule, FloatPoint offset = {});
|
||||
|
||||
private:
|
||||
using SubpixelSample = Detail::Sample<SamplesPerPixel>;
|
||||
using SampleType = typename SubpixelSample::Type;
|
||||
|
||||
static u8 coverage_to_alpha(u8 coverage)
|
||||
{
|
||||
constexpr auto alpha_shift = AK::log2(256 / SamplesPerPixel);
|
||||
if (!coverage)
|
||||
return 0;
|
||||
return (coverage << alpha_shift) - 1;
|
||||
}
|
||||
|
||||
struct EdgeExtent {
|
||||
int min_x;
|
||||
int max_x;
|
||||
|
||||
template<typename T>
|
||||
void memset_extent(T* data, int value)
|
||||
{
|
||||
if (min_x <= max_x)
|
||||
memset(data + min_x, value, (max_x - min_x + 1) * sizeof(T));
|
||||
}
|
||||
};
|
||||
|
||||
void fill_internal(DeprecatedPainter&, DeprecatedPath 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(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);
|
||||
|
||||
template<WindingRule, typename Callback>
|
||||
auto accumulate_scanline(EdgeExtent, auto, Callback);
|
||||
auto accumulate_even_odd_scanline(EdgeExtent, auto, auto sample_callback);
|
||||
auto accumulate_non_zero_scanline(EdgeExtent, auto, auto sample_callback);
|
||||
|
||||
struct WindingCounts {
|
||||
// NOTE: This only allows up to 256 winding levels. Increase this if required (i.e. to an i16).
|
||||
i8 counts[SamplesPerPixel];
|
||||
};
|
||||
|
||||
struct NonZeroAcc {
|
||||
SampleType sample;
|
||||
WindingCounts winding;
|
||||
};
|
||||
|
||||
template<WindingRule WindingRule>
|
||||
constexpr auto initial_acc() const
|
||||
{
|
||||
if constexpr (WindingRule == WindingRule::EvenOdd)
|
||||
return SampleType {};
|
||||
else
|
||||
return NonZeroAcc {};
|
||||
}
|
||||
|
||||
IntSize m_size;
|
||||
IntPoint m_blit_origin;
|
||||
IntRect m_clip;
|
||||
|
||||
Vector<SampleType> m_scanline;
|
||||
Vector<WindingCounts> m_windings;
|
||||
|
||||
class EdgeTable {
|
||||
public:
|
||||
EdgeTable() = default;
|
||||
|
||||
void set_scanline_range(int min_scanline, int max_scanline)
|
||||
{
|
||||
m_min_scanline = min_scanline;
|
||||
m_edges.resize(max_scanline - min_scanline + 1);
|
||||
}
|
||||
|
||||
auto& operator[](int scanline) { return m_edges[scanline - m_min_scanline]; }
|
||||
|
||||
private:
|
||||
Vector<Detail::Edge*> m_edges;
|
||||
int m_min_scanline { 0 };
|
||||
} m_edge_table;
|
||||
};
|
||||
|
||||
extern template class EdgeFlagPathRasterizer<8>;
|
||||
extern template class EdgeFlagPathRasterizer<16>;
|
||||
extern template class EdgeFlagPathRasterizer<32>;
|
||||
|
||||
}
|
|
@ -22,13 +22,10 @@ class ScaledFont;
|
|||
template<typename T>
|
||||
class Line;
|
||||
|
||||
class AntiAliasingPainter;
|
||||
class DeprecatedPainter;
|
||||
class Painter;
|
||||
class PaintingSurface;
|
||||
class Palette;
|
||||
class PaletteImpl;
|
||||
class DeprecatedPath;
|
||||
class Path;
|
||||
class ShareableBitmap;
|
||||
struct SystemTheme;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/Math.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Gradients.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
|
||||
|
@ -122,18 +121,6 @@ public:
|
|||
return color;
|
||||
}
|
||||
|
||||
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();
|
||||
for (int y = 0; y < clipped_rect.height(); y++) {
|
||||
for (int x = 0; x < clipped_rect.width(); x++) {
|
||||
auto pixel = sample_color(location_transform(x + start_offset.x(), y + start_offset.y()));
|
||||
painter.set_physical_pixel(clipped_rect.location().translated(x, y), pixel, m_requires_blending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool repeating() const
|
||||
{
|
||||
return m_repeat_mode != RepeatMode::None;
|
||||
|
@ -171,11 +158,6 @@ struct Gradient {
|
|||
{
|
||||
}
|
||||
|
||||
void paint(DeprecatedPainter& painter, IntRect rect)
|
||||
{
|
||||
m_gradient_line.paint_into_physical_rect(painter, rect, m_transform_function);
|
||||
}
|
||||
|
||||
template<typename CoordinateType = int>
|
||||
auto sample_function()
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/PainterSkia.h>
|
||||
#include <LibGfx/Quad.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/AudioTrackList.h>
|
||||
#include <LibWeb/HTML/HTMLAudioElement.h>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/CircularQueue.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
|
||||
|
@ -61,7 +60,7 @@ Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_
|
|||
return border_data.color;
|
||||
}
|
||||
|
||||
void paint_border(DisplayListRecorder& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::CornerRadius const& radius, Gfx::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last)
|
||||
void paint_border(DisplayListRecorder& painter, BorderEdge edge, DevicePixelRect const& rect, CornerRadius const& radius, CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last)
|
||||
{
|
||||
auto const& border_data = [&] {
|
||||
switch (edge) {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -26,7 +25,7 @@ enum class BorderEdge {
|
|||
// Returns OptionalNone if there is no outline to paint.
|
||||
Optional<BordersData> borders_data_for_outline(Layout::Node const&, Color outline_color, CSS::OutlineStyle outline_style, CSSPixels outline_width);
|
||||
|
||||
void paint_border(DisplayListRecorder& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::CornerRadius const& radius, Gfx::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path&, bool last);
|
||||
void paint_border(DisplayListRecorder& painter, BorderEdge edge, DevicePixelRect const& rect, CornerRadius const& radius, CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path&, bool last);
|
||||
void paint_all_borders(DisplayListRecorder& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const&);
|
||||
|
||||
Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_data);
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::Painting {
|
||||
|
||||
Gfx::CornerRadius BorderRadiusData::as_corner(PaintContext const& context) const
|
||||
CornerRadius BorderRadiusData::as_corner(PaintContext const& context) const
|
||||
{
|
||||
return Gfx::CornerRadius {
|
||||
return CornerRadius {
|
||||
context.floored_device_pixels(horizontal_radius).value(),
|
||||
context.floored_device_pixels(vertical_radius).value()
|
||||
};
|
||||
|
|
|
@ -7,17 +7,25 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
|
||||
namespace Web::Painting {
|
||||
|
||||
struct CornerRadius {
|
||||
int horizontal_radius { 0 };
|
||||
int vertical_radius { 0 };
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return horizontal_radius > 0 && vertical_radius > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct BorderRadiusData {
|
||||
CSSPixels horizontal_radius { 0 };
|
||||
CSSPixels vertical_radius { 0 };
|
||||
|
||||
Gfx::CornerRadius as_corner(PaintContext const& context) const;
|
||||
CornerRadius as_corner(PaintContext const& context) const;
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
|
@ -39,8 +47,6 @@ struct BorderRadiusData {
|
|||
}
|
||||
};
|
||||
|
||||
using CornerRadius = Gfx::CornerRadius;
|
||||
|
||||
struct CornerRadii {
|
||||
CornerRadius top_left;
|
||||
CornerRadius top_right;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <AK/SegmentedVector.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Gradients.h>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <AK/SegmentedVector.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Gradients.h>
|
||||
|
|
|
@ -343,7 +343,7 @@ void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect boundi
|
|||
.color = color });
|
||||
}
|
||||
|
||||
void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, Gfx::CornerRadius top_left_radius, Gfx::CornerRadius top_right_radius, Gfx::CornerRadius bottom_right_radius, Gfx::CornerRadius bottom_left_radius)
|
||||
void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, CornerRadius top_left_radius, CornerRadius top_right_radius, CornerRadius bottom_right_radius, CornerRadius bottom_left_radius)
|
||||
{
|
||||
if (rect.is_empty())
|
||||
return;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <AK/SegmentedVector.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Gradients.h>
|
||||
|
@ -140,7 +139,7 @@ public:
|
|||
void paint_inner_box_shadow_params(PaintBoxShadowParams params);
|
||||
void paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const&, double glyph_run_scale, Color color, Gfx::IntPoint draw_location);
|
||||
|
||||
void fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, Gfx::CornerRadius top_left_radius, Gfx::CornerRadius top_right_radius, Gfx::CornerRadius bottom_right_radius, Gfx::CornerRadius bottom_left_radius);
|
||||
void fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, CornerRadius top_left_radius, CornerRadius top_right_radius, CornerRadius bottom_right_radius, CornerRadius bottom_left_radius);
|
||||
void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius);
|
||||
void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
||||
#include <LibWeb/Painting/MarkerPaintable.h>
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/HTMLAudioElement.h>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibUnicode/CharacterTypes.h>
|
||||
#include <LibWeb/CSS/SystemColor.h>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Quad.h>
|
||||
#include <LibWeb/Painting/SVGPathPaintable.h>
|
||||
#include <LibWeb/Painting/SVGSVGPaintable.h>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLMediaElement.h>
|
||||
#include <LibWeb/HTML/HTMLVideoElement.h>
|
||||
|
|
|
@ -25,15 +25,12 @@ shared_library("LibGfx") {
|
|||
public_configs = [ ":tiff_headers" ]
|
||||
sources = [
|
||||
"AffineTransform.cpp",
|
||||
"AntiAliasingPainter.cpp",
|
||||
"Bitmap.cpp",
|
||||
"BitmapSequence.cpp",
|
||||
"CMYKBitmap.cpp",
|
||||
"Color.cpp",
|
||||
"DeltaE.cpp",
|
||||
"DeprecatedPainter.cpp",
|
||||
"DeprecatedPath.cpp",
|
||||
"EdgeFlagPathRasterizer.cpp",
|
||||
"Font/Font.cpp",
|
||||
"Font/FontData.cpp",
|
||||
"Font/FontDatabase.cpp",
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/ImageFormats/BMPWriter.h>
|
||||
#include <LibWeb/HTML/SelectedFile.h>
|
||||
#include <LibWebView/SearchEngine.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue