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