mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibGfx+IPCCompiler: Add IPC encoders for Color and ShareableBitmap
This commit is contained in:
parent
f8e3c8326d
commit
fbda28248a
5 changed files with 19 additions and 7 deletions
|
@ -343,13 +343,7 @@ int main(int argc, char** argv)
|
||||||
out() << " stream << endpoint_magic();";
|
out() << " stream << endpoint_magic();";
|
||||||
out() << " stream << (int)MessageID::" << name << ";";
|
out() << " stream << (int)MessageID::" << name << ";";
|
||||||
for (auto& parameter : parameters) {
|
for (auto& parameter : parameters) {
|
||||||
if (parameter.type == "Gfx::Color") {
|
if (parameter.type.starts_with("Optional<")) {
|
||||||
out() << " stream << m_" << parameter.name << ".value();";
|
|
||||||
} else if (parameter.type == "Gfx::ShareableBitmap") {
|
|
||||||
out() << " stream << m_" << parameter.name << ".shbuf_id();";
|
|
||||||
out() << " stream << m_" << parameter.name << ".width();";
|
|
||||||
out() << " stream << m_" << parameter.name << ".height();";
|
|
||||||
} else if (parameter.type.starts_with("Optional<")) {
|
|
||||||
out() << " stream << m_" << parameter.name << ".has_value();";
|
out() << " stream << m_" << parameter.name << ".has_value();";
|
||||||
out() << " if (m_" << parameter.name << ".has_value())";
|
out() << " if (m_" << parameter.name << ".has_value())";
|
||||||
out() << " stream << m_" << parameter.name << ".value();";
|
out() << " stream << m_" << parameter.name << ".value();";
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <LibGfx/Color.h>
|
#include <LibGfx/Color.h>
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
#include <LibIPC/Decoder.h>
|
#include <LibIPC/Decoder.h>
|
||||||
|
#include <LibIPC/Encoder.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -433,6 +434,12 @@ const LogStream& operator<<(const LogStream& stream, Color value)
|
||||||
return stream << value.to_string();
|
return stream << value.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IPC::encode(IPC::Encoder& encoder, const Color& color)
|
||||||
|
{
|
||||||
|
encoder << color.value();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool IPC::decode(IPC::Decoder& decoder, Color& color)
|
bool IPC::decode(IPC::Decoder& decoder, Color& color)
|
||||||
{
|
{
|
||||||
u32 rgba = 0;
|
u32 rgba = 0;
|
||||||
|
|
|
@ -282,5 +282,6 @@ const LogStream& operator<<(const LogStream&, Color);
|
||||||
using Gfx::Color;
|
using Gfx::Color;
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
bool encode(Encoder&, const Gfx::Color&);
|
||||||
bool decode(Decoder&, Gfx::Color&);
|
bool decode(Decoder&, Gfx::Color&);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/ShareableBitmap.h>
|
#include <LibGfx/ShareableBitmap.h>
|
||||||
#include <LibIPC/Decoder.h>
|
#include <LibIPC/Decoder.h>
|
||||||
|
#include <LibIPC/Encoder.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
@ -40,6 +41,14 @@ ShareableBitmap::ShareableBitmap(const Bitmap& bitmap)
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
|
bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap)
|
||||||
|
{
|
||||||
|
encoder << shareable_bitmap.shbuf_id();
|
||||||
|
encoder << shareable_bitmap.width();
|
||||||
|
encoder << shareable_bitmap.height();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
|
bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
|
||||||
{
|
{
|
||||||
i32 shbuf_id = 0;
|
i32 shbuf_id = 0;
|
||||||
|
|
|
@ -57,5 +57,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
bool encode(Encoder&, const Gfx::ShareableBitmap&);
|
||||||
bool decode(Decoder&, Gfx::ShareableBitmap&);
|
bool decode(Decoder&, Gfx::ShareableBitmap&);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue