3a01345ae6e925e724cc2150743304c58b12b258
2 * Copyright 2005 Ge van Geldorp (gvg@reactos.com).
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * This is a code generator. It outputs C code which can be compiled using the
20 * standard build tools. It is used to generate code for the DIB Blt routines.
21 * There are a lot of possible Blt routines (256 rop codes, for 6 different
22 * bit depths). It is possible to use a generic Blt routine which handles all
23 * rop codes and all depths. The drawback is that it will be relatively slow.
24 * The other extreme is to write (generate) a separate Blt routine for each
25 * rop code/depth combination. This will result in a extremely large amount
26 * of code. So, we opt for something in between: named rops get their own
27 * routine, unnamed rops are handled by a generic routine.
28 * Basically, what happens is that generic code which looks like:
49 * is specialized for named rops to look like:
69 * pumpSomeBytesSlightlyDifferentE;
75 * i.e. we make the inner loops as tight as possible.
76 * Another optimization is to try to load/store 32 alligned bits at a time from
77 * video memory. Accessing video memory from the CPU is slooooooow, so let's
78 * try to do this as little as possible, even if that means we have to do some
79 * extra operations using main memory.
89 #define USES_DEST(RopCode) ((((RopCode) & 0xaa) >> 1) != ((RopCode) & 0x55))
90 #define USES_SOURCE(RopCode) ((((RopCode) & 0xcc) >> 2) != ((RopCode) & 0x33))
91 #define USES_PATTERN(RopCode) ((((RopCode) & 0xf0) >> 4) != ((RopCode) & 0x0f))
96 #define MARK(Out) Output((Out), "/* Generated by %s line %d*/\n", \
97 __FUNCTION__, __LINE__);
100 #define ROPCODE_BLACKNESS 0x00
101 #define ROPCODE_NOTSRCERASE 0x11
102 #define ROPCODE_NOTSRCCOPY 0x33
103 #define ROPCODE_SRCERASE 0x44
104 #define ROPCODE_DSTINVERT 0x55
105 #define ROPCODE_PATINVERT 0x5a
106 #define ROPCODE_SRCINVERT 0x66
107 #define ROPCODE_SRCAND 0x88
108 #define ROPCODE_NOOP 0xaa
109 #define ROPCODE_MERGEPAINT 0xbb
110 #define ROPCODE_MERGECOPY 0xc0
111 #define ROPCODE_SRCCOPY 0xcc
112 #define ROPCODE_SRCPAINT 0xee
113 #define ROPCODE_PATCOPY 0xf0
114 #define ROPCODE_PATPAINT 0xfb
115 #define ROPCODE_WHITENESS 0xff
117 #define ROPCODE_GENERIC 256 /* Special case */
119 typedef struct _ROPINFO
130 #define FLAG_PATTERNSURFACE 0x01
131 #define FLAG_TRIVIALXLATE 0x02
132 #define FLAG_BOTTOMUP 0x04
133 #define FLAG_FORCENOUSESSOURCE 0x08
134 #define FLAG_FORCERAWSOURCEAVAIL 0x10
137 FindRopInfo(unsigned RopCode
)
139 static ROPINFO KnownCodes
[] =
141 { ROPCODE_BLACKNESS
, "BLACKNESS", "0", 0, 0, 0 },
142 { ROPCODE_NOTSRCERASE
, "NOTSRCERASE","~(D | S)", 1, 1, 0 },
143 { ROPCODE_NOTSRCCOPY
, "NOTSRCCOPY", "~S", 0, 1, 0 },
144 { ROPCODE_SRCERASE
, "SRCERASE", "(~D) & S", 1, 1, 0 },
145 { ROPCODE_DSTINVERT
, "DSTINVERT", "~D", 1, 0, 0 },
146 { ROPCODE_PATINVERT
, "PATINVERT", "D ^ P", 1, 0, 1 },
147 { ROPCODE_SRCINVERT
, "SRCINVERT", "D ^ S", 1, 1, 0 },
148 { ROPCODE_SRCAND
, "SRCAND", "D & S", 1, 1, 0 },
149 { ROPCODE_NOOP
, "NOOP", "D", 1, 0, 0 },
150 { ROPCODE_MERGEPAINT
, "MERGEPAINT", "D & (~S)", 1, 1, 0 },
151 { ROPCODE_MERGECOPY
, "MERGECOPY", "S & P", 0, 1, 1 },
152 { ROPCODE_SRCCOPY
, "SRCCOPY", "S", 0, 1, 0 },
153 { ROPCODE_SRCPAINT
, "SRCPAINT", "D | S", 1, 1, 0 },
154 { ROPCODE_PATCOPY
, "PATCOPY", "P", 0, 0, 1 },
155 { ROPCODE_PATPAINT
, "PATPAINT", "D | (~S) | P", 1, 1, 1 },
156 { ROPCODE_WHITENESS
, "WHITENESS", "0xffffffff", 0, 0, 0 },
157 { ROPCODE_GENERIC
, NULL
, NULL
, 1, 1, 1 }
161 for (Index
= 0; Index
< sizeof(KnownCodes
) / sizeof(KnownCodes
[0]); Index
++)
163 if (RopCode
== KnownCodes
[Index
].RopCode
)
165 return KnownCodes
+ Index
;
173 Output(FILE *Out
, char *Fmt
, ...)
175 static unsigned Indent
= 0;
176 static int AtBOL
= 1;
180 if (NULL
!= strchr(Fmt
, '{') && 0 != Indent
)
184 else if (NULL
!= strchr(Fmt
, '}'))
190 for (n
= 0; n
< Indent
; n
++)
198 vfprintf(Out
, Fmt
, Args
);
201 if (NULL
!= strchr(Fmt
, '{'))
205 else if (NULL
!= strchr(Fmt
, '}') && 0 != Indent
)
209 AtBOL
= '\n' == Fmt
[strlen(Fmt
) - 1];
213 PrintRoutineName(FILE *Out
, unsigned Bpp
, PROPINFO RopInfo
)
215 if (NULL
!= RopInfo
&& ROPCODE_GENERIC
!= RopInfo
->RopCode
)
217 Output(Out
, "DIB_%uBPP_BitBlt_%s", Bpp
, RopInfo
->Name
);
221 Output(Out
, "DIB_%uBPP_BitBlt_Generic", Bpp
);
226 CreateShiftTables(FILE *Out
)
229 Output(Out
, "static unsigned Shift1Bpp[] =\n");
232 Output(Out
, "24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23,\n");
233 Output(Out
, "8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7\n");
235 Output(Out
, "static unsigned Shift4Bpp[] =\n");
238 Output(Out
, "24, 28, 16, 20, 8, 12, 0, 4\n");
240 Output(Out
, "static unsigned Shift8Bpp[] =\n");
243 Output(Out
, "24, 16, 8, 0\n");
245 Output(Out
, "static unsigned Shift16Bpp[] =\n");
248 Output(Out
, "16, 0\n");
253 CreateOperation(FILE *Out
, unsigned Bpp
, PROPINFO RopInfo
, unsigned SourceBpp
,
269 Dest
= "*((PUSHORT) DestPtr)";
271 Output(Out
, "%s = ", Dest
);
272 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
274 Output(Out
, "%sDIB_DoRop(BltInfo->Rop4, %s, Source, Pattern)",
279 Template
= RopInfo
->Operation
;
280 while ('\0' != *Template
)
285 Output(Out
, "%sSource", Cast
);
288 Output(Out
, "%sPattern", Cast
);
291 Output(Out
, "%s", Dest
);
294 Output(Out
, "%c", *Template
);
303 CreateBase(FILE *Out
, int Source
, int Flags
, unsigned Bpp
)
305 char *What
= (Source
? "Source" : "Dest");
308 Output(Out
, "%sBase = (char *) BltInfo->%sSurface->pvScan0 +\n", What
, What
);
309 if (0 == (Flags
& FLAG_BOTTOMUP
))
313 Output(Out
, " BltInfo->SourcePoint.y *\n");
317 Output(Out
, " BltInfo->DestRect.top *\n");
324 Output(Out
, " (BltInfo->SourcePoint.y +\n");
325 Output(Out
, " BltInfo->DestRect.bottom -\n");
326 Output(Out
, " BltInfo->DestRect.top - 1) *\n");
330 Output(Out
, " (BltInfo->DestRect.bottom - 1) *\n");
333 Output(Out
, " %sBltInfo->%sSurface->lDelta +\n",
334 Source
? " " : "", What
);
337 Output(Out
, " %sBltInfo->SourcePoint.x",
338 16 < Bpp
? "" : "((");
342 Output(Out
, " BltInfo->DestRect.left");
346 Output(Out
, " / %u", 8 / Bpp
);
350 Output(Out
, " * %u", Bpp
/ 8);
352 if (Source
&& Bpp
<= 16)
354 Output(Out
, ") & ~ 0x3)");
356 Output(Out
, ";\n", Bpp
/ 8);
357 if (Source
&& Bpp
<= 16)
359 Output(Out
, "BaseSourcePixels = %u - (BltInfo->SourcePoint.x & 0x%x);\n",
360 32 / Bpp
, 32 / Bpp
- 1);
365 CreateGetSource(FILE *Out
, unsigned Bpp
, PROPINFO RopInfo
, int Flags
,
366 unsigned SourceBpp
, unsigned Shift
)
383 sprintf(After
, ") << %u", Shift
);
386 if (ROPCODE_SRCCOPY
!= RopInfo
->RopCode
||
387 0 == (Flags
& FLAG_TRIVIALXLATE
) || Bpp
!= SourceBpp
)
389 if (0 == (Flags
& FLAG_FORCERAWSOURCEAVAIL
) && SourceBpp
<= 16)
391 Output(Out
, "if (0 == SourcePixels)\n");
393 Output(Out
, "RawSource = *SourcePtr++;\n");
394 Output(Out
, "SourcePixels = %u;\n", 32 / SourceBpp
);
397 Output(Out
, "Source %s (%s", AssignOp
, Before
);
398 if (0 == (Flags
& FLAG_TRIVIALXLATE
))
400 Output(Out
, "XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, %s",
401 16 < SourceBpp
? "" : "(");
405 Output(Out
, "*SourcePtr++");
407 else if (24 == SourceBpp
)
409 Output(Out
, "*(PUSHORT) SourcePtr + (*((PBYTE) SourcePtr + 2) << 16)");
413 Output(Out
, "RawSource >> Shift%uBpp[SourcePixels]", SourceBpp
);
415 if (0 == (Flags
& FLAG_TRIVIALXLATE
))
423 Output(Out
, ") & 0x%x)", (1 << SourceBpp
) - 1);
426 Output(Out
, " & 0xffff)%s;\n", After
);
429 Output(Out
, "SourcePixels--;\n");
431 else if (24 == SourceBpp
)
433 Output(Out
, "SourcePtr = (PULONG)((char *) SourcePtr + 3);\n");
439 CreateCounts(FILE *Out
)
442 Output(Out
, "LeftCount = ((ULONG_PTR) DestBase >> 1) & 0x01;\n");
443 Output(Out
, "CenterCount = (BltInfo->DestRect.right - BltInfo->DestRect.left -\n");
444 Output(Out
, " LeftCount) / 2;\n");
445 Output(Out
, "RightCount = (BltInfo->DestRect.right - BltInfo->DestRect.left -\n");
446 Output(Out
, " LeftCount - 2 * CenterCount);\n");
450 CreateBitCase(FILE *Out
, unsigned Bpp
, PROPINFO RopInfo
, int Flags
,
454 if (RopInfo
->UsesSource
)
456 if (0 == (Flags
& FLAG_FORCENOUSESSOURCE
))
458 CreateBase(Out
, 1, Flags
, SourceBpp
);
460 CreateBase(Out
, 0, Flags
, Bpp
);
464 if (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
))
466 if (0 == (Flags
& FLAG_BOTTOMUP
))
468 Output(Out
, "PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %%\n");
469 Output(Out
, " BltInfo->PatternSurface->sizlBitmap.cy;\n");
473 Output(Out
, "PatternY = (BltInfo->DestRect.bottom - 1 +\n");
474 Output(Out
, " BltInfo->BrushOrigin.y) %%\n");
475 Output(Out
, " BltInfo->PatternSurface->sizlBitmap.cy;\n");
478 if (ROPCODE_SRCCOPY
== RopInfo
->RopCode
&&
479 0 != (Flags
& FLAG_TRIVIALXLATE
) && Bpp
== SourceBpp
)
481 Output(Out
, "CenterCount = 2 * (BltInfo->DestRect.right -\n");
482 Output(Out
, " BltInfo->DestRect.left);\n");
484 Output(Out
, "for (LineIndex = 0; LineIndex < LineCount; LineIndex++)\n");
486 if (ROPCODE_SRCCOPY
!= RopInfo
->RopCode
||
487 0 == (Flags
& FLAG_TRIVIALXLATE
) || Bpp
!= SourceBpp
)
489 if (RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
))
491 Output(Out
, "SourcePtr = (PULONG) SourceBase;\n");
494 Output(Out
, "RawSource = *SourcePtr++;\n");
495 Output(Out
, "SourcePixels = BaseSourcePixels;\n");
498 Output(Out
, "DestPtr = (PULONG) DestBase;\n");
500 if (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
))
502 Output(Out
, "PatternX = (BltInfo->DestRect.left + BltInfo->BrushOrigin.x) %%\n");
503 Output(Out
, " BltInfo->PatternSurface->sizlBitmap.cx;\n");
505 if (ROPCODE_SRCCOPY
== RopInfo
->RopCode
&&
506 0 != (Flags
& FLAG_TRIVIALXLATE
) && Bpp
== SourceBpp
)
508 Output(Out
, "RtlMoveMemory(DestBase, SourceBase, CenterCount);\n");
514 Output(Out
, "if (0 != LeftCount)\n");
516 if (RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
))
518 CreateGetSource(Out
, Bpp
, RopInfo
, Flags
| FLAG_FORCERAWSOURCEAVAIL
,
522 if (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
))
524 Output(Out
, "Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);\n");
525 Output(Out
, "if (BltInfo->PatternSurface->sizlBitmap.cx <= ++PatternX)\n");
527 Output(Out
, "PatternX -= BltInfo->PatternSurface->sizlBitmap.cx;\n");
530 if ((RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
) &&
532 (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
)))
536 CreateOperation(Out
, Bpp
, RopInfo
, SourceBpp
, 16);
540 Output(Out
, "DestPtr = (PULONG)((char *) DestPtr + 2);\n");
543 Output(Out
, "for (i = 0; i < CenterCount; i++)\n");
545 if (RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
))
547 CreateGetSource(Out
, Bpp
, RopInfo
, Flags
, SourceBpp
, 0);
548 CreateGetSource(Out
, Bpp
, RopInfo
, Flags
, SourceBpp
, 16);
552 if (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
))
554 Output(Out
, "Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);\n");
555 Output(Out
, "if (BltInfo->PatternSurface->sizlBitmap.cx <= ++PatternX)\n");
557 Output(Out
, "PatternX -= BltInfo->PatternSurface->sizlBitmap.cx;\n");
559 Output(Out
, "Pattern |= DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest) << 16;\n");
560 Output(Out
, "if (BltInfo->PatternSurface->sizlBitmap.cx <= ++PatternX)\n");
562 Output(Out
, "PatternX -= BltInfo->PatternSurface->sizlBitmap.cx;\n");
566 CreateOperation(Out
, Bpp
, RopInfo
, SourceBpp
, 32);
570 Output(Out
, "DestPtr++;\n");
573 Output(Out
, "if (0 != RightCount)\n");
575 if (RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
))
577 CreateGetSource(Out
, Bpp
, RopInfo
, Flags
, SourceBpp
, 0);
580 if (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
))
582 Output(Out
, "Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);\n");
584 if ((RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
)) ||
585 (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
)))
589 CreateOperation(Out
, Bpp
, RopInfo
, SourceBpp
, 16);
594 if (RopInfo
->UsesPattern
&& 0 != (Flags
& FLAG_PATTERNSURFACE
))
596 if (0 == (Flags
& FLAG_BOTTOMUP
))
598 Output(Out
, "if (BltInfo->PatternSurface->sizlBitmap.cy <= ++PatternY)\n");
600 Output(Out
, "PatternY -= BltInfo->PatternSurface->sizlBitmap.cy;\n");
605 Output(Out
, "if (0 == PatternY--)\n");
607 Output(Out
, "PatternY = BltInfo->PatternSurface->sizlBitmap.cy - 1;\n");
612 if (RopInfo
->UsesSource
&& 0 == (Flags
& FLAG_FORCENOUSESSOURCE
))
614 Output(Out
, "SourceBase %c= BltInfo->SourceSurface->lDelta;\n",
615 0 == (Flags
& FLAG_BOTTOMUP
) ? '+' : '-');
617 Output(Out
, "DestBase %c= BltInfo->DestSurface->lDelta;\n",
618 0 == (Flags
& FLAG_BOTTOMUP
) ? '+' : '-');
623 CreateActionBlock(FILE *Out
, unsigned Bpp
, PROPINFO RopInfo
,
626 static unsigned SourceBpp
[ ] =
627 { 1, 4, 8, 16, 24, 32 };
631 if (RopInfo
->UsesSource
)
633 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
635 Output(Out
, "if (UsesSource)\n");
638 Output(Out
, "switch (BltInfo->SourceSurface->iBitmapFormat)\n");
641 BppIndex
< sizeof(SourceBpp
) / sizeof(unsigned);
644 Output(Out
, "case BMF_%uBPP:\n", SourceBpp
[BppIndex
]);
646 if (Bpp
== SourceBpp
[BppIndex
])
648 Output(Out
, "if (NULL == BltInfo->XlateSourceToDest ||\n");
649 Output(Out
, " 0 != (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))\n");
651 Output(Out
, "if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)\n");
653 CreateBitCase(Out
, Bpp
, RopInfo
,
654 Flags
| FLAG_TRIVIALXLATE
,
655 SourceBpp
[BppIndex
]);
658 Output(Out
, "else\n");
660 CreateBitCase(Out
, Bpp
, RopInfo
,
661 Flags
| FLAG_BOTTOMUP
| FLAG_TRIVIALXLATE
,
662 SourceBpp
[BppIndex
]);
666 Output(Out
, "else\n");
668 Output(Out
, "if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)\n");
670 CreateBitCase(Out
, Bpp
, RopInfo
, Flags
, SourceBpp
[BppIndex
]);
673 Output(Out
, "else\n");
675 CreateBitCase(Out
, Bpp
, RopInfo
,
676 Flags
| FLAG_BOTTOMUP
,
677 SourceBpp
[BppIndex
]);
684 CreateBitCase(Out
, Bpp
, RopInfo
, Flags
,
685 SourceBpp
[BppIndex
]);
688 Output(Out
, "break;\n");
692 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
695 Output(Out
, "else\n");
697 CreateBitCase(Out
, Bpp
, RopInfo
, Flags
| FLAG_FORCENOUSESSOURCE
, 0);
704 CreateBitCase(Out
, Bpp
, RopInfo
, Flags
, 0);
709 CreatePrimitive(FILE *Out
, unsigned Bpp
, PROPINFO RopInfo
)
715 Output(Out
, "static void\n");
716 PrintRoutineName(Out
, Bpp
, RopInfo
);
717 Output(Out
, "(PBLTINFO BltInfo)\n");
719 if (ROPCODE_BLACKNESS
== RopInfo
->RopCode
)
721 Output(Out
, "DIB_%uBPP_ColorFill(BltInfo->DestSurface, "
722 "&BltInfo->DestRect, 0x0);\n", Bpp
);
724 else if (ROPCODE_WHITENESS
== RopInfo
->RopCode
)
726 Output(Out
, "DIB_%uBPP_ColorFill(BltInfo->DestSurface, "
727 "&BltInfo->DestRect, ~0);\n", Bpp
);
729 else if (ROPCODE_NOOP
== RopInfo
->RopCode
)
731 Output(Out
, "return;\n");
735 Output(Out
, "ULONG LineIndex, LineCount;\n");
736 Output(Out
, "ULONG i;\n");
738 if (RopInfo
->UsesSource
)
740 Output(Out
, "ULONG SourceX, SourceY;\n");
743 if (RopInfo
->UsesPattern
)
745 Output(Out
, "ULONG PatternX, PatternY = 0;\n");
748 if (RopInfo
->UsesSource
)
750 Output(Out
, "ULONG Source = 0");
753 if (RopInfo
->UsesPattern
)
755 Output(Out
, "%s Pattern = 0", First
? "ULONG" : ",");
762 Output(Out
, "char *DestBase;\n");
763 Output(Out
, "PULONG DestPtr;\n");
764 if (RopInfo
->UsesSource
)
766 Output(Out
, "char *SourceBase;\n");
767 Output(Out
, "PULONG SourcePtr;\n");
768 Output(Out
, "ULONG RawSource;\n");
769 Output(Out
, "unsigned SourcePixels, BaseSourcePixels;\n");
771 Output(Out
, "ULONG LeftCount, CenterCount, RightCount;\n");
772 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
774 Output(Out
, "BOOLEAN UsesDest, UsesSource, UsesPattern;\n");
776 Output(Out
, "UsesDest = ROP4_USES_DEST(BltInfo->Rop4);\n");
777 Output(Out
, "UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);\n");
778 Output(Out
, "UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);\n");
781 if (! RopInfo
->UsesSource
)
783 CreateBase(Out
, 0, 0, Bpp
);
787 Output(Out
, "LineCount = BltInfo->DestRect.bottom - BltInfo->DestRect.top;\n");
790 if (RopInfo
->UsesPattern
)
792 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
794 Output(Out
, "if (UsesPattern && NULL != BltInfo->PatternSurface)\n");
798 Output(Out
, "if (NULL != BltInfo->PatternSurface)\n");
801 CreateActionBlock(Out
, Bpp
, RopInfo
, FLAG_PATTERNSURFACE
);
804 Output(Out
, "else\n");
806 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
808 Output(Out
, "if (UsesPattern)\n");
811 Output(Out
, "Pattern = BltInfo->Brush->iSolidColor |\n");
812 Output(Out
, " (BltInfo->Brush->iSolidColor << 16);\n");
813 if (ROPCODE_PATINVERT
== RopInfo
->RopCode
||
814 ROPCODE_MERGECOPY
== RopInfo
->RopCode
)
816 Output(Out
, "if (0 == Pattern)\n");
818 if (ROPCODE_MERGECOPY
== RopInfo
->RopCode
)
820 Output(Out
, "DIB_%uBPP_ColorFill(BltInfo->DestSurface, "
821 "&BltInfo->DestRect, 0x0);\n", Bpp
);
823 Output(Out
, "return;\n");
826 else if (ROPCODE_PATPAINT
== RopInfo
->RopCode
)
828 Output(Out
, "if ((~0) == Pattern)\n");
830 Output(Out
, "DIB_%uBPP_ColorFill(BltInfo->DestSurface, "
831 "&BltInfo->DestRect, ~0);\n", Bpp
);
832 Output(Out
, "return;\n");
835 if (ROPCODE_GENERIC
== RopInfo
->RopCode
)
839 CreateActionBlock(Out
, Bpp
, RopInfo
, 0);
845 CreateActionBlock(Out
, Bpp
, RopInfo
, 0);
853 CreateTable(FILE *Out
, unsigned Bpp
)
859 Output(Out
, "static void (*PrimitivesTable[256])(PBLTINFO) =\n");
861 for (RopCode
= 0; RopCode
< 256; RopCode
++)
864 PrintRoutineName(Out
, Bpp
, FindRopInfo(RopCode
));
871 Output(Out
, " };\n");
875 CreateBitBlt(FILE *Out
, unsigned Bpp
)
879 Output(Out
, "BOOLEAN\n");
880 Output(Out
, "DIB_%uBPP_BitBlt(PBLTINFO BltInfo)\n", Bpp
);
882 Output(Out
, " PrimitivesTable[BltInfo->Rop4 & 0xff](BltInfo);\n");
884 Output(Out
, " return TRUE;\n");
889 main(int argc
, char *argv
[])
897 Out
= fopen(argv
[1], "w");
900 perror("Error opening output file");
905 Output(Out
, "/* This is a generated file. Please do not edit */\n");
907 Output(Out
, "#include \"w32k.h\"\n");
908 CreateShiftTables(Out
);
910 RopInfo
= FindRopInfo(ROPCODE_GENERIC
);
911 CreatePrimitive(Out
, Bpp
, RopInfo
);
912 for (RopCode
= 0; RopCode
< 256; RopCode
++)
914 RopInfo
= FindRopInfo(RopCode
);
917 CreatePrimitive(Out
, Bpp
, RopInfo
);
920 CreateTable(Out
, Bpp
);
921 CreateBitBlt(Out
, Bpp
);