summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2019-06-07 01:39:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2019-06-07 01:59:28 +0300
commitac794c7928225108f27bbad161682c74756da8fb (patch)
treeb12735eaaad587a3e41be80b577850f87f0430a7
parent154b95c308911b04f11a991b5ac792269f89ab7d (diff)
Stop using bundled libjpeg from qtbase
[*] Its usage is too fragile, updates on QtBase side often break compilation, also maintaining compatibility with different Qt versions becomes harder [*] Mismatch between vendor and version of libjpeg bundled with QtBase is the often sources of troubles for Windows and macOS users trying to build QtWebKit from sources against precompiled Qt SDK. This patch makes libjpeg optional dependency when CMake option USE_LIBJPEG is set to off. In qmake wrapper detection of bunled libjpeg in QtGui configuration disables use of libjpeg automatically. When WebKit JPEG decoder is disabled, JPEG images are handled by QImageReader, losing support for progressive rendering and possibly some other features. Note that libpng is still mandatory, because it doesn't expose issues described above. Change-Id: Ibf270f2f9e3230b27f4c63390918dd7e78ffee2b Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
-rw-r--r--Source/WebCore/PlatformQt.cmake6
-rw-r--r--Source/WebCore/platform/image-decoders/ImageDecoder.cpp4
-rw-r--r--Source/cmake/OptionsQt.cmake23
-rw-r--r--Tools/qmake/projects/qtjpeg/qtjpeg.pro14
-rw-r--r--Tools/qmake/projects/run_cmake.pro12
-rw-r--r--WebKit.pro3
6 files changed, 20 insertions, 42 deletions
diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake
index 8414d21e5..cd2e79d5d 100644
--- a/Source/WebCore/PlatformQt.cmake
+++ b/Source/WebCore/PlatformQt.cmake
@@ -2,6 +2,12 @@ include(platform/ImageDecoders.cmake)
include(platform/Linux.cmake)
include(platform/TextureMapper.cmake)
+if (NOT USE_LIBJPEG)
+ list(REMOVE_ITEM WebCore_SOURCES
+ platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+ )
+endif ()
+
if (JPEG_DEFINITIONS)
add_definitions(${JPEG_DEFINITIONS})
endif ()
diff --git a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp b/Source/WebCore/platform/image-decoders/ImageDecoder.cpp
index 46366823f..0273dd3c2 100644
--- a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp
+++ b/Source/WebCore/platform/image-decoders/ImageDecoder.cpp
@@ -28,7 +28,9 @@
#if PLATFORM(QT)
#include "ImageDecoderQt.h"
#endif
+#if !PLATFORM(QT) || USE(LIBJPEG)
#include "JPEGImageDecoder.h"
+#endif
#include "PNGImageDecoder.h"
#include "SharedBuffer.h"
#if USE(WEBP)
@@ -115,8 +117,10 @@ ImageDecoder* ImageDecoder::create(const SharedBuffer& data, ImageSource::AlphaO
if (matchesICOSignature(contents) || matchesCURSignature(contents))
return new ICOImageDecoder(alphaOption, gammaAndColorProfileOption);
+#if !PLATFORM(QT) || USE(LIBJPEG)
if (matchesJPEGSignature(contents))
return new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption);
+#endif
#if USE(WEBP)
if (matchesWebPSignature(contents))
diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake
index ff207fe77..ac1065d92 100644
--- a/Source/cmake/OptionsQt.cmake
+++ b/Source/cmake/OptionsQt.cmake
@@ -259,6 +259,7 @@ option(USE_STATIC_RUNTIME "Use static runtime (MSVC only)" OFF)
# Private options specific to the Qt port. Changing these options is
# completely unsupported. They are intended for use only by WebKit developers.
WEBKIT_OPTION_DEFINE(ENABLE_TOUCH_ADJUSTMENT "Whether to use touch adjustment" PRIVATE ON)
+WEBKIT_OPTION_DEFINE(USE_LIBJPEG "Support JPEG format directly. If it is disabled, QImageReader will be used with possible degradation of user experience" PUBLIC ON)
# Public options shared with other WebKit ports. There must be strong reason
@@ -439,23 +440,13 @@ endif ()
find_package(Threads REQUIRED)
-if (NOT QT_BUNDLED_JPEG)
- find_package(JPEG REQUIRED)
+if (USE_LIBJPEG)
+ find_package(JPEG)
+ if (NOT JPEG_FOUND)
+ message(FATAL_ERROR "libjpeg not found. Please make sure that CMake can find its header files and libraries, or build with -DUSE_LIBJPEG=OFF with possible degradation of user experience")
+ endif ()
else ()
- set(JPEG_FOUND 1)
- # As of Qt 5.10, libjpeg-turbo shipped as a part of Qt requires using a few macro definitions
- # WARNING: Keep in sync with libjpeg.pri
- # FIXME: Change Qt so we can avoid this
- include(CheckTypeSize)
- check_type_size(size_t _SIZEOF_SIZE_T)
- set(JPEG_DEFINITIONS
- -DC_ARITH_CODING_SUPPORTED=1
- -DD_ARITH_CODING_SUPPORTED=1
- -DBITS_IN_JSAMPLE=8
- -DJPEG_LIB_VERSION=80
- -DSIZEOF_SIZE_T=${_SIZEOF_SIZE_T}
- )
- unset(_SIZEOF_SIZE_T)
+ message(WARNING "USE_LIBJPEG is disabled, will attempt using QImageReader to decode JPEG with possible degradation of user experience")
endif ()
if (NOT QT_BUNDLED_PNG)
diff --git a/Tools/qmake/projects/qtjpeg/qtjpeg.pro b/Tools/qmake/projects/qtjpeg/qtjpeg.pro
deleted file mode 100644
index 33aa665d3..000000000
--- a/Tools/qmake/projects/qtjpeg/qtjpeg.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-load(functions)
-
-TARGET = qtjpeg
-
-CONFIG += \
- static \
- hide_symbols \
- exceptions_off rtti_off warn_off
-
-load(qt_helper_lib)
-
-DESTDIR = $$ROOT_BUILD_DIR/lib
-
-include($$QTBASE_DIR/src/3rdparty/libjpeg.pri)
diff --git a/Tools/qmake/projects/run_cmake.pro b/Tools/qmake/projects/run_cmake.pro
index b9d0f08a2..ff6d1d562 100644
--- a/Tools/qmake/projects/run_cmake.pro
+++ b/Tools/qmake/projects/run_cmake.pro
@@ -35,15 +35,9 @@ build_pass|!debug_and_release {
static_runtime: CMAKE_CONFIG += USE_STATIC_RUNTIME=ON
QT_FOR_CONFIG += gui-private
- !qtConfig(system-jpeg):exists($$QTBASE_DIR) {
- CMAKE_CONFIG += \
- QT_BUNDLED_JPEG=1 \
- JPEG_LIBRARIES=$$staticLibPath(qtjpeg)
-
- exists($$QTBASE_DIR/src/3rdparty/libjpeg/src/jpeglib.h): \
- CMAKE_CONFIG += JPEG_INCLUDE_DIR=$$QTBASE_DIR/src/3rdparty/libjpeg/src
- else: \
- CMAKE_CONFIG += JPEG_INCLUDE_DIR=$$QTBASE_DIR/src/3rdparty/libjpeg
+ !qtConfig(system-jpeg):qtConfig(jpeg) {
+ # Use QImageReader for JPEG
+ CMAKE_CONFIG += USE_LIBJPEG=OFF
}
!qtConfig(system-png):qtConfig(png):exists($$QTBASE_DIR) {
diff --git a/WebKit.pro b/WebKit.pro
index ca3b009aa..09debf182 100644
--- a/WebKit.pro
+++ b/WebKit.pro
@@ -9,9 +9,6 @@ isPlatformSupported() {
!qtConfig(system-png):qtConfig(png):exists($$QTBASE_DIR): \
SUBDIRS += $$PROJECTS_DIR/qtpng
- !qtConfig(system-jpeg):exists($$QTBASE_DIR): \
- SUBDIRS += $$PROJECTS_DIR/qtjpeg
-
SUBDIRS += \
$$PROJECTS_DIR/generate_cmake_toolchain_file.pro \
$$PROJECTS_DIR/generate_forwarding_pris.pro \