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.

104 lines
2.9 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: rops.c
  3. *
  4. *
  5. * Utility routines to manilpulate rop codes.
  6. *
  7. * Copyright (c) 1998 Microsoft Corporation
  8. *
  9. \**************************************************************************/
  10. #include "precomp.h"
  11. //
  12. // The gaMix table converts a mix code (1-16) and converts it to a rop3
  13. // Note that we also define mix code 0 == code 16 to allow for the masking
  14. // of the mix code by 0xff to produce the correct result.
  15. //
  16. ULONG gaMix[] =
  17. {
  18. ROP3_WHITENESS, // (R2_WHITE & 0xff)
  19. ROP3_BLACKNESS, // R2_BLACK
  20. 0x05, // R2_NOTMERGEPEN
  21. 0x0A, // R2_MASKNOTPEN
  22. 0x0F, // R2_NOTCOPYPEN
  23. 0x50, // R2_MASKPENNOT
  24. ROP3_DSTINVERT, // R2_NOT
  25. ROP3_PATINVERT, // R2_XORPEN
  26. 0x5F, // R2_NOTMASKPEN
  27. 0xA0, // R2_MASKPEN
  28. 0xA5, // R2_NOTXORPEN
  29. 0xAA, // R2_NOP
  30. 0xAF, // R2_MERGENOTPEN
  31. ROP3_PATCOPY, // R2_COPYPEN
  32. 0xF5, // R2_MERGEPENNOT
  33. 0xFA, // R2_MERGEPEN
  34. ROP3_WHITENESS // R2_WHITE
  35. };
  36. //
  37. // Convert a rop2 code to a hardware specific logical operation code
  38. //
  39. ULONG gRop2ToLogicop[] =
  40. {
  41. K_LOGICOP_CLEAR, // 0
  42. K_LOGICOP_NOR, // DSon
  43. K_LOGICOP_AND_INVERTED, // DSna
  44. K_LOGICOP_COPY_INVERT, // Sn
  45. K_LOGICOP_AND_REVERSE, // SDna
  46. K_LOGICOP_INVERT, // Dn
  47. K_LOGICOP_XOR, // DSx
  48. K_LOGICOP_NAND, // DSan
  49. K_LOGICOP_AND, // DSa
  50. K_LOGICOP_EQUIV, // DSxn
  51. K_LOGICOP_NOOP, // D
  52. K_LOGICOP_OR_INVERT, // DSno
  53. K_LOGICOP_COPY, // S
  54. K_LOGICOP_OR_REVERSE, // SDno
  55. K_LOGICOP_OR, // DSo
  56. K_LOGICOP_SET
  57. };
  58. //------------------------------------------------------------------------------
  59. //
  60. // ULONG ulRop3ToLogicop
  61. //
  62. //
  63. // Convert a source invariant rop3 code into a hardware specific logical
  64. // operation.
  65. // Note we could instead define this routine as a macro.
  66. //
  67. //------------------------------------------------------------------------------
  68. ULONG
  69. ulRop3ToLogicop(ULONG ulRop3)
  70. {
  71. ASSERTDD(ulRop3 <= 0xFF, "ulRop3ToLogicop: unexpected rop3 code");
  72. ULONG ulRop2;
  73. ulRop2 = ((ulRop3 & 0x3) | ((ulRop3 & 0xC0) >> 4));
  74. return gRop2ToLogicop[ulRop2];
  75. }
  76. //------------------------------------------------------------------------------
  77. //
  78. // ULONG ulRop2ToLogicop
  79. //
  80. // Convert a rop2 code into a hardware dependent logical operation.
  81. // Note we could instead define this routine as a macro.
  82. //
  83. //------------------------------------------------------------------------------
  84. ULONG
  85. ulRop2ToLogicop(ULONG ulRop2)
  86. {
  87. ASSERTDD(ulRop2 <= 0xF, "ulRop2ToLogicop: unexpected rop2 code");
  88. return (ULONG)(gRop2ToLogicop[ulRop2]);
  89. }