From 1a8b9ce8d8de2fde2ee3eac50439f734fb07e5d8 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 11 Sep 2020 19:26:41 -0400
Subject: [PATCH] Add libjpeg-turbo for windows and update hunspell package for
 windows

---
 autobuild.xml                      | 64 +++++++++++++++++++++++++++---
 indra/cmake/Copy3rdPartyLibs.cmake |  1 +
 indra/cmake/JPEG.cmake             |  6 ++-
 indra/llui/llspellcheck.cpp        | 25 ++++--------
 indra/newview/viewer_manifest.py   |  1 +
 5 files changed, 71 insertions(+), 26 deletions(-)

diff --git a/autobuild.xml b/autobuild.xml
index 65f43073bab..5663d9f341b 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -1464,7 +1464,7 @@
       <key>libhunspell</key>
       <map>
         <key>copyright</key>
-        <string>See hunspell.txt</string>
+        <string>LGPL 2.1</string>
         <key>description</key>
         <string>Spell checking library</string>
         <key>license</key>
@@ -1528,9 +1528,11 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>ec22ec25160bcfd2a74f1c7bc8ff6133</string>
+              <string>a413602360424a4e9526d87f9df78132</string>
+              <key>hash_algorithm</key>
+              <string>md5</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/54986/511824/libhunspell-1.3.2.538974-windows-538974.tar.bz2</string>
+              <string>https://pkg.alchemyviewer.org/repository/autobuild-external/hunspell/windows/libhunspell-1.7.0.335-windows-335.tar.bz2</string>
             </map>
             <key>name</key>
             <string>windows</string>
@@ -1540,16 +1542,66 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>f470c6f3f7b0559e95e76467b808de10</string>
+              <string>9324049a0fd170c3e34542c2a8efcf19</string>
+              <key>hash_algorithm</key>
+              <string>md5</string>
+              <key>url</key>
+              <string>https://pkg.alchemyviewer.org/repository/autobuild-external/hunspell/windows64/libhunspell-1.7.0.335-windows64-335.tar.bz2</string>
+            </map>
+            <key>name</key>
+            <string>windows64</string>
+          </map>
+        </map>
+        <key>version</key>
+        <string>1.7.0.335</string>
+      </map>
+      <key>libjpeg-turbo</key>
+      <map>
+        <key>canonical_repo</key>
+        <string>https://git.alchemyviewer.org/alchemy/thirdparty/3p-libjpeg-turbo</string>
+        <key>copyright</key>
+        <string>Copyright (C)2009-2020 D. R. Commander. All Rights Reserved. Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.</string>
+        <key>description</key>
+        <string>JPEG encoding, decoding library</string>
+        <key>license</key>
+        <string>libjpeg-turbo</string>
+        <key>license_file</key>
+        <string>LICENSES/libjpeg-turbo.txt</string>
+        <key>name</key>
+        <string>libjpeg-turbo</string>
+        <key>platforms</key>
+        <map>
+          <key>windows</key>
+          <map>
+            <key>archive</key>
+            <map>
+              <key>hash</key>
+              <string>f57e40f2be3f1dd392ffce9cbe9fb731</string>
+              <key>hash_algorithm</key>
+              <string>md5</string>
+              <key>url</key>
+              <string>https://pkg.alchemyviewer.org/repository/autobuild-external/libjpeg-turbo/windows/libjpeg_turbo-2.0.5.336-windows-336.tar.bz2</string>
+            </map>
+            <key>name</key>
+            <string>windows</string>
+          </map>
+          <key>windows64</key>
+          <map>
+            <key>archive</key>
+            <map>
+              <key>hash</key>
+              <string>c3d06364c50d312d7b26a42f380ea3f4</string>
+              <key>hash_algorithm</key>
+              <string>md5</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/54985/511817/libhunspell-1.3.2.538974-windows64-538974.tar.bz2</string>
+              <string>https://pkg.alchemyviewer.org/repository/autobuild-external/libjpeg-turbo/windows64/libjpeg_turbo-2.0.5.336-windows64-336.tar.bz2</string>
             </map>
             <key>name</key>
             <string>windows64</string>
           </map>
         </map>
         <key>version</key>
-        <string>1.3.2.538974</string>
+        <string>2.0.5.336</string>
       </map>
       <key>libndofdev</key>
       <map>
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index ac3b701b81c..3339dd8010f 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -65,6 +65,7 @@ if(WINDOWS)
         ${EXPAT_COPY}
         freetype.dll
         glod.dll
+        jpeg8.dll
         libapr-1.dll
         libaprutil-1.dll
         libapriconv-1.dll
diff --git a/indra/cmake/JPEG.cmake b/indra/cmake/JPEG.cmake
index d6da22aecc1..3a91f739d7d 100644
--- a/indra/cmake/JPEG.cmake
+++ b/indra/cmake/JPEG.cmake
@@ -8,13 +8,15 @@ set(JPEG_FIND_REQUIRED ON)
 if (USESYSTEMLIBS)
   include(FindJPEG)
 else (USESYSTEMLIBS)
-  use_prebuilt_binary(jpeglib)
   if (LINUX)
+    use_prebuilt_binary(jpeglib)
     set(JPEG_LIBRARIES jpeg)
   elseif (DARWIN)
+    use_prebuilt_binary(jpeglib)
     set(JPEG_LIBRARIES jpeg)
   elseif (WINDOWS)
-    set(JPEG_LIBRARIES jpeglib)
+    use_prebuilt_binary(libjpeg-turbo)
+    set(JPEG_LIBRARIES jpeg)
   endif (LINUX)
   set(JPEG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
 endif (USESYSTEMLIBS)
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index 296ea090793..7baf0012d71 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -30,12 +30,8 @@
 #include "llsdserialize.h"
 
 #include "llspellcheck.h"
-#if LL_WINDOWS
-	#include <hunspell/hunspelldll.h>
-	#pragma comment(lib, "libhunspell.lib")
-#else
-	#include <hunspell/hunspell.hxx>
-#endif
+#include <hunspell/hunspell.hxx>
+
 
 static const std::string DICT_DIR = "dictionaries";
 static const std::string DICT_FILE_CUSTOM = "user_custom.dic";
@@ -60,11 +56,11 @@ LLSpellChecker::~LLSpellChecker()
 
 bool LLSpellChecker::checkSpelling(const std::string& word) const
 {
-	if ( (!mHunspell) || (word.length() < 3) || (0 != mHunspell->spell(word.c_str())) )
+	if ( (!mHunspell) || (word.length() < 3) || (0 != mHunspell->spell(word)) )
 	{
 		return true;
 	}
-	if (mIgnoreList.size() > 0)
+	if (!mIgnoreList.empty())
 	{
 		std::string word_lower(word);
 		LLStringUtil::toLower(word_lower);
@@ -81,15 +77,8 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str
 		return 0;
 	}
 
-	char** suggestion_list; int suggestion_cnt = 0;
-	if ( (suggestion_cnt = mHunspell->suggest(&suggestion_list, word.c_str())) != 0 )
-	{
-		for (int suggestion_index = 0; suggestion_index < suggestion_cnt; suggestion_index++)
-		{
-			suggestions.push_back(suggestion_list[suggestion_index]);
-		}
-		mHunspell->free_list(&suggestion_list, suggestion_cnt);	
-	}
+	suggestions = mHunspell->suggest(word);
+
 	return suggestions.size();
 }
 
@@ -190,7 +179,7 @@ void LLSpellChecker::addToCustomDictionary(const std::string& word)
 {
 	if (mHunspell)
 	{
-		mHunspell->add(word.c_str());
+		mHunspell->add(word);
 	}
 	addToDictFile(getDictionaryUserPath() + DICT_FILE_CUSTOM, word);
 	sSettingsChangeSignal();
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index e76f398156e..08c667127b2 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -533,6 +533,7 @@ def construct(self):
                 print "Skipping GLOD library (assumming linked statically)"
 
             # For image support
+            self.path("jpeg8.dll")
             self.path("libpng16*.dll")
             self.path("libwebp.dll")
             self.path("openjpeg.dll")
-- 
GitLab