ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04902
[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-scenegraph-rendering into lp:ubuntu-docviewer-app/reboot
Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-scenegraph-rendering into lp:ubuntu-docviewer-app/reboot.
Commit message:
QtQuick SceneGraph rendering, with multithreading support.
Includes changes from: lp:~mrqtros/ubuntu-docviewer-app/docviewer-sg-rendering
Requested reviews:
Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/reboot-scenegraph-rendering/+merge/270809
QtQuick SceneGraph rendering, with multithreading support.
Includes changes from: lp:~mrqtros/ubuntu-docviewer-app/docviewer-sg-rendering
--
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-scenegraph-rendering into lp:ubuntu-docviewer-app/reboot.
=== modified file 'src/app/CMakeLists.txt'
--- src/app/CMakeLists.txt 2015-04-29 16:06:32 +0000
+++ src/app/CMakeLists.txt 2015-09-11 12:40:32 +0000
@@ -19,7 +19,7 @@
add_executable(ubuntu-docviewer-app ${docviewer_SRCS})
-qt5_use_modules(ubuntu-docviewer-app Widgets Gui Qml Quick DBus)
+qt5_use_modules(ubuntu-docviewer-app Widgets Gui Qml Quick DBus Concurrent)
target_link_libraries( ubuntu-docviewer-app
${CONTENTHUB_LIBRARIES}
=== modified file 'src/app/command-line-parser.cpp'
--- src/app/command-line-parser.cpp 2015-04-29 15:23:32 +0000
+++ src/app/command-line-parser.cpp 2015-09-11 12:40:32 +0000
@@ -30,8 +30,8 @@
CommandLineParser::CommandLineParser()
: m_pickMode(false),
+ m_isFullscreen(false),
m_testability(false),
- m_isFullscreen(false),
m_documentFile(""),
m_documentsDir("")
{
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/CMakeLists.txt'
--- src/plugin/libreofficetoolkit-qml-plugin/CMakeLists.txt 2015-08-25 22:35:28 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/CMakeLists.txt 2015-09-11 12:40:32 +0000
@@ -1,9 +1,13 @@
set(PLUGIN_DIR DocumentViewer/LibreOffice)
-file(GLOB_RECURSE QML_SRCS *.qml *.js)
+file(GLOB_RECURSE QML_SRCS
+ qml/*.qml
+ qml/*.js
+)
+
include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/LibreOfficeKit/
)
@@ -12,7 +16,7 @@
plugin.cpp
lodocument.cpp
loview.cpp
- tileitem.cpp
+ sgtileitem.cpp
${QML_SRCS}
)
=== removed file 'src/plugin/libreofficetoolkit-qml-plugin/LOViewer.qml'
--- src/plugin/libreofficetoolkit-qml-plugin/LOViewer.qml 2015-07-26 17:33:51 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LOViewer.qml 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical, Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-import QtQuick 2.4
-import DocumentViewer.LibreOffice 1.0 as LibreOffice
-
-Flickable {
- id: rootFlickable
-
- property alias document: view.document
- property alias zoomFactor: view.zoomFactor
- property alias cacheBuffer: view.cacheBuffer
-
- contentHeight: view.height * view.zoomFactor
- contentWidth: view.width * view.zoomFactor
-
- boundsBehavior: Flickable.StopAtBounds
-
- LibreOffice.View {
- id: view
-
- parentFlickable: rootFlickable
- }
-}
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-07-23 01:05:20 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-09-11 12:40:32 +0000
@@ -28,6 +28,10 @@
// TODO: Error management
+#ifdef DEBUG_TILE_BENCHMARK
+#include <QElapsedTimer>
+#endif
+
lok::Office *LODocument::s_office = nullptr;
LODocument::LODocument()
@@ -105,6 +109,12 @@
QImage LODocument::paintTile(QSize canvasSize, QRect tileSize)
{
QImage result = QImage(canvasSize.width(), canvasSize.height(), QImage::Format_RGB32);
+
+#ifdef DEBUG_TILE_BENCHMARK
+ QElapsedTimer renderTimer;
+ renderTimer.start();
+#endif
+
m_document->paintTile(result.bits(),
canvasSize.width(), canvasSize.height(),
Twips::convertPixelsToTwips(tileSize.x()),
@@ -112,6 +122,10 @@
Twips::convertPixelsToTwips(tileSize.width()),
Twips::convertPixelsToTwips(tileSize.height()));
+#ifdef DEBUG_TILE_BENCHMARK
+ qDebug() << "Time to render the tile:" << renderTimer.elapsed() << "ms";
+#endif
+
return result.rgbSwapped();
}
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-07-26 17:33:51 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-09-11 12:40:32 +0000
@@ -16,7 +16,7 @@
#include "loview.h"
#include "lodocument.h"
-#include "tileitem.h"
+#include "sgtileitem.h"
#include "twips.h"
#include "config.h"
@@ -25,11 +25,8 @@
#include <QTimer>
#include <QtCore/qmath.h>
-// TODO: Use a QQuickItem and implement painting through
-// updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * data)
-
LOView::LOView(QQuickItem *parent)
- : QQuickPaintedItem(parent)
+ : QQuickItem(parent)
, m_parentFlickable(nullptr)
, m_document(nullptr)
, m_zoomFactor(1.0)
@@ -46,18 +43,6 @@
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateVisibleRect()));
}
-void LOView::paint(QPainter *painter)
-{
- Q_FOREACH(TileItem* tile, m_tiles) {
- painter->drawImage(tile->area(), tile->texture());
- tile->setPainted(true);
-
-#ifdef DEBUG_SHOW_TILE_BORDER
- painter->drawRect(tile->area());
-#endif
- }
-}
-
// Returns the parent QML Flickable
QQuickItem* LOView::parentFlickable() const
{
@@ -170,21 +155,37 @@
if (!m_tiles.isEmpty()) {
auto i = m_tiles.begin();
while (i != m_tiles.end()) {
- TileItem* tile = i.value();
-
- if (!m_bufferArea.intersects(tile->area())) {
- tile->releaseTexture();
- i = m_tiles.erase(i);
-
-#ifdef DEBUG_VERBOSE
- qDebug() << "Removing tile indexed as" << i.key();
-#endif
- } else {
- ++i;
+ SGTileItem* sgtile = i.value();
+
+ // Ok - we still need this item.
+ if (m_bufferArea.intersects(sgtile->area())) {
+ i++;
+ continue;
}
+
+ // Out of buffer - we should delete this item.
+#ifdef DEBUG_VERBOSE
+ qDebug() << "Removing tile indexed as" << i.key();
+#endif
+
+ sgtile->dispose();
+ i = m_tiles.erase(i);
}
}
+ /*
+ FIXME: It seems that LOView loads more tiles than necessary.
+ This can be easily tested with DEBUG_SHOW_TILE_BORDER enabled.
+
+ Step to reproduce:
+ 1) Open Document Viewer
+ 2) Resize the window, BEFORE opening any LibreOffice document
+ (Trying to resize the window or scrolling the Flickable when the
+ document is already loaded causes bad flickering)
+ 3) Outside the document area, at the bottom-right corner, there are
+ a few tiles that should not be visible/rendered/generated.
+ */
+
// Number of tiles per row
int tilesPerWidth = qCeil(this->width() / TILE_SIZE);
@@ -223,11 +224,7 @@
qDebug() << "Creating tile indexed as" << index;
#endif
- auto tile = new TileItem(rect, m_document);
- connect(tile, SIGNAL(textureChanged()), this, SLOT(update()));
- tile->requestTexture();
-
- // Append the tile in the map
+ auto tile = new SGTileItem(rect, m_document, this);
m_tiles.insert(index, tile);
}
#ifdef DEBUG_VERBOSE
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.h'
--- src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-07-26 17:33:51 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-09-11 12:40:32 +0000
@@ -18,12 +18,14 @@
#define LOVIEW_H
#include <QQuickPaintedItem>
+#include <QQuickItem>
#include <QTimer>
class LODocument;
class TileItem;
+class SGTileItem;
-class LOView : public QQuickPaintedItem
+class LOView : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QQuickItem* parentFlickable READ parentFlickable WRITE setParentFlickable NOTIFY parentFlickableChanged)
@@ -37,8 +39,6 @@
LOView(QQuickItem *parent = 0);
~LOView();
- void paint(QPainter *painter);
-
QQuickItem* parentFlickable() const;
void setParentFlickable(QQuickItem* flickable);
@@ -74,7 +74,7 @@
QTimer m_updateTimer;
- QMap<int, TileItem*> m_tiles;
+ QMap<int, SGTileItem*> m_tiles;
void generateTiles(int x1, int y1, int x2, int y2, int tilesPerWidth);
void createTile(int index, QRect rect);
=== added directory 'src/plugin/libreofficetoolkit-qml-plugin/qml'
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml'
--- src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml 2015-09-11 12:40:32 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.4
+import DocumentViewer.LibreOffice 1.0 as LibreOffice
+
+Flickable {
+ id: rootFlickable
+
+ property alias document: view.document
+ property alias zoomFactor: view.zoomFactor
+ property alias cacheBuffer: view.cacheBuffer
+
+ contentHeight: view.height * view.zoomFactor
+ contentWidth: view.width * view.zoomFactor
+
+ boundsBehavior: Flickable.StopAtBounds
+
+ LibreOffice.View {
+ id: view
+
+ parentFlickable: rootFlickable
+ }
+}
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/qmldir'
--- src/plugin/libreofficetoolkit-qml-plugin/qmldir 2015-07-04 16:00:33 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/qmldir 2015-09-11 12:40:32 +0000
@@ -1,4 +1,4 @@
module DocumentViewer.LibreOffice
plugin libreofficetoolkitqmlplugin
-Viewer 1.0 LOViewer.qml
+Viewer 1.0 Viewer.qml
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp 2015-09-11 12:40:32 +0000
@@ -0,0 +1,118 @@
+#include "sgtileitem.h"
+
+#include "lodocument.h"
+#include "config.h"
+
+#ifdef DEBUG_SHOW_TILE_BORDER
+#include <QSGGeometryNode>
+#include <QSGFlatColorMaterial>
+#endif
+
+SGTileItem::SGTileItem(const QRect &area, LODocument *document, QQuickItem *parent)
+ : QQuickItem(parent)
+ , m_area(area)
+ , m_document(document)
+ , m_state(SgstInitial)
+{
+ setFlag(ItemHasContents, true);
+}
+
+SGTileItem::~SGTileItem()
+{ }
+
+void SGTileItem::dispose()
+{
+ if (m_state.loadAcquire() != SgstRendering)
+ deleteLater();
+ m_state.storeRelease(SgstDisposed);
+
+#ifdef DEBUG_VERBOSE
+ qDebug() << "---- dispose called: " << this << m_state;
+#endif
+}
+
+QSGNode *SGTileItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
+{
+ QSGSimpleTextureNode* node = static_cast<QSGSimpleTextureNode*>(oldNode);
+ QQuickWindow* wnd = window();
+
+ if (!node && wnd) {
+ if (this->m_state.loadAcquire() == SgstInitial) {
+ m_state.storeRelease(SgstRendering);
+
+ QtConcurrent::run( [=] {
+ if (!m_document)
+ return;
+
+ QImage img;
+
+ // By this time already can be disposed, so it's better to ckeck again.
+ if (this->m_state.loadAcquire() == SgstRendering)
+ img = m_document->paintTile(this->area().size(), this->area());
+
+#ifdef DEBUG_VERBOSE
+ else if (this->m_state.loadAcquire() == SgstDisposed)
+ qDebug() << "Already disposed:" << m_state.loadAcquire();
+#endif
+
+ QMetaObject::invokeMethod(this, "renderCallback", Q_ARG(QImage, img));
+ });
+ } else if (m_state.loadAcquire() == SgstActive) {
+ QImage image = m_data;
+ auto texture = wnd->createTextureFromImage(image);
+ node = new QSGSimpleTextureNode();
+ node->setTexture(texture);
+ node->setOwnsTexture(true);
+ node->setRect(m_area);
+
+#ifdef DEBUG_SHOW_TILE_BORDER
+ auto tileBorderGeometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 8);
+ tileBorderGeometry->setDrawingMode(GL_LINES);
+ tileBorderGeometry->setLineWidth(4);
+
+ QSGGeometry::Point2D* vertex = tileBorderGeometry->vertexDataAsPoint2D();
+ vertex[0].set(node->rect().left(), node->rect().top());
+ vertex[1].set(node->rect().left(), node->rect().bottom());
+
+ vertex[2].set(node->rect().right(), node->rect().top());
+ vertex[3].set(node->rect().right(), node->rect().bottom());
+
+ vertex[4].set(vertex[0].x, vertex[0].y);
+ vertex[5].set(vertex[2].x, vertex[2].y);
+
+ vertex[6].set(vertex[1].x, vertex[1].y);
+ vertex[7].set(vertex[3].x, vertex[3].y);
+
+ auto tileBorderMaterial = new QSGFlatColorMaterial;
+ tileBorderMaterial->setColor(Qt::red);
+
+ auto tileBorderNode = new QSGGeometryNode;
+
+ tileBorderNode->setGeometry(tileBorderGeometry);
+ tileBorderNode->setFlag(QSGNode::OwnsGeometry);
+
+ tileBorderNode->setMaterial(tileBorderMaterial);
+ tileBorderNode->setFlag(QSGNode::OwnsMaterial);
+
+ node->appendChildNode(tileBorderNode);
+#endif
+ }
+ }
+
+ return node;
+}
+
+void SGTileItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ QQuickItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void SGTileItem::renderCallback(QImage image)
+{
+ if (m_state.loadAcquire() == SgstRendering) {
+ m_data = image;
+ m_state.storeRelease(SgstActive);
+ update();
+ } else deleteLater();
+}
+
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h'
--- src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h 2015-09-11 12:40:32 +0000
@@ -0,0 +1,54 @@
+#ifndef SGTILEITEM_H
+#define SGTILEITEM_H
+
+#include <QQuickItem>
+#include <QQuickWindow>
+#include <QSGSimpleTextureNode>
+#include <QImage>
+#include <QtConcurrent/QtConcurrent>
+#include <QAtomicInteger>
+
+enum SGTileItemState
+{
+ SgstInitial = 1,
+ SgstRendering,
+ SgstActive,
+ SgstDisposed
+};
+
+class LODocument;
+
+class SGTileItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ SGTileItem(const QRect &area, LODocument *document, QQuickItem *parent = 0);
+ ~SGTileItem();
+
+ inline QRect area() const { return m_area; }
+ inline void setArea(const QRect &area) { m_area = area; }
+
+ inline LODocument* document() const { return m_document; }
+ inline void setDocument(LODocument* document) { m_document = document; }
+
+ void dispose();
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+ virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+
+private:
+ Q_INVOKABLE void renderCallback(QImage image);
+
+signals:
+
+private:
+ QRect m_area;
+ LODocument* m_document;
+ QImage m_data;
+ QAtomicInteger<int> m_state;
+
+public slots:
+};
+
+#endif // SGTILEITEM_H
=== removed file 'src/plugin/libreofficetoolkit-qml-plugin/tileitem.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/tileitem.cpp 2015-07-22 16:44:39 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/tileitem.cpp 1970-01-01 00:00:00 +0000
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical, Ltd.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Stefano Verzegnassi <stefano92.100@xxxxxxxxx>
- */
-
-#include "tileitem.h"
-#include "lodocument.h"
-#include "config.h"
-
-#include <QThreadPool>
-#include <QDebug>
-
-#ifdef DEBUG_TILE_BENCHMARK
-#include <QElapsedTimer>
-#endif
-
-/* ****************
- * TileItem class *
- ******************/
-
-TileItem::TileItem(const QRect &area, LODocument *document)
- : m_painted(false)
- , m_document(nullptr)
-{
- this->setArea(area);
- this->setDocument(document);
-}
-
-// Destructor
-TileItem::~TileItem()
-{
- this->releaseTexture();
-}
-
-QRect TileItem::area() const
-{
- return m_area;
-}
-
-void TileItem::setArea(const QRect &area)
-{
- if (m_area == area)
- return;
-
- m_area = area;
- Q_EMIT areaChanged();
-}
-
-QImage TileItem::texture() const
-{
- return m_texture;
-}
-
-bool TileItem::isPainted() const
-{
- return m_painted;
-}
-
-void TileItem::setPainted(bool isPainted)
-{
- if (m_painted == isPainted)
- return;
-
- m_painted = isPainted;
- Q_EMIT isPaintedChanged();
-}
-
-LODocument* TileItem::document() const
-{
- return m_document;
-}
-
-void TileItem::setDocument(LODocument* document)
-{
- if (m_document == document)
- return;
-
- m_document = document;
- Q_EMIT documentChanged();
-}
-
-void TileItem::requestTexture()
-{
- auto task = new RenderTask(this->area(), this->document());
- connect(task, SIGNAL(renderCompleted(QImage)), this, SLOT(updateTexture(QImage)));
-
- task->setAutoDelete(true);
- QThreadPool::globalInstance()->start(task);
-}
-
-// Free memory used by the texture
-void TileItem::releaseTexture()
-{
- if (m_texture.isNull())
- return;
-
- m_texture = QImage();
- Q_EMIT textureChanged();
-}
-
-// This is a slot, connect to renderCompleted() signal from RenderTask class.
-void TileItem::updateTexture(QImage t)
-{
- m_texture = t;
- Q_EMIT textureChanged();
-}
-
-/* ******************
- * RenderTask class *
- ********************/
-
-RenderTask::RenderTask(const QRect &area, LODocument* document)
-{
- this->setArea(area);
- this->setDocument(document);
-}
-
-
-QRect RenderTask::area() const
-{
- return m_area;
-}
-
-void RenderTask::setArea(const QRect &area)
-{
- if (m_area == area)
- return;
-
- m_area = area;
- Q_EMIT areaChanged();
-}
-
-LODocument* RenderTask::document() const
-{
- return m_document;
-}
-
-void RenderTask::setDocument(LODocument* document)
-{
- if (m_document == document)
- return;
-
- m_document = document;
- Q_EMIT documentChanged();
-}
-
-// Render the texture for this tile.
-void RenderTask::run()
-{
-#ifdef DEBUG_TILE_BENCHMARK
- QElapsedTimer renderTimer;
- renderTimer.start();
-#endif
-
- QImage render = this->document()->paintTile(this->area().size(),
- this->area());
-
- Q_EMIT renderCompleted(render);
-
-#ifdef DEBUG_TILE_BENCHMARK
- qDebug() << "Time to render the tile:" << renderTimer.elapsed() << "ms";
-#endif
-}
=== removed file 'src/plugin/libreofficetoolkit-qml-plugin/tileitem.h'
--- src/plugin/libreofficetoolkit-qml-plugin/tileitem.h 2015-07-13 23:49:43 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/tileitem.h 1970-01-01 00:00:00 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical, Ltd.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Stefano Verzegnassi <stefano92.100@xxxxxxxxx>
- */
-
-#ifndef TILEITEM_H
-#define TILEITEM_H
-
-#include <QRunnable>
-#include <QImage>
-
-class LODocument;
-
-class TileItem : public QObject
-{
- Q_OBJECT
-
-public:
- TileItem(const QRect &area, LODocument* document);
- ~TileItem();
-
- QRect area() const;
- void setArea(const QRect &area);
-
- QImage texture() const;
-
- bool isPainted() const;
- void setPainted(bool isPainted);
-
- LODocument* document() const;
- void setDocument(LODocument* document);
-
-public Q_SLOTS:
- void requestTexture();
- void releaseTexture();
-
-Q_SIGNALS:
- void areaChanged();
- void textureChanged();
- void isPaintedChanged();
- void documentChanged();
-
-private Q_SLOTS:
- void updateTexture(QImage t);
-
-private:
- QRect m_area;
- QImage m_texture;
- bool m_painted;
-
- LODocument* m_document;
-};
-
-class RenderTask : public QObject, public QRunnable
-{
- Q_OBJECT
-
-public:
- RenderTask(const QRect &area, LODocument* document);
-
- QRect area() const;
- void setArea(const QRect &area);
-
- LODocument* document() const;
- void setDocument(LODocument* document);
-
- void run();
-
-Q_SIGNALS:
- void areaChanged();
- void documentChanged();
- void renderCompleted(QImage t);
-
-private:
- QRect m_area;
- LODocument* m_document;
-};
-
-#endif // TILEITEM_H
Follow ups