mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
LibGfx: Support scaling in AntiAliasingPainter::draw_circle()
Previously the painter would crash if scaling was enabled.
This commit is contained in:
parent
6edea1d59f
commit
3c0e17f29f
3 changed files with 10 additions and 6 deletions
|
@ -193,6 +193,9 @@ void Gfx::AntiAliasingPainter::draw_circle(IntPoint center, int radius, Color co
|
|||
Inline comments are from the paper.
|
||||
*/
|
||||
|
||||
center *= m_underlying_painter.scale();
|
||||
radius *= m_underlying_painter.scale();
|
||||
|
||||
// TODO: Generalize to ellipses (see paper)
|
||||
|
||||
// These happen to be the same here, but are treated separately in the paper:
|
||||
|
@ -352,11 +355,11 @@ void Gfx::AntiAliasingPainter::fill_rect_with_rounded_corners(IntRect const& a_r
|
|||
a_rect.x() + a_rect.width() - top_right_radius,
|
||||
a_rect.y() + top_right_radius,
|
||||
};
|
||||
IntPoint bottom_right_corner {
|
||||
IntPoint bottom_left_corner {
|
||||
a_rect.x() + bottom_left_radius,
|
||||
a_rect.y() + a_rect.height() - bottom_right_radius
|
||||
};
|
||||
IntPoint bottom_left_corner {
|
||||
IntPoint bottom_right_corner {
|
||||
a_rect.x() + a_rect.width() - bottom_left_radius,
|
||||
a_rect.y() + a_rect.height() - bottom_left_radius
|
||||
};
|
||||
|
|
|
@ -1713,11 +1713,11 @@ void Painter::draw_text(Function<void(IntRect const&, Utf8CodePointIterator&)> d
|
|||
|
||||
void Painter::set_pixel(IntPoint const& p, Color color, bool blend)
|
||||
{
|
||||
VERIFY(scale() == 1); // FIXME: Add scaling support.
|
||||
|
||||
auto point = p;
|
||||
point.translate_by(state().translation);
|
||||
if (!clip_rect().contains(point))
|
||||
// Use the scale only to avoid clipping pixels set in drawing functions that handle
|
||||
// scaling and call set_pixel() -- do not scale the pixel.
|
||||
if (!clip_rect().contains(point / scale()))
|
||||
return;
|
||||
auto& dst = m_target->scanline(point.y())[point.x()];
|
||||
if (!blend) {
|
||||
|
|
|
@ -145,11 +145,12 @@ public:
|
|||
|
||||
IntRect clip_rect() const { return state().clip_rect; }
|
||||
|
||||
int scale() const { return state().scale; }
|
||||
|
||||
protected:
|
||||
IntPoint translation() const { return state().translation; }
|
||||
IntRect to_physical(IntRect const& r) const { return r.translated(translation()) * scale(); }
|
||||
IntPoint to_physical(IntPoint const& p) const { return p.translated(translation()) * scale(); }
|
||||
int scale() const { return state().scale; }
|
||||
void set_physical_pixel_with_draw_op(u32& pixel, Color const&);
|
||||
void fill_physical_scanline_with_draw_op(int y, int x, int width, Color const& color);
|
||||
void fill_rect_with_draw_op(IntRect const&, Color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue