[Libreoffice-commits] online.git: loolwsd/bundled loolwsd/LOOLKit.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Fri May 6 15:06:55 UTC 2016


 loolwsd/LOOLKit.cpp                                     |   37 +++-------------
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h |   13 +++++
 2 files changed, 20 insertions(+), 30 deletions(-)

New commits:
commit 8e480d7ac12fbdad5a983e4ef594392b440f0b7c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri May 6 11:03:34 2016 -0400

    loolwsd: use paintPartTile and remove workarounds
    
    Change-Id: Ice59004a23919c7a77a00782f7210a83bc1464e7
    Reviewed-on: https://gerrit.libreoffice.org/24703
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 60b3e02..2f524cb 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -659,24 +659,11 @@ public:
 
         std::vector<unsigned char> pixmap;
         pixmap.resize(4 * width * height);
-        int oldPart = _loKitDocument->pClass->getPart(_loKitDocument);
-        if (part != oldPart)
-        {
-            if (editLock || id != -1)
-            {
-                _loKitDocument->pClass->setPart(_loKitDocument, part);
-            }
-            else
-            {
-                // Session without editlock cannot change part
-                Log::debug() << "Declining tile render request: " << response  << Log::end;
-                ws->sendFrame(response.data(), response.size());
-                return;
-            }
-        }
 
         Timestamp timestamp;
-        _loKitDocument->pClass->paintTile(_loKitDocument, pixmap.data(), width, height, tilePosX, tilePosY, tileWidth, tileHeight);
+        _loKitDocument->pClass->paintPartTile(_loKitDocument, pixmap.data(), part,
+                                              width, height, tilePosX, tilePosY,
+                                              tileWidth, tileHeight);
         Log::trace() << "paintTile at [" << tilePosX << ", " << tilePosY
                      << "] rendered in " << (timestamp.elapsed()/1000.) << " ms" << Log::end;
 
@@ -689,12 +676,6 @@ public:
             return;
         }
 
-        // restore the original part if tilepreview request changed the part
-        if (id != -1)
-        {
-            _loKitDocument->pClass->setPart(_loKitDocument, oldPart);
-        }
-
         const auto length = output.size();
         if (length > SMALL_MESSAGE_SIZE)
         {
@@ -789,11 +770,6 @@ public:
             tiles.push_back(rectangle);
         }
 
-        if (_docType != "text" && part != _loKitDocument->pClass->getPart(_loKitDocument))
-        {
-            _loKitDocument->pClass->setPart(_loKitDocument, part);
-        }
-
         LibreOfficeKitTileMode mode = static_cast<LibreOfficeKitTileMode>(_loKitDocument->pClass->getTileMode(_loKitDocument));
 
         int tilesByX = renderArea.getWidth() / tileWidth;
@@ -807,9 +783,10 @@ public:
         std::vector<unsigned char> pixmap(pixmapSize, 0);
 
         Timestamp timestamp;
-        _loKitDocument->pClass->paintTile(_loKitDocument, pixmap.data(), pixmapWidth, pixmapHeight,
-                                          renderArea.getLeft(), renderArea.getTop(),
-                                          renderArea.getWidth(), renderArea.getHeight());
+        _loKitDocument->pClass->paintPartTile(_loKitDocument, pixmap.data(), part,
+                                              pixmapWidth, pixmapHeight,
+                                              renderArea.getLeft(), renderArea.getTop(),
+                                              renderArea.getWidth(), renderArea.getHeight());
 
         Log::debug() << "paintTile (combined) called, tile at [" << renderArea.getLeft() << ", " << renderArea.getTop() << "]"
                     << " (" << renderArea.getWidth() << ", " << renderArea.getHeight() << ") rendered in "
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index 1281a21..110d4d5 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -228,6 +228,19 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::getPartHash().
     char* (*getPartHash) (LibreOfficeKitDocument* pThis,
                           int nPart);
+
+    /// Paints a tile from a specific part.
+    /// @see lok::Document::paintTile().
+    void (*paintPartTile) (LibreOfficeKitDocument* pThis,
+                           unsigned char* pBuffer,
+                           const int nPart,
+                           const int nCanvasWidth,
+                           const int nCanvasHeight,
+                           const int nTilePosX,
+                           const int nTilePosY,
+                           const int nTileWidth,
+                           const int nTileHeight);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 


More information about the Libreoffice-commits mailing list