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.

174 lines
6.3 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // This file contains C span loops.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997.
  6. //
  7. //-----------------------------------------------------------------------------
  8. #include "rgb_pch.h"
  9. #pragma hdrstop
  10. HRESULT
  11. CMLRast_1(
  12. PD3DI_RASTCTX pCtx)
  13. {
  14. PD3DI_RASTPRIM pP = pCtx->pPrim;
  15. while (pP)
  16. {
  17. UINT16 uSpans = pP->uSpans;
  18. PD3DI_RASTSPAN pS = (PD3DI_RASTSPAN)(pP + 1);
  19. while (uSpans-- > 0)
  20. {
  21. UINT16 uPix = pS->uPix;
  22. INT iSurfaceStep;
  23. INT iZStep;
  24. if (pP->uFlags & D3DI_RASTPRIM_X_DEC) {
  25. iZStep = -pCtx->iZStep;
  26. iSurfaceStep = -pCtx->iSurfaceStep;
  27. pCtx->SI.iXStep = -1; // for dithering
  28. } else {
  29. iZStep = pCtx->iZStep;
  30. iSurfaceStep = pCtx->iSurfaceStep;
  31. pCtx->SI.iXStep = 1;
  32. }
  33. while (1) {
  34. UINT16 uZ = (UINT16)(pS->uZ>>15);
  35. UINT16 uZB = *((UINT16*)pS->pZ);
  36. pS->uZ += pP->iDZDX;
  37. if ((pCtx->iZXorMask)^(uZ > uZB)) {
  38. *((UINT16*)pS->pZ) = uZ;
  39. pCtx->SI.uBB = pS->uB;
  40. pCtx->SI.uBG = pS->uG;
  41. pCtx->SI.uBR = pS->uR;
  42. pCtx->SI.uBA = pS->uA;
  43. pS->uB += pP->iDBDX; pS->uG += pP->iDGDX;
  44. pS->uR += pP->iDRDX; pS->uA += pP->iDADX;
  45. pCtx->SI.uBB = (UINT16)min< UINT32>((UINT32)pCtx->SI.uBB + (UINT32)pS->uBS, 0xffff);
  46. pCtx->SI.uBG = (UINT16)min< UINT32>((UINT32)pCtx->SI.uBG + (UINT32)pS->uGS, 0xffff);
  47. pCtx->SI.uBR = (UINT16)min< UINT32>((UINT32)pCtx->SI.uBR + (UINT32)pS->uRS, 0xffff);
  48. pS->uBS += pP->iDBSDX; pS->uGS += pP->iDGSDX;
  49. pS->uRS += pP->iDRSDX;
  50. *(PUINT16)pS->pSurface =
  51. ((pCtx->SI.uBR >> 1) & 0x7c00) |
  52. ((pCtx->SI.uBG >> 6) & 0x03e0) |
  53. ((pCtx->SI.uBB >> 11) & 0x001f) |
  54. 0x8000;
  55. } else {
  56. pS->uB += pP->iDBDX; pS->uG += pP->iDGDX;
  57. pS->uR += pP->iDRDX; pS->uA += pP->iDADX;
  58. if (pCtx->pdwRenderState[D3DRS_SPECULARENABLE]) {
  59. pS->uBS += pP->iDBSDX; pS->uGS += pP->iDGSDX;
  60. pS->uRS += pP->iDRSDX;
  61. }
  62. if (pCtx->pdwRenderState[D3DRS_FOGENABLE]) {
  63. pS->uFog += (INT16)pS->iDFog;
  64. pCtx->SI.uFogB += pCtx->SI.iFogBDX;
  65. pCtx->SI.uFogG += pCtx->SI.iFogGDX;
  66. pCtx->SI.uFogR += pCtx->SI.iFogRDX;
  67. }
  68. }
  69. if (--uPix <= 0)
  70. break;
  71. pS->pZ += iZStep;
  72. pS->pSurface += iSurfaceStep;
  73. #ifdef DBG
  74. // handy for debug to see where we are
  75. pS->uX += (INT16)pCtx->SI.iXStep;
  76. #endif
  77. }
  78. pS++;
  79. }
  80. pP = pP->pNext;
  81. }
  82. return DD_OK;
  83. }
  84. HRESULT
  85. CMLRast_2(
  86. PD3DI_RASTCTX pCtx)
  87. {
  88. PD3DI_RASTPRIM pP = pCtx->pPrim;
  89. while (pP)
  90. {
  91. UINT16 uSpans = pP->uSpans;
  92. PD3DI_RASTSPAN pS = (PD3DI_RASTSPAN)(pP + 1);
  93. while (uSpans-- > 0)
  94. {
  95. UINT16 uPix = pS->uPix;
  96. INT iSurfaceStep;
  97. INT iZStep;
  98. if (pP->uFlags & D3DI_RASTPRIM_X_DEC) {
  99. iZStep = -pCtx->iZStep;
  100. iSurfaceStep = -pCtx->iSurfaceStep;
  101. pCtx->SI.iXStep = -1; // for dithering
  102. } else {
  103. iZStep = pCtx->iZStep;
  104. iSurfaceStep = pCtx->iSurfaceStep;
  105. pCtx->SI.iXStep = 1;
  106. }
  107. while (1) {
  108. UINT16 uZ = (UINT16)(pS->uZ>>15);
  109. UINT16 uZB = *((UINT16*)pS->pZ);
  110. pS->uZ += pP->iDZDX;
  111. if ((pCtx->iZXorMask)^(uZ > uZB)) {
  112. *((UINT16*)pS->pZ) = uZ;
  113. pCtx->SI.uBB = pS->uB;
  114. pCtx->SI.uBG = pS->uG;
  115. pCtx->SI.uBR = pS->uR;
  116. pCtx->SI.uBA = pS->uA;
  117. pS->uB += pP->iDBDX; pS->uG += pP->iDGDX;
  118. pS->uR += pP->iDRDX; pS->uA += pP->iDADX;
  119. pCtx->SI.uBB = (UINT16)min< UINT32>((UINT32)pCtx->SI.uBB + (UINT32)pS->uBS, 0xffff);
  120. pCtx->SI.uBG = (UINT16)min< UINT32>((UINT32)pCtx->SI.uBG + (UINT32)pS->uGS, 0xffff);
  121. pCtx->SI.uBR = (UINT16)min< UINT32>((UINT32)pCtx->SI.uBR + (UINT32)pS->uRS, 0xffff);
  122. pS->uBS += pP->iDBSDX; pS->uGS += pP->iDGSDX;
  123. pS->uRS += pP->iDRSDX;
  124. UINT32 uARGB = RGBA_MAKE(pCtx->SI.uBR>>8, pCtx->SI.uBG>>8,
  125. pCtx->SI.uBB>>8, 0xff);
  126. PUINT32 pSurface = (PUINT32)pS->pSurface;
  127. *pSurface = uARGB;
  128. } else {
  129. pS->uB += pP->iDBDX; pS->uG += pP->iDGDX;
  130. pS->uR += pP->iDRDX; pS->uA += pP->iDADX;
  131. if (pCtx->pdwRenderState[D3DRS_SPECULARENABLE]) {
  132. pS->uBS += pP->iDBSDX; pS->uGS += pP->iDGSDX;
  133. pS->uRS += pP->iDRSDX;
  134. }
  135. if (pCtx->pdwRenderState[D3DRS_FOGENABLE]) {
  136. pS->uFog += (INT16)pS->iDFog;
  137. pCtx->SI.uFogB += pCtx->SI.iFogBDX;
  138. pCtx->SI.uFogG += pCtx->SI.iFogGDX;
  139. pCtx->SI.uFogR += pCtx->SI.iFogRDX;
  140. }
  141. }
  142. if (--uPix <= 0)
  143. break;
  144. pS->pZ += iZStep;
  145. pS->pSurface += iSurfaceStep;
  146. #ifdef DBG
  147. // handy for debug to see where we are
  148. pS->uX += (INT16)pCtx->SI.iXStep;
  149. #endif
  150. }
  151. pS++;
  152. }
  153. pP = pP->pNext;
  154. }
  155. return DD_OK;
  156. }