source: trunk/src/gui/image/qimage_neon.cpp@ 855

Last change on this file since 855 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 4.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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**
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.
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**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <qimage.h>
43#include <private/qimage_p.h>
44#include <private/qsimd_p.h>
45
46#ifdef QT_HAVE_NEON
47
48QT_BEGIN_NAMESPACE
49
50Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len)
51{
52 if (!len)
53 return;
54
55 const quint32 *const end = dst + len;
56
57 // align dst on 64 bits
58 const int offsetToAlignOn8Bytes = (reinterpret_cast<quintptr>(dst) >> 2) & 0x1;
59 for (int i = 0; i < offsetToAlignOn8Bytes; ++i) {
60 *dst++ = qRgb(src[0], src[1], src[2]);
61 src += 3;
62 }
63
64 if ((len - offsetToAlignOn8Bytes) >= 8) {
65 const quint32 *const simdEnd = end - 7;
66 register uint8x8_t fullVector asm ("d3") = vdup_n_u8(0xff);
67 do {
68#if Q_BYTE_ORDER == Q_BIG_ENDIAN
69 asm volatile (
70 "vld3.8 { d4, d5, d6 }, [%[SRC]] !\n\t"
71 "vst4.8 { d3, d4, d5, d6 }, [%[DST],:64] !\n\t"
72 : [DST]"+r" (dst), [SRC]"+r" (src)
73 : "w"(fullVector)
74 : "memory", "d4", "d5", "d6"
75 );
76#else
77 asm volatile (
78 "vld3.8 { d0, d1, d2 }, [%[SRC]] !\n\t"
79 "vswp d0, d2\n\t"
80 "vst4.8 { d0, d1, d2, d3 }, [%[DST],:64] !\n\t"
81 : [DST]"+r" (dst), [SRC]"+r" (src)
82 : "w"(fullVector)
83 : "memory", "d0", "d1", "d2"
84 );
85#endif
86 } while (dst < simdEnd);
87 }
88
89 while (dst != end) {
90 *dst++ = qRgb(src[0], src[1], src[2]);
91 src += 3;
92 }
93}
94
95void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
96{
97 Q_ASSERT(src->format == QImage::Format_RGB888);
98 Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied);
99 Q_ASSERT(src->width == dest->width);
100 Q_ASSERT(src->height == dest->height);
101
102 const uchar *src_data = (uchar *) src->data;
103 quint32 *dest_data = (quint32 *) dest->data;
104
105 for (int i = 0; i < src->height; ++i) {
106 qt_convert_rgb888_to_rgb32_neon(dest_data, src_data, src->width);
107 src_data += src->bytes_per_line;
108 dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line);
109 }
110}
111
112QT_END_NAMESPACE
113
114#endif // QT_HAVE_NEON
Note: See TracBrowser for help on using the repository browser.