Blitting improvements

* Use a single QImage copy for actual drawing
* Use std::array and std::unique_ptr for image buffers
* Signal immediately after copying the buffer to internal image
This commit is contained in:
Cacodemon345
2021-12-21 16:38:13 +06:00
parent bbb0b38d31
commit 67a0f7a85f
9 changed files with 17 additions and 25 deletions

View File

@@ -7,6 +7,7 @@
#include <memory>
#include <vector>
#include <atomic>
#include <array>
namespace Ui {
class RendererStack;
@@ -42,7 +43,7 @@ public:
void switchRenderer(Renderer renderer);
signals:
void blitToRenderer(const QImage& img, int, int, int, int, std::atomic_flag* in_use);
void blitToRenderer(const std::unique_ptr<uint8_t>* img, int, int, int, int, std::atomic_flag* in_use);
public slots:
void blit(int x, int y, int w, int h);
@@ -59,11 +60,8 @@ private:
int x, y, w, h, sx, sy, sw, sh;
// always have a qimage available for writing, which is _probably_ unused
// worst case - it will just get reallocated because it's refcounter is > 1
// when calling bits();
int currentBuf = 0;
QVector<QImage> imagebufs;
std::array<std::unique_ptr<uint8_t>, 2> imagebufs;
std::unique_ptr<QWidget> current;