summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibGfx')
-rw-r--r--Libraries/LibGfx/AffineTransform.cpp10
-rw-r--r--Libraries/LibGfx/AffineTransform.h6
-rw-r--r--Libraries/LibGfx/Bitmap.cpp16
-rw-r--r--Libraries/LibGfx/Bitmap.h24
-rw-r--r--Libraries/LibGfx/CharacterBitmap.h4
-rw-r--r--Libraries/LibGfx/DisjointRectSet.cpp4
-rw-r--r--Libraries/LibGfx/DisjointRectSet.h6
-rw-r--r--Libraries/LibGfx/FloatPoint.h4
-rw-r--r--Libraries/LibGfx/FloatRect.h4
-rw-r--r--Libraries/LibGfx/FloatSize.h4
-rw-r--r--Libraries/LibGfx/Font.h6
-rw-r--r--Libraries/LibGfx/Forward.h6
-rw-r--r--Libraries/LibGfx/GIFLoader.cpp2
-rw-r--r--Libraries/LibGfx/GIFLoader.h2
-rw-r--r--Libraries/LibGfx/ImageDecoder.h4
-rw-r--r--Libraries/LibGfx/PNGLoader.cpp2
-rw-r--r--Libraries/LibGfx/PNGLoader.h2
-rw-r--r--Libraries/LibGfx/Painter.cpp144
-rw-r--r--Libraries/LibGfx/Painter.h88
-rw-r--r--Libraries/LibGfx/Point.cpp8
-rw-r--r--Libraries/LibGfx/Point.h54
-rw-r--r--Libraries/LibGfx/Rect.cpp32
-rw-r--r--Libraries/LibGfx/Rect.h92
-rw-r--r--Libraries/LibGfx/ShareableBitmap.cpp2
-rw-r--r--Libraries/LibGfx/ShareableBitmap.h4
-rw-r--r--Libraries/LibGfx/Size.cpp8
-rw-r--r--Libraries/LibGfx/Size.h20
-rw-r--r--Libraries/LibGfx/StylePainter.cpp22
-rw-r--r--Libraries/LibGfx/StylePainter.h14
-rw-r--r--Libraries/LibGfx/Triangle.h16
30 files changed, 305 insertions, 305 deletions
diff --git a/Libraries/LibGfx/AffineTransform.cpp b/Libraries/LibGfx/AffineTransform.cpp
index 976686d03b..02dad6c24e 100644
--- a/Libraries/LibGfx/AffineTransform.cpp
+++ b/Libraries/LibGfx/AffineTransform.cpp
@@ -75,12 +75,12 @@ void AffineTransform::map(float unmapped_x, float unmapped_y, float& mapped_x, f
mapped_y = (m_values[1] * unmapped_x + m_values[3] * unmapped_y + m_values[5]);
}
-Point AffineTransform::map(const Point& point) const
+IntPoint AffineTransform::map(const IntPoint& point) const
{
float mapped_x;
float mapped_y;
map(point.x(), point.y(), mapped_x, mapped_y);
- return Point(roundf(mapped_x), roundf(mapped_y));
+ return IntPoint(roundf(mapped_x), roundf(mapped_y));
}
FloatPoint AffineTransform::map(const FloatPoint& point) const
@@ -91,9 +91,9 @@ FloatPoint AffineTransform::map(const FloatPoint& point) const
return FloatPoint(mapped_x, mapped_y);
}
-Size AffineTransform::map(const Size& size) const
+IntSize AffineTransform::map(const IntSize& size) const
{
- return Size(roundf(size.width() * x_scale()), roundf(y_scale()));
+ return IntSize(roundf(size.width() * x_scale()), roundf(y_scale()));
}
FloatSize AffineTransform::map(const FloatSize& size) const
@@ -101,7 +101,7 @@ FloatSize AffineTransform::map(const FloatSize& size) const
return { size.width() * x_scale(), size.height() * y_scale() };
}
-Rect AffineTransform::map(const Rect& rect) const
+IntRect AffineTransform::map(const IntRect& rect) const
{
return enclosing_int_rect(map(FloatRect(rect)));
}
diff --git a/Libraries/LibGfx/AffineTransform.h b/Libraries/LibGfx/AffineTransform.h
index 9cc2b080d7..9e6aa35113 100644
--- a/Libraries/LibGfx/AffineTransform.h
+++ b/Libraries/LibGfx/AffineTransform.h
@@ -43,13 +43,13 @@ public:
void map(float unmapped_x, float unmapped_y, float& mapped_x, float& mapped_y) const;
- Point map(const Point&) const;
+ IntPoint map(const IntPoint&) const;
FloatPoint map(const FloatPoint&) const;
- Size map(const Size&) const;
+ IntSize map(const IntSize&) const;
FloatSize map(const FloatSize&) const;
- Rect map(const Rect&) const;
+ IntRect map(const IntRect&) const;
FloatRect map(const FloatRect&) const;
float a() const { return m_values[0]; }
diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp
index e885833110..0391b9b201 100644
--- a/Libraries/LibGfx/Bitmap.cpp
+++ b/Libraries/LibGfx/Bitmap.cpp
@@ -40,28 +40,28 @@
namespace Gfx {
-static bool size_would_overflow(BitmapFormat format, const Size& size)
+static bool size_would_overflow(BitmapFormat format, const IntSize& size)
{
if (size.width() < 0 || size.height() < 0)
return true;
return Checked<size_t>::multiplication_would_overflow(size.width(), size.height(), Bitmap::bpp_for_format(format));
}
-RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const Size& size)
+RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const IntSize& size)
{
if (size_would_overflow(format, size))
return nullptr;
return adopt(*new Bitmap(format, size, Purgeable::No));
}
-RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const Size& size)
+RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size)
{
if (size_would_overflow(format, size))
return nullptr;
return adopt(*new Bitmap(format, size, Purgeable::Yes));
}
-Bitmap::Bitmap(BitmapFormat format, const Size& size, Purgeable purgeable)
+Bitmap::Bitmap(BitmapFormat format, const IntSize& size, Purgeable purgeable)
: m_size(size)
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
, m_format(format)
@@ -77,7 +77,7 @@ Bitmap::Bitmap(BitmapFormat format, const Size& size, Purgeable purgeable)
m_needs_munmap = true;
}
-RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data)
+RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size, size_t pitch, RGBA32* data)
{
if (size_would_overflow(format, size))
return nullptr;
@@ -94,7 +94,7 @@ RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path)
return nullptr;
}
-Bitmap::Bitmap(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data)
+Bitmap::Bitmap(BitmapFormat format, const IntSize& size, size_t pitch, RGBA32* data)
: m_size(size)
, m_data(data)
, m_pitch(pitch)
@@ -105,14 +105,14 @@ Bitmap::Bitmap(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data
m_palette = new RGBA32[256];
}
-RefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
+RefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const IntSize& size)
{
if (size_would_overflow(format, size))
return nullptr;
return adopt(*new Bitmap(format, move(shared_buffer), size));
}
-Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
+Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const IntSize& size)
: m_size(size)
, m_data((RGBA32*)shared_buffer->data())
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
diff --git a/Libraries/LibGfx/Bitmap.h b/Libraries/LibGfx/Bitmap.h
index 75be882187..4d1a0ef90b 100644
--- a/Libraries/LibGfx/Bitmap.h
+++ b/Libraries/LibGfx/Bitmap.h
@@ -49,11 +49,11 @@ enum RotationDirection {
class Bitmap : public RefCounted<Bitmap> {
public:
- static RefPtr<Bitmap> create(BitmapFormat, const Size&);
- static RefPtr<Bitmap> create_purgeable(BitmapFormat, const Size&);
- static RefPtr<Bitmap> create_wrapper(BitmapFormat, const Size&, size_t pitch, RGBA32*);
+ static RefPtr<Bitmap> create(BitmapFormat, const IntSize&);
+ static RefPtr<Bitmap> create_purgeable(BitmapFormat, const IntSize&);
+ static RefPtr<Bitmap> create_wrapper(BitmapFormat, const IntSize&, size_t pitch, RGBA32*);
static RefPtr<Bitmap> load_from_file(const StringView& path);
- static RefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&);
+ static RefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const IntSize&);
RefPtr<Gfx::Bitmap> rotated(Gfx::RotationDirection) const;
RefPtr<Gfx::Bitmap> flipped(Gfx::Orientation) const;
@@ -69,8 +69,8 @@ public:
u8* bits(int y);
const u8* bits(int y) const;
- Rect rect() const { return { {}, m_size }; }
- Size size() const { return m_size; }
+ IntRect rect() const { return { {}, m_size }; }
+ IntSize size() const { return m_size; }
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
size_t pitch() const { return m_pitch; }
@@ -121,7 +121,7 @@ public:
Color get_pixel(int x, int y) const;
- Color get_pixel(const Point& position) const
+ Color get_pixel(const IntPoint& position) const
{
return get_pixel(position.x(), position.y());
}
@@ -136,7 +136,7 @@ public:
void set_pixel(int x, int y, Color);
- void set_pixel(const Point& position, Color color)
+ void set_pixel(const IntPoint& position, Color color)
{
set_pixel(position.x(), position.y(), color);
}
@@ -149,11 +149,11 @@ public:
private:
enum class Purgeable { No,
Yes };
- Bitmap(BitmapFormat, const Size&, Purgeable);
- Bitmap(BitmapFormat, const Size&, size_t pitch, RGBA32*);
- Bitmap(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&);
+ Bitmap(BitmapFormat, const IntSize&, Purgeable);
+ Bitmap(BitmapFormat, const IntSize&, size_t pitch, RGBA32*);
+ Bitmap(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const IntSize&);
- Size m_size;
+ IntSize m_size;
RGBA32* m_data { nullptr };
RGBA32* m_palette { nullptr };
size_t m_pitch { 0 };
diff --git a/Libraries/LibGfx/CharacterBitmap.h b/Libraries/LibGfx/CharacterBitmap.h
index 0a77d123af..9780383570 100644
--- a/Libraries/LibGfx/CharacterBitmap.h
+++ b/Libraries/LibGfx/CharacterBitmap.h
@@ -40,7 +40,7 @@ public:
bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; }
const char* bits() const { return m_bits; }
- Size size() const { return m_size; }
+ IntSize size() const { return m_size; }
unsigned width() const { return m_size.width(); }
unsigned height() const { return m_size.height(); }
@@ -48,7 +48,7 @@ private:
CharacterBitmap(const char* b, unsigned w, unsigned h);
const char* m_bits { nullptr };
- Size m_size;
+ IntSize m_size;
};
}
diff --git a/Libraries/LibGfx/DisjointRectSet.cpp b/Libraries/LibGfx/DisjointRectSet.cpp
index 9600f65f65..2ca643b85b 100644
--- a/Libraries/LibGfx/DisjointRectSet.cpp
+++ b/Libraries/LibGfx/DisjointRectSet.cpp
@@ -28,7 +28,7 @@
namespace Gfx {
-void DisjointRectSet::add(const Rect& new_rect)
+void DisjointRectSet::add(const IntRect& new_rect)
{
for (auto& rect : m_rects) {
if (rect.contains(new_rect))
@@ -42,7 +42,7 @@ void DisjointRectSet::add(const Rect& new_rect)
void DisjointRectSet::shatter()
{
- Vector<Rect, 32> output;
+ Vector<IntRect, 32> output;
output.ensure_capacity(m_rects.size());
bool pass_had_intersections = false;
do {
diff --git a/Libraries/LibGfx/DisjointRectSet.h b/Libraries/LibGfx/DisjointRectSet.h
index 7b1c319141..5844d7bf75 100644
--- a/Libraries/LibGfx/DisjointRectSet.h
+++ b/Libraries/LibGfx/DisjointRectSet.h
@@ -40,19 +40,19 @@ public:
{
}
- void add(const Rect&);
+ void add(const IntRect&);
bool is_empty() const { return m_rects.is_empty(); }
size_t size() const { return m_rects.size(); }
void clear() { m_rects.clear(); }
void clear_with_capacity() { m_rects.clear_with_capacity(); }
- const Vector<Rect, 32>& rects() const { return m_rects; }
+ const Vector<IntRect, 32>& rects() const { return m_rects; }
private:
void shatter();
- Vector<Rect, 32> m_rects;
+ Vector<IntRect, 32> m_rects;
};
}
diff --git a/Libraries/LibGfx/FloatPoint.h b/Libraries/LibGfx/FloatPoint.h
index 9867d8327d..ef50987e0b 100644
--- a/Libraries/LibGfx/FloatPoint.h
+++ b/Libraries/LibGfx/FloatPoint.h
@@ -44,7 +44,7 @@ public:
{
}
- explicit FloatPoint(const Point& other)
+ explicit FloatPoint(const IntPoint& other)
: m_x(other.x())
, m_y(other.y())
{
@@ -149,7 +149,7 @@ public:
set_y(value);
}
- Point to_int_point() const { return Point(x(), y()); }
+ IntPoint to_int_point() const { return IntPoint(x(), y()); }
private:
float m_x { 0 };
diff --git a/Libraries/LibGfx/FloatRect.h b/Libraries/LibGfx/FloatRect.h
index 39caf90e03..3908dd8318 100644
--- a/Libraries/LibGfx/FloatRect.h
+++ b/Libraries/LibGfx/FloatRect.h
@@ -56,7 +56,7 @@ public:
{
}
- explicit FloatRect(const Rect& other)
+ explicit FloatRect(const IntRect& other)
: FloatRect((FloatPoint)other.location(), (FloatSize)other.size())
{
}
@@ -327,7 +327,7 @@ inline const LogStream& operator<<(const LogStream& stream, const FloatRect& val
return stream << value.to_string();
}
-inline Rect enclosing_int_rect(const FloatRect& float_rect)
+inline IntRect enclosing_int_rect(const FloatRect& float_rect)
{
return { (int)float_rect.x(), (int)float_rect.y(), (int)ceilf(float_rect.width()), (int)ceilf(float_rect.height()) };
}
diff --git a/Libraries/LibGfx/FloatSize.h b/Libraries/LibGfx/FloatSize.h
index c513b921ce..1bbe2453a3 100644
--- a/Libraries/LibGfx/FloatSize.h
+++ b/Libraries/LibGfx/FloatSize.h
@@ -41,7 +41,7 @@ public:
, m_height(h)
{
}
- explicit FloatSize(const Size& other)
+ explicit FloatSize(const IntSize& other)
: m_width(other.width())
, m_height(other.height())
{
@@ -110,7 +110,7 @@ public:
String to_string() const { return String::format("[%gx%g]", m_width, m_height); }
- Size to_int_size() const { return Size(width(), height()); }
+ IntSize to_int_size() const { return IntSize(width(), height()); }
private:
float m_width { 0 };
diff --git a/Libraries/LibGfx/Font.h b/Libraries/LibGfx/Font.h
index 2dae06f4b8..a28fde8a78 100644
--- a/Libraries/LibGfx/Font.h
+++ b/Libraries/LibGfx/Font.h
@@ -58,19 +58,19 @@ public:
mutable_row &= ~(1 << x);
}
- Size size() const { return m_size; }
+ IntSize size() const { return m_size; }
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
private:
- GlyphBitmap(const unsigned* rows, Size size)
+ GlyphBitmap(const unsigned* rows, IntSize size)
: m_rows(rows)
, m_size(size)
{
}
const unsigned* m_rows { nullptr };
- Size m_size;
+ IntSize m_size;
};
class Font : public RefCounted<Font> {
diff --git a/Libraries/LibGfx/Forward.h b/Libraries/LibGfx/Forward.h
index 6a6378c9b2..befacc8171 100644
--- a/Libraries/LibGfx/Forward.h
+++ b/Libraries/LibGfx/Forward.h
@@ -43,10 +43,10 @@ class Painter;
class Palette;
class PaletteImpl;
class Path;
-class Point;
-class Rect;
+class IntPoint;
+class IntRect;
class ShareableBitmap;
-class Size;
+class IntSize;
class StylePainter;
struct SystemTheme;
class Triangle;
diff --git a/Libraries/LibGfx/GIFLoader.cpp b/Libraries/LibGfx/GIFLoader.cpp
index 70d2354f14..0856e94324 100644
--- a/Libraries/LibGfx/GIFLoader.cpp
+++ b/Libraries/LibGfx/GIFLoader.cpp
@@ -538,7 +538,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size)
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { }
-Size GIFImageDecoderPlugin::size()
+IntSize GIFImageDecoderPlugin::size()
{
if (m_context->state == GIFLoadingContext::State::Error) {
return {};
diff --git a/Libraries/LibGfx/GIFLoader.h b/Libraries/LibGfx/GIFLoader.h
index b76b131d19..24be735381 100644
--- a/Libraries/LibGfx/GIFLoader.h
+++ b/Libraries/LibGfx/GIFLoader.h
@@ -41,7 +41,7 @@ public:
virtual ~GIFImageDecoderPlugin() override;
GIFImageDecoderPlugin(const u8*, size_t);
- virtual Size size() override;
+ virtual IntSize size() override;
virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile() override;
diff --git a/Libraries/LibGfx/ImageDecoder.h b/Libraries/LibGfx/ImageDecoder.h
index 7b8b5edf9d..a081348cbd 100644
--- a/Libraries/LibGfx/ImageDecoder.h
+++ b/Libraries/LibGfx/ImageDecoder.h
@@ -45,7 +45,7 @@ class ImageDecoderPlugin {
public:
virtual ~ImageDecoderPlugin() { }
- virtual Size size() = 0;
+ virtual IntSize size() = 0;
virtual RefPtr<Gfx::Bitmap> bitmap() = 0;
virtual void set_volatile() = 0;
@@ -68,7 +68,7 @@ public:
static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt(*new ImageDecoder(data.data(), data.size())); }
~ImageDecoder();
- Size size() const { return m_plugin->size(); }
+ IntSize size() const { return m_plugin->size(); }
int width() const { return size().width(); }
int height() const { return size().height(); }
RefPtr<Gfx::Bitmap> bitmap() const;
diff --git a/Libraries/LibGfx/PNGLoader.cpp b/Libraries/LibGfx/PNGLoader.cpp
index 584b77bc6c..eeb56d5771 100644
--- a/Libraries/LibGfx/PNGLoader.cpp
+++ b/Libraries/LibGfx/PNGLoader.cpp
@@ -763,7 +763,7 @@ PNGImageDecoderPlugin::~PNGImageDecoderPlugin()
{
}
-Size PNGImageDecoderPlugin::size()
+IntSize PNGImageDecoderPlugin::size()
{
if (m_context->state == PNGLoadingContext::State::Error)
return {};
diff --git a/Libraries/LibGfx/PNGLoader.h b/Libraries/LibGfx/PNGLoader.h
index d6820b931d..2432f231e0 100644
--- a/Libraries/LibGfx/PNGLoader.h
+++ b/Libraries/LibGfx/PNGLoader.h
@@ -41,7 +41,7 @@ public:
virtual ~PNGImageDecoderPlugin() override;
PNGImageDecoderPlugin(const u8*, size_t);
- virtual Size size() override;
+ virtual IntSize size() override;
virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile() override;
diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp
index 5c2a67a79c..a7ecb7a763 100644
--- a/Libraries/LibGfx/Painter.cpp
+++ b/Libraries/LibGfx/Painter.cpp
@@ -73,7 +73,7 @@ Painter::~Painter()
{
}
-void Painter::fill_rect_with_draw_op(const Rect& a_rect, Color color)
+void Painter::fill_rect_with_draw_op(const IntRect& a_rect, Color color)
{
auto rect = a_rect.translated(translation()).intersected(clip_rect());
if (rect.is_empty())
@@ -89,7 +89,7 @@ void Painter::fill_rect_with_draw_op(const Rect& a_rect, Color color)
}
}
-void Painter::clear_rect(const Rect& a_rect, Color color)
+void Painter::clear_rect(const IntRect& a_rect, Color color)
{
auto rect = a_rect.translated(translation()).intersected(clip_rect());
if (rect.is_empty())
@@ -106,7 +106,7 @@ void Painter::clear_rect(const Rect& a_rect, Color color)
}
}
-void Painter::fill_rect(const Rect& a_rect, Color color)
+void Painter::fill_rect(const IntRect& a_rect, Color color)
{
if (color.alpha() == 0)
return;
@@ -137,7 +137,7 @@ void Painter::fill_rect(const Rect& a_rect, Color color)
}
}
-void Painter::fill_rect_with_dither_pattern(const Rect& a_rect, Color color_a, Color color_b)
+void Painter::fill_rect_with_dither_pattern(const IntRect& a_rect, Color color_a, Color color_b)
{
auto rect = a_rect.translated(translation()).intersected(clip_rect());
if (rect.is_empty())
@@ -155,7 +155,7 @@ void Painter::fill_rect_with_dither_pattern(const Rect& a_rect, Color color_a, C
}
}
-void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_size, Color color_dark, Color color_light)
+void Painter::fill_rect_with_checkerboard(const IntRect& a_rect, const IntSize& cell_size, Color color_dark, Color color_light)
{
auto rect = a_rect.translated(translation()).intersected(clip_rect());
if (rect.is_empty())
@@ -174,13 +174,13 @@ void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_s
}
}
-void Painter::fill_rect_with_gradient(Orientation orientation, const Rect& a_rect, Color gradient_start, Color gradient_end)
+void Painter::fill_rect_with_gradient(Orientation orientation, const IntRect& a_rect, Color gradient_start, Color gradient_end)
{
#ifdef NO_FPU
return fill_rect(a_rect, gradient_start);
#endif
auto rect = a_rect.translated(translation());
- auto clipped_rect = Rect::intersection(rect, clip_rect());
+ auto clipped_rect = IntRect::intersection(rect, clip_rect());
if (clipped_rect.is_empty())
return;
@@ -227,12 +227,12 @@ void Painter::fill_rect_with_gradient(Orientation orientation, const Rect& a_rec
}
}
-void Painter::fill_rect_with_gradient(const Rect& a_rect, Color gradient_start, Color gradient_end)
+void Painter::fill_rect_with_gradient(const IntRect& a_rect, Color gradient_start, Color gradient_end)
{
return fill_rect_with_gradient(Orientation::Horizontal, a_rect, gradient_start, gradient_end);
}
-void Painter::fill_ellipse(const Rect& a_rect, Color color)
+void Painter::fill_ellipse(const IntRect& a_rect, Color color)
{
auto rect = a_rect.translated(translation()).intersected(clip_rect());
if (rect.is_empty())
@@ -251,7 +251,7 @@ void Painter::fill_ellipse(const Rect& a_rect, Color color)
}
}
-void Painter::draw_ellipse_intersecting(const Rect& rect, Color color, int thickness)
+void Painter::draw_ellipse_intersecting(const IntRect& rect, Color color, int thickness)
{
constexpr int number_samples = 100; // FIXME: dynamically work out the number of samples based upon the rect size
double increment = M_PI / number_samples;
@@ -269,9 +269,9 @@ void Painter::draw_ellipse_intersecting(const Rect& rect, Color color, int thick
}
}
-void Painter::draw_rect(const Rect& a_rect, Color color, bool rough)
+void Painter::draw_rect(const IntRect& a_rect, Color color, bool rough)
{
- Rect rect = a_rect.translated(translation());
+ IntRect rect = a_rect.translated(translation());
auto clipped_rect = rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -313,9 +313,9 @@ void Painter::draw_rect(const Rect& a_rect, Color color, bool rough)
}
}
-void Painter::draw_bitmap(const Point& p, const CharacterBitmap& bitmap, Color color)
+void Painter::draw_bitmap(const IntPoint& p, const CharacterBitmap& bitmap, Color color)
{
- auto rect = Rect(p, bitmap.size()).translated(translation());
+ auto rect = IntRect(p, bitmap.size()).translated(translation());
auto clipped_rect = rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -339,9 +339,9 @@ void Painter::draw_bitmap(const Point& p, const CharacterBitmap& bitmap, Color c
}
}
-void Painter::draw_bitmap(const Point& p, const GlyphBitmap& bitmap, Color color)
+void Painter::draw_bitmap(const IntPoint& p, const GlyphBitmap& bitmap, Color color)
{
- auto dst_rect = Rect(p, bitmap.size()).translated(translation());
+ auto dst_rect = IntRect(p, bitmap.size()).translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -361,13 +361,13 @@ void Painter::draw_bitmap(const Point& p, const GlyphBitmap& bitmap, Color color
}
}
-void Painter::draw_triangle(const Point& a, const Point& b, const Point& c, Color color)
+void Painter::draw_triangle(const IntPoint& a, const IntPoint& b, const IntPoint& c, Color color)
{
RGBA32 rgba = color.value();
- Point p0(a);
- Point p1(b);
- Point p2(c);
+ IntPoint p0(a);
+ IntPoint p1(b);
+ IntPoint p2(c);
if (p0.y() > p1.y())
swap(p0, p1);
@@ -429,9 +429,9 @@ void Painter::draw_triangle(const Point& a, const Point& b, const Point& c, Colo
}
}
-void Painter::blit_scaled(const Rect& dst_rect_raw, const Gfx::Bitmap& source, const Rect& src_rect, float hscale, float vscale)
+void Painter::blit_scaled(const IntRect& dst_rect_raw, const Gfx::Bitmap& source, const IntRect& src_rect, float hscale, float vscale)
{
- auto dst_rect = Rect(dst_rect_raw.location(), dst_rect_raw.size()).translated(translation());
+ auto dst_rect = IntRect(dst_rect_raw.location(), dst_rect_raw.size()).translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -459,7 +459,7 @@ void Painter::blit_scaled(const Rect& dst_rect_raw, const Gfx::Bitmap& source, c
return;
}
-void Painter::blit_with_opacity(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect, float opacity)
+void Painter::blit_with_opacity(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, float opacity)
{
ASSERT(!m_target->has_alpha_channel());
@@ -470,10 +470,10 @@ void Painter::blit_with_opacity(const Point& position, const Gfx::Bitmap& source
u8 alpha = 255 * opacity;
- Rect safe_src_rect = Rect::intersection(src_rect, source.rect());
- Rect dst_rect(position, safe_src_rect.size());
+ IntRect safe_src_rect = IntRect::intersection(src_rect, source.rect());
+ IntRect dst_rect(position, safe_src_rect.size());
dst_rect.move_by(state().translation);
- auto clipped_rect = Rect::intersection(dst_rect, clip_rect());
+ auto clipped_rect = IntRect::intersection(dst_rect, clip_rect());
if (clipped_rect.is_empty())
return;
const int first_row = clipped_rect.top() - dst_rect.top();
@@ -497,10 +497,10 @@ void Painter::blit_with_opacity(const Point& position, const Gfx::Bitmap& source
}
}
-void Painter::blit_filtered(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect, Function<Color(Color)> filter)
+void Painter::blit_filtered(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, Function<Color(Color)> filter)
{
- Rect safe_src_rect = src_rect.intersected(source.rect());
- auto dst_rect = Rect(position, safe_src_rect.size()).translated(translation());
+ IntRect safe_src_rect = src_rect.intersected(source.rect());
+ auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -528,21 +528,21 @@ void Painter::blit_filtered(const Point& position, const Gfx::Bitmap& source, co
}
}
-void Painter::blit_brightened(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect)
+void Painter::blit_brightened(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect)
{
return blit_filtered(position, source, src_rect, [](Color src) {
return src.lightened();
});
}
-void Painter::blit_dimmed(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect)
+void Painter::blit_dimmed(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect)
{
return blit_filtered(position, source, src_rect, [](Color src) {
return src.to_grayscale().lightened();
});
}
-void Painter::draw_tiled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& source)
+void Painter::draw_tiled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& source)
{
auto dst_rect = a_dst_rect.translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
@@ -570,12 +570,12 @@ void Painter::draw_tiled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sourc
ASSERT_NOT_REACHED();
}
-void Painter::blit_offset(const Point& position,
+void Painter::blit_offset(const IntPoint& position,
const Gfx::Bitmap& source,
- const Rect& src_rect,
- const Point& offset)
+ const IntRect& src_rect,
+ const IntPoint& offset)
{
- auto dst_rect = Rect(position, src_rect.size()).translated(translation());
+ auto dst_rect = IntRect(position, src_rect.size()).translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -607,11 +607,11 @@ void Painter::blit_offset(const Point& position,
ASSERT_NOT_REACHED();
}
-void Painter::blit_with_alpha(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect)
+void Painter::blit_with_alpha(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect)
{
ASSERT(source.has_alpha_channel());
- Rect safe_src_rect = src_rect.intersected(source.rect());
- auto dst_rect = Rect(position, safe_src_rect.size()).translated(translation());
+ IntRect safe_src_rect = src_rect.intersected(source.rect());
+ auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -639,7 +639,7 @@ void Painter::blit_with_alpha(const Point& position, const Gfx::Bitmap& source,
}
}
-void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect, float opacity)
+void Painter::blit(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, float opacity)
{
if (opacity < 1.0f)
return blit_with_opacity(position, source, src_rect, opacity);
@@ -647,7 +647,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect&
return blit_with_alpha(position, source, src_rect);
auto safe_src_rect = src_rect.intersected(source.rect());
ASSERT(source.rect().contains(safe_src_rect));
- auto dst_rect = Rect(position, safe_src_rect.size()).translated(translation());
+ auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation());
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
@@ -684,7 +684,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect&
}
template<bool has_alpha_channel, typename GetPixel>
-ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, const Rect& dst_rect, const Gfx::Bitmap& source, int hfactor, int vfactor, GetPixel get_pixel)
+ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, const IntRect& dst_rect, const Gfx::Bitmap& source, int hfactor, int vfactor, GetPixel get_pixel)
{
for (int y = source.rect().top(); y <= source.rect().bottom(); ++y) {
int dst_y = dst_rect.y() + y * vfactor;
@@ -705,7 +705,7 @@ ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, con
}
template<bool has_alpha_channel, typename GetPixel>
-ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, const Rect& dst_rect, const Rect& clipped_rect, const Gfx::Bitmap& source, const Rect& src_rect, int hscale, int vscale, GetPixel get_pixel)
+ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, const IntRect& dst_rect, const IntRect& clipped_rect, const Gfx::Bitmap& source, const IntRect& src_rect, int hscale, int vscale, GetPixel get_pixel)
{
if (dst_rect == clipped_rect && !(dst_rect.width() % src_rect.width()) && !(dst_rect.height() % src_rect.height())) {
int hfactor = dst_rect.width() / src_rect.width();
@@ -734,7 +734,7 @@ ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, const Rect&
}
}
-void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& source, const Rect& src_rect)
+void Painter::draw_scaled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& source, const IntRect& src_rect)
{
auto dst_rect = a_dst_rect;
if (dst_rect.size() == src_rect.size())
@@ -783,22 +783,22 @@ void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sour
}
}
-FLATTEN void Painter::draw_glyph(const Point& point, u32 codepoint, Color color)
+FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, Color color)
{
draw_glyph(point, codepoint, font(), color);
}
-FLATTEN void Painter::draw_glyph(const Point& point, u32 codepoint, const Font& font, Color color)
+FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, const Font& font, Color color)
{
draw_bitmap(point, font.glyph_bitmap(codepoint), color);
}
-void Painter::draw_emoji(const Point& point, const Gfx::Bitmap& emoji, const Font& font)
+void Painter::draw_emoji(const IntPoint& point, const Gfx::Bitmap& emoji, const Font& font)
{
if (!font.is_fixed_width())
blit(point, emoji, emoji.rect());
else {
- Rect dst_rect {
+ IntRect dst_rect {
point.x(),
point.y(),
font.glyph_width('x'),
@@ -808,7 +808,7 @@ void Painter::draw_emoji(const Point& point, const Gfx::Bitmap& emoji, const Fon
}
}
-void Painter::draw_glyph_or_emoji(const Point& point, u32 codepoint, const Font& font, Color color)
+void Painter::draw_glyph_or_emoji(const IntPoint& point, u32 codepoint, const Font& font, Color color)
{
if (codepoint < (u32)font.glyph_count()) {
// This looks like a regular character.
@@ -829,7 +829,7 @@ void Painter::draw_glyph_or_emoji(const Point& point, u32 codepoint, const Font&
draw_emoji(point, *emoji, font);
}
-void Painter::draw_text_line(const Rect& a_rect, const Utf8View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
+void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
{
auto rect = a_rect;
Utf8View final_text(text);
@@ -894,7 +894,7 @@ void Painter::draw_text_line(const Rect& a_rect, const Utf8View& text, const Fon
}
}
-void Painter::draw_text_line(const Rect& a_rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
+void Painter::draw_text_line(const IntRect& a_rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
{
auto rect = a_rect;
Utf32View final_text(text);
@@ -960,17 +960,17 @@ void Painter::draw_text_line(const Rect& a_rect, const Utf32View& text, const Fo
}
}
-void Painter::draw_text(const Rect& rect, const StringView& text, TextAlignment alignment, Color color, TextElision elision)
+void Painter::draw_text(const IntRect& rect, const StringView& text, TextAlignment alignment, Color color, TextElision elision)
{
draw_text(rect, text, font(), alignment, color, elision);
}
-void Painter::draw_text(const Rect& rect, const Utf32View& text, TextAlignment alignment, Color color, TextElision elision)
+void Painter::draw_text(const IntRect& rect, const Utf32View& text, TextAlignment alignment, Color color, TextElision elision)
{
draw_text(rect, text, font(), alignment, color, elision);
}
-void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
+void Painter::draw_text(const IntRect& rect, const StringView& raw_text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
{
Utf8View text { raw_text };
Vector<Utf8View, 32> lines;
@@ -993,7 +993,7 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font
static const int line_spacing = 4;
int line_height = font.glyph_height() + line_spacing;
- Rect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
+ IntRect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
for (auto& line : lines) {
auto line_width = font.width(line);
@@ -1023,13 +1023,13 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font
for (size_t i = 0; i < lines.size(); ++i) {
auto& line = lines[i];
- Rect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
+ IntRect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
line_rect.intersect(rect);
draw_text_line(line_rect, line, font, alignment, color, elision);
}
}
-void Painter::draw_text(const Rect& rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
+void Painter::draw_text(const IntRect& rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision)
{
Vector<Utf32View, 32> lines;
@@ -1050,7 +1050,7 @@ void Painter::draw_text(const Rect& rect, const Utf32View& text, const Font& fon
static const int line_spacing = 4;
int line_height = font.glyph_height() + line_spacing;
- Rect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
+ IntRect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
for (auto& line : lines) {
auto line_width = font.width(line);
@@ -1080,13 +1080,13 @@ void Painter::draw_text(const Rect& rect, const Utf32View& text, const Font& fon
for (size_t i = 0; i < lines.size(); ++i) {
auto& line = lines[i];
- Rect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
+ IntRect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
line_rect.intersect(rect);
draw_text_line(line_rect, line, font, alignment, color, elision);
}
}
-void Painter::set_pixel(const Point& p, Color color)
+void Painter::set_pixel(const IntPoint& p, Color color)
{
auto point = p;
point.move_by(state().translation);
@@ -1103,16 +1103,16 @@ ALWAYS_INLINE void Painter::set_pixel_with_draw_op(u32& pixel, const Color& colo
pixel ^= color.value();
}
-void Painter::draw_pixel(const Point& position, Color color, int thickness)
+void Painter::draw_pixel(const IntPoint& position, Color color, int thickness)
{
ASSERT(draw_op() == DrawOp::Copy);
if (thickness == 1)
return set_pixel_with_draw_op(m_target->scanline(position.y())[position.x()], color);
- Rect rect { position.translated(-(thickness / 2), -(thickness / 2)), { thickness, thickness } };
+ IntRect rect { position.translated(-(thickness / 2), -(thickness / 2)), { thickness, thickness } };
fill_rect(rect.translated(-state().translation), color);
}
-void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thickness, LineStyle style)
+void Painter::draw_line(const IntPoint& p1, const IntPoint& p2, Color color, int thickness, LineStyle style)
{
auto clip_rect = this->clip_rect();
@@ -1274,14 +1274,14 @@ void Painter::for_each_line_segment_on_bezier_curve(const FloatPoint& control_po
for_each_line_segment_on_bezier_curve(control_point, p1, p2, callback);
}
-void Painter::draw_quadratic_bezier_curve(const Point& control_point, const Point& p1, const Point& p2, Color color, int thickness, LineStyle style)
+void Painter::draw_quadratic_bezier_curve(const IntPoint& control_point, const IntPoint& p1, const IntPoint& p2, Color color, int thickness, LineStyle style)
{
for_each_line_segment_on_bezier_curve(FloatPoint(control_point.x(), control_point.y()), FloatPoint(p1.x(), p1.y()), FloatPoint(p2.x(), p2.y()), [&](const FloatPoint& p1, const FloatPoint& p2) {
- draw_line(Point(p1.x(), p1.y()), Point(p2.x(), p2.y()), color, thickness, style);
+ draw_line(IntPoint(p1.x(), p1.y()), IntPoint(p2.x(), p2.y()), color, thickness, style);
});
}
-void Painter::add_clip_rect(const Rect& rect)
+void Painter::add_clip_rect(const IntRect& rect)
{
state().clip_rect.intersect(rect.translated(translation()));
state().clip_rect.intersect(m_target->rect());
@@ -1316,12 +1316,12 @@ void Painter::stroke_path(const Path& path, Color color, int thickness)
cursor = segment.point;
break;
case Path::Segment::Type::LineTo:
- draw_line(Point(cursor.x(), cursor.y()), Point(segment.point.x(), segment.point.y()), color, thickness);
+ draw_line(IntPoint(cursor.x(), cursor.y()), IntPoint(segment.point.x(), segment.point.y()), color, thickness);
cursor = segment.point;
break;
case Path::Segment::Type::QuadraticBezierCurveTo:
ASSERT(segment.through.has_value());
- draw_quadratic_bezier_curve(Point(segment.through.value().x(), segment.through.value().y()), Point(cursor.x(), cursor.y()), Point(segment.point.x(), segment.point.y()), color, thickness);
+ draw_quadratic_bezier_curve(IntPoint(segment.through.value().x(), segment.through.value().y()), IntPoint(cursor.x(), cursor.y()), IntPoint(segment.point.x(), segment.point.y()), color, thickness);
cursor = segment.point;
break;
}
@@ -1364,7 +1364,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
ASSERT_NOT_REACHED();
};
- auto increment_winding = [winding_rule](int& winding_number, const Point& from, const Point& to) {
+ auto increment_winding = [winding_rule](int& winding_number, const IntPoint& from, const IntPoint& to) {
if (winding_rule == WindingRule::EvenOdd) {
++winding_number;
return;
@@ -1400,8 +1400,8 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
auto& current = active_list[i];
int int_distance = fabs(current.x - previous.x);
- Point from(previous.x, scanline);
- Point to(current.x, scanline);
+ IntPoint from(previous.x, scanline);
+ IntPoint to(current.x, scanline);
if (int_distance < 1) {
// the two lines intersect on an int grid
@@ -1445,7 +1445,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
}
active_list.last().x -= active_list.last().inverse_slope;
} else {
- auto point = Point(active_list[0].x, scanline);
+ auto point = IntPoint(active_list[0].x, scanline);
draw_line(point, point, color);
// update the x coord
diff --git a/Libraries/LibGfx/Painter.h b/Libraries/LibGfx/Painter.h
index 4b06c78a90..89172c1716 100644
--- a/Libraries/LibGfx/Painter.h
+++ b/Libraries/LibGfx/Painter.h
@@ -50,37 +50,37 @@ public:
Dashed,
};
- void clear_rect(const Rect&, Color);
- void fill_rect(const Rect&, Color);
- void fill_rect_with_dither_pattern(const Rect&, Color, Color);
- void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light);
- void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end);
- void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end);
- void fill_ellipse(const Rect&, Color);
- void draw_rect(const Rect&, Color, bool rough = false);
- void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color());
- void draw_bitmap(const Point&, const GlyphBitmap&, Color = Color());
- void draw_triangle(const Point&, const Point&, const Point&, Color);
- void draw_ellipse_intersecting(const Rect&, Color, int thickness = 1);
- void set_pixel(const Point&, Color);
- void draw_line(const Point&, const Point&, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
- void draw_quadratic_bezier_curve(const Point& control_point, const Point&, const Point&, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
- void draw_scaled_bitmap(const Rect& dst_rect, const Gfx::Bitmap&, const Rect& src_rect);
- void blit(const Point&, const Gfx::Bitmap&, const Rect& src_rect, float opacity = 1.0f);
- void blit_dimmed(const Point&, const Gfx::Bitmap&, const Rect& src_rect);
- void blit_brightened(const Point&, const Gfx::Bitmap&, const Rect& src_rect);
- void blit_filtered(const Point&, const Gfx::Bitmap&, const Rect& src_rect, Function<Color(Color)>);
- void draw_tiled_bitmap(const Rect& dst_rect, const Gfx::Bitmap&);
- void blit_offset(const Point&, const Gfx::Bitmap&, const Rect& src_rect, const Point&);
- void blit_scaled(const Rect&, const Gfx::Bitmap&, const Rect&, float, float);
- void draw_text(const Rect&, const StringView&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
- void draw_text(const Rect&, const StringView&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
- void draw_text(const Rect&, const Utf32View&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
- void draw_text(const Rect&, const Utf32View&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
- void draw_glyph(const Point&, u32, Color);
- void draw_glyph(const Point&, u32, const Font&, Color);
- void draw_emoji(const Point&, const Gfx::Bitmap&, const Font&);
- void draw_glyph_or_emoji(const Point&, u32 codepoint, const Font&, Color);
+ void clear_rect(const IntRect&, Color);
+ void fill_rect(const IntRect&, Color);
+ void fill_rect_with_dither_pattern(const IntRect&, Color, Color);
+ void fill_rect_with_checkerboard(const IntRect&, const IntSize&, Color color_dark, Color color_light);
+ void fill_rect_with_gradient(Orientation, const IntRect&, Color gradient_start, Color gradient_end);
+ void fill_rect_with_gradient(const IntRect&, Color gradient_start, Color gradient_end);
+ void fill_ellipse(const IntRect&, Color);
+ void draw_rect(const IntRect&, Color, bool rough = false);
+ void draw_bitmap(const IntPoint&, const CharacterBitmap&, Color = Color());
+ void draw_bitmap(const IntPoint&, const GlyphBitmap&, Color = Color());
+ void draw_triangle(const IntPoint&, const IntPoint&, const IntPoint&, Color);
+ void draw_ellipse_intersecting(const IntRect&, Color, int thickness = 1);
+ void set_pixel(const IntPoint&, Color);
+ void draw_line(const IntPoint&, const IntPoint&, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
+ void draw_quadratic_bezier_curve(const IntPoint& control_point, const IntPoint&, const IntPoint&, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
+ void draw_scaled_bitmap(const IntRect& dst_rect, const Gfx::Bitmap&, const IntRect& src_rect);
+ void blit(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, float opacity = 1.0f);
+ void blit_dimmed(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect);
+ void blit_brightened(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect);
+ void blit_filtered(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, Function<Color(Color)>);
+ void draw_tiled_bitmap(const IntRect& dst_rect, const Gfx::Bitmap&);
+ void blit_offset(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, const IntPoint&);
+ void blit_scaled(const IntRect&, const Gfx::Bitmap&, const IntRect&, float, float);
+ void draw_text(const IntRect&, const StringView&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
+ void draw_text(const IntRect&, const StringView&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
+ void draw_text(const IntRect&, const Utf32View&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
+ void draw_text(const IntRect&, const Utf32View&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None);
+ void draw_glyph(const IntPoint&, u32, Color);
+ void draw_glyph(const IntPoint&, u32, const Font&, Color);
+ void draw_emoji(const IntPoint&, const Gfx::Bitmap&, const Font&);
+ void draw_glyph_or_emoji(const IntPoint&, u32 codepoint, const Font&, Color);
static void for_each_line_segment_on_bezier_curve(const FloatPoint& control_point, const FloatPoint& p1, const FloatPoint& p2, Function<void(const FloatPoint&, const FloatPoint&)>&);
static void for_each_line_segment_on_bezier_curve(const FloatPoint& control_point, const FloatPoint& p1, const FloatPoint& p2, Function<void(const FloatPoint&, const FloatPoint&)>&&);
@@ -103,14 +103,14 @@ public:
void set_draw_op(DrawOp op) { state().draw_op = op; }
DrawOp draw_op() const { return state().draw_op; }
- void add_clip_rect(const Rect& rect);
+ void add_clip_rect(const IntRect& rect);
void clear_clip_rect();
- Rect clip_rect() const { return state().clip_rect; }
+ IntRect clip_rect() const { return state().clip_rect; }
void translate(int dx, int dy) { state().translation.move_by(dx, dy); }
- void translate(const Point& delta) { state().translation.move_by(delta); }
+ void translate(const IntPoint& delta) { state().translation.move_by(delta); }
- Point translation() const { return state().translation; }
+ IntPoint translation() const { return state().translation; }
Gfx::Bitmap* target() { return m_target.ptr(); }
@@ -123,25 +123,25 @@ public:
protected:
void set_pixel_with_draw_op(u32& pixel, const Color&);
- void fill_rect_with_draw_op(const Rect&, Color);
- void blit_with_alpha(const Point&, const Gfx::Bitmap&, const Rect& src_rect);
- void blit_with_opacity(const Point&, const Gfx::Bitmap&, const Rect& src_rect, float opacity);
- void draw_pixel(const Point&, Color, int thickness = 1);
+ void fill_rect_with_draw_op(const IntRect&, Color);
+ void blit_with_alpha(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect);
+ void blit_with_opacity(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, float opacity);
+ void draw_pixel(const IntPoint&, Color, int thickness = 1);
- void draw_text_line(const Rect&, const Utf8View&, const Font&, TextAlignment, Color, TextElision);
- void draw_text_line(const Rect&, const Utf32View&, const Font&, TextAlignment, Color, TextElision);
+ void draw_text_line(const IntRect&, const Utf8View&, const Font&, TextAlignment, Color, TextElision);
+ void draw_text_line(const IntRect&, const Utf32View&, const Font&, TextAlignment, Color, TextElision);
struct State {
const Font* font;
- Point translation;
- Rect clip_rect;
+ IntPoint translation;
+ IntRect clip_rect;
DrawOp draw_op;
};
State& state() { return m_state_stack.last(); }
const State& state() const { return m_state_stack.last(); }
- Rect m_clip_origin;
+ IntRect m_clip_origin;
NonnullRefPtr<Gfx::Bitmap> m_target;
Vector<State, 4> m_state_stack;
};
diff --git a/Libraries/LibGfx/Point.cpp b/Libraries/LibGfx/Point.cpp
index 9bdca66ed5..e792190847 100644
--- a/Libraries/LibGfx/Point.cpp
+++ b/Libraries/LibGfx/Point.cpp
@@ -31,12 +31,12 @@
namespace Gfx {
-String Point::to_string() const
+String IntPoint::to_string() const
{
return String::format("[%d,%d]", x(), y());
}
-const LogStream& operator<<(const LogStream& stream, const Point& value)
+const LogStream& operator<<(const LogStream& stream, const IntPoint& value)
{
return stream << value.to_string();
}
@@ -45,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Point& value)
namespace IPC {
-bool encode(Encoder& encoder, const Gfx::Point& point)
+bool encode(Encoder& encoder, const Gfx::IntPoint& point)
{
encoder << point.x() << point.y();
return true;
}
-bool decode(Decoder& decoder, Gfx::Point& point)
+bool decode(Decoder& decoder, Gfx::IntPoint& point)
{
int x = 0;
int y = 0;
diff --git a/Libraries/LibGfx/Point.h b/Libraries/LibGfx/Point.h
index 7b97b51a5d..9413095aa6 100644
--- a/Libraries/LibGfx/Point.h
+++ b/Libraries/LibGfx/Point.h
@@ -34,12 +34,12 @@
namespace Gfx {
-class Rect;
+class IntRect;
-class Point {
+class IntPoint {
public:
- Point() { }
- Point(int x, int y)
+ IntPoint() { }
+ IntPoint(int x, int y)
: m_x(x)
, m_y(y)
{
@@ -57,71 +57,71 @@ public:
m_y += dy;
}
- void move_by(const Point& delta)
+ void move_by(const IntPoint& delta)
{
move_by(delta.x(), delta.y());
}
- Point translated(const Point& delta) const
+ IntPoint translated(const IntPoint& delta) const
{
- Point point = *this;
+ IntPoint point = *this;
point.move_by(delta);
return point;
}
- Point translated(int dx, int dy) const
+ IntPoint translated(int dx, int dy) const
{
- Point point = *this;
+ IntPoint point = *this;
point.move_by(dx, dy);
return point;
}
- void constrain(const Rect&);
+ void constrain(const IntRect&);
- bool operator==(const Point& other) const
+ bool operator==(const IntPoint& other) const
{
return m_x == other.m_x
&& m_y == other.m_y;
}
- bool operator!=(const Point& other) const
+ bool operator!=(const IntPoint& other) const
{
return !(*this == other);
}
- Point operator-() const { return { -m_x, -m_y }; }
+ IntPoint operator-() const { return { -m_x, -m_y }; }
- Point operator-(const Point& other) const { return { m_x - other.m_x, m_y - other.m_y }; }
- Point& operator-=(const Point& other)
+ IntPoint operator-(const IntPoint& other) const { return { m_x - other.m_x, m_y - other.m_y }; }
+ IntPoint& operator-=(const IntPoint& other)
{
m_x -= other.m_x;
m_y -= other.m_y;
return *this;
}
- Point& operator+=(const Point& other)
+ IntPoint& operator+=(const IntPoint& other)
{
m_x += other.m_x;
m_y += other.m_y;
return *this;
}
- Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
+ IntPoint operator+(const IntPoint& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
- Point& operator*=(int factor)
+ IntPoint& operator*=(int factor)
{
m_x *= factor;
m_y *= factor;
return *this;
}
- Point operator*(int factor) const { return { m_x * factor, m_y * factor }; }
+ IntPoint operator*(int factor) const { return { m_x * factor, m_y * factor }; }
- Point& operator/=(int factor)
+ IntPoint& operator/=(int factor)
{
m_x /= factor;
m_y /= factor;
return *this;
}
- Point operator/(int factor) const { return { m_x / factor, m_y / factor }; }
+ IntPoint operator/(int factor) const { return { m_x / factor, m_y / factor }; }
String to_string() const;
@@ -153,18 +153,18 @@ public:
set_y(value);
}
- int dx_relative_to(const Point& other) const
+ int dx_relative_to(const IntPoint& other) const
{
return x() - other.x();
}
- int dy_relative_to(const Point& other) const
+ int dy_relative_to(const IntPoint& other) const
{
return y() - other.y();
}
// Returns pixels moved from other in either direction
- int pixels_moved(const Point& other) const
+ int pixels_moved(const IntPoint& other) const
{
return max(abs(dx_relative_to(other)), abs(dy_relative_to(other)));
}
@@ -174,11 +174,11 @@ private:
int m_y { 0 };
};
-const LogStream& operator<<(const LogStream&, const Point&);
+const LogStream& operator<<(const LogStream&, const IntPoint&);
}
namespace IPC {
-bool encode(Encoder&, const Gfx::Point&);
-bool decode(Decoder&, Gfx::Point&);
+bool encode(Encoder&, const Gfx::IntPoint&);
+bool decode(Decoder&, Gfx::IntPoint&);
}
diff --git a/Libraries/LibGfx/Rect.cpp b/Libraries/LibGfx/Rect.cpp
index 32d1f30c3c..f824f2b5ec 100644
--- a/Libraries/LibGfx/Rect.cpp
+++ b/Libraries/LibGfx/Rect.cpp
@@ -33,7 +33,7 @@
namespace Gfx {
-void Rect::intersect(const Rect& other)
+void IntRect::intersect(const IntRect& other)
{
int l = max(left(), other.left());
int r = min(right(), other.right());
@@ -52,13 +52,13 @@ void Rect::intersect(const Rect& other)
m_size.set_height((b - t) + 1);
}
-Rect Rect::united(const Rect& other) const
+IntRect IntRect::united(const IntRect& other) const
{
if (is_null())
return other;
if (other.is_null())
return *this;
- Rect rect;
+ IntRect rect;
rect.set_left(min(left(), other.left()));
rect.set_top(min(top(), other.top()));
rect.set_right(max(right(), other.right()));
@@ -66,32 +66,32 @@ Rect Rect::united(const Rect& other) const
return rect;
}
-Vector<Rect, 4> Rect::shatter(const Rect& hammer) const
+Vector<IntRect, 4> IntRect::shatter(const IntRect& hammer) const
{
- Vector<Rect, 4> pieces;
+ Vector<IntRect, 4> pieces;
if (!intersects(hammer)) {
pieces.unchecked_append(*this);
return pieces;
}
- Rect top_shard {
+ IntRect top_shard {
x(),
y(),
width(),
hammer.y() - y()
};
- Rect bottom_shard {
+ IntRect bottom_shard {
x(),
hammer.y() + hammer.height(),
width(),
(y() + height()) - (hammer.y() + hammer.height())
};
- Rect left_shard {
+ IntRect left_shard {
x(),
max(hammer.y(), y()),
hammer.x() - x(),
min((hammer.y() + hammer.height()), (y() + height())) - max(hammer.y(), y())
};
- Rect right_shard {
+ IntRect right_shard {
hammer.x() + hammer.width(),
max(hammer.y(), y()),
right() - hammer.right(),
@@ -109,7 +109,7 @@ Vector<Rect, 4> Rect::shatter(const Rect& hammer) const
return pieces;
}
-void Rect::align_within(const Rect& other, TextAlignment alignment)
+void IntRect::align_within(const IntRect& other, TextAlignment alignment)
{
switch (alignment) {
case TextAlignment::Center:
@@ -133,12 +133,12 @@ void Rect::align_within(const Rect& other, TextAlignment alignment)
}
}
-String Rect::to_string() const
+String IntRect::to_string() const
{
return String::format("[%d,%d %dx%d]", x(), y(), width(), height());
}
-const LogStream& operator<<(const LogStream& stream, const Rect& value)
+const LogStream& operator<<(const LogStream& stream, const IntRect& value)
{
return stream << value.to_string();
}
@@ -147,16 +147,16 @@ const LogStream& operator<<(const LogStream& stream, const Rect& value)
namespace IPC {
-bool encode(Encoder& encoder, const Gfx::Rect& rect)
+bool encode(Encoder& encoder, const Gfx::IntRect& rect)
{
encoder << rect.location() << rect.size();
return true;
}
-bool decode(Decoder& decoder, Gfx::Rect& rect)
+bool decode(Decoder& decoder, Gfx::IntRect& rect)
{
- Gfx::Point point;
- Gfx::Size size;
+ Gfx::IntPoint point;
+ Gfx::IntSize size;
if (!decoder.decode(point))
return false;
if (!decoder.decode(size))
diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h
index 6baedfe092..67c495b193 100644
--- a/Libraries/LibGfx/Rect.h
+++ b/Libraries/LibGfx/Rect.h
@@ -36,15 +36,15 @@
namespace Gfx {
-class Rect {
+class IntRect {
public:
- Rect() {}
- Rect(int x, int y, int width, int height)
+ IntRect() {}
+ IntRect(int x, int y, int width, int height)
: m_location(x, y)
, m_size(width, height)
{
}
- Rect(const Point& location, const Size& size)
+ IntRect(const IntPoint& location, const IntSize& size)
: m_location(location)
, m_size(size)
{
@@ -65,22 +65,22 @@ public:
m_location.move_by(dx, dy);
}
- void move_by(const Point& delta)
+ void move_by(const IntPoint& delta)
{
m_location.move_by(delta);
}
- Point center() const
+ IntPoint center() const
{
return { x() + width() / 2, y() + height() / 2 };
}
- void set_location(const Point& location)
+ void set_location(const IntPoint& location)
{
m_location = location;
}
- void set_size(const Size& size)
+ void set_size(const IntSize& size)
{
m_size = size;
}
@@ -107,30 +107,30 @@ public:
set_height(height() - h);
}
- Rect shrunken(int w, int h) const
+ IntRect shrunken(int w, int h) const
{
- Rect rect = *this;
+ IntRect rect = *this;
rect.shrink(w, h);
return rect;
}
- Rect inflated(int w, int h) const
+ IntRect inflated(int w, int h) const
{
- Rect rect = *this;
+ IntRect rect = *this;
rect.inflate(w, h);
return rect;
}
- Rect translated(int dx, int dy) const
+ IntRect translated(int dx, int dy) const
{
- Rect rect = *this;
+ IntRect rect = *this;
rect.move_by(dx, dy);
return rect;
}
- Rect translated(const Point& delta) const
+ IntRect translated(const IntPoint& delta) const
{
- Rect rect = *this;
+ IntRect rect = *this;
rect.move_by(delta);
return rect;
}
@@ -150,12 +150,12 @@ public:
return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom();
}
- bool contains(const Point& point) const
+ bool contains(const IntPoint& point) const
{
return contains(point.x(), point.y());
}
- bool contains(const Rect& other) const
+ bool contains(const IntRect& other) const
{
return left() <= other.left()
&& right() >= other.right()
@@ -224,19 +224,19 @@ public:
move_by(0, delta);
}
- bool intersects_vertically(const Rect& other) const
+ bool intersects_vertically(const IntRect& other) const
{
return top() <= other.bottom()
&& other.top() <= bottom();
}
- bool intersects_horizontally(const Rect& other) const
+ bool intersects_horizontally(const IntRect& other) const
{
return left() <= other.right()
&& other.left() <= right();
}
- bool intersects(const Rect& other) const
+ bool intersects(const IntRect& other) const
{
return left() <= other.right()
&& other.left() <= right()
@@ -254,62 +254,62 @@ public:
void set_width(int width) { m_size.set_width(width); }
void set_height(int height) { m_size.set_height(height); }
- Point location() const { return m_location; }
- Size size() const { return m_size; }
+ IntPoint location() const { return m_location; }
+ IntSize size() const { return m_size; }
- Vector<Rect, 4> shatter(const Rect& hammer) const;
+ Vector<IntRect, 4> shatter(const IntRect& hammer) const;
- bool operator==(const Rect& other) const
+ bool operator==(const IntRect& other) const
{
return m_location == other.m_location
&& m_size == other.m_size;
}
- bool operator!=(const Rect& other) const
+ bool operator!=(const IntRect& other) const
{
return !(*this == other);
}
- void intersect(const Rect&);
+ void intersect(const IntRect&);
- static Rect from_two_points(const Point& a, const Point& b)
+ static IntRect from_two_points(const IntPoint& a, const IntPoint& b)
{
return { min(a.x(), b.x()), min(a.y(), b.y()), abs(a.x() - b.x()), abs(a.y() - b.y()) };
}
- static Rect intersection(const Rect& a, const Rect& b)
+ static IntRect intersection(const IntRect& a, const IntRect& b)
{
- Rect r(a);
+ IntRect r(a);
r.intersect(b);
return r;
}
- Rect intersected(const Rect& other) const
+ IntRect intersected(const IntRect& other) const
{
return intersection(*this, other);
}
- Rect united(const Rect&) const;
+ IntRect united(const IntRect&) const;
- Point top_left() const { return { left(), top() }; }
- Point top_right() const { return { right(), top() }; }
- Point bottom_left() const { return { left(), bottom() }; }
- Point bottom_right() const { return { right(), bottom() }; }
+ IntPoint top_left() const { return { left(), top() }; }
+ IntPoint top_right() const { return { right(), top() }; }
+ IntPoint bottom_left() const { return { left(), bottom() }; }
+ IntPoint bottom_right() const { return { right(), bottom() }; }
- void align_within(const Rect&, TextAlignment);
+ void align_within(const IntRect&, TextAlignment);
- void center_within(const Rect& other)
+ void center_within(const IntRect& other)
{
center_horizontally_within(other);
center_vertically_within(other);
}
- void center_horizontally_within(const Rect& other)
+ void center_horizontally_within(const IntRect& other)
{
set_x(other.center().x() - width() / 2);
}
- void center_vertically_within(const Rect& other)
+ void center_vertically_within(const IntRect& other)
{
set_y(other.center().y() - height() / 2);
}
@@ -317,11 +317,11 @@ public:
String to_string() const;
private:
- Point m_location;
- Size m_size;
+ IntPoint m_location;
+ IntSize m_size;
};
-inline void Point::constrain(const Rect& rect)
+inline void IntPoint::constrain(const IntRect& rect)
{
if (x() < rect.left())
set_x(rect.left());
@@ -333,11 +333,11 @@ inline void Point::constrain(const Rect& rect)
set_y(rect.bottom());
}
-const LogStream& operator<<(const LogStream&, const Rect&);
+const LogStream& operator<<(const LogStream&, const IntRect&);
}
namespace IPC {
-bool decode(Decoder&, Gfx::Rect&);
-bool encode(Encoder&, const Gfx::Rect&);
+bool decode(Decoder&, Gfx::IntRect&);
+bool encode(Encoder&, const Gfx::IntRect&);
}
diff --git a/Libraries/LibGfx/ShareableBitmap.cpp b/Libraries/LibGfx/ShareableBitmap.cpp
index 606c857cce..ea19a5c67f 100644
--- a/Libraries/LibGfx/ShareableBitmap.cpp
+++ b/Libraries/LibGfx/ShareableBitmap.cpp
@@ -52,7 +52,7 @@ bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap)
bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
{
i32 shbuf_id = 0;
- Gfx::Size size;
+ Gfx::IntSize size;
if (!decoder.decode(shbuf_id))
return false;
if (!decoder.decode(size))
diff --git a/Libraries/LibGfx/ShareableBitmap.h b/Libraries/LibGfx/ShareableBitmap.h
index 8dd63d14ac..ac0ecca36b 100644
--- a/Libraries/LibGfx/ShareableBitmap.h
+++ b/Libraries/LibGfx/ShareableBitmap.h
@@ -44,8 +44,8 @@ public:
const Bitmap* bitmap() const { return m_bitmap; }
Bitmap* bitmap() { return m_bitmap; }
- Size size() const { return m_bitmap ? m_bitmap->size() : Size(); }
- Rect rect() const { return m_bitmap ? m_bitmap->rect() : Rect(); }
+ IntSize size() const { return m_bitmap ? m_bitmap->size() : IntSize(); }
+ IntRect rect() const { return m_bitmap ? m_bitmap->rect() : IntRect(); }
int width() const { return size().width(); }
int height() const { return size().height(); }
diff --git a/Libraries/LibGfx/Size.cpp b/Libraries/LibGfx/Size.cpp
index 45caf1ef57..648aa5708b 100644
--- a/Libraries/LibGfx/Size.cpp
+++ b/Libraries/LibGfx/Size.cpp
@@ -31,12 +31,12 @@
namespace Gfx {
-String Size::to_string() const
+String IntSize::to_string() const
{
return String::format("[%dx%d]", m_width, m_height);
}
-const LogStream& operator<<(const LogStream& stream, const Size& value)
+const LogStream& operator<<(const LogStream& stream, const IntSize& value)
{
return stream << value.to_string();
}
@@ -45,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Size& value)
namespace IPC {
-bool encode(Encoder& encoder, const Gfx::Size& size)
+bool encode(Encoder& encoder, const Gfx::IntSize& size)
{
encoder << size.width() << size.height();
return true;
}
-bool decode(Decoder& decoder, Gfx::Size& size)
+bool decode(Decoder& decoder, Gfx::IntSize& size)
{
int width = 0;
int height = 0;
diff --git a/Libraries/LibGfx/Size.h b/Libraries/LibGfx/Size.h
index c48ebac2ec..59eb27a66d 100644
--- a/Libraries/LibGfx/Size.h
+++ b/Libraries/LibGfx/Size.h
@@ -32,10 +32,10 @@
namespace Gfx {
-class Size {
+class IntSize {
public:
- Size() {}
- Size(int w, int h)
+ IntSize() {}
+ IntSize(int w, int h)
: m_width(w)
, m_height(h)
{
@@ -52,24 +52,24 @@ public:
void set_width(int w) { m_width = w; }
void set_height(int h) { m_height = h; }
- bool operator==(const Size& other) const
+ bool operator==(const IntSize& other) const
{
return m_width == other.m_width && m_height == other.m_height;
}
- bool operator!=(const Size& other) const
+ bool operator!=(const IntSize& other) const
{
return !(*this == other);
}
- Size& operator-=(const Size& other)
+ IntSize& operator-=(const IntSize& other)
{
m_width -= other.m_width;
m_height -= other.m_height;
return *this;
}
- Size& operator+=(const Size& other)
+ IntSize& operator+=(const IntSize& other)
{
m_width += other.m_width;
m_height += other.m_height;
@@ -109,11 +109,11 @@ private:
int m_height { 0 };
};
-const LogStream& operator<<(const LogStream&, const Size&);
+const LogStream& operator<<(const LogStream&, const IntSize&);
}
namespace IPC {
-bool encode(Encoder&, const Gfx::Size&);
-bool decode(Decoder&, Gfx::Size&);
+bool encode(Encoder&, const Gfx::IntSize&);
+bool decode(Decoder&, Gfx::IntSize&);
}
diff --git a/Libraries/LibGfx/StylePainter.cpp b/Libraries/LibGfx/StylePainter.cpp
index 3408594d8f..2e24ca3a9c 100644
--- a/Libraries/LibGfx/StylePainter.cpp
+++ b/Libraries/LibGfx/StylePainter.cpp
@@ -31,7 +31,7 @@
namespace Gfx {
-void StylePainter::paint_tab_button(Painter& painter, const Rect& rect, const Palette& palette, bool active, bool hovered, bool enabled)
+void StylePainter::paint_tab_button(Painter& painter, const IntRect& rect, const Palette& palette, bool active, bool hovered, bool enabled)
{
Color base_color = palette.button();
Color highlight_color2 = palette.threed_highlight();
@@ -72,7 +72,7 @@ void StylePainter::paint_tab_button(Painter& painter, const Rect& rect, const Pa
shadow_color2);
}
-static void paint_button_new(Painter& painter, const Rect& rect, const Palette& palette, bool pressed, bool checked, bool hovered, bool enabled)
+static void paint_button_new(Painter& painter, const IntRect& rect, const Palette& palette, bool pressed, bool checked, bool hovered, bool enabled)
{
Color button_color = palette.button();
Color highlight_color2 = palette.threed_highlight();
@@ -117,7 +117,7 @@ static void paint_button_new(Painter& painter, const Rect& rect, const Palette&
}
}
-void StylePainter::paint_button(Painter& painter, const Rect& rect, const Palette& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled)
+void StylePainter::paint_button(Painter& painter, const IntRect& rect, const Palette& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled)
{
if (button_style == ButtonStyle::Normal)
return paint_button_new(painter, rect, palette, pressed, checked, hovered, enabled);
@@ -157,7 +157,7 @@ void StylePainter::paint_button(Painter& painter, const Rect& rect, const Palett
}
}
-void StylePainter::paint_surface(Painter& painter, const Rect& rect, const Palette& palette, bool paint_vertical_lines, bool paint_top_line)
+void StylePainter::paint_surface(Painter& painter, const IntRect& rect, const Palette& palette, bool paint_vertical_lines, bool paint_top_line)
{
painter.fill_rect({ rect.x(), rect.y() + 1, rect.width(), rect.height() - 2 }, palette.button());
painter.draw_line(rect.top_left(), rect.top_right(), paint_top_line ? palette.threed_highlight() : palette.button());
@@ -168,7 +168,7 @@ void StylePainter::paint_surface(Painter& painter, const Rect& rect, const Palet
}
}
-void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines)
+void StylePainter::paint_frame(Painter& painter, const IntRect& rect, const Palette& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines)
{
Color top_left_color;
Color bottom_right_color;
@@ -218,7 +218,7 @@ void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette
top_left_color = dark_shade;
bottom_right_color = dark_shade;
}
- Rect inner_container_frame_rect = rect.shrunken(2, 2);
+ IntRect inner_container_frame_rect = rect.shrunken(2, 2);
painter.draw_line(inner_container_frame_rect.top_left(), inner_container_frame_rect.top_right(), top_left_color);
painter.draw_line(inner_container_frame_rect.bottom_left(), inner_container_frame_rect.bottom_right(), bottom_right_color);
painter.draw_line(inner_container_frame_rect.top_left().translated(0, 1), inner_container_frame_rect.bottom_left().translated(0, -1), top_left_color);
@@ -227,7 +227,7 @@ void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette
if (shape == FrameShape::Box && thickness >= 2) {
swap(top_left_color, bottom_right_color);
- Rect inner_rect = rect.shrunken(2, 2);
+ IntRect inner_rect = rect.shrunken(2, 2);
painter.draw_line(inner_rect.top_left(), inner_rect.top_right(), top_left_color);
painter.draw_line(inner_rect.bottom_left(), inner_rect.bottom_right(), bottom_right_color);
painter.draw_line(inner_rect.top_left().translated(0, 1), inner_rect.bottom_left().translated(0, -1), top_left_color);
@@ -235,7 +235,7 @@ void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette
}
}
-void StylePainter::paint_window_frame(Painter& painter, const Rect& rect, const Palette& palette)
+void StylePainter::paint_window_frame(Painter& painter, const IntRect& rect, const Palette& palette)
{
Color base_color = palette.button();
Color dark_shade = palette.threed_shadow2();
@@ -261,7 +261,7 @@ void StylePainter::paint_window_frame(Painter& painter, const Rect& rect, const
painter.draw_line(rect.bottom_left().translated(3, -3), rect.bottom_right().translated(-3, -3), base_color);
}
-void StylePainter::paint_progress_bar(Painter& painter, const Rect& rect, const Palette& palette, int min, int max, int value, const StringView& text)
+void StylePainter::paint_progress_bar(Painter& painter, const IntRect& rect, const Palette& palette, int min, int max, int value, const StringView& text)
{
// First we fill the entire widget with the gradient. This incurs a bit of
// overdraw but ensures a consistent look throughout the progression.
@@ -280,7 +280,7 @@ void StylePainter::paint_progress_bar(Painter& painter, const Rect& rect, const
// Then we carve out a hole in the remaining part of the widget.
// We draw the text a third time, clipped and inverse, for sharp contrast.
float progress_width = progress * rect.width();
- Rect hole_rect { (int)progress_width, 0, (int)(rect.width() - progress_width), rect.height() };
+ IntRect hole_rect { (int)progress_width, 0, (int)(rect.width() - progress_width), rect.height() };
hole_rect.move_by(rect.location());
hole_rect.set_right_without_resize(rect.right());
PainterStateSaver saver(painter);
@@ -303,7 +303,7 @@ static const Gfx::Bitmap& circle_bitmap(bool checked, bool changing)
return checked ? *s_filled_circle_bitmap : *s_unfilled_circle_bitmap;
}
-void StylePainter::paint_radio_button(Painter& painter, const Rect& rect, const Palette&, bool is_checked, bool is_being_pressed)
+void StylePainter::paint_radio_button(Painter& painter, const IntRect& rect, const Palette&, bool is_checked, bool is_being_pressed)
{
if (!s_unfilled_circle_bitmap) {
s_unfilled_circle_bitmap = Bitmap::load_from_file("/res/icons/unfilled-radio-circle.png");
diff --git a/Libraries/LibGfx/StylePainter.h b/Libraries/LibGfx/StylePainter.h
index c677d21a91..a684dd8566 100644
--- a/Libraries/LibGfx/StylePainter.h
+++ b/Libraries/LibGfx/StylePainter.h
@@ -51,13 +51,13 @@ enum class FrameShape {
class StylePainter {
public:
- static void paint_button(Painter&, const Rect&, const Palette&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true);
- static void paint_tab_button(Painter&, const Rect&, const Palette&, bool active, bool hovered, bool enabled);
- static void paint_surface(Painter&, const Rect&, const Palette&, bool paint_vertical_lines = true, bool paint_top_line = true);
- static void paint_frame(Painter&, const Rect&, const Palette&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false);
- static void paint_window_frame(Painter&, const Rect&, const Palette&);
- static void paint_progress_bar(Painter&, const Rect&, const Palette&, int min, int max, int value, const StringView& text);
- static void paint_radio_button(Painter&, const Rect&, const Palette&, bool is_checked, bool is_being_pressed);
+ static void paint_button(Painter&, const IntRect&, const Palette&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true);
+ static void paint_tab_button(Painter&, const IntRect&, const Palette&, bool active, bool hovered, bool enabled);
+ static void paint_surface(Painter&, const IntRect&, const Palette&, bool paint_vertical_lines = true, bool paint_top_line = true);
+ static void paint_frame(Painter&, const IntRect&, const Palette&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false);
+ static void paint_window_frame(Painter&, const IntRect&, const Palette&);
+ static void paint_progress_bar(Painter&, const IntRect&, const Palette&, int min, int max, int value, const StringView& text);
+ static void paint_radio_button(Painter&, const IntRect&, const Palette&, bool is_checked, bool is_being_pressed);
};
}
diff --git a/Libraries/LibGfx/Triangle.h b/Libraries/LibGfx/Triangle.h
index 8720700cb9..7d8e69e80d 100644
--- a/Libraries/LibGfx/Triangle.h
+++ b/Libraries/LibGfx/Triangle.h
@@ -33,7 +33,7 @@ namespace Gfx {
class Triangle {
public:
- Triangle(Point a, Point b, Point c)
+ Triangle(IntPoint a, IntPoint b, IntPoint c)
: m_a(a)
, m_b(b)
, m_c(c)
@@ -41,11 +41,11 @@ public:
m_det = (m_b.x() - m_a.x()) * (m_c.y() - m_a.y()) - (m_b.y() - m_a.y()) * (m_c.x() - m_a.x());
}
- Point a() const { return m_a; }
- Point b() const { return m_b; }
- Point c() const { return m_c; }
+ IntPoint a() const { return m_a; }
+ IntPoint b() const { return m_b; }
+ IntPoint c() const { return m_c; }
- bool contains(Point p) const
+ bool contains(IntPoint p) const
{
int x = p.x();
int y = p.y();
@@ -71,9 +71,9 @@ public:
private:
int m_det;
- Point m_a;
- Point m_b;
- Point m_c;
+ IntPoint m_a;
+ IntPoint m_b;
+ IntPoint m_c;
};
const LogStream& operator<<(const LogStream&, const Triangle&);