- fetch fill colour for text drawing in CheckComposite, swap red and blue channels as needed - support solid sources without a drawable now gtk2 apps no longer crash the Xserver and text is drawn in the correct colour next step: 32bit PictOpOver with 32bit mask, gtk2 seems to use those a lotdiff -r1.8 -r1.9 xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h
(macallan)
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h 2013/07/03 02:05:52 1.8
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h 2013/07/03 15:29:34 1.9
@@ -89,27 +89,27 @@ typedef struct { | @@ -89,27 +89,27 @@ typedef struct { | |||
89 | CloseScreenProcPtr CloseScreen; | 89 | CloseScreenProcPtr CloseScreen; | |
90 | CreateScreenResourcesProcPtr CreateScreenResources; | 90 | CreateScreenResourcesProcPtr CreateScreenResources; | |
91 | OptionInfoPtr Options; | 91 | OptionInfoPtr Options; | |
92 | xf86CursorInfoPtr CursorInfoRec; | 92 | xf86CursorInfoPtr CursorInfoRec; | |
93 | /* SX accel stuff */ | 93 | /* SX accel stuff */ | |
94 | void *sxreg, *sxio; | 94 | void *sxreg, *sxio; | |
95 | int use_accel, use_xrender; | 95 | int use_accel, use_xrender; | |
96 | uint32_t last_mask; | 96 | uint32_t last_mask; | |
97 | uint32_t last_rop; | 97 | uint32_t last_rop; | |
98 | uint32_t srcoff, srcpitch, mskoff, mskpitch; | 98 | uint32_t srcoff, srcpitch, mskoff, mskpitch; | |
99 | uint32_t srcformat, dstformat, mskformat; | 99 | uint32_t srcformat, dstformat, mskformat; | |
100 | uint32_t fillcolour; | 100 | uint32_t fillcolour; | |
101 | int op; | 101 | int op; | |
102 | Bool source_is_solid; | 102 | Bool source_is_solid, no_source_pixmap; | |
103 | int xdir, ydir; | 103 | int xdir, ydir; | |
104 | ExaDriverPtr pExa; | 104 | ExaDriverPtr pExa; | |
105 | } Cg14Rec, *Cg14Ptr; | 105 | } Cg14Rec, *Cg14Ptr; | |
106 | 106 | |||
107 | /* SX stuff */ | 107 | /* SX stuff */ | |
108 | /* write an SX register */ | 108 | /* write an SX register */ | |
109 | static inline void | 109 | static inline void | |
110 | write_sx_reg(Cg14Ptr p, int reg, uint32_t val) | 110 | write_sx_reg(Cg14Ptr p, int reg, uint32_t val) | |
111 | { | 111 | { | |
112 | *(volatile uint32_t *)(p->sxreg + reg) = val; | 112 | *(volatile uint32_t *)(p->sxreg + reg) = val; | |
113 | } | 113 | } | |
114 | 114 | |||
115 | /* read an SX register */ | 115 | /* read an SX register */ |
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c 2013/07/03 02:05:52 1.4
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c 2013/07/03 15:29:34 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cg14_accel.c,v 1.4 2013/07/03 02:05:52 macallan Exp $ */ | 1 | /* $NetBSD: cg14_accel.c,v 1.5 2013/07/03 15:29:34 macallan Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2013 Michael Lorenz | 3 | * Copyright (c) 2013 Michael Lorenz | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * | 9 | * | |
10 | * - Redistributions of source code must retain the above copyright | 10 | * - Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * - Redistributions in binary form must reproduce the above | 12 | * - Redistributions in binary form must reproduce the above | |
13 | * copyright notice, this list of conditions and the following | 13 | * copyright notice, this list of conditions and the following | |
14 | * disclaimer in the documentation and/or other materials provided | 14 | * disclaimer in the documentation and/or other materials provided | |
@@ -573,65 +573,101 @@ CG14CheckComposite(int op, PicturePtr pS | @@ -573,65 +573,101 @@ CG14CheckComposite(int op, PicturePtr pS | |||
573 | Bool | 573 | Bool | |
574 | CG14PrepareComposite(int op, PicturePtr pSrcPicture, | 574 | CG14PrepareComposite(int op, PicturePtr pSrcPicture, | |
575 | PicturePtr pMaskPicture, | 575 | PicturePtr pMaskPicture, | |
576 | PicturePtr pDstPicture, | 576 | PicturePtr pDstPicture, | |
577 | PixmapPtr pSrc, | 577 | PixmapPtr pSrc, | |
578 | PixmapPtr pMask, | 578 | PixmapPtr pMask, | |
579 | PixmapPtr pDst) | 579 | PixmapPtr pDst) | |
580 | { | 580 | { | |
581 | ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; | 581 | ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; | |
582 | Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); | 582 | Cg14Ptr p = GET_CG14_FROM_SCRN(pScrn); | |
583 | 583 | |||
584 | ENTER; | 584 | ENTER; | |
585 | 585 | |||
586 | p->no_source_pixmap = FALSE; | |||
587 | p->source_is_solid = FALSE; | |||
588 | ||||
586 | if (pSrcPicture->format == PICT_a1) { | 589 | if (pSrcPicture->format == PICT_a1) { | |
587 | xf86Msg(X_ERROR, "src mono, dst %x, op %d\n", | 590 | xf86Msg(X_ERROR, "src mono, dst %x, op %d\n", | |
588 | pDstPicture->format, op); | 591 | pDstPicture->format, op); | |
589 | if (pMaskPicture != NULL) { | 592 | if (pMaskPicture != NULL) { | |
590 | xf86Msg(X_ERROR, "msk %x\n", pMaskPicture->format); | 593 | xf86Msg(X_ERROR, "msk %x\n", pMaskPicture->format); | |
591 | } | 594 | } | |
592 | } | 595 | } | |
593 | if (pSrcPicture->pSourcePict != NULL) { | 596 | if (pSrcPicture->pSourcePict != NULL) { | |
594 | if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { | 597 | if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { | |
595 | p->fillcolour = | 598 | p->fillcolour = | |
596 | pSrcPicture->pSourcePict->solidFill.color; | 599 | pSrcPicture->pSourcePict->solidFill.color; | |
597 | xf86Msg(X_ERROR, "%s: solid src %08x\n", | 600 | DPRINTF(X_ERROR, "%s: solid src %08x\n", | |
598 | __func__, p->fillcolour); | 601 | __func__, p->fillcolour); | |
602 | p->no_source_pixmap = TRUE; | |||
603 | p->source_is_solid = TRUE; | |||
599 | } | 604 | } | |
600 | } | 605 | } | |
601 | if ((pMaskPicture != NULL) && (pMaskPicture->pSourcePict != NULL)) { | 606 | if ((pMaskPicture != NULL) && (pMaskPicture->pSourcePict != NULL)) { | |
602 | if (pMaskPicture->pSourcePict->type == | 607 | if (pMaskPicture->pSourcePict->type == | |
603 | SourcePictTypeSolidFill) { | 608 | SourcePictTypeSolidFill) { | |
604 | p->fillcolour = | 609 | p->fillcolour = | |
605 | pMaskPicture->pSourcePict->solidFill.color; | 610 | pMaskPicture->pSourcePict->solidFill.color; | |
606 | xf86Msg(X_ERROR, "%s: solid mask %08x\n", | 611 | xf86Msg(X_ERROR, "%s: solid mask %08x\n", | |
607 | __func__, p->fillcolour); | 612 | __func__, p->fillcolour); | |
608 | } | 613 | } | |
609 | } | 614 | } | |
610 | if (pMaskPicture != NULL) { | 615 | if (pMaskPicture != NULL) { | |
611 | p->mskoff = exaGetPixmapOffset(pMask); | 616 | p->mskoff = exaGetPixmapOffset(pMask); | |
612 | p->mskpitch = exaGetPixmapPitch(pMask); | 617 | p->mskpitch = exaGetPixmapPitch(pMask); | |
613 | p->mskformat = pMaskPicture->format; | 618 | p->mskformat = pMaskPicture->format; | |
614 | } else { | 619 | } else { | |
615 | p->mskoff = 0; | 620 | p->mskoff = 0; | |
616 | p->mskpitch = 0; | 621 | p->mskpitch = 0; | |
617 | p->mskformat = 0; | 622 | p->mskformat = 0; | |
618 | } | 623 | } | |
619 | p->source_is_solid = | 624 | if (pSrc != NULL) { | |
620 | ((pSrc->drawable.width == 1) && (pSrc->drawable.height == 1)); | 625 | p->source_is_solid = | |
621 | p->srcoff = exaGetPixmapOffset(pSrc); | 626 | ((pSrc->drawable.width == 1) && (pSrc->drawable.height == 1)); | |
622 | p->srcpitch = exaGetPixmapPitch(pSrc); | 627 | p->srcoff = exaGetPixmapOffset(pSrc); | |
628 | p->srcpitch = exaGetPixmapPitch(pSrc); | |||
629 | if (p->source_is_solid) { | |||
630 | p->fillcolour = *(uint32_t *)(p->fb + p->srcoff); | |||
631 | } | |||
632 | } | |||
623 | p->srcformat = pSrcPicture->format; | 633 | p->srcformat = pSrcPicture->format; | |
624 | p->dstformat = pDstPicture->format; | 634 | p->dstformat = pDstPicture->format; | |
635 | ||||
636 | if (p->source_is_solid) { | |||
637 | uint32_t temp; | |||
638 | ||||
639 | /* stuff source colour into SX registers, swap as needed */ | |||
640 | temp = p->fillcolour; | |||
641 | switch (p->srcformat) { | |||
642 | case PICT_a8r8g8b8: | |||
643 | case PICT_x8r8g8b8: | |||
644 | write_sx_reg(p, SX_QUEUED(9), temp & 0xff); | |||
645 | temp = temp >> 8; | |||
646 | write_sx_reg(p, SX_QUEUED(10), temp & 0xff); | |||
647 | temp = temp >> 8; | |||
648 | write_sx_reg(p, SX_QUEUED(11), temp & 0xff); | |||
649 | break; | |||
650 | case PICT_a8b8g8r8: | |||
651 | case PICT_x8b8g8r8: | |||
652 | write_sx_reg(p, SX_QUEUED(11), temp & 0xff); | |||
653 | temp = temp >> 8; | |||
654 | write_sx_reg(p, SX_QUEUED(10), temp & 0xff); | |||
655 | temp = temp >> 8; | |||
656 | write_sx_reg(p, SX_QUEUED(9), temp & 0xff); | |||
657 | break; | |||
658 | } | |||
659 | write_sx_reg(p, SX_QUEUED(8), 0xff); | |||
660 | } | |||
625 | p->op = op; | 661 | p->op = op; | |
626 | if (op == PictOpSrc) { | 662 | if (op == PictOpSrc) { | |
627 | CG14PrepareCopy(pSrc, pDst, 1, 1, GXcopy, 0xffffffff); | 663 | CG14PrepareCopy(pSrc, pDst, 1, 1, GXcopy, 0xffffffff); | |
628 | } | 664 | } | |
629 | #ifdef SX_DEBUG | 665 | #ifdef SX_DEBUG | |
630 | DPRINTF(X_ERROR, "%x %x -> %x\n", p->srcoff, p->mskoff, | 666 | DPRINTF(X_ERROR, "%x %x -> %x\n", p->srcoff, p->mskoff, | |
631 | *(uint32_t *)(p->fb + p->srcoff)); | 667 | *(uint32_t *)(p->fb + p->srcoff)); | |
632 | #endif | 668 | #endif | |
633 | return TRUE; | 669 | return TRUE; | |
634 | } | 670 | } | |
635 | 671 | |||
636 | void | 672 | void | |
637 | CG14Composite(PixmapPtr pDst, int srcX, int srcY, | 673 | CG14Composite(PixmapPtr pDst, int srcX, int srcY, |
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c 2013/07/03 02:05:52 1.3
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c 2013/07/03 15:29:34 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cg14_render.c,v 1.3 2013/07/03 02:05:52 macallan Exp $ */ | 1 | /* $NetBSD: cg14_render.c,v 1.4 2013/07/03 15:29:34 macallan Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2013 Michael Lorenz | 3 | * Copyright (c) 2013 Michael Lorenz | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * | 9 | * | |
10 | * - Redistributions of source code must retain the above copyright | 10 | * - Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * - Redistributions in binary form must reproduce the above | 12 | * - Redistributions in binary form must reproduce the above | |
13 | * copyright notice, this list of conditions and the following | 13 | * copyright notice, this list of conditions and the following | |
14 | * disclaimer in the documentation and/or other materials provided | 14 | * disclaimer in the documentation and/or other materials provided | |
@@ -53,29 +53,27 @@ | @@ -53,29 +53,27 @@ | |||
53 | 53 | |||
54 | char c[8] = " .,:+*oX"; | 54 | char c[8] = " .,:+*oX"; | |
55 | 55 | |||
56 | 56 | |||
57 | void CG14Comp_Over32Solid(Cg14Ptr p, | 57 | void CG14Comp_Over32Solid(Cg14Ptr p, | |
58 | uint32_t src, uint32_t srcpitch, | 58 | uint32_t src, uint32_t srcpitch, | |
59 | uint32_t dst, uint32_t dstpitch, | 59 | uint32_t dst, uint32_t dstpitch, | |
60 | int width, int height) | 60 | int width, int height) | |
61 | { | 61 | { | |
62 | uint32_t msk = src, mskx, dstx, m; | 62 | uint32_t msk = src, mskx, dstx, m; | |
63 | int line, x, i; | 63 | int line, x, i; | |
64 | 64 | |||
65 | ENTER; | 65 | ENTER; | |
66 | /* first get the source colour */ | 66 | ||
67 | write_sx_io(p, p->srcoff, SX_LDUQ0(8, 0, p->srcoff & 7)); | |||
68 | write_sx_reg(p, SX_QUEUED(8), 0xff); | |||
69 | for (line = 0; line < height; line++) { | 67 | for (line = 0; line < height; line++) { | |
70 | mskx = msk; | 68 | mskx = msk; | |
71 | dstx = dst; | 69 | dstx = dst; | |
72 | #ifdef SX_SINGLE | 70 | #ifdef SX_SINGLE | |
73 | 71 | |||
74 | for (x = 0; x < width; x++) { | 72 | for (x = 0; x < width; x++) { | |
75 | m = *(volatile uint32_t *)(p->fb + mskx); | 73 | m = *(volatile uint32_t *)(p->fb + mskx); | |
76 | m = m >> 24; | 74 | m = m >> 24; | |
77 | if (m == 0) { | 75 | if (m == 0) { | |
78 | /* nothing to do - all transparent */ | 76 | /* nothing to do - all transparent */ | |
79 | } else if (m == 0xff) { | 77 | } else if (m == 0xff) { | |
80 | /* all opaque */ | 78 | /* all opaque */ | |
81 | write_sx_io(p, dstx, SX_STUQ0(8, 0, dstx & 7)); | 79 | write_sx_io(p, dstx, SX_STUQ0(8, 0, dstx & 7)); | |
@@ -154,29 +152,26 @@ void CG14Comp_Over32Solid(Cg14Ptr p, | @@ -154,29 +152,26 @@ void CG14Comp_Over32Solid(Cg14Ptr p, | |||
154 | 152 | |||
155 | void CG14Comp_Over8Solid(Cg14Ptr p, | 153 | void CG14Comp_Over8Solid(Cg14Ptr p, | |
156 | uint32_t src, uint32_t srcpitch, | 154 | uint32_t src, uint32_t srcpitch, | |
157 | uint32_t dst, uint32_t dstpitch, | 155 | uint32_t dst, uint32_t dstpitch, | |
158 | int width, int height) | 156 | int width, int height) | |
159 | { | 157 | { | |
160 | uint32_t msk = src, mskx, dstx, m; | 158 | uint32_t msk = src, mskx, dstx, m; | |
161 | int line, x, i; | 159 | int line, x, i; | |
162 | #ifdef SX_DEBUG | 160 | #ifdef SX_DEBUG | |
163 | char buffer[256]; | 161 | char buffer[256]; | |
164 | #endif | 162 | #endif | |
165 | ENTER; | 163 | ENTER; | |
166 | 164 | |||
167 | /* first get the source colour */ | |||
168 | write_sx_io(p, p->srcoff, SX_LDUQ0(8, 0, p->srcoff & 7)); | |||
169 | write_sx_reg(p, SX_QUEUED(8), 0xff); | |||
170 | DPRINTF(X_ERROR, "src: %d %d %d, %08x\n", read_sx_reg(p, SX_QUEUED(9)), | 165 | DPRINTF(X_ERROR, "src: %d %d %d, %08x\n", read_sx_reg(p, SX_QUEUED(9)), | |
171 | read_sx_reg(p, SX_QUEUED(10)), read_sx_reg(p, SX_QUEUED(11)), | 166 | read_sx_reg(p, SX_QUEUED(10)), read_sx_reg(p, SX_QUEUED(11)), | |
172 | *(uint32_t *)(p->fb + p->srcoff)); | 167 | *(uint32_t *)(p->fb + p->srcoff)); | |
173 | for (line = 0; line < height; line++) { | 168 | for (line = 0; line < height; line++) { | |
174 | mskx = msk; | 169 | mskx = msk; | |
175 | dstx = dst; | 170 | dstx = dst; | |
176 | #ifdef SX_SINGLE | 171 | #ifdef SX_SINGLE | |
177 | 172 | |||
178 | for (x = 0; x < width; x++) { | 173 | for (x = 0; x < width; x++) { | |
179 | m = *(volatile uint8_t *)(p->fb + mskx); | 174 | m = *(volatile uint8_t *)(p->fb + mskx); | |
180 | #ifdef SX_DEBUG | 175 | #ifdef SX_DEBUG | |
181 | buffer[x] = c[m >> 5]; | 176 | buffer[x] = c[m >> 5]; | |
182 | #endif | 177 | #endif | |
@@ -437,30 +432,33 @@ void CG14Comp_Over32Mask(Cg14Ptr p, | @@ -437,30 +432,33 @@ void CG14Comp_Over32Mask(Cg14Ptr p, | |||
437 | write_sx_reg(p, SX_QUEUED(8), 0xff); | 432 | write_sx_reg(p, SX_QUEUED(8), 0xff); | |
438 | for (line = 0; line < height; line++) { | 433 | for (line = 0; line < height; line++) { | |
439 | srcx = src; | 434 | srcx = src; | |
440 | mskx = msk; | 435 | mskx = msk; | |
441 | dstx = dst; | 436 | dstx = dst; | |
442 | 437 | |||
443 | for (x = 0; x < width; x++) { | 438 | for (x = 0; x < width; x++) { | |
444 | /* fetch source pixel */ | 439 | /* fetch source pixel */ | |
445 | write_sx_io(p, srcx, SX_LDUQ0(12, 0, srcx & 7)); | 440 | write_sx_io(p, srcx, SX_LDUQ0(12, 0, srcx & 7)); | |
446 | /* fetch mask */ | 441 | /* fetch mask */ | |
447 | write_sx_io(p, mskx & (~7), SX_LDB(9, 0, mskx & 7)); | 442 | write_sx_io(p, mskx & (~7), SX_LDB(9, 0, mskx & 7)); | |
448 | /* fetch dst pixel */ | 443 | /* fetch dst pixel */ | |
449 | write_sx_io(p, dstx, SX_LDUQ0(20, 0, dstx & 7)); | 444 | write_sx_io(p, dstx, SX_LDUQ0(20, 0, dstx & 7)); | |
450 | /* apply mask */ | 445 | /* stick mask alpha into SCAM */ | |
451 | write_sx_reg(p, SX_INSTRUCTIONS, | 446 | write_sx_reg(p, SX_INSTRUCTIONS, | |
452 | SX_ANDS(12, 9, 16, 3)); | 447 | SX_ORS(9, 0, R_SCAM, 0)); | |
448 | /* apply mask */ | |||
453 | /* src is premultiplied with alpha */ | 449 | /* src is premultiplied with alpha */ | |
450 | write_sx_reg(p, SX_INSTRUCTIONS, | |||
451 | SX_SAXP16X16SR8(12, 0, 16, 3)); | |||
454 | /* write inverted alpha into SCAM */ | 452 | /* write inverted alpha into SCAM */ | |
455 | write_sx_reg(p, SX_INSTRUCTIONS, | 453 | write_sx_reg(p, SX_INSTRUCTIONS, | |
456 | SX_XORV(16, 8, R_SCAM, 0)); | 454 | SX_XORV(16, 8, R_SCAM, 0)); | |
457 | /* dst * (1 - alpha) + R[13:15] */ | 455 | /* dst * (1 - alpha) + R[13:15] */ | |
458 | write_sx_reg(p, SX_INSTRUCTIONS, | 456 | write_sx_reg(p, SX_INSTRUCTIONS, | |
459 | SX_SAXP16X16SR8(21, 17, 25, 2)); | 457 | SX_SAXP16X16SR8(21, 17, 25, 2)); | |
460 | write_sx_io(p, dstx, | 458 | write_sx_io(p, dstx, | |
461 | SX_STUQ0C(24, 0, dstx & 7)); | 459 | SX_STUQ0C(24, 0, dstx & 7)); | |
462 | srcx += 4; | 460 | srcx += 4; | |
463 | mskx += 1; | 461 | mskx += 1; | |
464 | dstx += 4; | 462 | dstx += 4; | |
465 | } | 463 | } | |
466 | src += srcpitch; | 464 | src += srcpitch; |