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.

134 lines
5.3 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: span2.h
  3. *
  4. * This code figures out the color for pixel and stores it
  5. *
  6. * 14-Oct-1994 mikeke Created
  7. *
  8. * Copyright (c) 1994 Microsoft Corporation
  9. \**************************************************************************/
  10. {
  11. DWORD r, g, b;
  12. DWORD color;
  13. #if DITHER
  14. #if (BPP == 8)
  15. ULONG ditherVal = pdither[((ULONG_PTR)pPix) & 0x3];
  16. #elif (BPP == 16)
  17. ULONG ditherVal = pdither[((ULONG_PTR)pPix & 0x6) >> 1];
  18. #elif (BPP == 24)
  19. ULONG ditherVal = pdither[iDither];
  20. #else
  21. ULONG ditherVal = pdither[((ULONG_PTR)pPix & 0xc) >> 2];
  22. #endif
  23. #else
  24. #if (RGBMODE) && (TEXTURE) && (SHADE)
  25. #define ditherVal 0x0008
  26. #else
  27. #define ditherVal 0x0000
  28. #endif
  29. #endif
  30. #if TEXTURE
  31. #if !(SHADE) && !(DITHER) && (BPP == 8)
  32. texBits = (BYTE *)(texAddr + ((sAccum & GENACCEL(gengc).sMask) >> 16) +
  33. ((tAccum & GENACCEL(gengc).tMask) >> GENACCEL(gengc).tShift));
  34. #elif !(SHADE) && !(DITHER) && (BPP == 16)
  35. texBits = (BYTE *)(texAddr + ((sAccum & GENACCEL(gengc).sMask) >> 15) +
  36. ((tAccum & GENACCEL(gengc).tMask) >> GENACCEL(gengc).tShift));
  37. #else
  38. texBits = (BYTE *)(texAddr + ((sAccum & GENACCEL(gengc).sMask) >> 14) +
  39. ((tAccum & GENACCEL(gengc).tMask) >> GENACCEL(gengc).tShift));
  40. #endif
  41. #endif
  42. #if !(RGBMODE)
  43. // !!! probably don't need to mask values
  44. #if (BPP == 8)
  45. color = ((rAccum + ditherVal) >> 16) & 0xff;
  46. #else
  47. color = ((PULONG)pXlat)[(((rAccum + ditherVal) >> 16) & 0xfff)];
  48. #endif
  49. #else //RGBMODE
  50. #if TEXTURE
  51. #if SHADE
  52. #define BIGSHIFT 8
  53. #ifdef RSHIFT
  54. r = ((ULONG)gbMulTable[(((rAccum >> RBITS) & 0xff00) | texBits[2])] << RBITS) + ditherVal;
  55. g = ((ULONG)gbMulTable[(((gAccum >> GBITS) & 0xff00) | texBits[1])] << GBITS) + ditherVal;
  56. b = ((ULONG)gbMulTable[(((bAccum >> BBITS) & 0xff00) | texBits[0])] << BBITS) + ditherVal;
  57. #else
  58. r = ((ULONG)gbMulTable[(((rAccum >> rBits) & 0xff00) | texBits[2])] << rBits) + ditherVal;
  59. g = ((ULONG)gbMulTable[(((gAccum >> gBits) & 0xff00) | texBits[1])] << gBits) + ditherVal;
  60. b = ((ULONG)gbMulTable[(((bAccum >> bBits) & 0xff00) | texBits[0])] << bBits) + ditherVal;
  61. #endif
  62. #else //!SHADE
  63. #define BIGSHIFT 8
  64. #if DITHER
  65. #ifdef RSHIFT
  66. r = ((ULONG)gbMulTable[(rAccum | texBits[2])] << RBITS) + ditherVal;
  67. g = ((ULONG)gbMulTable[(gAccum | texBits[1])] << GBITS) + ditherVal;
  68. b = ((ULONG)gbMulTable[(bAccum | texBits[0])] << BBITS) + ditherVal;
  69. #else
  70. r = ((ULONG)gbMulTable[(rAccum | texBits[2])] << rBits) + ditherVal;
  71. g = ((ULONG)gbMulTable[(gAccum | texBits[1])] << gBits) + ditherVal;
  72. b = ((ULONG)gbMulTable[(bAccum | texBits[0])] << bBits) + ditherVal;
  73. #endif
  74. #else //!DITHER
  75. #if (!((BPP == 8) || (BPP == 16)))
  76. #ifdef RSHIFT
  77. r = (texBits[2] << RBITS);
  78. g = (texBits[1] << GBITS);
  79. b = (texBits[0] << BBITS);
  80. #else
  81. r = (texBits[2] << rBits);
  82. g = (texBits[1] << gBits);
  83. b = (texBits[0] << bBits);
  84. #endif
  85. #endif
  86. #endif //DITHER
  87. #endif //SHADE
  88. #else //!TEXTURE
  89. #define BIGSHIFT 16
  90. r = rAccum + ditherVal;
  91. g = gAccum + ditherVal;
  92. b = bAccum + ditherVal;
  93. #endif //TEXTURE
  94. #if !((TEXTURE) && !(SHADE) && !(DITHER) && ((BPP == 8) || (BPP == 16)))
  95. #ifdef RSHIFT
  96. color = ((r >> BIGSHIFT) << RSHIFT) |
  97. ((g >> BIGSHIFT) << GSHIFT) |
  98. ((b >> BIGSHIFT) << BSHIFT);
  99. #else
  100. color = ((r >> BIGSHIFT) << rShift) |
  101. ((g >> BIGSHIFT) << gShift) |
  102. ((b >> BIGSHIFT) << bShift);
  103. #endif
  104. #endif
  105. #undef BIGSHIFT
  106. #endif //RGBMODE
  107. #if (TEXTURE) && !(SHADE) && !(DITHER) && ((BPP == 8) || (BPP == 16))
  108. #if (BPP == 8)
  109. *pPix = texBits[0];
  110. #else
  111. *((WORD *)pPix) = *((WORD *)texBits);
  112. #endif
  113. #else
  114. #if (BPP == 8)
  115. *pPix = gengc->xlatPalette[color & 0xff];
  116. #elif (BPP == 16)
  117. *((WORD *)pPix) = (USHORT)color;
  118. #elif (BPP == 24)
  119. *pPix = (BYTE)color;
  120. *(pPix + 1) = (BYTE)(color >> 8);
  121. *(pPix + 2) = (BYTE)(color >> 16);
  122. #else
  123. *((DWORD *)pPix) = color;
  124. #endif // BPP
  125. #endif
  126. }