diff options
author | Ken Moore <ken@ixsystems.com> | 2017-07-19 15:34:05 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-07-19 15:35:23 -0400 |
commit | ef7735a27d66660ae8775ca3fef0af7b15926a85 (patch) | |
tree | 2a72349b12670a4809751988cd33fe38ac53149e /src-qt5/core/libLumina | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-ef7735a27d66660ae8775ca3fef0af7b15926a85.tar.gz lumina-ef7735a27d66660ae8775ca3fef0af7b15926a85.tar.bz2 lumina-ef7735a27d66660ae8775ca3fef0af7b15926a85.zip |
Get the compositing working much smoother now.
Only re-grab the X11 image when it changes, then store it for all paint events (including partial painting updates) - making things much faster to update on-demand.
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.cpp | 25 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.h | 1 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.cpp b/src-qt5/core/libLumina/NativeEmbedWidget.cpp index 80c843e0..34501f2a 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.cpp +++ b/src-qt5/core/libLumina/NativeEmbedWidget.cpp @@ -163,6 +163,11 @@ void NativeEmbedWidget::resyncWindow(){ } void NativeEmbedWidget::repaintWindow(){ + qDebug() << "Update Window Image"; + QImage tmp = windowImage( QRect(QPoint(0,0), this->size()) ); + if(!tmp.isNull()){ + winImage = tmp; + }else{ qDebug() << "Got Null Image!!"; } this->update(); } // ============== @@ -186,23 +191,17 @@ void NativeEmbedWidget::hideEvent(QHideEvent *ev){ } void NativeEmbedWidget::paintEvent(QPaintEvent *ev){ - //QWidget::paintEvent(ev); //ensure all the Qt-compositing is done first if(this->size()!=winSize){ return; } //do not paint here - waiting to re-sync the sizes if(WIN==0){ QWidget::paintEvent(ev); return; } //Need to paint the image from the window onto the widget as an overlay - QRect geom = QRect(0,0,this->width(), this->height()); //always paint the whole window - //qDebug() << "Get Paint image:" << ev->rect() << geom; - //geom = ev->rect(); //atomic updates - //geom.adjust(-1,-1,1,1); //add an additional pixel in each direction to be painted - //geom = geom.intersected(QRect(0,0,this->width(), this->height())); //ensure intersection with actual window - QImage img = windowImage(geom); - if(!img.isNull()){ - if(img.size() != geom.size()){ return; } + QRect geom = ev->rect(); //atomic updates + geom.adjust(-1,-1,1,1); //add an additional pixel in each direction to be painted + geom = geom.intersected(QRect(0,0,this->width(), this->height())); //ensure intersection with actual window + if(!winImage.isNull()){ + if( !QRect(QPoint(0,0),winImage.size()).contains(geom) ){ QTimer::singleShot(0,this, SLOT(repaintWindow()) );return; } QPainter P(this); - P.drawImage( geom , img, QRect(geom.topLeft(), img.size()), Qt::NoOpaqueDetection); //1-to-1 mapping - //qDebug() << "Painted Rect:" << ev->rect() << this->geometry(); + P.drawImage( geom , winImage, geom, Qt::NoOpaqueDetection); //1-to-1 mapping //Note: Qt::NoOpaqueDetection Speeds up the paint by bypassing the checks to see if there are [semi-]transparent pixels - // Since this is an embedded image - we fully expect there to be transparency most of the time. + // Since this is an embedded image - we fully expect there to be transparency all/most of the time. } - //qDebug() << "Done Painting"; } diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.h b/src-qt5/core/libLumina/NativeEmbedWidget.h index 78c11dfc..756c8317 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.h +++ b/src-qt5/core/libLumina/NativeEmbedWidget.h @@ -24,6 +24,7 @@ class NativeEmbedWidget : public QWidget{ private: NativeWindow *WIN; QSize winSize; + QImage winImage; private slots: //Simplification functions |