diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-26 14:22:07 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-12-07 10:57:57 +0000 |
commit | a76f2897143e3c428ea5e106c023105270b7ed0c (patch) | |
tree | a40f7e40d43ef4bbac15cb23d63f390779d46be0 /src/gui | |
parent | 2766215c9ec68bf175c0ddafbd7be5a03b403795 (diff) |
Initialize function tables without QGuiApplication
QImage can be used without QGuiApplication, but wihout QGuiApplication
the accelerated methods would not be used.
This patch changes the initialization of the QtGui function tables to
happen in static object constructors on QtGui load, instead of in
the QGuiApplication init.
Change-Id: Ib58982fbc50fd79122352d021d93a3c99aca5043
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 13 | ||||
-rw-r--r-- | src/gui/image/qimage_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 17 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 2 |
5 files changed, 28 insertions, 16 deletions
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 7d1fb23b15..cbdcf49da7 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -2920,7 +2920,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma } // Format_Grayscale8 }; -void qInitImageConversions() +static void qInitImageConversions() { #if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSSE3) if (qCpuHasFeature(SSSE3)) { @@ -2967,4 +2967,15 @@ void qInitImageConversions() #endif } +class QImageConversionsInitializer { +public: + QImageConversionsInitializer() + { + qInitImageConversions(); + } +}; + +// Ensure initialization if this object file is linked. +static QImageConversionsInitializer qImageConversionsInitializer; + QT_END_NAMESPACE diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index feeab60abd..3badda0864 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -111,8 +111,6 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im void dither_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags, bool fromalpha); -void qInitImageConversions(); - const uchar *qt_get_bitflip_array(); Q_GUI_EXPORT void qGamma_correct_back_to_linear_cs(QImage *image); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 087bed439c..00245b25b0 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -192,9 +192,6 @@ extern void qRegisterGuiVariant(); #ifndef QT_NO_ANIMATION extern void qRegisterGuiGetInterpolator(); #endif -extern void qInitBlendFunctions(); -extern void qInitDrawhelperAsm(); -extern void qInitImageConversions(); static bool qt_detectRTLLanguage() { @@ -1327,13 +1324,6 @@ void QGuiApplicationPrivate::init() if (platform_integration == 0) createPlatformIntegration(); - // Set up blend function tables. - qInitBlendFunctions(); - // Set up which span functions should be used in raster engine... - qInitDrawhelperAsm(); - // and QImage conversion functions - qInitImageConversions(); - initPalette(); QFont::initialize(); diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 5854008ea3..8f5eb4d095 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6328,7 +6328,7 @@ void qt_memfill32(quint32 *dest, quint32 color, int count) template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); #endif -void qInitDrawhelperAsm() +static void qInitDrawhelperFunctions() { #ifdef __SSE2__ qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2; @@ -6523,4 +6523,19 @@ void qInitDrawhelperAsm() #endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2 } +extern void qInitBlendFunctions(); +class DrawHelperInitializer { +public: + DrawHelperInitializer() + { + // Set up basic blend function tables. + qInitBlendFunctions(); + // Set up architecture optimized methods for the current machine. + qInitDrawhelperFunctions(); + } +}; + +// Ensure initialization if this object file is linked. +static DrawHelperInitializer drawHelperInitializer; + QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 1d70477051..1ff19f4e04 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -213,8 +213,6 @@ struct Operator }; }; -void qInitDrawhelperAsm(); - class QRasterPaintEngine; struct QSolidData |