1 /****************************************************************************
3 ** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic <dtatalovic@mips.com>
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include <private/qdrawhelper_p.h>
43 #include <private/qdrawhelper_mips_dsp_p.h>
44 #include <private/qpaintengine_raster_p.h>
48 #if defined(QT_COMPILER_SUPPORTS_MIPS_DSP)
50 extern "C" uint INTERPOLATE_PIXEL_255_asm_mips_dsp(uint x, uint a, uint y, uint b);
52 extern "C" uint BYTE_MUL_asm_mips_dsp(uint x, uint a);
54 extern "C" uint * destfetchARGB32_asm_mips_dsp(uint *buffer, const uint *data, int length);
56 extern "C" uint * qt_destStoreARGB32_asm_mips_dsp(uint *buffer, const uint *data, int length);
58 #if defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
60 extern "C" uint INTERPOLATE_PIXEL_255_asm_mips_dspr2(uint x, uint a, uint y, uint b);
62 extern "C" uint BYTE_MUL_asm_mips_dspr2(uint x, uint a);
64 #endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2
66 void qt_blend_argb32_on_argb32_mips_dsp(uchar *destPixels, int dbpl,
67 const uchar *srcPixels, int sbpl,
74 "qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
75 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
79 const uint *src = (const uint *) srcPixels;
80 uint *dst = (uint *) destPixels;
81 if (const_alpha == 256) {
82 for (int y=0; y<h; ++y) {
83 for (int x=0; x<w; ++x) {
88 #if !defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
89 dst[x] = s + BYTE_MUL_asm_mips_dsp(dst[x], qAlpha(~s));
91 dst[x] = s + BYTE_MUL_asm_mips_dspr2(dst[x], qAlpha(~s));
94 dst = (quint32 *)(((uchar *) dst) + dbpl);
95 src = (const quint32 *)(((const uchar *) src) + sbpl);
97 } else if (const_alpha != 0) {
98 const_alpha = (const_alpha * 255) >> 8;
99 for (int y=0; y<h; ++y) {
100 for (int x=0; x<w; ++x) {
101 #if !defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
102 uint s = BYTE_MUL_asm_mips_dsp(src[x], const_alpha);
103 dst[x] = s + BYTE_MUL_asm_mips_dsp(dst[x], qAlpha(~s));
105 uint s = BYTE_MUL_asm_mips_dspr2(src[x], const_alpha);
106 dst[x] = s + BYTE_MUL_asm_mips_dspr2(dst[x], qAlpha(~s));
109 dst = (quint32 *)(((uchar *) dst) + dbpl);
110 src = (const quint32 *)(((const uchar *) src) + sbpl);
115 void qt_blend_rgb32_on_rgb32_mips_dsp(uchar *destPixels, int dbpl,
116 const uchar *srcPixels, int sbpl,
122 "qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
123 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
127 if (const_alpha != 256) {
128 qt_blend_argb32_on_argb32_mips_dsp(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
132 const uint *src = (const uint *) srcPixels;
133 uint *dst = (uint *) destPixels;
135 for (int y=0; y<h; ++y) {
136 memcpy(dst, src, len);
137 dst = (quint32 *)(((uchar *) dst) + dbpl);
138 src = (const quint32 *)(((const uchar *) src) + sbpl);
142 void comp_func_Source_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
144 if (const_alpha == 255) {
145 ::memcpy(dest, src, length * sizeof(uint));
147 int ialpha = 255 - const_alpha;
148 for (int i = 0; i < length; ++i) {
149 #if !defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
150 dest[i] = INTERPOLATE_PIXEL_255_asm_mips_dsp(src[i], const_alpha, dest[i], ialpha);
152 dest[i] = INTERPOLATE_PIXEL_255_asm_mips_dspr2(src[i], const_alpha, dest[i], ialpha);
158 uint * QT_FASTCALL qt_destFetchARGB32_mips_dsp(uint *buffer,
159 QRasterBuffer *rasterBuffer,
160 int x, int y, int length)
162 const uint *data = (const uint *)rasterBuffer->scanLine(y) + x;
163 buffer = destfetchARGB32_asm_mips_dsp(buffer, data, length);
167 void QT_FASTCALL qt_destStoreARGB32_mips_dsp(QRasterBuffer *rasterBuffer, int x, int y,
168 const uint *buffer, int length)
170 uint *data = (uint *)rasterBuffer->scanLine(y) + x;
171 qt_destStoreARGB32_asm_mips_dsp(data, buffer, length);
174 #endif // QT_COMPILER_SUPPORTS_MIPS_DSP