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.

130 lines
4.7 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: pattern.c
  3. *
  4. * Used for creating and destroying the default patterns to be used on this
  5. * device.
  6. *
  7. * Copyright (c) 1992 Microsoft Corporation
  8. \**************************************************************************/
  9. #include "precomp.h"
  10. /******************************Public*Data*Struct*************************\
  11. * gaajPat
  12. *
  13. * These are the standard patterns defined Windows, they are used to produce
  14. * hatch brushes, grey brushes etc.
  15. *
  16. \**************************************************************************/
  17. const BYTE gaajPat[HS_DDI_MAX][32] = {
  18. { 0x00,0x00,0x00,0x00, // ........ HS_HORIZONTAL 0
  19. 0x00,0x00,0x00,0x00, // ........
  20. 0x00,0x00,0x00,0x00, // ........
  21. 0xff,0x00,0x00,0x00, // ********
  22. 0x00,0x00,0x00,0x00, // ........
  23. 0x00,0x00,0x00,0x00, // ........
  24. 0x00,0x00,0x00,0x00, // ........
  25. 0x00,0x00,0x00,0x00 }, // ........
  26. { 0x08,0x00,0x00,0x00, // ....*... HS_VERTICAL 1
  27. 0x08,0x00,0x00,0x00, // ....*...
  28. 0x08,0x00,0x00,0x00, // ....*...
  29. 0x08,0x00,0x00,0x00, // ....*...
  30. 0x08,0x00,0x00,0x00, // ....*...
  31. 0x08,0x00,0x00,0x00, // ....*...
  32. 0x08,0x00,0x00,0x00, // ....*...
  33. 0x08,0x00,0x00,0x00 }, // ....*...
  34. { 0x80,0x00,0x00,0x00, // *....... HS_FDIAGONAL 2
  35. 0x40,0x00,0x00,0x00, // .*......
  36. 0x20,0x00,0x00,0x00, // ..*.....
  37. 0x10,0x00,0x00,0x00, // ...*....
  38. 0x08,0x00,0x00,0x00, // ....*...
  39. 0x04,0x00,0x00,0x00, // .....*..
  40. 0x02,0x00,0x00,0x00, // ......*.
  41. 0x01,0x00,0x00,0x00 }, // .......*
  42. { 0x01,0x00,0x00,0x00, // .......* HS_BDIAGONAL 3
  43. 0x02,0x00,0x00,0x00, // ......*.
  44. 0x04,0x00,0x00,0x00, // .....*..
  45. 0x08,0x00,0x00,0x00, // ....*...
  46. 0x10,0x00,0x00,0x00, // ...*....
  47. 0x20,0x00,0x00,0x00, // ..*.....
  48. 0x40,0x00,0x00,0x00, // .*......
  49. 0x80,0x00,0x00,0x00 }, // *.......
  50. { 0x08,0x00,0x00,0x00, // ....*... HS_CROSS 4
  51. 0x08,0x00,0x00,0x00, // ....*...
  52. 0x08,0x00,0x00,0x00, // ....*...
  53. 0xff,0x00,0x00,0x00, // ********
  54. 0x08,0x00,0x00,0x00, // ....*...
  55. 0x08,0x00,0x00,0x00, // ....*...
  56. 0x08,0x00,0x00,0x00, // ....*...
  57. 0x08,0x00,0x00,0x00 }, // ....*...
  58. { 0x81,0x00,0x00,0x00, // *......* HS_DIAGCROSS 5
  59. 0x42,0x00,0x00,0x00, // .*....*.
  60. 0x24,0x00,0x00,0x00, // ..*..*..
  61. 0x18,0x00,0x00,0x00, // ...**...
  62. 0x18,0x00,0x00,0x00, // ...**...
  63. 0x24,0x00,0x00,0x00, // ..*..*..
  64. 0x42,0x00,0x00,0x00, // .*....*.
  65. 0x81,0x00,0x00,0x00 } // *......*
  66. };
  67. /******************************Public*Routine******************************\
  68. * bInitPatterns
  69. *
  70. * This routine initializes the default patterns.
  71. *
  72. \**************************************************************************/
  73. BOOL bInitPatterns(IN PPDEV ppdev, ULONG cPatterns)
  74. {
  75. SIZEL sizl;
  76. ULONG ulLoop;
  77. sizl.cx = 8;
  78. sizl.cy = 8;
  79. for (ulLoop = 0; ulLoop < cPatterns; ulLoop++)
  80. {
  81. ppdev->ahbmPat[ulLoop] = EngCreateBitmap(sizl, 4, BMF_1BPP,
  82. BMF_TOPDOWN, (PULONG) (&gaajPat[ulLoop][0]));
  83. if (ppdev->ahbmPat[ulLoop] == (HBITMAP) 0)
  84. {
  85. // Set the count created so vDisablePatterns will clean up.
  86. ppdev->cPatterns = ulLoop;
  87. return(FALSE);
  88. }
  89. }
  90. ppdev->cPatterns = cPatterns;
  91. return(TRUE);
  92. }
  93. /******************************Public*Routine******************************\
  94. * vDisablePatterns
  95. *
  96. * Delete the standard patterns allocated.
  97. *
  98. \**************************************************************************/
  99. VOID vDisablePatterns(IN PPDEV ppdev)
  100. {
  101. ULONG ulIndex;
  102. // Erase all patterns.
  103. for (ulIndex = 0; ulIndex < ppdev->cPatterns; ulIndex++)
  104. {
  105. if (ppdev->ahbmPat[ulIndex])
  106. {
  107. EngDeleteSurface((HSURF) ppdev->ahbmPat[ulIndex]);
  108. }
  109. }
  110. }