From c6cca64c89ebee90a9d6238660fade83106c3484 Mon Sep 17 00:00:00 2001 From: Debian Qt/KDE Maintainers Date: Sat, 7 Apr 2018 21:23:09 +0100 Subject: [PATCH] use_system_woff2 Gbp-Pq: Name use_system_woff2.diff --- Source/CMakeLists.txt | 2 +- Source/WebCore/CMakeLists.txt | 9 +++- .../platform/graphics/WOFFFileFormat.cpp | 8 +-- Source/cmake/FindWOFF2Dec.cmake | 53 +++++++++++++++++++ Source/cmake/OptionsQt.cmake | 9 ++++ 5 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 Source/cmake/FindWOFF2Dec.cmake diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9d9483ec..a473dbf1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -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 () diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index 7d0ad043..37533df7 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -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 diff --git a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp index c2323cf0..d8f4a5da 100644 --- a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp +++ b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp @@ -31,8 +31,8 @@ #include #if USE(WOFF2) -#include "woff2_common.h" -#include "woff2_dec.h" +#include +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& sfnt) } #if USE(WOFF2) - if (signature == woff2::kWoff2Signature) { + if (signature == kWoff2Signature) { const uint8_t* woffData = reinterpret_cast_ptr(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 index 00000000..4927eeeb --- /dev/null +++ b/Source/cmake/FindWOFF2Dec.cmake @@ -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 +) diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index f29b3dd6..de25c634 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -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 -- 2.30.2