Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdrawhelper_mips_dsp.cpp
Go to the documentation of this file.
1// Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include <private/qdrawhelper_p.h>
6#include <private/qdrawhelper_mips_dsp_p.h>
7#include <private/qpaintengine_raster_p.h>
8
10
11void qt_memfill32(quint32 *dest, quint32 color, qsizetype count)
12{
13 qt_memfill32_asm_mips_dsp(dest, color, count);
14}
15
16void qt_blend_argb32_on_argb32_mips_dsp(uchar *destPixels, int dbpl,
17 const uchar *srcPixels, int sbpl,
18 int w, int h,
19 int const_alpha)
20
21{
22#ifdef QT_DEBUG_DRAW
23 fprintf(stdout,
24 "qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
25 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
26 fflush(stdout);
27#endif
28
29 const uint *src = (const uint *) srcPixels;
30 uint *dst = (uint *) destPixels;
31 if (const_alpha == 256) {
32 for (int y=0; y<h; ++y) {
33 qt_blend_argb32_on_argb32_const_alpha_256_mips_dsp_asm(dst, src, w);
34 dst = (quint32 *)(((uchar *) dst) + dbpl);
35 src = (const quint32 *)(((const uchar *) src) + sbpl);
36 }
37 } else if (const_alpha != 0) {
38 const_alpha = (const_alpha * 255) >> 8;
39 for (int y=0; y<h; ++y) {
40 if (h%2 > 0) {
41 uint s = BYTE_MUL(src[0], const_alpha);
42 dst[0] = s + BYTE_MUL(dst[0], qAlpha(~s));
43 h--;
44 dst++;
45 src++;
46 }
47 qt_blend_argb32_on_argb32_mips_dsp_asm_x2(dst, src, h, const_alpha);
48 dst = (quint32 *)(((uchar *) dst) + dbpl);
49 src = (const quint32 *)(((const uchar *) src) + sbpl);
50 }
51 }
52}
53
54void qt_blend_rgb32_on_rgb32_mips_dsp(uchar *destPixels, int dbpl,
55 const uchar *srcPixels, int sbpl,
56 int w, int h,
57 int const_alpha)
58{
59#ifdef QT_DEBUG_DRAW
60 fprintf(stdout,
61 "qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
62 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
63 fflush(stdout);
64#endif
65
66 if (const_alpha != 256) {
67 qt_blend_argb32_on_argb32_mips_dsp(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
68 return;
69 }
70
71 const uint *src = (const uint *) srcPixels;
72 uint *dst = (uint *) destPixels;
73 int len = w * 4;
74 for (int y=0; y<h; ++y) {
75 memcpy(dst, src, len);
76 dst = (quint32 *)(((uchar *) dst) + dbpl);
77 src = (const quint32 *)(((const uchar *) src) + sbpl);
78 }
79}
80
81#if defined(__MIPS_DSPR2__)
82void qt_blend_rgb16_on_rgb16_mips_dspr2(uchar *destPixels, int dbpl,
83 const uchar *srcPixels, int sbpl,
84 int w, int h,
85 int const_alpha)
86{
87 if (const_alpha == 256) {
88 if (w < 256) {
89 const quint16 *src = (const quint16*) srcPixels;
90 quint16 *dst = (quint16*) destPixels;
91 for (int y = 0; y < h; ++y) {
92 qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm(dst, src, w);
93 dst = (quint16*) (((uchar*) dst) + dbpl);
94 src = (quint16*) (((uchar*) src) + sbpl);
95 }
96 }
97 else {
98 int length = w << 1;
99 while (--h >= 0) {
100 memcpy(destPixels, srcPixels, length);
101 destPixels += dbpl;
102 srcPixels += sbpl;
103 }
104 }
105 }
106 else if (const_alpha != 0) {
107 const quint16 *src = (const quint16*) srcPixels;
108 quint16 *dst = (quint16*) destPixels;
109 for (int y = 0; y < h; ++y) {
110 qt_blend_rgb16_on_rgb16_mips_dspr2_asm(dst, src, w, const_alpha);
111 dst = (quint16*) (((uchar*) dst) + dbpl);
112 src = (quint16*) (((uchar*) src) + sbpl);
113 }
114 }
115}
116#else
117void qt_blend_rgb16_on_rgb16_mips_dsp(uchar *destPixels, int dbpl,
118 const uchar *srcPixels, int sbpl,
119 int w, int h,
120 int const_alpha)
121{
122 if (const_alpha == 256) {
123 if (w < 256) {
124 const quint16 *src = (const quint16*) srcPixels;
125 quint16 *dst = (quint16*) destPixels;
126 for (int y = 0; y < h; ++y) {
127 qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm(dst, src, w);
128 dst = (quint16*) (((uchar*) dst) + dbpl);
129 src = (quint16*) (((uchar*) src) + sbpl);
130 }
131 }
132 else {
133 int length = w << 1;
134 while (--h >= 0) {
135 memcpy(destPixels, srcPixels, length);
136 destPixels += dbpl;
137 srcPixels += sbpl;
138 }
139 }
140 }
141 else if (const_alpha != 0) {
142 const quint16 *src = (const quint16*) srcPixels;
143 quint16 *dst = (quint16*) destPixels;
144 for (int y = 0; y < h; ++y) {
145 qt_blend_rgb16_on_rgb16_mips_dsp_asm(dst, src, w, const_alpha);
146 dst = (quint16*) (((uchar*) dst) + dbpl);
147 src = (quint16*) (((uchar*) src) + sbpl);
148 }
149 }
150}
151#endif
152
153void comp_func_Source_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
154{
155 if (const_alpha == 255) {
156 ::memcpy(dest, src, length * sizeof(uint));
157 } else {
158 int ialpha = 255 - const_alpha;
159 if (length%2 > 0) {
160 dest[0] = INTERPOLATE_PIXEL_255(src[0], const_alpha, dest[0], ialpha);
161 length--;
162 dest++;
163 src++;
164 }
165 comp_func_Source_dsp_asm_x2(dest, src, length, const_alpha);
166 }
167}
168
169uint * QT_FASTCALL qt_destFetchARGB32_mips_dsp(uint *buffer,
170 QRasterBuffer *rasterBuffer,
171 int x, int y, int length)
172{
173 const uint *data = (const uint *)rasterBuffer->scanLine(y) + x;
174 buffer = destfetchARGB32_asm_mips_dsp(buffer, data, length);
175 return buffer;
176}
177
178void QT_FASTCALL qt_destStoreARGB32_mips_dsp(QRasterBuffer *rasterBuffer, int x, int y,
179 const uint *buffer, int length)
180{
181 uint *data = (uint *)rasterBuffer->scanLine(y) + x;
182 qt_destStoreARGB32_asm_mips_dsp(data, buffer, length);
183}
184
185void QT_FASTCALL comp_func_solid_SourceOver_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
186{
187 if (const_alpha != 255)
188 color = BYTE_MUL(color, const_alpha);
189 if (length%2 > 0) {
190 dest[0] = color + BYTE_MUL(dest[0], qAlpha(~color));
191 length--;
192 dest++;
193 }
194 comp_func_solid_Source_dsp_asm_x2(dest, length, color, qAlpha(~color));
195}
196
197void QT_FASTCALL comp_func_solid_DestinationOver_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
198{
199 if (const_alpha != 255)
200 color = BYTE_MUL(color, const_alpha);
201 if (length%2 > 0) {
202 uint d = dest[0];
203 dest[0] = d + BYTE_MUL(color, qAlpha(~d));
204 length--;
205 dest++;
206 }
207 comp_func_solid_DestinationOver_dsp_asm_x2(dest, length, color);
208}
209
210void QT_FASTCALL comp_func_DestinationOver_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
211{
212 if (length%2 > 0) {
213 if (const_alpha == 255) {
214 uint d = dest[0];
215 dest[0] = d + BYTE_MUL(src[0], qAlpha(~d));
216 } else {
217 uint d = dest[0];
218 uint s = BYTE_MUL(src[0], const_alpha);
219 dest[0] = d + BYTE_MUL(s, qAlpha(~d));
220 }
221 length--;
222 dest++;
223 src++;
224 }
225 comp_func_DestinationOver_dsp_asm_x2(dest, src, length, const_alpha);
226}
227
228void QT_FASTCALL comp_func_solid_SourceIn_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
229{
230 if (length%2 > 0) {
231 if (const_alpha == 255) {
232 dest[0] = BYTE_MUL(color, qAlpha(dest[0]));
233 } else {
234 uint tmp_color = BYTE_MUL(color, const_alpha);
235 uint cia = 255 - const_alpha;
236 uint d = dest[0];
237 dest[0] = INTERPOLATE_PIXEL_255(tmp_color, qAlpha(d), d, cia);
238 }
239 length--;
240 dest++;
241 }
242 comp_func_solid_SourceIn_dsp_asm_x2(dest, length, color, const_alpha);
243}
244
245void QT_FASTCALL comp_func_SourceIn_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
246{
247 if (length%2 > 0) {
248 if (const_alpha == 255) {
249 dest[0] = BYTE_MUL(src[0], qAlpha(dest[0]));
250 } else {
251 uint cia = 255 - const_alpha;
252 uint d = dest[0];
253 uint s = BYTE_MUL(src[0], const_alpha);
254 dest[0] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, cia);
255 }
256 length--;
257 dest++;
258 src++;
259 }
260 comp_func_SourceIn_dsp_asm_x2(dest, src, length, const_alpha);
261}
262
263void QT_FASTCALL comp_func_solid_DestinationIn_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
264{
265 uint a = qAlpha(color);
266 if (const_alpha != 255) {
267 a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
268 }
269 if (length%2 > 0) {
270 dest[0] = BYTE_MUL(dest[0], a);
271 length--;
272 dest++;
273 }
274 comp_func_solid_DestinationIn_dsp_asm_x2(dest, length, a);
275}
276
277void QT_FASTCALL comp_func_DestinationIn_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
278{
279 if (length%2 > 0) {
280 if (const_alpha == 255) {
281 dest[0] = BYTE_MUL(dest[0], qAlpha(src[0]));
282 } else {
283 int cia = 255 - const_alpha;
284 uint a = BYTE_MUL(qAlpha(src[0]), const_alpha) + cia;
285 dest[0] = BYTE_MUL(dest[0], a);
286 }
287 length--;
288 src++;
289 dest++;
290 }
291 comp_func_DestinationIn_dsp_asm_x2(dest, src, length, const_alpha);
292}
293
294void QT_FASTCALL comp_func_solid_DestinationOut_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
295{
296 uint a = qAlpha(~color);
297 if (const_alpha != 255) {
298 a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
299 }
300 if (length%2 > 0) {
301 dest[0] = BYTE_MUL(dest[0], a);
302 length--;
303 dest++;
304 }
305 comp_func_solid_DestinationIn_dsp_asm_x2(dest, length, a);
306}
307
308void QT_FASTCALL comp_func_DestinationOut_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
309{
310 if (length%2 > 0) {
311 if (const_alpha == 255) {
312 dest[0] = BYTE_MUL(dest[0], qAlpha(~src[0]));
313 } else {
314 int cia = 255 - const_alpha;
315 uint sia = BYTE_MUL(qAlpha(~src[0]), const_alpha) + cia;
316 dest[0] = BYTE_MUL(dest[0], sia);
317 }
318 length--;
319 dest++;
320 src++;
321 }
322 comp_func_DestinationOut_dsp_asm_x2(dest, src, length, const_alpha);
323}
324
325void QT_FASTCALL comp_func_solid_SourceAtop_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
326{
327 if (const_alpha != 255) {
328 color = BYTE_MUL(color, const_alpha);
329 }
330 uint sia = qAlpha(~color);
331 if (length%2 > 0) {
332 dest[0] = INTERPOLATE_PIXEL_255(color, qAlpha(dest[0]), dest[0], sia);
333 length--;
334 dest++;
335 }
336 comp_func_solid_SourceAtop_dsp_asm_x2(dest, length, color, sia);
337}
338
339void QT_FASTCALL comp_func_SourceAtop_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
340{
341 if (length%2 > 0) {
342 if (const_alpha == 255) {
343 uint s = src[0];
344 uint d = dest[0];
345 dest[0] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s));
346 } else {
347 uint s = BYTE_MUL(src[0], const_alpha);
348 uint d = dest[0];
349 dest[0] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s));
350 }
351 length--;
352 dest++;
353 src++;
354 }
355 comp_func_SourceAtop_dsp_asm_x2(dest, src, length, const_alpha);
356}
357
358
359void QT_FASTCALL comp_func_solid_DestinationAtop_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
360{
361 uint a = qAlpha(color);
362 if (const_alpha != 255) {
363 color = BYTE_MUL(color, const_alpha);
364 a = qAlpha(color) + 255 - const_alpha;
365 }
366 if (length%2 > 0) {
367 uint d = dest[0];
368 dest[0] = INTERPOLATE_PIXEL_255(d, a, color, qAlpha(~d));
369 length--;
370 dest++;
371 }
372 comp_func_solid_DestinationAtop_dsp_asm_x2(dest, length, color, a);
373}
374
375void QT_FASTCALL comp_func_DestinationAtop_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
376{
377 if (length%2 > 0) {
378 if (const_alpha == 255) {
379 uint s = src[0];
380 uint d = dest[0];
381 dest[0] = INTERPOLATE_PIXEL_255(d, qAlpha(s), s, qAlpha(~d));
382 } else {
383 int cia = 255 - const_alpha;
384 uint s = BYTE_MUL(src[0], const_alpha);
385 uint d = dest[0];
386 uint a = qAlpha(s) + cia;
387 dest[0] = INTERPOLATE_PIXEL_255(d, a, s, qAlpha(~d));
388 }
389 length--;
390 dest++;
391 src++;
392 }
393 comp_func_DestinationAtop_dsp_asm_x2(dest, src, length, const_alpha);
394}
395
396void QT_FASTCALL comp_func_solid_XOR_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
397{
398 if (const_alpha != 255)
399 color = BYTE_MUL(color, const_alpha);
400 uint sia = qAlpha(~color);
401
402 if (length%2 > 0) {
403 uint d = dest[0];
404 dest[0] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, sia);
405 length--;
406 dest++;
407 }
408 comp_func_solid_XOR_dsp_asm_x2(dest, length, color, sia);
409}
410
411void QT_FASTCALL comp_func_XOR_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
412{
413 if (length%2 > 0) {
414 if (const_alpha == 255) {
415 uint d = dest[0];
416 uint s = src[0];
417 dest[0] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s));
418 } else {
419 uint d = dest[0];
420 uint s = BYTE_MUL(src[0], const_alpha);
421 dest[0] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s));
422 }
423 length--;
424 dest++;
425 src++;
426 }
427 comp_func_XOR_dsp_asm_x2(dest, src, length, const_alpha);
428}
429
430void QT_FASTCALL comp_func_solid_SourceOut_mips_dsp(uint *dest, int length, uint color, uint const_alpha)
431{
432 if (length%2 > 0) {
433 if (const_alpha == 255) {
434 dest[0] = BYTE_MUL(color, qAlpha(~dest[0]));
435 } else {
436 uint tmp_color = BYTE_MUL(color, const_alpha);
437 int cia = 255 - const_alpha;
438 uint d = dest[0];
439 dest[0] = INTERPOLATE_PIXEL_255(tmp_color, qAlpha(~d), d, cia);
440 }
441 length--;
442 dest++;
443 }
444 comp_func_solid_SourceOut_dsp_asm_x2(dest, length, color, const_alpha);
445}
446
447void QT_FASTCALL comp_func_SourceOut_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
448{
449 if (length%2 > 0) {
450 if (const_alpha == 255) {
451 dest[0] = BYTE_MUL(src[0], qAlpha(~dest[0]));
452 } else {
453 int cia = 255 - const_alpha;
454 uint s = BYTE_MUL(src[0], const_alpha);
455 uint d = dest[0];
456 dest[0] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, cia);
457 }
458 length--;
459 dest++;
460 src++;
461 }
462 comp_func_SourceOut_dsp_asm_x2(dest, src, length, const_alpha);
463}
464
465const uint * QT_FASTCALL qt_fetchUntransformed_888_mips_dsp (uint *buffer, const Operator *, const QSpanData *data,
466 int y, int x, int length)
467{
468 const uchar *line = data->texture.scanLine(y) + x * 3;
469 fetchUntransformed_888_asm_mips_dsp(buffer, line, length);
470 return buffer;
471}
472
473const uint * QT_FASTCALL qt_fetchUntransformed_444_mips_dsp (uint *buffer, const Operator *, const QSpanData *data,
474 int y, int x, int length)
475{
476 const uchar *line = data->texture.scanLine(y) + x * 2;
477 fetchUntransformed_444_asm_mips_dsp(buffer, line, length);
478 return buffer;
479}
480
481const uint * QT_FASTCALL qt_fetchUntransformed_argb8565_premultiplied_mips_dsp (uint *buffer, const Operator *, const QSpanData *data,
482 int y, int x, int length)
483{
484 const uchar *line = data->texture.scanLine(y) + x * 3;
485 fetchUntransformed_argb8565_premultiplied_asm_mips_dsp(buffer, line, length);
486 return buffer;
487}
488
489#if defined(__MIPS_DSPR2__)
490extern "C" void qConvertRgb16To32_asm_mips_dspr2(quint32 *dest, const quint16 *src, int length);
491
492const uint *QT_FASTCALL qt_fetchUntransformedRGB16_mips_dspr2(uint *buffer, const Operator *,
493 const QSpanData *data, int y, int x,
494 int length)
495{
496 const quint16 *scanLine = (const quint16 *)data->texture.scanLine(y) + x;
497 qConvertRgb16To32_asm_mips_dspr2(buffer, scanLine, length);
498 return buffer;
499}
500#endif
501
502QT_END_NAMESPACE
uint QT_FASTCALL fetch1Pixel< QPixelLayout::BPP1LSB >(const uchar *src, int index)
void qt_blend_argb32_on_argb32_mips_dsp(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void qt_blend_rgb16_on_rgb16_mips_dsp(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void comp_func_Source_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha)
void qt_blend_rgb32_on_rgb32_mips_dsp(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void qt_memfill32(quint32 *dest, quint32 value, qsizetype count)