use_system_woff2
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Sat, 7 Apr 2018 20:23:09 +0000 (21:23 +0100)
committerLisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
Sat, 7 Apr 2018 20:23:09 +0000 (21:23 +0100)
Gbp-Pq: Name use_system_woff2.diff

Source/CMakeLists.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/platform/graphics/WOFFFileFormat.cpp
Source/cmake/FindWOFF2Dec.cmake [new file with mode: 0644]
Source/cmake/OptionsQt.cmake

index 9d9483ecc9cabcf04900ae1196e46ba8b5dcd91f..a473dbf145cdd7d010362914e02cb540f0ad4afd 100644 (file)
@@ -19,7 +19,7 @@ if (ENABLE_API_TESTS)
     add_subdirectory(ThirdParty/gtest)
 endif ()
 
-if (USE_WOFF2)
+if (USE_WOFF2 AND NOT WOFF2DEC_FOUND)
     add_subdirectory(ThirdParty/brotli)
     add_subdirectory(ThirdParty/woff2)
 endif ()
index 7d0ad0433ecb4514eb313cca7ae10abaeab6ba67..37533df7fe10c00435474816fd93cbdfa34b6090 100644 (file)
@@ -3353,8 +3353,13 @@ if (ENABLE_USER_MESSAGE_HANDLERS)
 endif ()
 
 if (USE_WOFF2)
-  list(APPEND WebCore_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/woff2/src")
-  list(APPEND WebCore_LIBRARIES woff2)
+    if (WOFF2DEC_FOUND)
+        list(APPEND WebCore_INCLUDE_DIRECTORIES "${WOFF2DEC_INCLUDE_DIRS}")
+        list(APPEND WebCore_LIBRARIES "${WOFF2DEC_LIBRARIES}")
+    else ()
+        list(APPEND WebCore_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/woff2/src")
+        list(APPEND WebCore_LIBRARIES woff2)
+    endif ()
 endif ()
 
 set(WebCoreTestSupport_INCLUDE_DIRECTORIES
index c2323cf04222174f8b24c2b46b6cb4cfbedb16bf..d8f4a5da7b42431ac50d8a5bf072f3b896e52f6f 100644 (file)
@@ -31,8 +31,8 @@
 #include <wtf/ByteOrder.h>
 
 #if USE(WOFF2)
-#include "woff2_common.h"
-#include "woff2_dec.h"
+#include <woff2/decode.h>
+static const uint32_t kWoff2Signature = 0x774f4632; // "wOF2"
 #endif
 
 namespace WebCore {
@@ -84,7 +84,7 @@ bool isWOFF(SharedBuffer& buffer)
         return false;
 
 #if USE(WOFF2)
-    return signature == woffSignature || signature == woff2::kWoff2Signature;
+    return signature == woffSignature || signature == kWoff2Signature;
 #else
     return signature == woffSignature;
 #endif
@@ -140,7 +140,7 @@ bool convertWOFFToSfnt(SharedBuffer& woff, Vector<char>& sfnt)
     }
 
 #if USE(WOFF2)
-    if (signature == woff2::kWoff2Signature) {
+    if (signature == kWoff2Signature) {
         const uint8_t* woffData = reinterpret_cast_ptr<const uint8_t*>(woff.data());
         const size_t woffSize = woff.size();
         const size_t sfntSize = woff2::ComputeWOFF2FinalSize(woffData, woffSize);
diff --git a/Source/cmake/FindWOFF2Dec.cmake b/Source/cmake/FindWOFF2Dec.cmake
new file mode 100644 (file)
index 0000000..4927eee
--- /dev/null
@@ -0,0 +1,53 @@
+# - Try to find WOFF2Dec.
+# Once done, this will define
+#
+#  WOFF2DEC_FOUND - system has WOFF2Dec.
+#  WOFF2DEC_INCLUDE_DIRS - the WOFF2Dec include directories
+#  WOFF2DEC_LIBRARIES - link these to use WOFF2Dec.
+#
+# Copyright (C) 2017 Igalia S.L.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+find_package(PkgConfig)
+pkg_check_modules(PC_WOFF2DEC libwoff2dec)
+
+find_path(WOFF2DEC_INCLUDE_DIRS
+    NAMES woff2/decode.h
+    HINTS ${PC_WOFF2DEC_INCLUDEDIR}
+)
+
+find_library(WOFF2DEC_LIBRARIES
+    NAMES woff2dec
+    HINTS ${PC_WOFF2DEC_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WOFF2Dec
+    REQUIRED_VARS WOFF2DEC_INCLUDE_DIRS WOFF2DEC_LIBRARIES
+    FOUND_VAR WOFF2DEC_FOUND
+    VERSION_VAR PC_WOFF2DEC_VERSION)
+
+mark_as_advanced(
+    WOFF2DEC_INCLUDE_DIRS
+    WOFF2DEC_LIBRARIES
+)
index f29b3dd64e992382b7aab0793967f800ab65fe12..de25c6341886755c3f98518019077ebc29142cdb 100644 (file)
@@ -679,6 +679,15 @@ if (USE_LIBHYPHEN)
     endif ()
 endif ()
 
+if (USE_WOFF2)
+    find_package(WOFF2Dec 1.0.1)
+    if (WOFF2DEC_FOUND)
+        message(STATUS "Using system WOFF2Dec library.")
+    else ()
+        message(STATUS "WOFF2Dec not found, using the bundled library.")
+    endif ()
+endif ()
+
 # From OptionsGTK.cmake
 if (CMAKE_MAJOR_VERSION LESS 3)
     # Before CMake 3 it was necessary to use a build script instead of using cmake --build directly