base: Add serialization support to Pixels and FrameBuffer

Serialize pixels as unsigned 32 bit integers by adding the required
to_number() and stream operators. This is used by the FrameBuffer,
which now implements the Serializable interface. Users of frame
buffers are expected to serialize it into its own section by calling
serializeSection().
This commit is contained in:
Andreas Sandberg
2015-07-07 09:51:04 +01:00
parent 888ec455cb
commit b3ecfa6ae0
3 changed files with 46 additions and 2 deletions

View File

@@ -122,6 +122,23 @@ FrameBuffer::~FrameBuffer()
{
}
void
FrameBuffer::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(_width);
SERIALIZE_SCALAR(_height);
SERIALIZE_CONTAINER(pixels);
}
void
FrameBuffer::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(_width);
UNSERIALIZE_SCALAR(_height);
UNSERIALIZE_CONTAINER(pixels);
}
void
FrameBuffer::resize(unsigned width, unsigned height)
{