Skip to content

Commit

Permalink
TEMP: draw via pixmap
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Mar 13, 2024
1 parent 1d6ef57 commit 00304d5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
39 changes: 26 additions & 13 deletions vncviewer/abstractvncview.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -696,31 +696,44 @@ void QAbstractVNCView::updateWindow()
int w = rect.br.x - x;
int h = rect.br.y - y;
if (!rect.is_empty()) {
damage += QRect(x, y, w, h);
update(x, y, w, h);
}
}

void QAbstractVNCView::paintEvent(QPaintEvent *event)
{
QRect rect = event->rect();
int x = rect.x();
int y = rect.y();
int w = rect.width();
int h = rect.height();

QVNCConnection *cc = AppManager::instance()->connection();
PlatformPixelBuffer *framebuffer = static_cast<PlatformPixelBuffer*>(cc->framebuffer());

QPainter painter(this);
if ((framebuffer->width() != pixmap.width()) ||
(framebuffer->height() != pixmap.height())) {
pixmap = QPixmap(framebuffer->width(), framebuffer->height());
damage = QRegion(0, 0, pixmap.width(), pixmap.height());
}

if (!damage.isEmpty()) {
QPainter pixmapPainter(&pixmap);
const uint8_t *data;
int stride;
QRect bounds = damage.boundingRect();
int x = bounds.x();
int y = bounds.y();
int w = bounds.width();
int h = bounds.height();
rfb::Rect rfbrect(x, y, x+w, y+h);

const uint8_t *data;
int stride;
rfb::Rect rfbrect(x, y, x+w, y+h);
data = framebuffer->getBuffer(rfbrect, &stride);
QImage image(data, w, h, stride*4, QImage::Format_RGB32);

data = framebuffer->getBuffer(rfbrect, &stride);
QImage image(data, w, h, stride*4, QImage::Format_RGB32);
pixmapPainter.drawImage(bounds, image);
damage = QRegion();
}

QPainter painter(this);
QRect rect = event->rect();

painter.drawImage(rect, image);
painter.drawPixmap(rect, pixmap, rect);
}

void QAbstractVNCView::handleDesktopSize()
Expand Down
3 changes: 3 additions & 0 deletions vncviewer/abstractvncview.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public slots:
void delayedInitialized();

protected:
QPixmap pixmap;
QRegion damage;

static QClipboard *clipboard_;
QByteArray geometry_;
double devicePixelRatio_;
Expand Down

0 comments on commit 00304d5

Please sign in to comment.