qt: Refactor renderers buffer ownership

Invert the way buffers are created; make renderer create buffers for
renderer stack.
Use QImage bits as the buffer for software renderer.
This commit is contained in:
ts-korhonen
2022-01-15 21:45:34 +02:00
parent 07446719a4
commit 8c8e2219d8
8 changed files with 108 additions and 44 deletions

View File

@@ -7,7 +7,7 @@
#include <memory>
#include <vector>
#include <atomic>
#include <array>
#include <tuple>
namespace Ui {
class RendererStack;
@@ -46,7 +46,7 @@ public:
RendererCommon* rendererWindow{nullptr};
signals:
void blitToRenderer(const std::unique_ptr<uint8_t>* img, int, int, int, int, std::atomic_flag* in_use);
void blitToRenderer(int buf_idx, int x, int y, int w, int h);
public slots:
void blit(int x, int y, int w, int h);
@@ -64,13 +64,10 @@ private:
int x, y, w, h, sx, sy, sw, sh;
int currentBuf = 0;
std::array<std::unique_ptr<uint8_t>, 2> imagebufs;
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> imagebufs;
std::unique_ptr<QWidget> current;
/* atomic flag for each buffer to not overload the renderer */
std::vector<std::atomic_flag> buffers_in_use;
friend class MainWindow;
};