kit/Kit.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
New commits: commit da30dc3df3f5502586ab7da0e56b260621fdc39e Author: Ashod Nakashian <ashod.nakash...@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 <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@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, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits