Add new Stream base class, internal-only for now.

This commit is contained in:
Alex Szpakowski
2022-04-21 19:52:04 -03:00
parent 76193899b3
commit ceb23eee48
7 changed files with 143 additions and 21 deletions
+3 -2
View File
@@ -31,11 +31,12 @@ namespace data
love::Type ByteData::type("ByteData", &Data::type);
ByteData::ByteData(size_t size)
ByteData::ByteData(size_t size, bool clear)
: size(size)
{
create();
memset(data, 0, size);
if (clear)
memset(data, 0, size);
}
ByteData::ByteData(const void *d, size_t size)
+1 -1
View File
@@ -35,7 +35,7 @@ public:
static love::Type type;
ByteData(size_t size);
ByteData(size_t size, bool clear = true);
ByteData(const void *d, size_t size);
ByteData(void *d, size_t size, bool own);
ByteData(const ByteData &d);
-1
View File
@@ -23,7 +23,6 @@
// LOVE
#include "common/Module.h"
#include "common/Stream.h"
#include "filesystem/File.h"
#include "VideoStream.h"
+1 -1
View File
@@ -27,7 +27,7 @@ namespace love
namespace video
{
love::Type VideoStream::type("VideoStream", &Stream::type);
love::Type VideoStream::type("VideoStream", &Object::type);
void VideoStream::setSync(VideoStream::FrameSync *frameSync)
{
+24 -2
View File
@@ -22,7 +22,7 @@
#define LOVE_VIDEO_VIDEOSTREAM_H
// LOVE
#include "common/Stream.h"
#include "common/Object.h"
#include "audio/Source.h"
#include "thread/threads.h"
@@ -31,7 +31,7 @@ namespace love
namespace video
{
class VideoStream : public Stream
class VideoStream : public love::Object
{
public:
@@ -39,6 +39,28 @@ public:
virtual ~VideoStream() {}
/**
* A callback, gets called when some Stream consumer exhausts the data
**/
virtual void fillBackBuffer() {}
/**
* Get the front buffer, Streams are supposed to be (at least) double-buffered
**/
virtual const void* getFrontBuffer() const = 0;
/**
* Get the size of any (and in particular the front) buffer
**/
virtual size_t getSize() const = 0;
/**
* Swap buffers. Returns true if there is new data in the front buffer,
* false otherwise.
* NOTE: If there is no back buffer ready, this call must be ignored
**/
virtual bool swapBuffers() = 0;
virtual int getWidth() const = 0;
virtual int getHeight() const = 0;
virtual const std::string &getFilename() const = 0;