Significantly improve renderer performance
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include <QImage>
|
||||
#include "qt_gleswidget.hpp"
|
||||
#ifdef __APPLE__
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
@@ -53,13 +54,20 @@ void GLESWidget::resizeGL(int w, int h)
|
||||
void GLESWidget::initializeGL()
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
connect(this, &GLESWidget::reqUpdate, this, &GLESWidget::reqUpdate_);
|
||||
}
|
||||
|
||||
void GLESWidget::paintGL()
|
||||
{
|
||||
QPainter painter(this);
|
||||
//painter.fillRect(rect, QColor(0, 0, 0));
|
||||
painter.drawImage(QRect(0, 0, width(), height()), m_image.convertToFormat(QImage::Format_RGBA8888), QRect(sx, sy, sw, sh));
|
||||
painter.drawImage(QRect(0, 0, width(), height()), m_image.convertToFormat(QImage::Format_RGBX8888), QRect(sx, sy, sw, sh));
|
||||
painter.end();
|
||||
firstupdate = true;
|
||||
}
|
||||
|
||||
void GLESWidget::reqUpdate_()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void GLESWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
@@ -114,8 +122,7 @@ void GLESWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void GLESWidget::qt_real_blit(int x, int y, int w, int h)
|
||||
{
|
||||
// printf("Offpainter thread ID: %X\n", SDL_ThreadID());
|
||||
if ((w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL))
|
||||
if ((w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || !firstupdate)
|
||||
{
|
||||
video_blit_complete();
|
||||
return;
|
||||
@@ -124,7 +131,7 @@ void GLESWidget::qt_real_blit(int x, int y, int w, int h)
|
||||
sy = y;
|
||||
sw = this->w = w;
|
||||
sh = this->h = h;
|
||||
auto imagebits = m_image.bits();
|
||||
static auto imagebits = m_image.bits();
|
||||
for (int y1 = y; y1 < (y + h - 1); y1++)
|
||||
{
|
||||
auto scanline = imagebits + (y1 * (2048 + 64) * 4);
|
||||
@@ -135,5 +142,5 @@ void GLESWidget::qt_real_blit(int x, int y, int w, int h)
|
||||
video_screenshot((uint32_t *)imagebits, 0, 0, 2048 + 64);
|
||||
}
|
||||
video_blit_complete();
|
||||
update();
|
||||
this->reqUpdate();
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class GLESWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -38,9 +40,13 @@ public:
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
signals:
|
||||
void reqUpdate();
|
||||
|
||||
public slots:
|
||||
void qt_real_blit(int x, int y, int w, int h);
|
||||
void qt_mouse_poll();
|
||||
void reqUpdate_();
|
||||
|
||||
private:
|
||||
struct mouseinputdata {
|
||||
@@ -48,5 +54,5 @@ private:
|
||||
int mousebuttons;
|
||||
};
|
||||
mouseinputdata mousedata;
|
||||
|
||||
std::atomic<bool> firstupdate{false};
|
||||
};
|
||||
|
@@ -44,8 +44,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
video_setblit(qt_blit);
|
||||
ui->glesWidget->setMouseTracking(true);
|
||||
|
||||
connect(this, &MainWindow::blitToWidget, ui->glesWidget, &GLESWidget::qt_real_blit);
|
||||
|
||||
connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection);
|
||||
|
||||
connect(this, &MainWindow::setTitleForNonQtThread, this, &MainWindow::setTitle_, Qt::BlockingQueuedConnection);
|
||||
@@ -702,6 +700,11 @@ void MainWindow::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::blitToWidget(int x, int y, int w, int h)
|
||||
{
|
||||
ui->glesWidget->qt_real_blit(x, y, w, h);
|
||||
}
|
||||
|
||||
void MainWindow::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
|
@@ -22,9 +22,9 @@ public:
|
||||
void showMessage(const QString& header, const QString& message);
|
||||
void setTitle(const wchar_t* title);
|
||||
void getTitle(wchar_t* title);
|
||||
void blitToWidget(int x, int y, int w, int h);
|
||||
signals:
|
||||
void paint(const QImage& image);
|
||||
void blitToWidget(int x, int y, int w, int h);
|
||||
void resizeContents(int w, int h);
|
||||
void pollMouse();
|
||||
void updateStatusBarPanes();
|
||||
|
Reference in New Issue
Block a user