| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qimage.h" | - |
| 43 | #include <private/qimage_p.h> | - |
| 44 | #include <private/qsimd_p.h> | - |
| 45 | #include <private/qdrawhelper_p.h> | - |
| 46 | #include <private/qdrawingprimitive_sse2_p.h> | - |
| 47 | | - |
| 48 | #ifdef QT_COMPILER_SUPPORTS_SSE2 | - |
| 49 | | - |
| 50 | QT_BEGIN_NAMESPACE | - |
| 51 | | - |
| 52 | bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags) | - |
| 53 | { | - |
| 54 | Q_ASSERT(data->format == QImage::Format_ARGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
| 55 | | - |
| 56 | // extra pixels on each line | - |
| 57 | const int spare = data->width & 3; executed (the execution status of this line is deduced): const int spare = data->width & 3; | - |
| 58 | // width in pixels of the pad at the end of each line | - |
| 59 | const int pad = (data->bytes_per_line >> 2) - data->width; executed (the execution status of this line is deduced): const int pad = (data->bytes_per_line >> 2) - data->width; | - |
| 60 | const int iter = data->width >> 2; executed (the execution status of this line is deduced): const int iter = data->width >> 2; | - |
| 61 | int height = data->height; executed (the execution status of this line is deduced): int height = data->height; | - |
| 62 | | - |
| 63 | const __m128i alphaMask = _mm_set1_epi32(0xff000000); executed (the execution status of this line is deduced): const __m128i alphaMask = _mm_set1_epi32(0xff000000); | - |
| 64 | const __m128i nullVector = _mm_setzero_si128(); executed (the execution status of this line is deduced): const __m128i nullVector = _mm_setzero_si128(); | - |
| 65 | const __m128i half = _mm_set1_epi16(0x80); executed (the execution status of this line is deduced): const __m128i half = _mm_set1_epi16(0x80); | - |
| 66 | const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); executed (the execution status of this line is deduced): const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); | - |
| 67 | | - |
| 68 | __m128i *d = reinterpret_cast<__m128i*>(data->data); executed (the execution status of this line is deduced): __m128i *d = reinterpret_cast<__m128i*>(data->data); | - |
| 69 | while (height--) { evaluated: height--| yes Evaluation Count:656 | yes Evaluation Count:13 |
| 13-656 |
| 70 | const __m128i *end = d + iter; executed (the execution status of this line is deduced): const __m128i *end = d + iter; | - |
| 71 | | - |
| 72 | for (; d != end; ++d) { evaluated: d != end| yes Evaluation Count:16960 | yes Evaluation Count:656 |
| 656-16960 |
| 73 | const __m128i srcVector = _mm_loadu_si128(d); executed (the execution status of this line is deduced): const __m128i srcVector = _mm_loadu_si128(d); | - |
| 74 | const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); executed (the execution status of this line is deduced): const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); | - |
| 75 | if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { evaluated: _mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff| yes Evaluation Count:2390 | yes Evaluation Count:14570 |
| 2390-14570 |
| 76 | // opaque, data is unchanged | - |
| 77 | } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) == 0xffff) { executed: }Execution Count:2390 evaluated: _mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) == 0xffff| yes Evaluation Count:1786 | yes Evaluation Count:12784 |
| 1786-12784 |
| 78 | // fully transparent | - |
| 79 | _mm_storeu_si128(d, nullVector); executed (the execution status of this line is deduced): _mm_storeu_si128(d, nullVector); | - |
| 80 | } else { executed: }Execution Count:1786 | 1786 |
| 81 | __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); executed (the execution status of this line is deduced): __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); | - |
| 82 | alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); executed (the execution status of this line is deduced): alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); | - |
| 83 | | - |
| 84 | __m128i result; executed (the execution status of this line is deduced): __m128i result; | - |
| 85 | BYTE_MUL_SSE2(result, srcVector, alphaChannel, colorMask, half); executed (the execution status of this line is deduced): { __m128i pixelVectorAG = _mm_srli_epi16(srcVector, 8); __m128i pixelVectorRB = _mm_and_si128(srcVector, colorMask); pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); result = _mm_or_si128(pixelVectorAG, pixelVectorRB); }; | - |
| 86 | result = _mm_or_si128(_mm_andnot_si128(alphaMask, result), srcVectorAlpha); executed (the execution status of this line is deduced): result = _mm_or_si128(_mm_andnot_si128(alphaMask, result), srcVectorAlpha); | - |
| 87 | _mm_storeu_si128(d, result); executed (the execution status of this line is deduced): _mm_storeu_si128(d, result); | - |
| 88 | } executed: }Execution Count:12784 | 12784 |
| 89 | } | - |
| 90 | | - |
| 91 | QRgb *p = reinterpret_cast<QRgb*>(d); executed (the execution status of this line is deduced): QRgb *p = reinterpret_cast<QRgb*>(d); | - |
| 92 | QRgb *pe = p+spare; executed (the execution status of this line is deduced): QRgb *pe = p+spare; | - |
| 93 | for (; p != pe; ++p) { partially evaluated: p != pe| no Evaluation Count:0 | yes Evaluation Count:656 |
| 0-656 |
| 94 | if (*p < 0x00ffffff) never evaluated: *p < 0x00ffffff | 0 |
| 95 | *p = 0; | 0 |
| 96 | else if (*p < 0xff000000) never evaluated: *p < 0xff000000 | 0 |
| 97 | *p = PREMUL(*p); never executed: *p = PREMUL(*p); | 0 |
| 98 | } | - |
| 99 | | - |
| 100 | d = reinterpret_cast<__m128i*>(p+pad); executed (the execution status of this line is deduced): d = reinterpret_cast<__m128i*>(p+pad); | - |
| 101 | } executed: }Execution Count:656 | 656 |
| 102 | | - |
| 103 | data->format = QImage::Format_ARGB32_Premultiplied; executed (the execution status of this line is deduced): data->format = QImage::Format_ARGB32_Premultiplied; | - |
| 104 | return true; executed: return true;Execution Count:13 | 13 |
| 105 | } | - |
| 106 | | - |
| 107 | QT_END_NAMESPACE | - |
| 108 | | - |
| 109 | #endif // QT_COMPILER_SUPPORTS_SSE2 | - |
| 110 | | - |
| | |