| [2] | 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| [651] | 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| [561] | 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| [2] | 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| [561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| [2] | 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| [561] | 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| [2] | 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include <private/qdrawhelper_x86_p.h>
|
|---|
| 43 |
|
|---|
| 44 | #ifdef QT_HAVE_SSE2
|
|---|
| 45 |
|
|---|
| 46 | #include <private/qpaintengine_raster_p.h>
|
|---|
| 47 |
|
|---|
| 48 | #ifdef QT_LINUXBASE
|
|---|
| 49 | // this is an evil hack - the posix_memalign declaration in LSB
|
|---|
| 50 | // is wrong - see http://bugs.linuxbase.org/show_bug.cgi?id=2431
|
|---|
| 51 | # define posix_memalign _lsb_hack_posix_memalign
|
|---|
| 52 | # include <emmintrin.h>
|
|---|
| 53 | # undef posix_memalign
|
|---|
| 54 | #else
|
|---|
| 55 | # include <emmintrin.h>
|
|---|
| 56 | #endif
|
|---|
| 57 |
|
|---|
| 58 | QT_BEGIN_NAMESPACE
|
|---|
| 59 |
|
|---|
| 60 | void qt_memfill32_sse2(quint32 *dest, quint32 value, int count)
|
|---|
| 61 | {
|
|---|
| 62 | if (count < 7) {
|
|---|
| 63 | switch (count) {
|
|---|
| 64 | case 6: *dest++ = value;
|
|---|
| 65 | case 5: *dest++ = value;
|
|---|
| 66 | case 4: *dest++ = value;
|
|---|
| 67 | case 3: *dest++ = value;
|
|---|
| 68 | case 2: *dest++ = value;
|
|---|
| 69 | case 1: *dest = value;
|
|---|
| 70 | }
|
|---|
| 71 | return;
|
|---|
| 72 | };
|
|---|
| 73 |
|
|---|
| 74 | const int align = (quintptr)(dest) & 0xf;
|
|---|
| 75 | switch (align) {
|
|---|
| 76 | case 4: *dest++ = value; --count;
|
|---|
| 77 | case 8: *dest++ = value; --count;
|
|---|
| 78 | case 12: *dest++ = value; --count;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | int count128 = count / 4;
|
|---|
| 82 | __m128i *dst128 = reinterpret_cast<__m128i*>(dest);
|
|---|
| 83 | const __m128i value128 = _mm_set_epi32(value, value, value, value);
|
|---|
| 84 |
|
|---|
| 85 | int n = (count128 + 3) / 4;
|
|---|
| 86 | switch (count128 & 0x3) {
|
|---|
| 87 | case 0: do { _mm_store_si128(dst128++, value128);
|
|---|
| 88 | case 3: _mm_store_si128(dst128++, value128);
|
|---|
| 89 | case 2: _mm_store_si128(dst128++, value128);
|
|---|
| 90 | case 1: _mm_store_si128(dst128++, value128);
|
|---|
| 91 | } while (--n > 0);
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | const int rest = count & 0x3;
|
|---|
| 95 | if (rest) {
|
|---|
| 96 | switch (rest) {
|
|---|
| 97 | case 3: dest[count - 3] = value;
|
|---|
| 98 | case 2: dest[count - 2] = value;
|
|---|
| 99 | case 1: dest[count - 1] = value;
|
|---|
| 100 | }
|
|---|
| 101 | }
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | void qt_memfill16_sse2(quint16 *dest, quint16 value, int count)
|
|---|
| 105 | {
|
|---|
| 106 | if (count < 3) {
|
|---|
| 107 | switch (count) {
|
|---|
| 108 | case 2: *dest++ = value;
|
|---|
| 109 | case 1: *dest = value;
|
|---|
| 110 | }
|
|---|
| 111 | return;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | const int align = (quintptr)(dest) & 0x3;
|
|---|
| 115 | switch (align) {
|
|---|
| 116 | case 2: *dest++ = value; --count;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | const quint32 value32 = (value << 16) | value;
|
|---|
| 120 | qt_memfill32_sse2(reinterpret_cast<quint32*>(dest), value32, count / 2);
|
|---|
| 121 |
|
|---|
| 122 | if (count & 0x1)
|
|---|
| 123 | dest[count - 1] = value;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
|
|---|
| |
|---|