diff options
author | Kevin Wright <kevin.wright@nokia.com> | 2010-07-27 08:29:37 (GMT) |
---|---|---|
committer | Kevin Wright <kevin.wright@nokia.com> | 2010-07-27 08:29:37 (GMT) |
commit | 2b76b4fb7f91cc266a160420d12f0581cd87539a (patch) | |
tree | c5c9b754f29c63295ab2c55ff8e1b837e02b2f8f /src/gui | |
parent | a98af1c7f1bba3c791d08e76e4896e48ea6ea019 (diff) | |
parent | 7b16419e61ea0ec2aa981b9600581f517addbb72 (diff) | |
download | Qt-2b76b4fb7f91cc266a160420d12f0581cd87539a.zip Qt-2b76b4fb7f91cc266a160420d12f0581cd87539a.tar.gz Qt-2b76b4fb7f91cc266a160420d12f0581cd87539a.tar.bz2 |
Merge branch '4.7' of http://git.scm.dev.nokia.troll.no/qt/oslo-staging-1 into 4.7
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.pro | 20 | ||||
-rw-r--r-- | src/gui/image/image.pri | 1 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 10 | ||||
-rw-r--r-- | src/gui/image/qimage_ssse3.cpp | 150 | ||||
-rw-r--r-- | src/gui/kernel/qpalette.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 3 |
6 files changed, 192 insertions, 2 deletions
diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 3aee078..1b43ef2 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -187,6 +187,25 @@ contains(QMAKE_MAC_XARCH, no) { silent:sse2_compiler.commands = @echo compiling[sse2] ${QMAKE_FILE_IN} && $$sse2_compiler.commands QMAKE_EXTRA_COMPILERS += sse2_compiler } + ssse3 { + ssse3_compiler.commands = $$QMAKE_CXX -c -Winline + + mac { + ssse3_compiler.commands += -Xarch_i386 -mssse3 + ssse3_compiler.commands += -Xarch_x86_64 -mssse3 + } else { + ssse3_compiler.commands += -mssse3 + } + + ssse3_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} + ssse3_compiler.dependency_type = TYPE_C + ssse3_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} + ssse3_compiler.input = SSSE3_SOURCES + ssse3_compiler.variable_out = OBJECTS + ssse3_compiler.name = compiling[ssse3] ${QMAKE_FILE_IN} + silent:ssse3_compiler.commands = @echo compiling[ssse3] ${QMAKE_FILE_IN} && $$ssse3_compiler.commands + QMAKE_EXTRA_COMPILERS += ssse3_compiler + } iwmmxt { iwmmxt_compiler.commands = $$QMAKE_CXX -c -Winline iwmmxt_compiler.commands += -mcpu=iwmmxt @@ -205,6 +224,7 @@ contains(QMAKE_MAC_XARCH, no) { 3dnow:sse: SOURCES += $$SSE3DNOW_SOURCES sse: SOURCES += $$SSE_SOURCES sse2: SOURCES += $$SSE2_SOURCES + ssse3: SOURCES += $$SSSE3_SOURCES iwmmxt: SOURCES += $$IWMMXT_SOURCES } } diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 3a02d56..b20a04f 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -95,3 +95,4 @@ contains(QT_CONFIG, gif):include($$PWD/qgifhandler.pri) # SIMD SSE2_SOURCES += image/qimage_sse2.cpp +SSSE3_SOURCES += image/qimage_ssse3.cpp diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 713e765..30cf758 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3354,7 +3354,7 @@ CONVERT_DECL(qargb4444, quint32) // first index source, second dest -static const Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats] = +static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -3761,6 +3761,14 @@ void qInitImageConversions() inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2; } #endif +#ifdef QT_HAVE_SSSE3 + if (features & SSSE3) { + extern void convert_RGB888_to_RGB32_ssse3(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); + converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_ssse3; + converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_ssse3; + converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_ssse3; + } +#endif } /*! diff --git a/src/gui/image/qimage_ssse3.cpp b/src/gui/image/qimage_ssse3.cpp new file mode 100644 index 0000000..1c664f2 --- /dev/null +++ b/src/gui/image/qimage_ssse3.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qimage.h> +#include <private/qimage_p.h> +#include <private/qsimd_p.h> + +#ifdef QT_HAVE_SSSE3 + +#include <stdio.h> +QT_BEGIN_NAMESPACE + +// Convert a scanline of RGB888 (src) to RGB32 (dst) +// src must be at least len * 3 bytes +// dst must be at least len * 4 bytes +inline void convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len) +{ + quint32 *const end = dst + len; + + // Prologue, align dst to 16 bytes. The alignement is done on dst because it has 4 store() + // for each 3 load() of src. + const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast<quintptr>(dst) >> 2) & 0x3)) & 0x3; + const int prologLength = qMin(len, offsetToAlignOn16Bytes); + + for (int i = 0; i < prologLength; ++i) { + *dst++ = qRgb(src[0], src[1], src[2]); + src += 3; + } + + // Mask the 4 first colors of the RGB888 vector + const __m128i shuffleMask = _mm_set_epi8(0xff, 9, 10, 11, 0xff, 6, 7, 8, 0xff, 3, 4, 5, 0xff, 0, 1, 2); + + // Mask the 4 last colors of a RGB888 vector with an offset of 1 (so the last 3 bytes are RGB) + const __m128i shuffleMaskEnd = _mm_set_epi8(0xff, 13, 14, 15, 0xff, 10, 11, 12, 0xff, 7, 8, 9, 0xff, 4, 5, 6); + + // Mask to have alpha = 0xff + const __m128i alphaMask = _mm_set1_epi32(0xff000000); + + __m128i *inVectorPtr = (__m128i *)src; + __m128i *dstVectorPtr = (__m128i *)dst; + + const int simdRoundCount = (len - prologLength) / 16; // one iteration in the loop converts 16 pixels + for (int i = 0; i < simdRoundCount; ++i) { + /* + RGB888 has 5 pixels per vector, + 1 byte from the next pixel. The idea here is + to load vectors of RGB888 and use palignr to select a vector out of two vectors. + + After 3 loads of RGB888 and 3 stores of RGB32, we have 4 pixels left in the last + vector of RGB888, we can mask it directly to get a last store or RGB32. After that, + the first next byte is a R, and we can loop for the next 16 pixels. + + The conversion itself is done with a byte permutation (pshufb). + */ + __m128i firstSrcVector = _mm_lddqu_si128(inVectorPtr); + __m128i outputVector = _mm_shuffle_epi8(firstSrcVector, shuffleMask); + _mm_store_si128(dstVectorPtr, _mm_or_si128(outputVector, alphaMask)); + ++inVectorPtr; + ++dstVectorPtr; + + // There are 4 unused bytes left in srcVector, we need to load the next 16 bytes + // and load the next input with palignr + __m128i secondSrcVector = _mm_lddqu_si128(inVectorPtr); + __m128i srcVector = _mm_alignr_epi8(secondSrcVector, firstSrcVector, 12); + outputVector = _mm_shuffle_epi8(srcVector, shuffleMask); + _mm_store_si128(dstVectorPtr, _mm_or_si128(outputVector, alphaMask)); + ++inVectorPtr; + ++dstVectorPtr; + firstSrcVector = secondSrcVector; + + // We now have 8 unused bytes left in firstSrcVector + secondSrcVector = _mm_lddqu_si128(inVectorPtr); + srcVector = _mm_alignr_epi8(secondSrcVector, firstSrcVector, 8); + outputVector = _mm_shuffle_epi8(srcVector, shuffleMask); + _mm_store_si128(dstVectorPtr, _mm_or_si128(outputVector, alphaMask)); + ++inVectorPtr; + ++dstVectorPtr; + + // There are now 12 unused bytes in firstSrcVector. + // We can mask them directly, almost there. + outputVector = _mm_shuffle_epi8(secondSrcVector, shuffleMaskEnd); + _mm_store_si128(dstVectorPtr, _mm_or_si128(outputVector, alphaMask)); + ++dstVectorPtr; + } + src = (uchar *)inVectorPtr; + dst = (quint32 *)dstVectorPtr; + + while (dst != end) { + *dst++ = qRgb(src[0], src[1], src[2]); + src += 3; + } +} + +void convert_RGB888_to_RGB32_ssse3(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +{ + Q_ASSERT(src->format == QImage::Format_RGB888); + Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied); + Q_ASSERT(src->width == dest->width); + Q_ASSERT(src->height == dest->height); + + const uchar *src_data = (uchar *) src->data; + quint32 *dest_data = (quint32 *) dest->data; + + for (int i = 0; i < src->height; ++i) { + convert_rgb888_to_rgb32_ssse3(dest_data, src_data, src->width); + src_data += src->bytes_per_line; + dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line); + } +} + +QT_END_NAMESPACE + +#endif // QT_HAVE_SSSE3 diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 98e8f66..38ec806 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -868,11 +868,21 @@ void QPalette::detach() Returns true (slowly) if this palette is different from \a p; otherwise returns false (usually quickly). + + \note The current ColorGroup is not taken into account when + comparing palettes + + \sa operator== */ /*! Returns true (usually quickly) if this palette is equal to \a p; otherwise returns false (slowly). + + \note The current ColorGroup is not taken into account when + comparing palettes + + \sa operator!= */ bool QPalette::operator==(const QPalette &p) const { diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index d7311ef..981e934 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1949,7 +1949,8 @@ void QLineEdit::paintEvent(QPaintEvent *) if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ flags |= QLineControl::DrawSelections; // Palette only used for selections/mask and may not be in sync - if(d->control->palette() != pal) + if (d->control->palette() != pal + || d->control->palette().currentColorGroup() != pal.currentColorGroup()) d->control->setPalette(pal); } |