summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx/Size.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-15 12:04:35 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-15 12:11:19 +0100
commita4d857e3c5e2040309613256f12c2de348d2b9ba (patch)
tree17eb99ec48c9fcd7086048c6091702f0a8743af3 /Libraries/LibGfx/Size.cpp
parentdc417ada6d58d2bab574aaf1c328f4f6be9e72f2 (diff)
downloadserenity-a4d857e3c5e2040309613256f12c2de348d2b9ba.zip
LibIPC+IPCCompiler: Add IPC::Decoder, let classes decode themselves
This shaves ~5 seconds off of a full build, not too bad. Also it just seems nicer to push this logic out to classes. It could be better but it's a start. :^)
Diffstat (limited to 'Libraries/LibGfx/Size.cpp')
-rw-r--r--Libraries/LibGfx/Size.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Libraries/LibGfx/Size.cpp b/Libraries/LibGfx/Size.cpp
index 1c278d7306..39f6868e5d 100644
--- a/Libraries/LibGfx/Size.cpp
+++ b/Libraries/LibGfx/Size.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/BufferStream.h>
#include <AK/String.h>
#include <LibGfx/Size.h>
@@ -40,3 +41,19 @@ const LogStream& operator<<(const LogStream& stream, const Size& value)
}
}
+
+namespace IPC {
+
+bool decode(BufferStream& stream, Gfx::Size& size)
+{
+ int width;
+ int height;
+ stream >> width;
+ stream >> height;
+ if (stream.handle_read_failure())
+ return false;
+ size = { width, height };
+ return true;
+}
+
+}