← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~mrqtros/ubuntu-docviewer-app/lo-tiled-rendering-pixel-shift-bug into lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering

 

Roman Shchekin has proposed merging lp:~mrqtros/ubuntu-docviewer-app/lo-tiled-rendering-pixel-shift-bug into lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering.

Commit message:
* Format_RGB32 used instead of Format_ARGB32 (renders ~3 times faster). I have string feeling that LO toolkit won't provide tiles with alpha. 
 * Memory leak fixed.
 * Member m_office now become static s_office.

Requested reviews:
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)

For more details, see:
https://code.launchpad.net/~mrqtros/ubuntu-docviewer-app/lo-tiled-rendering-pixel-shift-bug/+merge/264506

* Format_RGB32 used instead of Format_ARGB32 (renders ~3 times faster). I have string feeling that LO toolkit won't provide tiles with alpha. 
 * Memory leak fixed.
 * Member m_office now become static s_office.
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~mrqtros/ubuntu-docviewer-app/lo-tiled-rendering-pixel-shift-bug into lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering.
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp	2015-07-11 10:47:02 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp	2015-07-12 21:31:09 +0000
@@ -32,6 +32,8 @@
 
 // TODO: Error management
 
+lok::Office *LODocument::s_office = nullptr;
+
 LODocument::LODocument()
   : m_path("")
   , m_document(nullptr)
@@ -68,12 +70,15 @@
         return false;
     }
 
-    m_office = lok::lok_cpp_init(LO_PATH);
-    m_document = m_office->documentLoad(m_path.toUtf8().constData());
+    if (!s_office)
+        s_office = lok::lok_cpp_init(LO_PATH);
+
+    m_document = s_office->documentLoad(m_path.toUtf8().constData());
 
     m_docType = DocumentType(m_document->getDocumentType());
     Q_EMIT documentTypeChanged();
 
+    m_document->initializeForRendering();
     qDebug() << "Document loaded successfully !";
 
     return true;
@@ -103,9 +108,7 @@
 // the rect tileSize.
 QImage LODocument::paintTile(QSize canvasSize, QRect tileSize)
 {
-    m_document->initializeForRendering();
-
-    QImage result = QImage(canvasSize.width(), canvasSize.height(),  QImage::Format_ARGB32);
+    QImage result = QImage(canvasSize.width(), canvasSize.height(),  QImage::Format_RGB32);
     m_document->paintTile(result.bits(),
                           canvasSize.width(), canvasSize.height(),
                           Twips::convertPixelsToTwips(tileSize.x()),
@@ -118,4 +121,5 @@
 
 LODocument::~LODocument()
 {
+    delete m_document;
 }

=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.h'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.h	2015-07-04 16:00:33 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.h	2015-07-12 21:31:09 +0000
@@ -64,8 +64,9 @@
 
     bool loadDocument(QString &pathNAme);
 
-    lok::Office *m_office;
     lok::Document *m_document;
+
+    static lok::Office *s_office;
 };
 
 #endif // LODOCUMENT_H

=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp	2015-07-05 17:30:56 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp	2015-07-12 21:31:09 +0000
@@ -46,7 +46,7 @@
 
 void LOView::paint(QPainter *painter)
 {
-    qDebug() << "Painting new tiles...";
+    // qDebug() << "Painting new tiles...";
 
     // Clean area outside the visible one
     painter->eraseRect(QRect(0, 0, m_visibleArea.right(), m_visibleArea.top()));  // TOP
@@ -55,8 +55,9 @@
     painter->eraseRect(QRect(m_visibleArea.right(), m_visibleArea.top(), this->width() - m_visibleArea.right(), m_visibleArea.height()));  // RIGHT
 
     Q_FOREACH(TileItem* tile, m_tiles) {
-       // if (!tile->painted) {
+        // if (!tile->painted) {
             painter->drawImage(tile->area, tile->texture);
+            // painter->drawRect(tile->area); // Uncomment to see tile borders.
             tile->painted = true;
         //}
     }
@@ -164,7 +165,7 @@
     // TODO: Do the same described above backwards from the last element.
     if (!m_tiles.isEmpty()) {
         // Delete tiles that are outside the loading area
-        QMap<int, TileItem*>::iterator b = m_tiles.begin();
+        auto b = m_tiles.begin();
         while (b != m_tiles.end()) {
             if (!loadingArea.intersects(b.value()->area)) {
                 qDebug() << "Removing tile indexed as" << b.key();


Follow ups