summaryrefslogtreecommitdiff
path: root/kit
diff options
context:
space:
mode:
authorDarkByt31 <avihs.29@gmail.com>2019-09-15 07:34:06 +0530
committerMichael Meeks <michael.meeks@collabora.com>2019-09-28 12:51:18 +0200
commitef90709ad1cb6c8cbb649425d0f0c539bbd5f83f (patch)
tree5df106a24e9b43aca6140d08d4e13fc0d190fccb /kit
parentdd014e7029628dd95d2026bcb4fe4a66d75785aa (diff)
tdf#107038 Poco::Timestamp replacement with std::chrono
Change-Id: I55ba23fb104a90c882bc2af068b835e30877bc1e Reviewed-on: https://gerrit.libreoffice.org/78925 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'kit')
-rw-r--r--kit/ChildSession.cpp17
-rw-r--r--kit/Kit.cpp22
2 files changed, 25 insertions, 14 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index b201e4d34..1f4ea15a5 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -46,7 +46,6 @@
using Poco::JSON::Object;
using Poco::JSON::Parser;
using Poco::StringTokenizer;
-using Poco::Timestamp;
using Poco::URI;
using namespace LOOLProtocol;
@@ -662,7 +661,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, con
output.resize(response.size());
std::memcpy(output.data(), response.data(), response.size());
- Timestamp timestamp;
+ const auto start = std::chrono::system_clock::now();
// renderFont use a default font size (25) when width and height are 0
int width = 0, height = 0;
unsigned char* ptrFont = nullptr;
@@ -671,7 +670,9 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, con
ptrFont = getLOKitDocument()->renderFont(decodedFont.c_str(), decodedChar.c_str(), &width, &height);
- LOG_TRC("renderFont [" << font << "] rendered in " << (timestamp.elapsed()/1000.) << "ms");
+ const auto duration = std::chrono::system_clock::now() - start;
+ const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+ LOG_TRC("renderFont [" << font << "] rendered in " << elapsed << "ms");
if (!ptrFont)
{
@@ -1457,14 +1458,18 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st
std::vector<unsigned char> pixmap(pixmapDataSize);
int width = bufferWidth, height = bufferHeight;
std::string response;
- Timestamp timestamp;
+ const auto start = std::chrono::system_clock::now();
getLOKitDocument()->paintWindow(winId, pixmap.data(), startX, startY, width, height, dpiScale);
const double area = width * height;
+
+ const auto duration = std::chrono::system_clock::now() - start;
+ const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+ const double totalTime = elapsed/1000.;
LOG_TRC("paintWindow for " << winId << " returned " << width << "X" << height
<< "@(" << startX << "," << startY << ")"
<< " with dpi scale: " << dpiScale
- << " and rendered in " << (timestamp.elapsed()/1000.)
- << "ms (" << area / (timestamp.elapsed()) << " MP/s).");
+ << " and rendered in " << totalTime
+ << "ms (" << area / elapsed << " MP/s).");
response = "windowpaint: id=" + tokens[1] +
" width=" + std::to_string(width) + " height=" + std::to_string(height);
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index b2a4a8b23..0dd75ff7b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -97,7 +97,6 @@ using Poco::JSON::Object;
using Poco::JSON::Parser;
using Poco::StringTokenizer;
using Poco::Thread;
-using Poco::Timestamp;
using Poco::URI;
using Poco::Util::Application;
@@ -1119,17 +1118,19 @@ public:
// Render the whole area
const double area = pixmapWidth * pixmapHeight;
- Timestamp timestamp;
+ auto start = std::chrono::system_clock::now();
LOG_TRC("Calling paintPartTile(" << (void*)pixmap.data() << ")");
_loKitDocument->paintPartTile(pixmap.data(),
tileCombined.getPart(),
pixmapWidth, pixmapHeight,
renderArea.getLeft(), renderArea.getTop(),
renderArea.getWidth(), renderArea.getHeight());
- Timestamp::TimeDiff elapsed = timestamp.elapsed();
+ auto duration = std::chrono::system_clock::now() - start;
+ auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+ double totalTime = elapsed/1000.;
LOG_DBG("paintTile (combined) at (" << renderArea.getLeft() << ", " << renderArea.getTop() << "), (" <<
renderArea.getWidth() << ", " << renderArea.getHeight() << ") " <<
- " rendered in " << (elapsed/1000.) << " ms (" << area / elapsed << " MP/s).");
+ " rendered in " << totalTime << " ms (" << area / elapsed << " MP/s).");
const auto mode = static_cast<LibreOfficeKitTileMode>(_loKitDocument->getTileMode());
std::vector<char> output;
@@ -1267,10 +1268,12 @@ public:
_pngCache.balanceCache();
- elapsed = timestamp.elapsed();
+ duration = std::chrono::system_clock::now() - start;
+ elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+ totalTime = elapsed/1000.;
LOG_DBG("renderCombinedTiles at (" << renderArea.getLeft() << ", " << renderArea.getTop() << "), (" <<
renderArea.getWidth() << ", " << renderArea.getHeight() << ") " <<
- " took " << (elapsed/1000.) << " ms (including the paintTile).");
+ " took " << totalTime << " ms (including the paintTile).");
if (tileIndex == 0)
{
@@ -1766,9 +1769,12 @@ private:
_isDocPasswordProtected = false;
LOG_DBG("Calling lokit::documentLoad(" << uriAnonym << ", \"" << options << "\").");
- Timestamp timestamp;
+ const auto start = std::chrono::system_clock::now();
_loKitDocument.reset(_loKit->documentLoad(docTemplate.empty() ? uri.c_str() : docTemplate.c_str(), options.c_str()));
- LOG_DBG("Returned lokit::documentLoad(" << uriAnonym << ") in " << (timestamp.elapsed() / 1000.) << "ms.");
+ const auto duration = std::chrono::system_clock::now() - start;
+ const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+ const double totalTime = elapsed/1000.;
+ LOG_DBG("Returned lokit::documentLoad(" << uriAnonym << ") in " << totalTime << "ms.");
#ifdef IOS
// The iOS app (and the Android one) has max one document open at a time, so we can keep
// a pointer to it in a global.