[Libreoffice-commits] online.git: kit/Kit.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Nov 28 05:02:53 UTC 2016
kit/Kit.cpp | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
New commits:
commit da30dc3df3f5502586ab7da0e56b260621fdc39e
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Nov 27 11:22:21 2016 -0500
loolwsd: factor out the png cache lookup
Change-Id: Id287b136b687d9bc4f49a3583e18cb820f4eb21e
Reviewed-on: https://gerrit.libreoffice.org/31293
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 0836b1e..f070b3a 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -322,13 +322,10 @@ class PngCache
}
}
- bool cacheEncodeSubBufferToPNG(unsigned char* pixmap, size_t startX, size_t startY,
- int width, int height,
- int bufferWidth, int bufferHeight,
- std::vector<char>& output, LibreOfficeKitTileMode mode)
+ /// Lookup an entry in the cache and store the data in output.
+ /// Returns true on success, otherwise false.
+ bool cacheTest(const uint64_t hash, std::vector<char>& output)
{
- uint64_t hash = png::hashSubBuffer(pixmap, startX, startY, width, height,
- bufferWidth, bufferHeight);
if (hash)
{
++_cacheTests;
@@ -345,6 +342,21 @@ class PngCache
}
}
+ return false;
+ }
+
+ bool cacheEncodeSubBufferToPNG(unsigned char* pixmap, size_t startX, size_t startY,
+ int width, int height,
+ int bufferWidth, int bufferHeight,
+ std::vector<char>& output, LibreOfficeKitTileMode mode)
+ {
+ uint64_t hash = png::hashSubBuffer(pixmap, startX, startY, width, height,
+ bufferWidth, bufferHeight);
+ if (cacheTest(hash, output))
+ {
+ return true;
+ }
+
LOG_DBG("PNG cache with hash " << hash << " missed.");
CacheEntry newEntry(bufferWidth * bufferHeight * 1);
if (png::encodeSubBufferToPNG(pixmap, startX, startY, width, height,
More information about the Libreoffice-commits
mailing list