qimage_sse2.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qimage_sse2.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qimage.h"-
35#include <private/qimage_p.h>-
36#include <private/qsimd_p.h>-
37#include <private/qdrawhelper_p.h>-
38#include <private/qdrawingprimitive_sse2_p.h>-
39-
40#ifdef QT_COMPILER_SUPPORTS_SSE2-
41-
42QT_BEGIN_NAMESPACE-
43-
44bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags)-
45{-
46 Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_RGBA8888);-
47-
48 // extra pixels on each line-
49 const int spare = data->width & 3;-
50 // width in pixels of the pad at the end of each line-
51 const int pad = (data->bytes_per_line >> 2) - data->width;-
52 const int iter = data->width >> 2;-
53 int height = data->height;-
54-
55 const __m128i alphaMask = _mm_set1_epi32(0xff000000);-
56 const __m128i nullVector = _mm_setzero_si128();-
57 const __m128i half = _mm_set1_epi16(0x80);-
58 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
59-
60 __m128i *d = reinterpret_cast<__m128i*>(data->data);-
61 while (height--) {
height--Description
TRUEnever evaluated
FALSEnever evaluated
0
62 const __m128i *end = d + iter;-
63-
64 for (; d != end; ++d) {
d != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
65 const __m128i srcVector = _mm_loadu_si128(d);-
66 const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask);-
67 if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) {
_mm_movemask_e...sk)) == 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
68 // opaque, data is unchanged-
69 } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) == 0xffff) {
never executed: end of block
_mm_movemask_e...or)) == 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
70 // fully transparent-
71 _mm_storeu_si128(d, nullVector);-
72 } else {
never executed: end of block
0
73 __m128i alphaChannel = _mm_srli_epi32(srcVector, 24);-
74 alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16));-
75-
76 __m128i result;-
77 BYTE_MUL_SSE2(result, srcVector, alphaChannel, colorMask, half);-
78 result = _mm_or_si128(_mm_andnot_si128(alphaMask, result), srcVectorAlpha);-
79 _mm_storeu_si128(d, result);-
80 }
never executed: end of block
0
81 }-
82-
83 QRgb *p = reinterpret_cast<QRgb*>(d);-
84 QRgb *pe = p+spare;-
85 for (; p != pe; ++p) {
p != peDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 if (*p < 0x00ffffff)
*p < 0x00ffffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
87 *p = 0;
never executed: *p = 0;
0
88 else if (*p < 0xff000000)
*p < 0xff000000Description
TRUEnever evaluated
FALSEnever evaluated
0
89 *p = qPremultiply(*p);
never executed: *p = qPremultiply(*p);
0
90 }
never executed: end of block
0
91-
92 d = reinterpret_cast<__m128i*>(p+pad);-
93 }
never executed: end of block
0
94-
95 if (data->format == QImage::Format_ARGB32)
data->format =...:Format_ARGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
96 data->format = QImage::Format_ARGB32_Premultiplied;
never executed: data->format = QImage::Format_ARGB32_Premultiplied;
0
97 else-
98 data->format = QImage::Format_RGBA8888_Premultiplied;
never executed: data->format = QImage::Format_RGBA8888_Premultiplied;
0
99 return true;
never executed: return true;
0
100}-
101-
102QT_END_NAMESPACE-
103-
104#endif // QT_COMPILER_SUPPORTS_SSE2-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9