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.

79 lines
3.8 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // This file contains color blend functions.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997.
  6. //
  7. // WARNING WARNING WARNING
  8. // This cpp file generated from mcp file.
  9. // EDIT THE MCP FILE.
  10. // I warned you.
  11. // WARNING WARNING WARNING
  12. //
  13. //-----------------------------------------------------------------------------
  14. include(`m4hdr.mh')dnl
  15. #include "pch.cpp"
  16. #pragma hdrstop
  17. #include "mcrbd_mh.h"
  18. define(`d_ColorBlend', `
  19. void CMMX_ColorBlend_$1_$2(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  20. PD3DI_RASTSPAN pS)
  21. {
  22. dnl if (($1 == AllBlend) || ($2 == AllROP))
  23. ifelse(eval((d_index(`$1', `AllBlend') == 0) || (d_index(`$2', `AllROP') == 0)), `1', `
  24. D3DCOLOR DestColor = pCtx->pfnBufRead(pS->pSurface);')
  25. dnl
  26. ifelse(`$1', `AllBlend', `
  27. {
  28. UINT16 uSR, uSG, uSB, uSA;
  29. UINT16 uBR, uBG, uBB, uBA;
  30. pCtx->pfnSrcBlend (&uSR, &uSG, &uSB, &uSA, DestColor, pCtx);
  31. pCtx->pfnDestBlend(&uBR, &uBG, &uBB, &uBA, DestColor, pCtx);
  32. // This is an add with saturate in MMX
  33. pCtx->SI.uBB = (UINT16)min((UINT32)uSB + (UINT32)uBB, 0xffff);
  34. pCtx->SI.uBG = (UINT16)min((UINT32)uSG + (UINT32)uBG, 0xffff);
  35. pCtx->SI.uBR = (UINT16)min((UINT32)uSR + (UINT32)uBR, 0xffff);
  36. pCtx->SI.uBA = (UINT16)min((UINT32)uSA + (UINT32)uBA, 0xffff);
  37. }')
  38. dnl
  39. dnl
  40. ifelse(`$2', `AllROP', `
  41. {
  42. // It might be faster to do this in conjunction with the write.
  43. // It might be faster to do this through a function pointer too.
  44. UINT16 uBB = (UINT16)RGBA_GETBLUE(DestColor)<<8;
  45. UINT16 uBG = (UINT16)RGBA_GETGREEN(DestColor)<<8;
  46. UINT16 uBR = (UINT16)RGBA_GETRED(DestColor)<<8;
  47. UINT16 uBA = (UINT16)RGBA_GETALPHA(DestColor)<<8;
  48. switch (pCtx->pdwRenderState[D3DRENDERSTATE_ROP2]) {
  49. case R2_BLACK : d_RepStr(`pCtx->SI.XX = 0; ', XX, uBB, uBG, uBR, uBA)break;
  50. case R2_NOTMERGEPEN: d_RepStr(`pCtx->SI.XX = ~(pCtx->SI.XX | XX); ',XX, uBB, uBG, uBR, uBA)break;
  51. case R2_MASKNOTPEN : d_RepStr(`pCtx->SI.XX = ~pCtx->SI.XX & XX; ', XX, uBB, uBG, uBR, uBA)break;
  52. case R2_NOTCOPYPEN : d_RepStr(`pCtx->SI.XX = ~pCtx->SI.XX; ', XX, uBB, uBG, uBR, uBA)break;
  53. case R2_MASKPENNOT : d_RepStr(`pCtx->SI.XX = pCtx->SI.XX & ~XX; ', XX, uBB, uBG, uBR, uBA)break;
  54. case R2_NOT : d_RepStr(`pCtx->SI.XX = ~XX; ', XX, uBB, uBG, uBR, uBA)break;
  55. case R2_XORPEN : d_RepStr(`pCtx->SI.XX = pCtx->SI.XX ^ XX; ', XX, uBB, uBG, uBR, uBA)break;
  56. case R2_NOTMASKPEN : d_RepStr(`pCtx->SI.XX = ~(pCtx->SI.XX & XX); ',XX, uBB, uBG, uBR, uBA)break;
  57. case R2_MASKPEN : d_RepStr(`pCtx->SI.XX = pCtx->SI.XX & XX; ', XX, uBB, uBG, uBR, uBA)break;
  58. case R2_NOTXORPEN : d_RepStr(`pCtx->SI.XX = ~(pCtx->SI.XX ^ XX); ',XX, uBB, uBG, uBR, uBA)break;
  59. case R2_NOP : d_RepStr(`pCtx->SI.XX = XX; ', XX, uBB, uBG, uBR, uBA)break;
  60. case R2_MERGENOTPEN: d_RepStr(`pCtx->SI.XX = ~pCtx->SI.XX | XX; ', XX, uBB, uBG, uBR, uBA)break;
  61. case R2_COPYPEN : d_RepStr(`pCtx->SI.XX = pCtx->SI.XX; ', XX, uBB, uBG, uBR, uBA)break;
  62. case R2_MERGEPENNOT: d_RepStr(`pCtx->SI.XX = pCtx->SI.XX | ~XX; ', XX, uBB, uBG, uBR, uBA)break;
  63. case R2_MERGEPEN : d_RepStr(`pCtx->SI.XX = pCtx->SI.XX | XX; ', XX, uBB, uBG, uBR, uBA)break;
  64. case R2_WHITE : d_RepStr(`pCtx->SI.XX = 0xffff; ', XX, uBB, uBG, uBR, uBA)break;
  65. }
  66. }')
  67. dnl
  68. pCtx->pfnColorBlendEnd(pCtx, pP, pS);
  69. }')
  70. dnl
  71. d_RepStr(`d_RepStr(`d_ColorBlend(AA, BB)',
  72. `AA', `SrcOne_DestZero', `AllBlend')',
  73. `BB', `SrcCopy', `AllROP')