Merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-dont-be-dumb into lp:ubuntu-docviewer-app

Proposed by Stefano Verzegnassi
Status: Superseded
Proposed branch: lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-dont-be-dumb
Merge into: lp:ubuntu-docviewer-app
Diff against target: 202 lines (+56/-40)
5 files modified
src/plugin/libreofficetoolkit-qml-plugin/config.h (+2/-3)
src/plugin/libreofficetoolkit-qml-plugin/loview.cpp (+44/-32)
src/plugin/libreofficetoolkit-qml-plugin/loview.h (+1/-1)
src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp (+2/-3)
src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h (+7/-1)
To merge this branch: bzr merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-dont-be-dumb
Reviewer Review Type Date Requested Status
Ubuntu Document Viewer Developers Pending
Review via email: mp+277517@code.launchpad.net
To post a comment you must log in.
199. By Stefano Verzegnassi

Disable debug flags

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/config.h'
2--- src/plugin/libreofficetoolkit-qml-plugin/config.h 2015-10-13 19:08:48 +0000
3+++ src/plugin/libreofficetoolkit-qml-plugin/config.h 2015-11-15 14:24:21 +0000
4@@ -18,17 +18,16 @@
5 #ifndef CONFIG_H
6 #define CONFIG_H
7
8-// FIXME: Perhaps we want to use smaller tiles on mobile devices?
9 #define TILE_SIZE 256.0
10
11 // Uncomment it if you want to see tiles boundaries
12-//#define DEBUG_SHOW_TILE_BORDER
13+#define DEBUG_SHOW_TILE_BORDER
14
15 // Uncomment for benchmarking tile rendering performance
16 //#define DEBUG_TILE_BENCHMARK
17
18 // Uncomment if you want more verbose application output
19-//#define DEBUG_VERBOSE
20+#define DEBUG_VERBOSE
21
22 #include <QDir>
23 #include <QStandardPaths>
24
25=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
26--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-10-18 21:27:16 +0000
27+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-11-15 14:24:21 +0000
28@@ -238,17 +238,24 @@
29 }
30 }
31
32- // Update information about the visible area
33- m_visibleArea.setRect(m_parentFlickable->property("contentX").toInt(),
34- m_parentFlickable->property("contentY").toInt(),
35- m_parentFlickable->width(),
36- m_parentFlickable->height());
37-
38- // Update information about the buffer area
39- m_bufferArea.setRect(qMax(0, m_visibleArea.x() - m_cacheBuffer),
40- qMax(0, m_visibleArea.y() - m_cacheBuffer),
41- qMin(int(this->width() - m_bufferArea.x()), m_visibleArea.width() + (m_cacheBuffer * 2)),
42- qMin(int(this->height() - m_bufferArea.y()), m_visibleArea.height() + (m_cacheBuffer * 2)));
43+ // Just for convenience.
44+ QRect documentRect(this->boundingRect().toRect());
45+
46+ // Update visible area
47+ QRect visibleRect(m_parentFlickable->property("contentX").toInt(),
48+ m_parentFlickable->property("contentY").toInt(),
49+ m_parentFlickable->width(),
50+ m_parentFlickable->height());
51+
52+ m_visibleArea = visibleRect.intersected(documentRect);
53+
54+ // Update buffer area
55+ QRect bufferRect(m_visibleArea.left() - m_cacheBuffer,
56+ m_visibleArea.top() - m_cacheBuffer,
57+ m_visibleArea.width() + (m_cacheBuffer * 2),
58+ m_visibleArea.height() + (m_cacheBuffer * 2));
59+
60+ m_bufferArea = bufferRect.intersected(documentRect);
61
62 // Delete tiles that are outside the loading area
63 if (!m_tiles.isEmpty()) {
64@@ -273,21 +280,9 @@
65 }
66 }
67
68- /*
69- FIXME: It seems that LOView loads more tiles than necessary.
70- This can be easily tested with DEBUG_SHOW_TILE_BORDER enabled.
71-
72- Step to reproduce:
73- 1) Open Document Viewer
74- 2) Resize the window, BEFORE opening any LibreOffice document
75- (Trying to resize the window or scrolling the Flickable when the
76- document is already loaded causes bad flickering)
77- 3) Outside the document area, at the bottom-right corner, there are
78- a few tiles that should not be visible/rendered/generated.
79- */
80-
81 // Number of tiles per row
82 int tilesPerWidth = qCeil(this->width() / TILE_SIZE);
83+ int tilesPerHeight = qCeil(this->height() / TILE_SIZE);
84
85 // Get indexes for visible tiles
86 int visiblesFromWidth = int(m_visibleArea.left() / TILE_SIZE);
87@@ -301,18 +296,35 @@
88 int bufferToWidth = qCeil(qreal(m_bufferArea.right()) / TILE_SIZE);
89 int bufferToHeight = qCeil(qreal(m_bufferArea.bottom()) / TILE_SIZE);
90
91- this->generateTiles(visiblesFromWidth, visiblesFromHeight, visiblesToWidth, visiblesToHeight, tilesPerWidth);
92- this->generateTiles(bufferFromWidth, bufferFromHeight, bufferToWidth, bufferToHeight, tilesPerWidth);
93+#ifdef DEBUG_VERBOSE
94+ qDebug() << "Visible area - Left:" << visiblesFromWidth << "Right:" << visiblesToWidth << "Top:" << visiblesFromHeight << "Bottom:" << visiblesToHeight;
95+ qDebug() << "Buffer area - Left:" << bufferFromWidth << "Right:" << bufferToWidth << "Top:" << bufferFromHeight << "Bottom:" << bufferToHeight;
96+#endif
97+
98+ this->generateTiles(visiblesFromWidth, visiblesFromHeight, visiblesToWidth, visiblesToHeight, tilesPerWidth, tilesPerHeight);
99+ this->generateTiles(bufferFromWidth, bufferFromHeight, bufferToWidth, bufferToHeight, tilesPerWidth, tilesPerHeight);
100 }
101
102-void LOView::generateTiles(int x1, int y1, int x2, int y2, int tilesPerWidth)
103+void LOView::generateTiles(int x1, int y1, int x2, int y2, int tilesPerWidth, int tilesPerHeight)
104 {
105 for (int x = x1; x < x2; x++) {
106 for (int y = y1; y < y2; y++) {
107- QRect tileRect(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
108- int index = y * tilesPerWidth + x;
109-
110- this->createTile(index, tileRect);
111+ bool lastRow = (y == (tilesPerHeight - 1));
112+ bool lastColumn = (x == (tilesPerWidth - 1));
113+
114+ int left = TILE_SIZE * x;
115+ int top = TILE_SIZE * y;
116+ int width = lastColumn ? this->width() - left : TILE_SIZE;
117+ int height = lastRow ? this->height() - top : TILE_SIZE;
118+
119+ QRect tileRect(left, top, width, height);
120+ int index = x + tilesPerWidth * y;
121+
122+ createTile(index, tileRect);
123+
124+#ifdef DEBUG_VERBOSE
125+ qDebug() << "Generating tile - Index:" << index << "X:" << x << "Y:" << y;
126+#endif
127 }
128 }
129 }
130@@ -327,7 +339,7 @@
131 {
132 if (!m_tiles.contains(index)) {
133 #ifdef DEBUG_VERBOSE
134- qDebug() << "Creating tile indexed as" << index;
135+ qDebug() << "Creating tile indexed as" << index << "- Rect:" << rect;
136 #endif
137
138 auto tile = new SGTileItem(rect, m_zoomFactor, RenderEngine::getNextId(), this);
139
140=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.h'
141--- src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-10-11 11:27:29 +0000
142+++ src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-11-15 14:24:21 +0000
143@@ -103,7 +103,7 @@
144
145 QMap<int, SGTileItem*> m_tiles;
146
147- void generateTiles(int x1, int y1, int x2, int y2, int tilesPerWidth);
148+ void generateTiles(int x1, int y1, int x2, int y2, int tilesPerWidth, int tilesPerHeight);
149 void createTile(int index, QRect rect);
150 void setZoomMode(const ZoomMode zoomMode);
151 bool updateZoomIfAutomatic();
152
153=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp'
154--- src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp 2015-10-12 00:02:26 +0000
155+++ src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp 2015-11-15 14:24:21 +0000
156@@ -1,6 +1,5 @@
157 #include "sgtileitem.h"
158 #include "lodocument.h"
159-#include "config.h"
160
161 #include <QQuickWindow>
162 #include <QSGSimpleTextureNode>
163@@ -51,9 +50,9 @@
164 }
165
166 #ifdef DEBUG_SHOW_TILE_BORDER
167-void SGTileItem::drawTileBorders(QSGNode* basicNode)
168+void SGTileItem::drawTileBorders(QSGSimpleTextureNode* parentNode)
169 {
170- auto node = basicNode;
171+ auto node = parentNode;
172 auto tileBorderGeometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 8);
173 tileBorderGeometry->setDrawingMode(GL_LINES);
174 tileBorderGeometry->setLineWidth(4);
175
176=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h'
177--- src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h 2015-10-11 11:27:29 +0000
178+++ src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h 2015-11-15 14:24:21 +0000
179@@ -4,8 +4,14 @@
180 #include <QQuickItem>
181 #include <QImage>
182
183+#include "config.h"
184+
185 class LODocument;
186
187+#ifdef DEBUG_SHOW_TILE_BORDER
188+class QSGSimpleTextureNode;
189+#endif
190+
191 class SGTileItem : public QQuickItem
192 {
193 Q_OBJECT
194@@ -31,7 +37,7 @@
195
196 private:
197 #ifdef DEBUG_SHOW_TILE_BORDER
198- void drawTileBorders(QSGNode* basicNode);
199+ void drawTileBorders(QSGSimpleTextureNode *parentNode);
200 #endif
201
202 private:

Subscribers

People subscribed via source and target branches