summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-02-14 10:49:57 -0500
committerAshod Nakashian <ashnakash@gmail.com>2019-02-22 15:34:45 +0100
commit17a477c35cc43f37946dcea2b7c27f0f6571e118 (patch)
tree1c0762b447ea4ae0ebf9c4dac49b08dbce60ee7f /desktop
parent1666b302403e97d5fe92c963d745947554da6906 (diff)
LOK: Cache RectangleAndPart payloads
Change-Id: I3a2d98426729ad1b4e43a8f657b512679be82c26 Reviewed-on: https://gerrit.libreoffice.org/67891 Tested-by: Jenkins Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/inc/lib/init.hxx8
-rw-r--r--desktop/source/lib/init.cxx26
2 files changed, 29 insertions, 5 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index b02329e7f955..66696757292a 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -15,6 +15,8 @@
#include <memory>
#include <mutex>
+#include <boost/variant.hpp>
+
#include <osl/thread.h>
#include <rtl/ref.hxx>
#include <vcl/idle.hxx>
@@ -98,8 +100,14 @@ namespace desktop {
{
}
+ /// Parse and set the RectangleAndPart object and return it. Clobbers PayloadString.
+ RectangleAndPart& setRectangleAndPart(const std::string& payload);
+ /// Return the parsed RectangleAndPart instance.
+ const RectangleAndPart& getRectangleAndPart() const;
+
int Type;
std::string PayloadString;
+ boost::variant<boost::blank, RectangleAndPart> PayloadObject;
};
typedef std::vector<CallbackData> queue_type;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ea830cf67fbd..d2e732e53497 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -452,6 +452,20 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
aRet.m_nPart = nPart;
return aRet;
}
+
+RectangleAndPart& CallbackFlushHandler::CallbackData::setRectangleAndPart(const std::string& payload)
+{
+ PayloadString = payload;
+
+ PayloadObject = RectangleAndPart::Create(payload);
+ return boost::get<RectangleAndPart>(PayloadObject);
+}
+
+const RectangleAndPart& CallbackFlushHandler::CallbackData::getRectangleAndPart() const
+{
+ return boost::get<RectangleAndPart>(PayloadObject);
+}
+
}
namespace {
@@ -840,9 +854,11 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d
void CallbackFlushHandler::queue(const int type, const char* data)
{
- std::string payload(data ? data : "(nil)");
+ CallbackData aCallbackData(type, (data ? data : "(nil)"));
+ std::string& payload = aCallbackData.PayloadString;
SAL_INFO("lok", "Queue: " << type << " : " << payload);
+
if (m_bPartTilePainting)
{
// We drop notifications when this is set, except for important ones.
@@ -999,7 +1015,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_INVALIDATE_TILES:
{
- RectangleAndPart rcNew = RectangleAndPart::Create(payload);
+ RectangleAndPart& rcNew = aCallbackData.setRectangleAndPart(payload);
if (rcNew.isEmpty())
{
SAL_INFO("lok", "Skipping invalid event [" << type << "]: [" << payload << "].");
@@ -1012,7 +1028,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
[] (const queue_type::value_type& elem) { return (elem.Type == LOK_CALLBACK_INVALIDATE_TILES); });
if (pos != m_queue.rend())
{
- const RectangleAndPart rcOld = RectangleAndPart::Create(pos->PayloadString);
+ const RectangleAndPart& rcOld = pos->getRectangleAndPart();
if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart))
{
SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload << "] since all tiles need to be invalidated.");
@@ -1056,7 +1072,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
[&rcNew] (const queue_type::value_type& elem) {
if (elem.Type == LOK_CALLBACK_INVALIDATE_TILES)
{
- const RectangleAndPart rcOld = RectangleAndPart::Create(elem.PayloadString);
+ const RectangleAndPart& rcOld = elem.getRectangleAndPart();
if (rcNew.m_nPart != -1 && rcOld.m_nPart != -1 && rcOld.m_nPart != rcNew.m_nPart)
{
SAL_INFO("lok", "Nothing to merge between new: " << rcNew.toString() << ", and old: " << rcOld.toString());
@@ -1267,7 +1283,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
}
}
- m_queue.emplace_back(type, payload);
+ m_queue.emplace_back(aCallbackData);
SAL_INFO("lok", "Queued #" << (m_queue.size() - 1) <<
" [" << type << "]: [" << payload << "] to have " << m_queue.size() << " entries.");