Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
6.1 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: paint.c
  3. *
  4. * Copyright (c) 1992 Microsoft Corporation
  5. \**************************************************************************/
  6. #include "driver.h"
  7. /******************************Public*Data*********************************\
  8. * MIX translation table
  9. *
  10. * Translates a mix 1-16, into an old style Rop 0-255.
  11. *
  12. \**************************************************************************/
  13. BYTE gaMix[] =
  14. {
  15. 0xFF, // R2_WHITE - Allow rop = gaMix[mix & 0x0F]
  16. 0x00, // R2_BLACK
  17. 0x05, // R2_NOTMERGEPEN
  18. 0x0A, // R2_MASKNOTPEN
  19. 0x0F, // R2_NOTCOPYPEN
  20. 0x50, // R2_MASKPENNOT
  21. 0x55, // R2_NOT
  22. 0x5A, // R2_XORPEN
  23. 0x5F, // R2_NOTMASKPEN
  24. 0xA0, // R2_MASKPEN
  25. 0xA5, // R2_NOTXORPEN
  26. 0xAA, // R2_NOP
  27. 0xAF, // R2_MERGENOTPEN
  28. 0xF0, // R2_COPYPEN
  29. 0xF5, // R2_MERGEPENNOT
  30. 0xFA, // R2_MERGEPEN
  31. 0xFF // R2_WHITE
  32. };
  33. /******************************Public*Routine******************************\
  34. * bPaintRgn
  35. *
  36. * Paint the clipping region with the specified color and mode
  37. *
  38. \**************************************************************************/
  39. BOOL bPaintRgn
  40. (
  41. SURFOBJ *pso,
  42. CLIPOBJ *pco,
  43. MIX mix,
  44. RBRUSH_COLOR rbc,
  45. POINTL *pptlBrush,
  46. PFNFILL pfnFill
  47. )
  48. {
  49. BBENUM bben;
  50. PPDEV ppdev;
  51. ULONG iRT;
  52. BOOL bMore;
  53. // Get the target surface information.
  54. ppdev = (PPDEV) pso->dhsurf;
  55. switch(pco->iMode) {
  56. case TC_RECTANGLES:
  57. // Rectangular clipping can be handled without enumeration.
  58. // Note that trivial clipping is not possible, since the clipping
  59. // region defines the area to fill
  60. if (pco->iDComplexity == DC_RECT)
  61. {
  62. (*pfnFill)(ppdev, 1, &pco->rclBounds, mix, rbc, pptlBrush);
  63. } else {
  64. // Enumerate all the rectangles and draw them
  65. CLIPOBJ_cEnumStart(pco,FALSE,CT_RECTANGLES,CD_ANY,BB_RECT_LIMIT);
  66. do {
  67. bMore = CLIPOBJ_bEnum(pco, sizeof(bben), (PVOID) &bben);
  68. (*pfnFill)(ppdev, bben.c, &bben.arcl[0], mix, rbc, pptlBrush);
  69. } while (bMore);
  70. }
  71. return(TRUE);
  72. default:
  73. RIP("bPaintRgn: unhandled TC_xxx\n");
  74. return(FALSE);
  75. }
  76. }
  77. /**************************************************************************\
  78. * DrvPaint
  79. *
  80. * Paint the clipping region with the specified brush
  81. *
  82. \**************************************************************************/
  83. BOOL DrvPaint
  84. (
  85. SURFOBJ *pso,
  86. CLIPOBJ *pco,
  87. BRUSHOBJ *pbo,
  88. POINTL *pptlBrush,
  89. MIX mix
  90. )
  91. {
  92. ROP4 rop4;
  93. RBRUSH_COLOR rbc;
  94. PFNFILL pfnFill;
  95. // If this adapter supports planar mode and the foreground and background
  96. // mixes are the same,
  97. // LATER or if there's no brush mask
  98. // then see if we can use the brush accelerators
  99. // LATER handle non-planar also
  100. if ((((PPDEV) pso->dhsurf)->fl & DRIVER_PLANAR_CAPABLE) &&
  101. ((mix & 0xFF) == ((mix >> 8) & 0xFF))) {
  102. switch (mix & 0xFF) {
  103. case 0:
  104. break;
  105. // vTrgBlt can only handle solid color fills where if the
  106. // destination is inverted, no other action is also required
  107. case R2_MASKNOTPEN:
  108. case R2_NOTCOPYPEN:
  109. case R2_XORPEN:
  110. case R2_MASKPEN:
  111. case R2_NOTXORPEN:
  112. case R2_MERGENOTPEN:
  113. case R2_COPYPEN:
  114. case R2_MERGEPEN:
  115. case R2_NOTMERGEPEN:
  116. case R2_MASKPENNOT:
  117. case R2_NOTMASKPEN:
  118. case R2_MERGEPENNOT:
  119. // vTrgBlt can only handle solid color fills
  120. if (pbo->iSolidColor != 0xffffffff)
  121. {
  122. rbc.iSolidColor = pbo->iSolidColor;
  123. pfnFill = vTrgBlt;
  124. }
  125. else
  126. {
  127. rbc.prb = (RBRUSH*) pbo->pvRbrush;
  128. if (rbc.prb == NULL)
  129. {
  130. rbc.prb = (RBRUSH*) BRUSHOBJ_pvGetRbrush(pbo);
  131. if (rbc.prb == NULL)
  132. {
  133. // If we haven't realized the brush, punt the call:
  134. break;
  135. }
  136. }
  137. if (!(rbc.prb->fl & RBRUSH_BLACKWHITE) &&
  138. ((mix & 0xff) != R2_COPYPEN))
  139. {
  140. // Only black/white brushes can handle ROPs other
  141. // than COPYPEN:
  142. break;
  143. }
  144. if (rbc.prb->fl & RBRUSH_NCOLOR)
  145. pfnFill = vColorPat;
  146. else
  147. pfnFill = vMonoPat;
  148. }
  149. return(bPaintRgn(pso, pco, mix, rbc, pptlBrush, pfnFill));
  150. // Rops that are implicit solid colors
  151. case R2_NOT:
  152. case R2_WHITE:
  153. case R2_BLACK:
  154. // Brush color parameter doesn't matter for these rops
  155. // compiler error local variable 'rbc' used without having been initialized
  156. rbc.prb = NULL;
  157. rbc.iSolidColor = 0;
  158. return(bPaintRgn(pso, pco, mix, rbc, NULL, vTrgBlt));
  159. case R2_NOP:
  160. return(TRUE);
  161. default:
  162. break;
  163. }
  164. }
  165. rop4 = (gaMix[(mix >> 8) & 0x0F]) << 8;
  166. rop4 |= ((ULONG) gaMix[mix & 0x0F]);
  167. return(DrvBitBlt(
  168. pso,
  169. (SURFOBJ *) NULL,
  170. (SURFOBJ *) NULL,
  171. pco,
  172. (XLATEOBJ *) NULL,
  173. &pco->rclBounds,
  174. (POINTL *) NULL,
  175. (POINTL *) NULL,
  176. pbo,
  177. pptlBrush,
  178. rop4));
  179. }
  180.