summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-15 00:58:14 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-15 00:58:54 +0100
commit34b5ff7c29fbd9f72922710042577aa0d906592b (patch)
tree8872d43134202f5c5f66163f9c13c9bae57f0535
parent3866e0d4d4026a58e2577f6651e8796182d16a0e (diff)
downloadserenity-34b5ff7c29fbd9f72922710042577aa0d906592b.zip
LibGfx: Move a bunch of LogStream::operator<< to cpp files
-rw-r--r--Libraries/LibGfx/ImageDecoder.cpp6
-rw-r--r--Libraries/LibGfx/ImageDecoder.h2
-rw-r--r--Libraries/LibGfx/Makefile5
-rw-r--r--Libraries/LibGfx/Painter.h1
-rw-r--r--Libraries/LibGfx/Point.cpp42
-rw-r--r--Libraries/LibGfx/Point.h11
-rw-r--r--Libraries/LibGfx/Rect.cpp11
-rw-r--r--Libraries/LibGfx/Rect.h10
-rw-r--r--Libraries/LibGfx/Size.cpp42
-rw-r--r--Libraries/LibGfx/Size.h10
-rw-r--r--Libraries/LibGfx/Triangle.cpp42
-rw-r--r--Libraries/LibGfx/Triangle.h8
12 files changed, 162 insertions, 28 deletions
diff --git a/Libraries/LibGfx/ImageDecoder.cpp b/Libraries/LibGfx/ImageDecoder.cpp
index 87a9f79ca1..54796b40fa 100644
--- a/Libraries/LibGfx/ImageDecoder.cpp
+++ b/Libraries/LibGfx/ImageDecoder.cpp
@@ -37,4 +37,10 @@ ImageDecoder::ImageDecoder(const u8* data, size_t size)
ImageDecoder::~ImageDecoder()
{
}
+
+RefPtr<Gfx::Bitmap> ImageDecoder::bitmap() const
+{
+ return m_plugin->bitmap();
+}
+
}
diff --git a/Libraries/LibGfx/ImageDecoder.h b/Libraries/LibGfx/ImageDecoder.h
index dd3d901173..6feb4e693b 100644
--- a/Libraries/LibGfx/ImageDecoder.h
+++ b/Libraries/LibGfx/ImageDecoder.h
@@ -57,7 +57,7 @@ public:
Size size() const { return m_plugin->size(); }
int width() const { return size().width(); }
int height() const { return size().height(); }
- RefPtr<Gfx::Bitmap> bitmap() const { return m_plugin->bitmap(); }
+ RefPtr<Gfx::Bitmap> bitmap() const;
void set_volatile() { m_plugin->set_volatile(); }
[[nodiscard]] bool set_nonvolatile() { return m_plugin->set_nonvolatile(); }
diff --git a/Libraries/LibGfx/Makefile b/Libraries/LibGfx/Makefile
index 96fc1a064d..e02371bfe9 100644
--- a/Libraries/LibGfx/Makefile
+++ b/Libraries/LibGfx/Makefile
@@ -10,9 +10,12 @@ OBJS = \
PNGLoader.o \
Painter.o \
Palette.o \
+ Point.o \
Rect.o \
+ Size.o \
StylePainter.o \
- SystemTheme.o
+ SystemTheme.o \
+ Triangle.o
LIBRARY = libgfx.a
diff --git a/Libraries/LibGfx/Painter.h b/Libraries/LibGfx/Painter.h
index 168c31e5f6..efc2f64ab8 100644
--- a/Libraries/LibGfx/Painter.h
+++ b/Libraries/LibGfx/Painter.h
@@ -27,6 +27,7 @@
#pragma once
#include <AK/Forward.h>
+#include <AK/NonnullRefPtr.h>
#include <AK/Vector.h>
#include <LibGfx/Color.h>
#include <LibGfx/Forward.h>
diff --git a/Libraries/LibGfx/Point.cpp b/Libraries/LibGfx/Point.cpp
new file mode 100644
index 0000000000..8a42878dce
--- /dev/null
+++ b/Libraries/LibGfx/Point.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <AK/String.h>
+#include <LibGfx/Point.h>
+
+namespace Gfx {
+
+String Point::to_string() const
+{
+ return String::format("[%d,%d]", x(), y());
+}
+
+const LogStream& operator<<(const LogStream& stream, const Point& value)
+{
+ return stream << value.to_string();
+}
+
+}
diff --git a/Libraries/LibGfx/Point.h b/Libraries/LibGfx/Point.h
index bfc57ca21d..854e442668 100644
--- a/Libraries/LibGfx/Point.h
+++ b/Libraries/LibGfx/Point.h
@@ -26,8 +26,8 @@
#pragma once
-#include <AK/LogStream.h>
-#include <AK/String.h>
+#include <AK/Forward.h>
+#include <AK/StdLibExtras.h>
#include <LibGfx/Orientation.h>
namespace Gfx {
@@ -105,7 +105,7 @@ public:
}
Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
- String to_string() const { return String::format("[%d,%d]", x(), y()); }
+ String to_string() const;
bool is_null() const { return !m_x && !m_y; }
@@ -156,9 +156,6 @@ private:
int m_y { 0 };
};
-inline const LogStream& operator<<(const LogStream& stream, const Point& value)
-{
- return stream << value.to_string();
-}
+const LogStream& operator<<(const LogStream&, const Point&);
}
diff --git a/Libraries/LibGfx/Rect.cpp b/Libraries/LibGfx/Rect.cpp
index af663bfc09..7e33576077 100644
--- a/Libraries/LibGfx/Rect.cpp
+++ b/Libraries/LibGfx/Rect.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/StdLibExtras.h>
+#include <AK/String.h>
#include <AK/Vector.h>
#include <LibGfx/Rect.h>
@@ -130,4 +131,14 @@ void Rect::align_within(const Rect& other, TextAlignment alignment)
}
}
+String Rect::to_string() const
+{
+ return String::format("[%d,%d %dx%d]", x(), y(), width(), height());
+}
+
+const LogStream& operator<<(const LogStream& stream, const Rect& value)
+{
+ return stream << value.to_string();
+}
+
}
diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h
index 103df2b8ec..968208516f 100644
--- a/Libraries/LibGfx/Rect.h
+++ b/Libraries/LibGfx/Rect.h
@@ -26,8 +26,7 @@
#pragma once
-#include <AK/LogStream.h>
-#include <AK/String.h>
+#include <AK/Forward.h>
#include <LibGfx/Orientation.h>
#include <LibGfx/Point.h>
#include <LibGfx/Size.h>
@@ -313,7 +312,7 @@ public:
set_y(other.center().y() - height() / 2);
}
- String to_string() const { return String::format("[%d,%d %dx%d]", x(), y(), width(), height()); }
+ String to_string() const;
private:
Point m_location;
@@ -332,9 +331,6 @@ inline void Point::constrain(const Rect& rect)
set_y(rect.bottom());
}
-inline const LogStream& operator<<(const LogStream& stream, const Rect& value)
-{
- return stream << value.to_string();
-}
+const LogStream& operator<<(const LogStream&, const Rect&);
}
diff --git a/Libraries/LibGfx/Size.cpp b/Libraries/LibGfx/Size.cpp
new file mode 100644
index 0000000000..1c278d7306
--- /dev/null
+++ b/Libraries/LibGfx/Size.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <AK/String.h>
+#include <LibGfx/Size.h>
+
+namespace Gfx {
+
+String Size::to_string() const
+{
+ return String::format("[%dx%d]", m_width, m_height);
+}
+
+const LogStream& operator<<(const LogStream& stream, const Size& value)
+{
+ return stream << value.to_string();
+}
+
+}
diff --git a/Libraries/LibGfx/Size.h b/Libraries/LibGfx/Size.h
index fbb9cc0a2a..c228ffe6a3 100644
--- a/Libraries/LibGfx/Size.h
+++ b/Libraries/LibGfx/Size.h
@@ -26,8 +26,7 @@
#pragma once
-#include <AK/LogStream.h>
-#include <AK/String.h>
+#include <AK/Forward.h>
#include <LibGfx/Orientation.h>
namespace Gfx {
@@ -102,16 +101,13 @@ public:
set_height(value);
}
- String to_string() const { return String::format("[%dx%d]", m_width, m_height); }
+ String to_string() const;
private:
int m_width { 0 };
int m_height { 0 };
};
-inline const LogStream& operator<<(const LogStream& stream, const Size& value)
-{
- return stream << value.to_string();
-}
+const LogStream& operator<<(const LogStream&, const Size&);
}
diff --git a/Libraries/LibGfx/Triangle.cpp b/Libraries/LibGfx/Triangle.cpp
new file mode 100644
index 0000000000..d36ad50f0f
--- /dev/null
+++ b/Libraries/LibGfx/Triangle.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2020, Shannon Booth <shannon.ml.booth@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <AK/String.h>
+#include <LibGfx/Triangle.h>
+
+namespace Gfx {
+
+String Triangle::to_string() const
+{
+ return String::format("(%s,%s,%s)", m_a.to_string().characters(), m_b.to_string().characters(), m_c.to_string().characters());
+}
+
+const LogStream& operator<<(const LogStream& stream, const Triangle& value)
+{
+ return stream << value.to_string();
+}
+
+}
diff --git a/Libraries/LibGfx/Triangle.h b/Libraries/LibGfx/Triangle.h
index 3974f655a6..72a566a08f 100644
--- a/Libraries/LibGfx/Triangle.h
+++ b/Libraries/LibGfx/Triangle.h
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Forward.h>
#include <LibGfx/Point.h>
namespace Gfx {
@@ -64,7 +65,7 @@ public:
return true;
}
- String to_string() const { return String::format("(%s,%s,%s)", m_a.to_string().characters(), m_b.to_string().characters(), m_c.to_string().characters()); }
+ String to_string() const;
private:
int m_det;
@@ -73,9 +74,6 @@ private:
Point m_c;
};
-inline const LogStream& operator<<(const LogStream& stream, const Triangle& value)
-{
- return stream << value.to_string();
-}
+const LogStream& operator<<(const LogStream&, const Triangle&);
}