blob: 4f9beb174b6e05929cd8146e30f34810f6ca9c12 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26#if !defined(JAVA2D_NO_MLIB) || defined(MLIB_ADD_SUFF)
27
28#include "vis_AlphaMacros.h"
29
30/***************************************************************/
31
32/* ##############################################################
33 * IntArgbPreAlphaMaskFill()
34 */
35
36#undef MASK_FILL
37#define MASK_FILL(rr, pathA, dstA, dstARGB) \
38{ \
39 mlib_d64 t0, t1; \
40 mlib_s32 srcF, dstF; \
41 \
42 srcF = ((dstA & ConstAnd) ^ ConstXor) + ConstAdd; \
43 srcF = MUL8_INT(srcF, pathA); \
44 dstF = mul8_cnstF[pathA] + (255 - pathA); \
45 \
46 t0 = MUL8_VIS(cnstARGB0, srcF); \
47 t1 = MUL8_VIS(dstARGB, dstF); \
48 rr = vis_fpadd16(t0, t1); \
49}
50
51/***************************************************************/
52
53void IntArgbPreAlphaMaskFill_line(mlib_f32 *dst_ptr,
54 mlib_u8 *pMask,
55 mlib_s32 width,
56 mlib_f32 cnstARGB0,
57 mlib_s32 *log_val,
58 mlib_u8 *mul8_cnstF,
59 mlib_u8 *mul8_tbl);
60
61#pragma no_inline(IntArgbPreAlphaMaskFill_line)
62
63void IntArgbPreAlphaMaskFill_line(mlib_f32 *dst_ptr,
64 mlib_u8 *pMask,
65 mlib_s32 width,
66 mlib_f32 cnstARGB0,
67 mlib_s32 *log_val,
68 mlib_u8 *mul8_cnstF,
69 mlib_u8 *mul8_tbl)
70{
71 mlib_s32 i, i0;
72 mlib_s32 pathA0, pathA1, dstA0, dstA1, msk;
73 mlib_d64 res0, res1, dstARGB;
74 mlib_f32 dstARGB0;
75 mlib_s32 ConstAnd, ConstXor, ConstAdd;
76
77 ConstAnd = log_val[0];
78 ConstXor = log_val[1];
79 ConstAdd = log_val[2];
80
81 i = i0 = 0;
82
83 if ((mlib_s32)dst_ptr & 7) {
84 pathA0 = pMask[i];
85
86 if (pathA0) {
87 dstA0 = *(mlib_u8*)(dst_ptr + i);
88 dstARGB0 = dst_ptr[i];
89 MASK_FILL(res0, pathA0, dstA0, dstARGB0);
90 dst_ptr[i] = vis_fpack16(res0);
91 }
92
93 i0 = 1;
94 }
95
96#pragma pipeloop(0)
97 for (i = i0; i <= width - 2; i += 2) {
98 pathA0 = pMask[i];
99 pathA1 = pMask[i + 1];
100 dstA0 = *(mlib_u8*)(dst_ptr + i);
101 dstA1 = *(mlib_u8*)(dst_ptr + i + 1);
102 dstARGB = *(mlib_d64*)(dst_ptr + i);
103
104 MASK_FILL(res0, pathA0, dstA0, vis_read_hi(dstARGB));
105 MASK_FILL(res1, pathA1, dstA1, vis_read_lo(dstARGB));
106
107 res0 = vis_fpack16_pair(res0, res1);
108
109 msk = (((-pathA0) & (1 << 11)) | ((-pathA1) & (1 << 10))) >> 10;
110 vis_pst_32(res0, dst_ptr + i, msk);
111 }
112
113 if (i < width) {
114 pathA0 = pMask[i];
115
116 if (pathA0) {
117 dstA0 = *(mlib_u8*)(dst_ptr + i);
118 dstARGB0 = dst_ptr[i];
119 MASK_FILL(res0, pathA0, dstA0, dstARGB0);
120 dst_ptr[i] = vis_fpack16(res0);
121 }
122 }
123}
124
125/***************************************************************/
126
127#undef MASK_FILL
128#define MASK_FILL(rr, cnstF, dstA, dstARGB) \
129{ \
130 mlib_d64 t0, t1; \
131 mlib_s32 srcF, dstF; \
132 \
133 srcF = ((dstA & ConstAnd) ^ ConstXor) + ConstAdd; \
134 dstF = cnstF; \
135 \
136 t0 = MUL8_VIS(cnstARGB0, srcF); \
137 t1 = MUL8_VIS(dstARGB, dstF); \
138 rr = vis_fpadd16(t0, t1); \
139}
140
141/***************************************************************/
142
143void IntArgPrebAlphaMaskFill_A1_line(mlib_f32 *dst_ptr,
144 mlib_s32 width,
145 mlib_f32 cnstARGB0,
146 mlib_s32 *log_val,
147 mlib_s32 cnstF);
148
149#pragma no_inline(IntArgPrebAlphaMaskFill_A1_line)
150
151void IntArgPrebAlphaMaskFill_A1_line(mlib_f32 *dst_ptr,
152 mlib_s32 width,
153 mlib_f32 cnstARGB0,
154 mlib_s32 *log_val,
155 mlib_s32 cnstF)
156{
157 mlib_s32 i, i0;
158 mlib_s32 dstA0, dstA1;
159 mlib_d64 res0, res1, dstARGB;
160 mlib_f32 dstARGB0;
161 mlib_s32 ConstAnd, ConstXor, ConstAdd;
162
163 ConstAnd = log_val[0];
164 ConstXor = log_val[1];
165 ConstAdd = log_val[2];
166
167 i = i0 = 0;
168
169 if ((mlib_s32)dst_ptr & 7) {
170 {
171 dstA0 = *(mlib_u8*)(dst_ptr + i);
172 dstARGB0 = dst_ptr[i];
173 MASK_FILL(res0, cnstF, dstA0, dstARGB0);
174 dst_ptr[i] = vis_fpack16(res0);
175 }
176
177 i0 = 1;
178 }
179
180#pragma pipeloop(0)
181 for (i = i0; i <= width - 2; i += 2) {
182 dstA0 = *(mlib_u8*)(dst_ptr + i);
183 dstA1 = *(mlib_u8*)(dst_ptr + i + 1);
184 dstARGB = *(mlib_d64*)(dst_ptr + i);
185
186 MASK_FILL(res0, cnstF, dstA0, vis_read_hi(dstARGB));
187 MASK_FILL(res1, cnstF, dstA1, vis_read_lo(dstARGB));
188
189 res0 = vis_fpack16_pair(res0, res1);
190
191 *(mlib_d64*)(dst_ptr + i) = res0;
192 }
193
194 if (i < width) {
195 {
196 dstA0 = *(mlib_u8*)(dst_ptr + i);
197 dstARGB0 = dst_ptr[i];
198 MASK_FILL(res0, cnstF, dstA0, dstARGB0);
199 dst_ptr[i] = vis_fpack16(res0);
200 }
201 }
202}
203
204/***************************************************************/
205
206void ADD_SUFF(IntArgbPreAlphaMaskFill)(void *rasBase,
207 jubyte *pMask,
208 jint maskOff,
209 jint maskScan,
210 jint width,
211 jint height,
212 jint fgColor,
213 SurfaceDataRasInfo *pRasInfo,
214 NativePrimitive *pPrim,
215 CompositeInfo *pCompInfo)
216{
217 mlib_s32 cnstA, cnstR, cnstG, cnstB;
218 mlib_s32 rasScan = pRasInfo->scanStride;
219 mlib_f32 cnstARGB0;
220 mlib_u8 *mul8_cnstF;
221 mlib_s32 SrcOpAnd, SrcOpXor, SrcOpAdd;
222 mlib_s32 DstOpAnd, DstOpXor, DstOpAdd;
223 mlib_s32 dstFbase;
224 mlib_s32 log_val[3];
225 mlib_s32 j;
226
227 cnstA = (fgColor >> 24) & 0xff;
228 cnstR = (fgColor >> 16) & 0xff;
229 cnstG = (fgColor >> 8) & 0xff;
230 cnstB = (fgColor ) & 0xff;
231
232 if (cnstA != 0xff) {
233 cnstR = mul8table[cnstA][cnstR];
234 cnstG = mul8table[cnstA][cnstG];
235 cnstB = mul8table[cnstA][cnstB];
236 }
237
238 cnstARGB0 = F32_FROM_U8x4(cnstA, cnstR, cnstG, cnstB);
239
240 SrcOpAnd = (AlphaRules[pCompInfo->rule].srcOps).andval;
241 SrcOpXor = (AlphaRules[pCompInfo->rule].srcOps).xorval;
242 SrcOpAdd = (AlphaRules[pCompInfo->rule].srcOps).addval;
243 SrcOpAdd -= SrcOpXor;
244
245 log_val[0] = SrcOpAnd;
246 log_val[1] = SrcOpXor;
247 log_val[2] = SrcOpAdd;
248
249 DstOpAnd = (AlphaRules[pCompInfo->rule].dstOps).andval;
250 DstOpXor = (AlphaRules[pCompInfo->rule].dstOps).xorval;
251 DstOpAdd = (AlphaRules[pCompInfo->rule].dstOps).addval;
252 DstOpAdd -= DstOpXor;
253
254 dstFbase = (((cnstA) & DstOpAnd) ^ DstOpXor) + DstOpAdd;
255
256 mul8_cnstF = mul8table[dstFbase];
257
258 vis_write_gsr(0 << 3);
259
260 if (pMask != NULL) {
261 pMask += maskOff;
262
263 if (rasScan == 4*width && maskScan == width) {
264 width *= height;
265 height = 1;
266 }
267
268 for (j = 0; j < height; j++) {
269 IntArgbPreAlphaMaskFill_line(rasBase, pMask, width, cnstARGB0,
270 log_val, mul8_cnstF,
271 (void*)mul8table);
272
273 PTR_ADD(rasBase, rasScan);
274 PTR_ADD(pMask, maskScan);
275 }
276 } else {
277 if (rasScan == 4*width) {
278 width *= height;
279 height = 1;
280 }
281
282 for (j = 0; j < height; j++) {
283 IntArgPrebAlphaMaskFill_A1_line(rasBase, width, cnstARGB0,
284 log_val, dstFbase);
285
286 PTR_ADD(rasBase, rasScan);
287 }
288 }
289}
290
291/***************************************************************/
292
293void ADD_SUFF(FourByteAbgrPreAlphaMaskFill)(void *rasBase,
294 jubyte *pMask,
295 jint maskOff,
296 jint maskScan,
297 jint width,
298 jint height,
299 jint fgColor,
300 SurfaceDataRasInfo *pRasInfo,
301 NativePrimitive *pPrim,
302 CompositeInfo *pCompInfo)
303{
304 mlib_d64 buff[BUFF_SIZE/2];
305 void *pbuff = buff, *p_dst;
306 mlib_s32 cnstA, cnstR, cnstG, cnstB;
307 mlib_s32 rasScan = pRasInfo->scanStride;
308 mlib_f32 cnstARGB0;
309 mlib_u8 *mul8_cnstF;
310 mlib_s32 SrcOpAnd, SrcOpXor, SrcOpAdd;
311 mlib_s32 DstOpAnd, DstOpXor, DstOpAdd;
312 mlib_s32 dstFbase;
313 mlib_s32 log_val[3];
314 mlib_s32 j;
315
316 if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
317
318 cnstA = (fgColor >> 24) & 0xff;
319 cnstR = (fgColor >> 16) & 0xff;
320 cnstG = (fgColor >> 8) & 0xff;
321 cnstB = (fgColor ) & 0xff;
322
323 if (cnstA != 0xff) {
324 cnstR = mul8table[cnstA][cnstR];
325 cnstG = mul8table[cnstA][cnstG];
326 cnstB = mul8table[cnstA][cnstB];
327 }
328
329 cnstARGB0 = F32_FROM_U8x4(cnstA, cnstB, cnstG, cnstR);
330
331 SrcOpAnd = (AlphaRules[pCompInfo->rule].srcOps).andval;
332 SrcOpXor = (AlphaRules[pCompInfo->rule].srcOps).xorval;
333 SrcOpAdd = (AlphaRules[pCompInfo->rule].srcOps).addval;
334 SrcOpAdd -= SrcOpXor;
335
336 log_val[0] = SrcOpAnd;
337 log_val[1] = SrcOpXor;
338 log_val[2] = SrcOpAdd;
339
340 DstOpAnd = (AlphaRules[pCompInfo->rule].dstOps).andval;
341 DstOpXor = (AlphaRules[pCompInfo->rule].dstOps).xorval;
342 DstOpAdd = (AlphaRules[pCompInfo->rule].dstOps).addval;
343 DstOpAdd -= DstOpXor;
344
345 dstFbase = (((cnstA) & DstOpAnd) ^ DstOpXor) + DstOpAdd;
346
347 mul8_cnstF = mul8table[dstFbase];
348
349 vis_write_gsr(0 << 3);
350
351 if (pMask != NULL) {
352 pMask += maskOff;
353
354 for (j = 0; j < height; j++) {
355 if ((mlib_s32)rasBase & 3) {
356 mlib_ImageCopy_na(rasBase, pbuff, width*sizeof(mlib_s32));
357 p_dst = pbuff;
358 } else {
359 p_dst = rasBase;
360 }
361
362 IntArgbPreAlphaMaskFill_line(p_dst, pMask, width, cnstARGB0,
363 log_val, mul8_cnstF,
364 (void*)mul8table);
365
366 if (p_dst != rasBase) {
367 mlib_ImageCopy_na(p_dst, rasBase, width*sizeof(mlib_s32));
368 }
369
370 PTR_ADD(rasBase, rasScan);
371 PTR_ADD(pMask, maskScan);
372 }
373 } else {
374 for (j = 0; j < height; j++) {
375 if ((mlib_s32)rasBase & 3) {
376 mlib_ImageCopy_na(rasBase, pbuff, width*sizeof(mlib_s32));
377 p_dst = pbuff;
378 } else {
379 p_dst = rasBase;
380 }
381
382 IntArgPrebAlphaMaskFill_A1_line(p_dst, width, cnstARGB0,
383 log_val, dstFbase);
384
385 if (p_dst != rasBase) {
386 mlib_ImageCopy_na(p_dst, rasBase, width*sizeof(mlib_s32));
387 }
388
389 PTR_ADD(rasBase, rasScan);
390 }
391 }
392
393 if (pbuff != buff) {
394 mlib_free(pbuff);
395 }
396}
397
398/***************************************************************/
399
400/* ##############################################################
401 * IntArgbPreSrcMaskFill()
402 */
403
404#undef MASK_FILL
405#define MASK_FILL(rr, pathA, dstARGB) \
406{ \
407 mlib_d64 t0, t1; \
408 \
409 t0 = MUL8_VIS(cnstARGB0, pathA); \
410 t1 = MUL8_VIS(dstARGB, (0xff - pathA)); \
411 rr = vis_fpadd16(t0, t1); \
412}
413
414/***************************************************************/
415
416void IntArgbPreSrcMaskFill_line(mlib_f32 *dst_ptr,
417 mlib_u8 *pMask,
418 mlib_s32 width,
419 mlib_d64 fgARGB,
420 mlib_f32 cnstARGB0);
421
422#pragma no_inline(IntArgbPreSrcMaskFill_line)
423
424void IntArgbPreSrcMaskFill_line(mlib_f32 *dst_ptr,
425 mlib_u8 *pMask,
426 mlib_s32 width,
427 mlib_d64 fgARGB,
428 mlib_f32 cnstARGB0)
429{
430 mlib_s32 i, i0;
431 mlib_s32 pathA0, pathA1, msk;
432 mlib_d64 res0, res1, dstARGB;
433 mlib_f32 dstARGB0;
434
435 i = i0 = 0;
436
437 if ((mlib_s32)dst_ptr & 7) {
438 pathA0 = pMask[i];
439 if (pathA0 == 0xff) {
440 dst_ptr[i] = vis_read_hi(fgARGB);
441 } else if (pathA0) {
442 dstARGB0 = dst_ptr[i];
443 MASK_FILL(res0, pathA0, dstARGB0);
444 dst_ptr[i] = vis_fpack16(res0);
445 }
446
447 i0 = 1;
448 }
449
450#pragma pipeloop(0)
451 for (i = i0; i <= width - 2; i += 2) {
452 pathA0 = pMask[i];
453 pathA1 = pMask[i + 1];
454
455 dstARGB = *(mlib_d64*)(dst_ptr + i);
456
457 msk = (((254 - pathA0) & (1 << 11)) |
458 ((254 - pathA1) & (1 << 10))) >> 10;
459
460 MASK_FILL(res0, pathA0, vis_read_hi(dstARGB));
461 MASK_FILL(res1, pathA1, vis_read_lo(dstARGB));
462
463 res0 = vis_fpack16_pair(res0, res1);
464
465 *(mlib_d64*)(dst_ptr + i) = res0;
466
467 vis_pst_32(fgARGB, dst_ptr + i, msk);
468 }
469
470 if (i < width) {
471 pathA0 = pMask[i];
472 if (pathA0 == 0xff) {
473 dst_ptr[i] = vis_read_hi(fgARGB);
474 } else if (pathA0) {
475 dstARGB0 = dst_ptr[i];
476 MASK_FILL(res0, pathA0, dstARGB0);
477 dst_ptr[i] = vis_fpack16(res0);
478 }
479 }
480}
481
482/***************************************************************/
483
484void ADD_SUFF(IntArgbPreSrcMaskFill)(void *rasBase,
485 jubyte *pMask,
486 jint maskOff,
487 jint maskScan,
488 jint width,
489 jint height,
490 jint fgColor,
491 SurfaceDataRasInfo *pRasInfo,
492 NativePrimitive *pPrim,
493 CompositeInfo *pCompInfo)
494{
495 mlib_s32 cnstA, cnstR, cnstG, cnstB;
496 mlib_s32 rasScan = pRasInfo->scanStride;
497 mlib_f32 cnstARGB0;
498 mlib_d64 fgARGB;
499 mlib_s32 j;
500
501 cnstA = (fgColor >> 24) & 0xff;
502 cnstR = (fgColor >> 16) & 0xff;
503 cnstG = (fgColor >> 8) & 0xff;
504 cnstB = (fgColor ) & 0xff;
505
506 if (cnstA != 0xff) {
507#ifdef LOOPS_OLD_VERSION
508 if (cnstA == 0) return;
509#endif
510 cnstR = mul8table[cnstA][cnstR];
511 cnstG = mul8table[cnstA][cnstG];
512 cnstB = mul8table[cnstA][cnstB];
513 }
514
515 if (pMask == NULL) {
516#ifdef LOOPS_OLD_VERSION
517 ADD_SUFF(AnyIntSetRect)(pRasInfo, 0, 0, width, height,
518 fgColor, pPrim, pCompInfo);
519#else
520 if (cnstA != 0xff) {
521 fgColor = (cnstA << 24) | (cnstR << 16) | (cnstG << 8) | cnstB;
522 }
523 ADD_SUFF(AnyIntSetRect)(pRasInfo,
524 pRasInfo->bounds.x1, pRasInfo->bounds.y1,
525 pRasInfo->bounds.x2, pRasInfo->bounds.y2,
526 fgColor, pPrim, pCompInfo);
527#endif
528 return;
529 }
530
531 cnstARGB0 = F32_FROM_U8x4(cnstA, cnstR, cnstG, cnstB);
532
533 fgARGB = vis_to_double_dup(fgColor);
534
535 pMask += maskOff;
536
537 if (rasScan == 4*width && maskScan == width) {
538 width *= height;
539 height = 1;
540 }
541
542 vis_write_gsr(0 << 3);
543
544 for (j = 0; j < height; j++) {
545 IntArgbPreSrcMaskFill_line(rasBase, pMask, width, fgARGB, cnstARGB0);
546
547 PTR_ADD(rasBase, rasScan);
548 PTR_ADD(pMask, maskScan);
549 }
550}
551
552/***************************************************************/
553
554void ADD_SUFF(FourByteAbgrPreSrcMaskFill)(void *rasBase,
555 jubyte *pMask,
556 jint maskOff,
557 jint maskScan,
558 jint width,
559 jint height,
560 jint fgColor,
561 SurfaceDataRasInfo *pRasInfo,
562 NativePrimitive *pPrim,
563 CompositeInfo *pCompInfo)
564{
565 mlib_d64 buff[BUFF_SIZE/2];
566 void *pbuff = buff, *p_dst;
567 mlib_s32 cnstA, cnstR, cnstG, cnstB;
568 mlib_s32 rasScan = pRasInfo->scanStride;
569 mlib_f32 cnstARGB0;
570 mlib_d64 fgARGB;
571 mlib_s32 j;
572
573 cnstA = (fgColor >> 24) & 0xff;
574 cnstR = (fgColor >> 16) & 0xff;
575 cnstG = (fgColor >> 8) & 0xff;
576 cnstB = (fgColor ) & 0xff;
577
578 if (cnstA != 0xff) {
579 cnstR = mul8table[cnstA][cnstR];
580 cnstG = mul8table[cnstA][cnstG];
581 cnstB = mul8table[cnstA][cnstB];
582 }
583
584 if (pMask == NULL) {
585 fgColor = (cnstR << 24) | (cnstG << 16) | (cnstB << 8) | cnstA;
586 ADD_SUFF(Any4ByteSetRect)(pRasInfo,
587 pRasInfo->bounds.x1, pRasInfo->bounds.y1,
588 pRasInfo->bounds.x2, pRasInfo->bounds.y2,
589 fgColor, pPrim, pCompInfo);
590 return;
591 }
592
593 fgColor = (cnstA << 24) | (cnstB << 16) | (cnstG << 8) | cnstR;
594 cnstARGB0 = F32_FROM_U8x4(cnstA, cnstB, cnstG, cnstR);
595
596 fgARGB = vis_to_double_dup(fgColor);
597
598 pMask += maskOff;
599
600 vis_write_gsr(0 << 3);
601
602 if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
603
604 for (j = 0; j < height; j++) {
605 if ((mlib_s32)rasBase & 3) {
606 mlib_ImageCopy_na(rasBase, pbuff, width*sizeof(mlib_s32));
607 p_dst = pbuff;
608 } else {
609 p_dst = rasBase;
610 }
611
612 IntArgbPreSrcMaskFill_line(p_dst, pMask, width, fgARGB, cnstARGB0);
613
614 if (p_dst != rasBase) {
615 mlib_ImageCopy_na(p_dst, rasBase, width*sizeof(mlib_s32));
616 }
617
618 PTR_ADD(rasBase, rasScan);
619 PTR_ADD(pMask, maskScan);
620 }
621
622 if (pbuff != buff) {
623 mlib_free(pbuff);
624 }
625}
626
627/***************************************************************/
628
629/* ##############################################################
630 * IntArgbPreSrcOverMaskFill()
631 */
632
633#undef MASK_FILL
634#define MASK_FILL(rr, pathA, dstARGB) \
635{ \
636 mlib_d64 t0, t1; \
637 mlib_s32 dstA; \
638 \
639 dstA = 0xff - mul8_cnstA[pathA]; \
640 \
641 t0 = MUL8_VIS(cnstARGB0, pathA); \
642 t1 = MUL8_VIS(dstARGB, dstA); \
643 rr = vis_fpadd16(t0, t1); \
644}
645
646/***************************************************************/
647
648static void IntArgbPreSrcOverMaskFill_line(mlib_f32 *dst_ptr,
649 mlib_u8 *pMask,
650 mlib_s32 width,
651 mlib_f32 cnstARGB0,
652 mlib_u8 *mul8_cnstA);
653
654#pragma no_inline(IntArgbPreSrcOverMaskFill_line)
655
656static void IntArgbPreSrcOverMaskFill_line(mlib_f32 *dst_ptr,
657 mlib_u8 *pMask,
658 mlib_s32 width,
659 mlib_f32 cnstARGB0,
660 mlib_u8 *mul8_cnstA)
661{
662 mlib_s32 i, i0;
663 mlib_s32 pathA0, pathA1;
664 mlib_d64 res0, res1, dstARGB;
665 mlib_f32 dstARGB0;
666
667 i = i0 = 0;
668
669 if ((mlib_s32)dst_ptr & 7) {
670 pathA0 = pMask[i];
671
672 if (pathA0) {
673 dstARGB0 = dst_ptr[i];
674 MASK_FILL(res0, pathA0, dstARGB0);
675 dst_ptr[i] = vis_fpack16(res0);
676 }
677
678 i0 = 1;
679 }
680
681#pragma pipeloop(0)
682 for (i = i0; i <= width - 2; i += 2) {
683 pathA0 = pMask[i];
684 pathA1 = pMask[i + 1];
685 dstARGB = *(mlib_d64*)(dst_ptr + i);
686
687 MASK_FILL(res0, pathA0, vis_read_hi(dstARGB));
688 MASK_FILL(res1, pathA1, vis_read_lo(dstARGB));
689
690 res0 = vis_fpack16_pair(res0, res1);
691
692 *(mlib_d64 *)(dst_ptr + i) = res0;
693 }
694
695 if (i < width) {
696 pathA0 = pMask[i];
697
698 if (pathA0) {
699 dstARGB0 = dst_ptr[i];
700 MASK_FILL(res0, pathA0, dstARGB0);
701 dst_ptr[i] = vis_fpack16(res0);
702 }
703 }
704}
705
706/***************************************************************/
707
708#undef MASK_FILL
709#define MASK_FILL(rr, dstARGB) \
710{ \
711 rr = MUL8_VIS(dstARGB, cnstA); \
712 rr = vis_fpadd16(rr, cnstARGB); \
713}
714
715/***************************************************************/
716
717static void IntArgbPreSrcOverMaskFill_A1_line(mlib_f32 *dst_ptr,
718 mlib_s32 width,
719 mlib_d64 cnstARGB,
720 mlib_s32 cnstA);
721
722#pragma no_inline(IntArgbPreSrcOverMaskFill_A1_line)
723
724static void IntArgbPreSrcOverMaskFill_A1_line(mlib_f32 *dst_ptr,
725 mlib_s32 width,
726 mlib_d64 cnstARGB,
727 mlib_s32 cnstA)
728{
729 mlib_s32 i, i0;
730 mlib_d64 res0, res1, dstARGB;
731 mlib_f32 dstARGB0;
732
733 cnstA = 0xff - cnstA;
734
735 i = i0 = 0;
736
737 if ((mlib_s32)dst_ptr & 7) {
738 dstARGB0 = dst_ptr[i];
739 MASK_FILL(res0, dstARGB0);
740 dst_ptr[i] = vis_fpack16(res0);
741 i0 = 1;
742 }
743
744#pragma pipeloop(0)
745 for (i = i0; i <= width - 2; i += 2) {
746 dstARGB = *(mlib_d64*)(dst_ptr + i);
747
748 MASK_FILL(res0, vis_read_hi(dstARGB));
749 MASK_FILL(res1, vis_read_lo(dstARGB));
750
751 res0 = vis_fpack16_pair(res0, res1);
752
753 *(mlib_d64*)(dst_ptr + i) = res0;
754 }
755
756 if (i < width) {
757 dstARGB0 = dst_ptr[i];
758 MASK_FILL(res0, dstARGB0);
759 dst_ptr[i] = vis_fpack16(res0);
760 }
761}
762
763/***************************************************************/
764
765void ADD_SUFF(IntArgbPreSrcOverMaskFill)(void *rasBase,
766 jubyte *pMask,
767 jint maskOff,
768 jint maskScan,
769 jint width,
770 jint height,
771 jint fgColor,
772 SurfaceDataRasInfo *pRasInfo,
773 NativePrimitive *pPrim,
774 CompositeInfo *pCompInfo)
775{
776 mlib_s32 cnstA, cnstR, cnstG, cnstB;
777 mlib_s32 rasScan = pRasInfo->scanStride;
778 mlib_f32 cnstARGB0;
779 mlib_d64 cnstARGB;
780 mlib_u8 *mul8_cnstA;
781 mlib_s32 j;
782
783 cnstA = (fgColor >> 24) & 0xff;
784 cnstR = (fgColor >> 16) & 0xff;
785 cnstG = (fgColor >> 8) & 0xff;
786 cnstB = (fgColor ) & 0xff;
787
788 if (cnstA != 0xff) {
789 if (cnstA == 0) return;
790
791 cnstR = mul8table[cnstA][cnstR];
792 cnstG = mul8table[cnstA][cnstG];
793 cnstB = mul8table[cnstA][cnstB];
794 }
795
796 vis_write_gsr(0 << 3);
797
798 if (pMask != NULL) {
799 pMask += maskOff;
800
801 if (rasScan == 4*width && maskScan == width) {
802 width *= height;
803 height = 1;
804 }
805
806 mul8_cnstA = mul8table[cnstA];
807
808 cnstARGB0 = F32_FROM_U8x4(cnstA, cnstR, cnstG, cnstB);
809
810 for (j = 0; j < height; j++) {
811 IntArgbPreSrcOverMaskFill_line(rasBase, pMask, width, cnstARGB0,
812 mul8_cnstA);
813
814 PTR_ADD(rasBase, rasScan);
815 PTR_ADD(pMask, maskScan);
816 }
817 } else {
818 if (rasScan == 4*width) {
819 width *= height;
820 height = 1;
821 }
822
823 cnstARGB = vis_to_double((cnstA << 23) | (cnstR << 7),
824 (cnstG << 23) | (cnstB << 7));
825
826 for (j = 0; j < height; j++) {
827 IntArgbPreSrcOverMaskFill_A1_line(rasBase, width, cnstARGB, cnstA);
828
829 PTR_ADD(rasBase, rasScan);
830 }
831 }
832}
833
834/***************************************************************/
835
836void ADD_SUFF(FourByteAbgrPreSrcOverMaskFill)(void *rasBase,
837 jubyte *pMask,
838 jint maskOff,
839 jint maskScan,
840 jint width,
841 jint height,
842 jint fgColor,
843 SurfaceDataRasInfo *pRasInfo,
844 NativePrimitive *pPrim,
845 CompositeInfo *pCompInfo)
846{
847 mlib_d64 buff[BUFF_SIZE/2];
848 void *pbuff = buff, *p_dst;
849 mlib_s32 cnstA, cnstR, cnstG, cnstB;
850 mlib_s32 rasScan = pRasInfo->scanStride;
851 mlib_f32 cnstARGB0;
852 mlib_d64 cnstARGB;
853 mlib_u8 *mul8_cnstA;
854 mlib_s32 j;
855
856 if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
857
858 cnstA = (fgColor >> 24) & 0xff;
859 cnstR = (fgColor >> 16) & 0xff;
860 cnstG = (fgColor >> 8) & 0xff;
861 cnstB = (fgColor ) & 0xff;
862
863 if (cnstA != 0xff) {
864 if (cnstA == 0) return;
865
866 cnstR = mul8table[cnstA][cnstR];
867 cnstG = mul8table[cnstA][cnstG];
868 cnstB = mul8table[cnstA][cnstB];
869 }
870
871 vis_write_gsr(0 << 3);
872
873 if (pMask != NULL) {
874 pMask += maskOff;
875
876 mul8_cnstA = mul8table[cnstA];
877
878 cnstARGB0 = F32_FROM_U8x4(cnstA, cnstB, cnstG, cnstR);
879
880 for (j = 0; j < height; j++) {
881 if ((mlib_s32)rasBase & 3) {
882 mlib_ImageCopy_na(rasBase, pbuff, width*sizeof(mlib_s32));
883 p_dst = pbuff;
884 } else {
885 p_dst = rasBase;
886 }
887
888 IntArgbPreSrcOverMaskFill_line(p_dst, pMask, width, cnstARGB0,
889 mul8_cnstA);
890
891 if (p_dst != rasBase) {
892 mlib_ImageCopy_na(p_dst, rasBase, width*sizeof(mlib_s32));
893 }
894
895 PTR_ADD(rasBase, rasScan);
896 PTR_ADD(pMask, maskScan);
897 }
898 } else {
899 cnstARGB = vis_to_double((cnstA << 23) | (cnstB << 7),
900 (cnstG << 23) | (cnstR << 7));
901
902 for (j = 0; j < height; j++) {
903 if ((mlib_s32)rasBase & 3) {
904 mlib_ImageCopy_na(rasBase, pbuff, width*sizeof(mlib_s32));
905 p_dst = pbuff;
906 } else {
907 p_dst = rasBase;
908 }
909
910 IntArgbPreSrcOverMaskFill_A1_line(p_dst, width, cnstARGB, cnstA);
911
912 if (p_dst != rasBase) {
913 mlib_ImageCopy_na(p_dst, rasBase, width*sizeof(mlib_s32));
914 }
915
916 PTR_ADD(rasBase, rasScan);
917 }
918 }
919
920 if (pbuff != buff) {
921 mlib_free(pbuff);
922 }
923}
924
925/***************************************************************/
926
927/* ##############################################################
928 * IntArgbToIntArgbPreSrcOverMaskBlit()
929 */
930
931#undef MASK_FILL
932#define MASK_FILL(rr, pathA, dstARGB, srcA, srcARGB) \
933{ \
934 mlib_d64 t0, t1; \
935 mlib_s32 dstF; \
936 \
937 srcA = MUL8_INT(mul8_extra[pathA], srcA); \
938 dstF = 0xff - srcA; \
939 \
940 t0 = MUL8_VIS(srcARGB, srcA); \
941 t1 = MUL8_VIS(dstARGB, dstF); \
942 rr = vis_fpadd16(t0, t1); \
943}
944
945/***************************************************************/
946
947static void IntArgbToIntArgbPreSrcOverMaskBlit_line(mlib_f32 *dst_ptr,
948 mlib_f32 *src_ptr,
949 mlib_u8 *pMask,
950 mlib_s32 width,
951 mlib_u8 *mul8_extra,
952 mlib_u8 *mul8_tbl);
953
954#pragma no_inline(IntArgbToIntArgbPreSrcOverMaskBlit_line)
955
956static void IntArgbToIntArgbPreSrcOverMaskBlit_line(mlib_f32 *dst_ptr,
957 mlib_f32 *src_ptr,
958 mlib_u8 *pMask,
959 mlib_s32 width,
960 mlib_u8 *mul8_extra,
961 mlib_u8 *mul8_tbl)
962{
963 mlib_s32 i, i0;
964 mlib_s32 pathA0, pathA1, srcA0, srcA1;
965 mlib_d64 res0, res1, dstARGB, srcARGB;
966 mlib_f32 dstARGB0, srcARGB0;
967 mlib_d64 or_alpha = vis_to_double_dup(0xff000000);
968
969 i = i0 = 0;
970
971 if ((mlib_s32)dst_ptr & 7) {
972 pathA0 = pMask[i];
973 srcA0 = *(mlib_u8*)(src_ptr + i);
974 dstARGB0 = dst_ptr[i];
975 srcARGB0 = src_ptr[i];
976 srcARGB0 = vis_fors(vis_read_hi(or_alpha), srcARGB0);
977 MASK_FILL(res0, pathA0, dstARGB0, srcA0, srcARGB0);
978 if (srcA0) {
979 dst_ptr[i] = vis_fpack16(res0);
980 }
981
982 i0 = 1;
983 }
984
985#pragma pipeloop(0)
986 for (i = i0; i <= width - 2; i += 2) {
987 pathA0 = pMask[i];
988 pathA1 = pMask[i + 1];
989 dstARGB = *(mlib_d64*)(dst_ptr + i);
990 srcA0 = *(mlib_u8*)(src_ptr + i);
991 srcA1 = *(mlib_u8*)(src_ptr + i + 1);
992 srcARGB = vis_freg_pair(src_ptr[i], src_ptr[i + 1]);
993 srcARGB = vis_for(or_alpha, srcARGB);
994
995 MASK_FILL(res0, pathA0, vis_read_hi(dstARGB),
996 srcA0, vis_read_hi(srcARGB));
997 MASK_FILL(res1, pathA1, vis_read_lo(dstARGB),
998 srcA1, vis_read_lo(srcARGB));
999
1000 res0 = vis_fpack16_pair(res0, res1);
1001
1002 *(mlib_d64*)(dst_ptr + i) = res0;
1003 }
1004
1005 if (i < width) {
1006 pathA0 = pMask[i];
1007 srcA0 = *(mlib_u8*)(src_ptr + i);
1008 dstARGB0 = dst_ptr[i];
1009 srcARGB0 = src_ptr[i];
1010 srcARGB0 = vis_fors(vis_read_hi(or_alpha), srcARGB0);
1011 MASK_FILL(res0, pathA0, dstARGB0, srcA0, srcARGB0);
1012 if (srcA0) {
1013 dst_ptr[i] = vis_fpack16(res0);
1014 }
1015 }
1016}
1017
1018/***************************************************************/
1019
1020#undef MASK_FILL
1021#define MASK_FILL(rr, dstARGB, srcA, srcARGB) \
1022{ \
1023 mlib_d64 t0, t1; \
1024 mlib_s32 dstF; \
1025 \
1026 srcA = mul8_extra[srcA]; \
1027 dstF = 0xff - srcA; \
1028 \
1029 t0 = MUL8_VIS(srcARGB, srcA); \
1030 t1 = MUL8_VIS(dstARGB, dstF); \
1031 rr = vis_fpadd16(t0, t1); \
1032}
1033
1034/***************************************************************/
1035
1036static void IntArgbToIntArgbPreSrcOverMaskBlit_A1_line(mlib_f32 *dst_ptr,
1037 mlib_f32 *src_ptr,
1038 mlib_s32 width,
1039 mlib_u8 *mul8_extra);
1040
1041#pragma no_inline(IntArgbToIntArgbPreSrcOverMaskBlit_A1_line)
1042
1043static void IntArgbToIntArgbPreSrcOverMaskBlit_A1_line(mlib_f32 *dst_ptr,
1044 mlib_f32 *src_ptr,
1045 mlib_s32 width,
1046 mlib_u8 *mul8_extra)
1047{
1048 mlib_s32 i, i0;
1049 mlib_s32 srcA0, srcA1;
1050 mlib_d64 res0, res1, dstARGB, srcARGB;
1051 mlib_f32 dstARGB0, srcARGB0;
1052 mlib_d64 or_alpha = vis_to_double_dup(0xff000000);
1053
1054 i = i0 = 0;
1055
1056 if ((mlib_s32)dst_ptr & 7) {
1057 srcA0 = *(mlib_u8*)(src_ptr + i);
1058 dstARGB0 = dst_ptr[i];
1059 srcARGB0 = src_ptr[i];
1060 srcARGB0 = vis_fors(vis_read_hi(or_alpha), srcARGB0);
1061 MASK_FILL(res0, dstARGB0, srcA0, srcARGB0);
1062 if (srcA0) {
1063 dst_ptr[i] = vis_fpack16(res0);
1064 }
1065
1066 i0 = 1;
1067 }
1068
1069#pragma pipeloop(0)
1070 for (i = i0; i <= width - 2; i += 2) {
1071 dstARGB = *(mlib_d64*)(dst_ptr + i);
1072 srcA0 = *(mlib_u8*)(src_ptr + i);
1073 srcA1 = *(mlib_u8*)(src_ptr + i + 1);
1074 srcARGB = vis_freg_pair(src_ptr[i], src_ptr[i + 1]);
1075 srcARGB = vis_for(or_alpha, srcARGB);
1076
1077 MASK_FILL(res0, vis_read_hi(dstARGB), srcA0, vis_read_hi(srcARGB));
1078 MASK_FILL(res1, vis_read_lo(dstARGB), srcA1, vis_read_lo(srcARGB));
1079
1080 res0 = vis_fpack16_pair(res0, res1);
1081 *(mlib_d64*)(dst_ptr + i) = res0;
1082 }
1083
1084 if (i < width) {
1085 srcA0 = *(mlib_u8*)(src_ptr + i);
1086 dstARGB0 = dst_ptr[i];
1087 srcARGB0 = src_ptr[i];
1088 srcARGB0 = vis_fors(vis_read_hi(or_alpha), srcARGB0);
1089 MASK_FILL(res0, dstARGB0, srcA0, srcARGB0);
1090 if (srcA0) {
1091 dst_ptr[i] = vis_fpack16(res0);
1092 }
1093 }
1094}
1095
1096/***************************************************************/
1097
1098void ADD_SUFF(IntArgbToIntArgbPreSrcOverMaskBlit)(MASKBLIT_PARAMS)
1099{
1100 mlib_s32 extraA;
1101 mlib_s32 dstScan = pDstInfo->scanStride;
1102 mlib_s32 srcScan = pSrcInfo->scanStride;
1103 mlib_u8 *mul8_extra;
1104 mlib_s32 j;
1105
1106 extraA = (mlib_s32)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
1107
1108 mul8_extra = mul8table[extraA];
1109
1110 vis_write_gsr(0 << 3);
1111
1112 if (pMask != NULL) {
1113 pMask += maskOff;
1114
1115 if (dstScan == 4*width && srcScan == dstScan && maskScan == width) {
1116 width *= height;
1117 height = 1;
1118 }
1119
1120 for (j = 0; j < height; j++) {
1121 IntArgbToIntArgbPreSrcOverMaskBlit_line(dstBase, srcBase, pMask,
1122 width, mul8_extra,
1123 (void*)mul8table);
1124
1125 PTR_ADD(dstBase, dstScan);
1126 PTR_ADD(srcBase, srcScan);
1127 PTR_ADD(pMask, maskScan);
1128 }
1129 } else {
1130 if (dstScan == 4*width && srcScan == dstScan) {
1131 width *= height;
1132 height = 1;
1133 }
1134
1135 for (j = 0; j < height; j++) {
1136 IntArgbToIntArgbPreSrcOverMaskBlit_A1_line(dstBase, srcBase, width,
1137 mul8_extra);
1138
1139 PTR_ADD(dstBase, dstScan);
1140 PTR_ADD(srcBase, srcScan);
1141 }
1142 }
1143}
1144
1145/***************************************************************/
1146
1147void ADD_SUFF(IntArgbToFourByteAbgrPreSrcOverMaskBlit)(MASKBLIT_PARAMS)
1148{
1149 mlib_d64 buff[BUFF_SIZE/2];
1150 void *pbuff = buff;
1151 mlib_s32 extraA;
1152 mlib_s32 dstScan = pDstInfo->scanStride;
1153 mlib_s32 srcScan = pSrcInfo->scanStride;
1154 mlib_u8 *mul8_extra;
1155 mlib_s32 j;
1156
1157 if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
1158
1159 extraA = (mlib_s32)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
1160
1161 mul8_extra = mul8table[extraA];
1162
1163 vis_write_gsr(0 << 3);
1164
1165 if (pMask != NULL) {
1166 pMask += maskOff;
1167
1168 for (j = 0; j < height; j++) {
1169 ADD_SUFF(FourByteAbgrToIntArgbConvert)(dstBase, pbuff, width, 1,
1170 pSrcInfo, pDstInfo,
1171 pPrim, pCompInfo);
1172
1173 IntArgbToIntArgbPreSrcOverMaskBlit_line(pbuff, srcBase, pMask,
1174 width, mul8_extra,
1175 (void*)mul8table);
1176
1177 ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,
1178 pSrcInfo, pDstInfo,
1179 pPrim, pCompInfo);
1180
1181 PTR_ADD(dstBase, dstScan);
1182 PTR_ADD(srcBase, srcScan);
1183 PTR_ADD(pMask, maskScan);
1184 }
1185 } else {
1186 for (j = 0; j < height; j++) {
1187 ADD_SUFF(FourByteAbgrToIntArgbConvert)(dstBase, pbuff, width, 1,
1188 pSrcInfo, pDstInfo,
1189 pPrim, pCompInfo);
1190
1191 IntArgbToIntArgbPreSrcOverMaskBlit_A1_line(pbuff, srcBase, width,
1192 mul8_extra);
1193
1194 ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,
1195 pSrcInfo, pDstInfo,
1196 pPrim, pCompInfo);
1197
1198 PTR_ADD(dstBase, dstScan);
1199 PTR_ADD(srcBase, srcScan);
1200 }
1201 }
1202
1203 if (pbuff != buff) {
1204 mlib_free(pbuff);
1205 }
1206}
1207
1208/***************************************************************/
1209
1210/* ##############################################################
1211 * IntArgbToIntArgbPreAlphaMaskBlit()
1212 */
1213
1214#undef MASK_FILL
1215#define MASK_FILL(rr, pathA, dstA, dstARGB, srcA, srcARGB) \
1216{ \
1217 mlib_d64 t0, t1; \
1218 mlib_s32 srcF, dstF; \
1219 \
1220 srcA = mul8_extra[srcA]; \
1221 \
1222 srcF = ((dstA & SrcOpAnd) ^ SrcOpXor) + SrcOpAdd; \
1223 dstF = ((srcA & DstOpAnd) ^ DstOpXor) + DstOpAdd; \
1224 \
1225 srcF = MUL8_INT(pathA, srcF); \
1226 dstF = MUL8_INT(pathA, dstF) + (0xff - pathA); \
1227 \
1228 srcA = MUL8_INT(srcF, srcA); \
1229 \
1230 t0 = MUL8_VIS(srcARGB, srcA); \
1231 t1 = MUL8_VIS(dstARGB, dstF); \
1232 rr = vis_fpadd16(t0, t1); \
1233}
1234
1235/**************************************************************/
1236
1237static void IntArgbToIntArgbPreAlphaMaskBlit_line(mlib_f32 *dst_ptr,
1238 mlib_f32 *src_ptr,
1239 mlib_u8 *pMask,
1240 mlib_s32 width,
1241 mlib_s32 *log_val,
1242 mlib_u8 *mul8_extra,
1243 mlib_u8 *mul8_tbl);
1244
1245#pragma no_inline(IntArgbToIntArgbPreAlphaMaskBlit_line)
1246
1247static void IntArgbToIntArgbPreAlphaMaskBlit_line(mlib_f32 *dst_ptr,
1248 mlib_f32 *src_ptr,
1249 mlib_u8 *pMask,
1250 mlib_s32 width,
1251 mlib_s32 *log_val,
1252 mlib_u8 *mul8_extra,
1253 mlib_u8 *mul8_tbl)
1254{
1255 mlib_s32 i;
1256 mlib_s32 pathA0, dstA0, srcA0;
1257 mlib_d64 res0;
1258 mlib_f32 dstARGB0, srcARGB0;
1259 mlib_s32 SrcOpAnd = log_val[0];
1260 mlib_s32 SrcOpXor = log_val[1];
1261 mlib_s32 SrcOpAdd = log_val[2];
1262 mlib_s32 DstOpAnd = log_val[3];
1263 mlib_s32 DstOpXor = log_val[4];
1264 mlib_s32 DstOpAdd = log_val[5];
1265 mlib_f32 or_alpha = vis_to_float(0xff000000);
1266
1267#pragma pipeloop(0)
1268 for (i = 0; i < width; i++) {
1269
1270 pathA0 = pMask[i];
1271
1272 dstA0 = *(mlib_u8*)dst_ptr;
1273
1274 dstARGB0 = *dst_ptr;
1275 srcA0 = *(mlib_u8*)src_ptr;
1276 srcARGB0 = *src_ptr;
1277 srcARGB0 = vis_fors(or_alpha, srcARGB0);
1278
1279 MASK_FILL(res0, pathA0, dstA0, dstARGB0, srcA0, srcARGB0);
1280
1281 *dst_ptr = vis_fpack16(res0);
1282 dst_ptr++;
1283 src_ptr++;
1284 }
1285
1286}
1287
1288/***************************************************************/
1289
1290#undef MASK_FILL
1291#define MASK_FILL(rr, dstA, dstARGB, srcA, srcARGB) \
1292{ \
1293 mlib_d64 t0, t1; \
1294 mlib_s32 srcF, dstF; \
1295 \
1296 srcA = mul8_extra[srcA]; \
1297 \
1298 srcF = ((dstA & SrcOpAnd) ^ SrcOpXor) + SrcOpAdd; \
1299 dstF = ((srcA & DstOpAnd) ^ DstOpXor) + DstOpAdd; \
1300 \
1301 srcA = MUL8_INT(srcF, srcA); \
1302 \
1303 t0 = MUL8_VIS(srcARGB, srcA); \
1304 t1 = MUL8_VIS(dstARGB, dstF); \
1305 rr = vis_fpadd16(t0, t1); \
1306}
1307
1308/***************************************************************/
1309
1310static void IntArgbToIntArgbPreAlphaMaskBlit_A1_line(mlib_f32 *dst_ptr,
1311 mlib_f32 *src_ptr,
1312 mlib_s32 width,
1313 mlib_s32 *log_val,
1314 mlib_u8 *mul8_extra,
1315 mlib_u8 *mul8_tbl);
1316
1317#pragma no_inline(IntArgbToIntArgbPreAlphaMaskBlit_A1_line)
1318
1319static void IntArgbToIntArgbPreAlphaMaskBlit_A1_line(mlib_f32 *dst_ptr,
1320 mlib_f32 *src_ptr,
1321 mlib_s32 width,
1322 mlib_s32 *log_val,
1323 mlib_u8 *mul8_extra,
1324 mlib_u8 *mul8_tbl)
1325{
1326 mlib_s32 i;
1327 mlib_s32 dstA0, srcA0;
1328 mlib_d64 res0;
1329 mlib_f32 dstARGB0, srcARGB0;
1330 mlib_s32 SrcOpAnd = log_val[0];
1331 mlib_s32 SrcOpXor = log_val[1];
1332 mlib_s32 SrcOpAdd = log_val[2];
1333 mlib_s32 DstOpAnd = log_val[3];
1334 mlib_s32 DstOpXor = log_val[4];
1335 mlib_s32 DstOpAdd = log_val[5];
1336 mlib_f32 or_alpha = vis_to_float(0xff000000);
1337
1338#pragma pipeloop(0)
1339 for (i = 0; i < width; i++) {
1340 dstA0 = *(mlib_u8*)(dst_ptr + i);
1341 srcA0 = *(mlib_u8*)(src_ptr + i);
1342 dstARGB0 = dst_ptr[i];
1343 srcARGB0 = src_ptr[i];
1344 srcARGB0 = vis_fors(or_alpha, srcARGB0);
1345
1346 MASK_FILL(res0, dstA0, dstARGB0, srcA0, srcARGB0);
1347
1348 dst_ptr[i] = vis_fpack16(res0);
1349 }
1350}
1351
1352/***************************************************************/
1353
1354void ADD_SUFF(IntArgbToIntArgbPreAlphaMaskBlit)(MASKBLIT_PARAMS)
1355{
1356 mlib_s32 extraA;
1357 mlib_s32 dstScan = pDstInfo->scanStride;
1358 mlib_s32 srcScan = pSrcInfo->scanStride;
1359 mlib_s32 log_val[6];
1360 mlib_s32 j;
1361 mlib_s32 SrcOpAnd;
1362 mlib_s32 SrcOpXor;
1363 mlib_s32 SrcOpAdd;
1364 mlib_s32 DstOpAnd;
1365 mlib_s32 DstOpXor;
1366 mlib_s32 DstOpAdd;
1367 mlib_u8 *mul8_extra;
1368
1369 extraA = (mlib_s32)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
1370
1371 mul8_extra = mul8table[extraA];
1372
1373 SrcOpAnd = (AlphaRules[pCompInfo->rule].srcOps).andval;
1374 SrcOpXor = (AlphaRules[pCompInfo->rule].srcOps).xorval;
1375 SrcOpAdd = (AlphaRules[pCompInfo->rule].srcOps).addval;
1376 SrcOpAdd -= SrcOpXor;
1377
1378 DstOpAnd = (AlphaRules[pCompInfo->rule].dstOps).andval;
1379 DstOpXor = (AlphaRules[pCompInfo->rule].dstOps).xorval;
1380 DstOpAdd = (AlphaRules[pCompInfo->rule].dstOps).addval;
1381 DstOpAdd -= DstOpXor;
1382
1383 log_val[0] = SrcOpAnd;
1384 log_val[1] = SrcOpXor;
1385 log_val[2] = SrcOpAdd;
1386 log_val[3] = DstOpAnd;
1387 log_val[4] = DstOpXor;
1388 log_val[5] = DstOpAdd;
1389
1390 vis_write_gsr(0 << 3);
1391
1392 if (pMask != NULL) {
1393 pMask += maskOff;
1394
1395 if (dstScan == 4*width && srcScan == dstScan && maskScan == width) {
1396 width *= height;
1397 height = 1;
1398 }
1399
1400 for (j = 0; j < height; j++) {
1401 IntArgbToIntArgbPreAlphaMaskBlit_line(dstBase, srcBase, pMask,
1402 width, log_val, mul8_extra,
1403 (void*)mul8table);
1404
1405 PTR_ADD(dstBase, dstScan);
1406 PTR_ADD(srcBase, srcScan);
1407 PTR_ADD(pMask, maskScan);
1408 }
1409 } else {
1410 if (dstScan == 4*width && srcScan == dstScan) {
1411 width *= height;
1412 height = 1;
1413 }
1414
1415 for (j = 0; j < height; j++) {
1416 IntArgbToIntArgbPreAlphaMaskBlit_A1_line(dstBase, srcBase,
1417 width, log_val, mul8_extra,
1418 (void*)mul8table);
1419
1420 PTR_ADD(dstBase, dstScan);
1421 PTR_ADD(srcBase, srcScan);
1422 }
1423 }
1424}
1425
1426/***************************************************************/
1427
1428void ADD_SUFF(IntArgbToFourByteAbgrPreAlphaMaskBlit)(MASKBLIT_PARAMS)
1429{
1430 mlib_d64 buff[BUFF_SIZE/2];
1431 void *pbuff = buff;
1432 mlib_s32 extraA;
1433 mlib_s32 dstScan = pDstInfo->scanStride;
1434 mlib_s32 srcScan = pSrcInfo->scanStride;
1435 mlib_s32 log_val[6];
1436 mlib_s32 j;
1437 mlib_s32 SrcOpAnd;
1438 mlib_s32 SrcOpXor;
1439 mlib_s32 SrcOpAdd;
1440 mlib_s32 DstOpAnd;
1441 mlib_s32 DstOpXor;
1442 mlib_s32 DstOpAdd;
1443 mlib_u8 *mul8_extra;
1444
1445 if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
1446
1447 extraA = (mlib_s32)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
1448
1449 mul8_extra = mul8table[extraA];
1450
1451 SrcOpAnd = (AlphaRules[pCompInfo->rule].srcOps).andval;
1452 SrcOpXor = (AlphaRules[pCompInfo->rule].srcOps).xorval;
1453 SrcOpAdd = (AlphaRules[pCompInfo->rule].srcOps).addval;
1454 SrcOpAdd -= SrcOpXor;
1455
1456 DstOpAnd = (AlphaRules[pCompInfo->rule].dstOps).andval;
1457 DstOpXor = (AlphaRules[pCompInfo->rule].dstOps).xorval;
1458 DstOpAdd = (AlphaRules[pCompInfo->rule].dstOps).addval;
1459 DstOpAdd -= DstOpXor;
1460
1461 log_val[0] = SrcOpAnd;
1462 log_val[1] = SrcOpXor;
1463 log_val[2] = SrcOpAdd;
1464 log_val[3] = DstOpAnd;
1465 log_val[4] = DstOpXor;
1466 log_val[5] = DstOpAdd;
1467
1468 vis_write_gsr(0 << 3);
1469
1470 if (pMask != NULL) {
1471 pMask += maskOff;
1472
1473 for (j = 0; j < height; j++) {
1474 ADD_SUFF(FourByteAbgrToIntArgbConvert)(dstBase, pbuff, width, 1,
1475 pSrcInfo, pDstInfo,
1476 pPrim, pCompInfo);
1477
1478 IntArgbToIntArgbPreAlphaMaskBlit_line(pbuff, srcBase, pMask,
1479 width, log_val, mul8_extra,
1480 (void*)mul8table);
1481
1482 ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,
1483 pSrcInfo, pDstInfo,
1484 pPrim, pCompInfo);
1485
1486 PTR_ADD(dstBase, dstScan);
1487 PTR_ADD(srcBase, srcScan);
1488 PTR_ADD(pMask, maskScan);
1489 }
1490 } else {
1491 for (j = 0; j < height; j++) {
1492 ADD_SUFF(FourByteAbgrToIntArgbConvert)(dstBase, pbuff, width, 1,
1493 pSrcInfo, pDstInfo,
1494 pPrim, pCompInfo);
1495
1496 IntArgbToIntArgbPreAlphaMaskBlit_A1_line(pbuff, srcBase,
1497 width, log_val, mul8_extra,
1498 (void*)mul8table);
1499
1500 ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,
1501 pSrcInfo, pDstInfo,
1502 pPrim, pCompInfo);
1503
1504 PTR_ADD(dstBase, dstScan);
1505 PTR_ADD(srcBase, srcScan);
1506 }
1507 }
1508
1509 if (pbuff != buff) {
1510 mlib_free(pbuff);
1511 }
1512}
1513
1514/***************************************************************/
1515
1516/* ##############################################################
1517 * IntRgbToIntArgbPreAlphaMaskBlit()
1518 */
1519
1520#undef MASK_FILL
1521#define MASK_FILL(rr, pathA, dstA, dstARGB, srcA, srcARGB) \
1522{ \
1523 mlib_d64 t0, t1; \
1524 mlib_s32 srcF, dstF; \
1525 \
1526 srcF = ((dstA & SrcOpAnd) ^ SrcOpXor) + SrcOpAdd; \
1527 \
1528 srcF = MUL8_INT(pathA, srcF); \
1529 dstF = mul8_tbl[pathA + dstF_0] + (0xff - pathA); \
1530 \
1531 srcF = mul8_tbl[srcF + srcA]; \
1532 \
1533 t0 = MUL8_VIS(srcARGB, srcF); \
1534 t1 = MUL8_VIS(dstARGB, dstF); \
1535 rr = vis_fpadd16(t0, t1); \
1536}
1537
1538/**************************************************************/
1539
1540static void IntRgbToIntArgbPreAlphaMaskBlit_line(mlib_f32 *dst_ptr,
1541 mlib_f32 *src_ptr,
1542 mlib_u8 *pMask,
1543 mlib_s32 width,
1544 mlib_s32 *log_val,
1545 mlib_s32 extraA,
1546 mlib_s32 dstF_0,
1547 mlib_u8 *mul8_tbl);
1548
1549#pragma no_inline(IntRgbToIntArgbPreAlphaMaskBlit_line)
1550
1551static void IntRgbToIntArgbPreAlphaMaskBlit_line(mlib_f32 *dst_ptr,
1552 mlib_f32 *src_ptr,
1553 mlib_u8 *pMask,
1554 mlib_s32 width,
1555 mlib_s32 *log_val,
1556 mlib_s32 extraA,
1557 mlib_s32 dstF_0,
1558 mlib_u8 *mul8_tbl)
1559{
1560 mlib_s32 i;
1561 mlib_s32 pathA0, dstA0, srcA0;
1562 mlib_d64 res0;
1563 mlib_f32 dstARGB0, srcARGB0;
1564 mlib_s32 SrcOpAnd = log_val[0];
1565 mlib_s32 SrcOpXor = log_val[1];
1566 mlib_s32 SrcOpAdd = log_val[2];
1567 mlib_f32 or_alpha = vis_to_float(0xff000000);
1568
1569 srcA0 = extraA*256;
1570 dstF_0 *= 256;
1571
1572#pragma pipeloop(0)
1573 for (i = 0; i < width; i++) {
1574 pathA0 = pMask[i];
1575
1576 dstA0 = *(mlib_u8*)dst_ptr;
1577 dstARGB0 = *dst_ptr;
1578 srcARGB0 = *src_ptr;
1579
1580 srcARGB0 = vis_fors(or_alpha, srcARGB0);
1581
1582 MASK_FILL(res0, pathA0, dstA0, dstARGB0, srcA0, srcARGB0);
1583
1584 *dst_ptr = vis_fpack16(res0);
1585 dst_ptr++;
1586 src_ptr++;
1587 }
1588}
1589
1590/***************************************************************/
1591
1592#undef MASK_FILL
1593#define MASK_FILL(rr, dstA, dstARGB, srcA, srcARGB) \
1594{ \
1595 mlib_d64 t0, t1; \
1596 mlib_s32 srcF; \
1597 \
1598 srcF = ((dstA & SrcOpAnd) ^ SrcOpXor) + SrcOpAdd; \
1599 \
1600 srcF = mul8_tbl[srcF + srcA]; \
1601 \
1602 t0 = MUL8_VIS(srcARGB, srcF); \
1603 t1 = MUL8_VIS(dstARGB, dstF_0); \
1604 rr = vis_fpadd16(t0, t1); \
1605}
1606
1607/***************************************************************/
1608
1609static void IntRgbToIntArgbPreAlphaMaskBlit_A1_line(mlib_f32 *dst_ptr,
1610 mlib_f32 *src_ptr,
1611 mlib_s32 width,
1612 mlib_s32 *log_val,
1613 mlib_s32 extraA,
1614 mlib_s32 dstF_0,
1615 mlib_u8 *mul8_tbl);
1616
1617#pragma no_inline(IntRgbToIntArgbPreAlphaMaskBlit_A1_line)
1618
1619static void IntRgbToIntArgbPreAlphaMaskBlit_A1_line(mlib_f32 *dst_ptr,
1620 mlib_f32 *src_ptr,
1621 mlib_s32 width,
1622 mlib_s32 *log_val,
1623 mlib_s32 extraA,
1624 mlib_s32 dstF_0,
1625 mlib_u8 *mul8_tbl)
1626{
1627 mlib_s32 i;
1628 mlib_s32 dstA0, srcA0;
1629 mlib_d64 res0;
1630 mlib_f32 dstARGB0, srcARGB0;
1631 mlib_s32 SrcOpAnd = log_val[0];
1632 mlib_s32 SrcOpXor = log_val[1];
1633 mlib_s32 SrcOpAdd = log_val[2];
1634 mlib_f32 or_alpha = vis_to_float(0xff000000);
1635
1636 srcA0 = extraA*256;
1637
1638#pragma pipeloop(0)
1639 for (i = 0; i < width; i++) {
1640 dstA0 = *(mlib_u8*)dst_ptr;
1641
1642 dstARGB0 = *dst_ptr;
1643 srcARGB0 = *src_ptr;
1644 srcARGB0 = vis_fors(or_alpha, srcARGB0);
1645
1646 MASK_FILL(res0, dstA0, dstARGB0, srcA0, srcARGB0);
1647
1648 *dst_ptr = vis_fpack16(res0);
1649
1650 dst_ptr++;
1651 src_ptr++;
1652 }
1653}
1654
1655/***************************************************************/
1656
1657void ADD_SUFF(IntRgbToIntArgbPreAlphaMaskBlit)(MASKBLIT_PARAMS)
1658{
1659 mlib_s32 extraA;
1660 mlib_s32 dstScan = pDstInfo->scanStride;
1661 mlib_s32 srcScan = pSrcInfo->scanStride;
1662 mlib_s32 log_val[3];
1663 mlib_s32 j;
1664 mlib_s32 SrcOpAnd;
1665 mlib_s32 SrcOpXor;
1666 mlib_s32 SrcOpAdd;
1667 mlib_s32 DstOpAnd;
1668 mlib_s32 DstOpXor;
1669 mlib_s32 DstOpAdd;
1670 mlib_s32 dstF_0;
1671
1672 extraA = (mlib_s32)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
1673
1674 SrcOpAnd = (AlphaRules[pCompInfo->rule].srcOps).andval;
1675 SrcOpXor = (AlphaRules[pCompInfo->rule].srcOps).xorval;
1676 SrcOpAdd = (AlphaRules[pCompInfo->rule].srcOps).addval;
1677 SrcOpAdd -= SrcOpXor;
1678
1679 DstOpAnd = (AlphaRules[pCompInfo->rule].dstOps).andval;
1680 DstOpXor = (AlphaRules[pCompInfo->rule].dstOps).xorval;
1681 DstOpAdd = (AlphaRules[pCompInfo->rule].dstOps).addval;
1682 DstOpAdd -= DstOpXor;
1683
1684 log_val[0] = SrcOpAnd;
1685 log_val[1] = SrcOpXor;
1686 log_val[2] = SrcOpAdd;
1687
1688 vis_write_gsr(0 << 3);
1689
1690 dstF_0 = ((extraA & DstOpAnd) ^ DstOpXor) + DstOpAdd;
1691
1692 if (pMask != NULL) {
1693 pMask += maskOff;
1694
1695 if (dstScan == 4*width && srcScan == dstScan && maskScan == width) {
1696 width *= height;
1697 height = 1;
1698 }
1699
1700 for (j = 0; j < height; j++) {
1701 IntRgbToIntArgbPreAlphaMaskBlit_line(dstBase, srcBase, pMask,
1702 width, log_val, extraA, dstF_0,
1703 (void*)mul8table);
1704
1705 PTR_ADD(dstBase, dstScan);
1706 PTR_ADD(srcBase, srcScan);
1707 PTR_ADD(pMask, maskScan);
1708 }
1709 } else {
1710 if (dstScan == 4*width && srcScan == dstScan) {
1711 width *= height;
1712 height = 1;
1713 }
1714
1715 for (j = 0; j < height; j++) {
1716 IntRgbToIntArgbPreAlphaMaskBlit_A1_line(dstBase, srcBase, width,
1717 log_val, extraA, dstF_0,
1718 (void*)mul8table);
1719
1720 PTR_ADD(dstBase, dstScan);
1721 PTR_ADD(srcBase, srcScan);
1722 }
1723 }
1724}
1725
1726/***************************************************************/
1727
1728void ADD_SUFF(IntRgbToFourByteAbgrPreAlphaMaskBlit)(MASKBLIT_PARAMS)
1729{
1730 mlib_d64 buff[BUFF_SIZE/2];
1731 void *pbuff = buff;
1732 mlib_s32 extraA;
1733 mlib_s32 dstScan = pDstInfo->scanStride;
1734 mlib_s32 srcScan = pSrcInfo->scanStride;
1735 mlib_s32 log_val[3];
1736 mlib_s32 j;
1737 mlib_s32 SrcOpAnd;
1738 mlib_s32 SrcOpXor;
1739 mlib_s32 SrcOpAdd;
1740 mlib_s32 DstOpAnd;
1741 mlib_s32 DstOpXor;
1742 mlib_s32 DstOpAdd;
1743 mlib_s32 dstF_0;
1744
1745 if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
1746
1747 extraA = (mlib_s32)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
1748
1749 SrcOpAnd = (AlphaRules[pCompInfo->rule].srcOps).andval;
1750 SrcOpXor = (AlphaRules[pCompInfo->rule].srcOps).xorval;
1751 SrcOpAdd = (AlphaRules[pCompInfo->rule].srcOps).addval;
1752 SrcOpAdd -= SrcOpXor;
1753
1754 DstOpAnd = (AlphaRules[pCompInfo->rule].dstOps).andval;
1755 DstOpXor = (AlphaRules[pCompInfo->rule].dstOps).xorval;
1756 DstOpAdd = (AlphaRules[pCompInfo->rule].dstOps).addval;
1757 DstOpAdd -= DstOpXor;
1758
1759 log_val[0] = SrcOpAnd;
1760 log_val[1] = SrcOpXor;
1761 log_val[2] = SrcOpAdd;
1762
1763 vis_write_gsr(0 << 3);
1764
1765 dstF_0 = ((extraA & DstOpAnd) ^ DstOpXor) + DstOpAdd;
1766
1767 if (pMask != NULL) {
1768 pMask += maskOff;
1769
1770 for (j = 0; j < height; j++) {
1771 ADD_SUFF(FourByteAbgrToIntArgbConvert)(dstBase, pbuff, width, 1,
1772 pSrcInfo, pDstInfo,
1773 pPrim, pCompInfo);
1774
1775 IntRgbToIntArgbPreAlphaMaskBlit_line(pbuff, srcBase, pMask, width,
1776 log_val, extraA, dstF_0,
1777 (void*)mul8table);
1778
1779 ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,
1780 pSrcInfo, pDstInfo,
1781 pPrim, pCompInfo);
1782
1783 PTR_ADD(dstBase, dstScan);
1784 PTR_ADD(srcBase, srcScan);
1785 PTR_ADD(pMask, maskScan);
1786 }
1787 } else {
1788 for (j = 0; j < height; j++) {
1789 ADD_SUFF(FourByteAbgrToIntArgbConvert)(dstBase, pbuff, width, 1,
1790 pSrcInfo, pDstInfo,
1791 pPrim, pCompInfo);
1792
1793 IntRgbToIntArgbPreAlphaMaskBlit_A1_line(pbuff, srcBase, width,
1794 log_val, extraA, dstF_0,
1795 (void*)mul8table);
1796
1797 ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,
1798 pSrcInfo, pDstInfo,
1799 pPrim, pCompInfo);
1800
1801 PTR_ADD(dstBase, dstScan);
1802 PTR_ADD(srcBase, srcScan);
1803 }
1804 }
1805
1806 if (pbuff != buff) {
1807 mlib_free(pbuff);
1808 }
1809}
1810
1811/***************************************************************/
1812
1813#endif /* JAVA2D_NO_MLIB */