From d4e9686cd9c84a6f371697d40a1bb5cc72c6a655 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Fri, 3 Dec 2021 15:12:23 +0100 Subject: [PATCH] couple of simplifications * in paint: we can draw the m_image directly, no need to convert it * in blit: static auto imagebits = m_image.bits(); should not be static * in blit: we can bulk copy the entire image, no need to iterate horizontal lines --- src/qt/qt_gleswidget.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/qt/qt_gleswidget.cpp b/src/qt/qt_gleswidget.cpp index 5bab0910d..2348dc27e 100644 --- a/src/qt/qt_gleswidget.cpp +++ b/src/qt/qt_gleswidget.cpp @@ -67,7 +67,7 @@ void GLESWidget::paintGL() { std::scoped_lock lock(image_mx); QPainter painter(this); - 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, QRect(sx, sy, sw, sh)); } void GLESWidget::mouseReleaseEvent(QMouseEvent *event) @@ -141,12 +141,9 @@ void GLESWidget::qt_real_blit(int x, int y, int w, int h) sy = y; sw = this->w = w; sh = this->h = h; - static auto imagebits = m_image.bits(); - for (int y1 = y; y1 < (y + h - 1); y1++) - { - auto scanline = imagebits + (y1 * (2048 + 64) * 4); - video_copy(scanline + (x * 4), &(buffer32->line[y1][x]), w * 4); - } + auto imagebits = m_image.bits(); + video_copy(imagebits + y * ((2048 + 64) * 4) + x * 4, &(buffer32->line[y][x]), h * (2048 + 64) * sizeof(uint32_t)); + if (screenshots) { video_screenshot((uint32_t *)imagebits, 0, 0, 2048 + 64);