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.8 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: brush.h
  8. *
  9. * Contains all the brush related stuff
  10. *
  11. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  13. \**************************************************************************/
  14. #ifndef __BRUSH__H__
  15. #define __BRUSH__H__
  16. //
  17. // Brush stuff
  18. //
  19. // 'Slow' brushes are used when we don't have hardware pattern capability,
  20. // and we have to handle patterns using screen-to-screen blts:
  21. //
  22. #define SLOW_BRUSH_CACHE_DIM_X 8
  23. #define SLOW_BRUSH_CACHE_DIM_Y 1 // Controls the number of brushes cached
  24. // in off-screen memory, when we don't have
  25. // the hardware pattern support. We
  26. // allocate 3 x 3 brushes, so we can cache
  27. // a total of 9 brushes:
  28. #define SLOW_BRUSH_COUNT (SLOW_BRUSH_CACHE_DIM_X * SLOW_BRUSH_CACHE_DIM_Y)
  29. #define SLOW_BRUSH_DIMENSION 40 // After alignment is taken care of, every
  30. // off-screen brush cache entry will be 48
  31. // pels in both dimensions
  32. #define SLOW_BRUSH_ALLOCATION (SLOW_BRUSH_DIMENSION + 8)
  33. // Actually allocate 72x72 pels for each
  34. // pattern, using the 8 extra for brush
  35. // alignment
  36. //
  37. // 'Fast' brushes are used when we have hardware pattern capability:
  38. //
  39. #define FAST_BRUSH_COUNT 16 // Total number of non-hardware brushes
  40. // cached off-screen
  41. #define FAST_BRUSH_DIMENSION 8 // Every off-screen brush cache entry is
  42. // 8 pels in both dimensions
  43. #define FAST_BRUSH_ALLOCATION 8 // We have to align ourselves, so this is
  44. // the dimension of each brush allocation
  45. //
  46. // Common to both implementations:
  47. //
  48. #define RBRUSH_2COLOR 1 // For RBRUSH flags
  49. #define TOTAL_BRUSH_COUNT max(FAST_BRUSH_COUNT, SLOW_BRUSH_COUNT)
  50. // This is the maximum number of brushes
  51. // we can possibly have cached off-screen
  52. #define TOTAL_BRUSH_SIZE 64 // We'll only ever handle 8x8 patterns,
  53. // and this is the number of pels
  54. //
  55. // New brush support
  56. //
  57. #define NUM_CACHED_BRUSHES 16
  58. #define CACHED_BRUSH_WIDTH_LOG2 6
  59. #define CACHED_BRUSH_WIDTH (1 << CACHED_BRUSH_WIDTH_LOG2)
  60. #define CACHED_BRUSH_HEIGHT_LOG2 6
  61. #define CACHED_BRUSH_HEIGHT (1 << CACHED_BRUSH_HEIGHT_LOG2)
  62. #define CACHED_BRUSH_SIZE (CACHED_BRUSH_WIDTH * CACHED_BRUSH_HEIGHT)
  63. typedef struct _BrushEntry BrushEntry;
  64. //
  65. // NOTE: Changes to the RBRUSH or BRUSHENTRY structures must be reflected
  66. // in i386/strucs.inc!
  67. //
  68. typedef struct _RBrush
  69. {
  70. FLONG fl; // Type flags
  71. DWORD areaStippleMode; // area stipple mode if 1bpp.
  72. //
  73. //??? get rid of bTransparent later. We need it now so everything
  74. // compiles OK
  75. //
  76. BOOL bTransparent; // TRUE if brush was realized for a
  77. // transparent blt (meaning colours are
  78. // white and black).
  79. // FALSE if not (meaning it's already been
  80. // colour-expanded to the correct colours).
  81. // Value is undefined if the brush isn't
  82. // 2 colour.
  83. ULONG ulForeColor; // Foreground colour if 1bpp
  84. ULONG ulBackColor; // Background colour if 1bpp
  85. POINTL ptlBrushOrg; // Brush origin of cached pattern. Initial
  86. // value should be -1
  87. BrushEntry* pbe; // Points to brush-entry that keeps track
  88. // of the cached off-screen brush bits
  89. ULONG aulPattern[1]; // Open-ended array for keeping copy of the
  90. // actual pattern bits in case the brush
  91. // origin changes, or someone else steals
  92. // our brush entry (declared as a ULONG
  93. // for proper dword alignment)
  94. //
  95. // Don't put anything after here
  96. //
  97. } RBrush; /* rb, prb */
  98. typedef struct _BrushEntry
  99. {
  100. RBrush* prbVerify; // We never dereference this pointer to
  101. // find a brush realization; it is only
  102. // ever used in a compare to verify that
  103. // for a given realized brush, our
  104. // off-screen brush entry is still valid.
  105. ULONG ulPixelOffset; // pixel offset in video memory to brush
  106. // partial product for this stride is
  107. // ppdev->ulBrushPackedPP
  108. } BrushEntry; /* be, pbe */
  109. typedef union _RBrushColor
  110. {
  111. RBrush* prb;
  112. ULONG iSolidColor;
  113. } RBrushColor; /* rbc, prbc */
  114. BOOL bEnableBrushCache(PDev* ppdev);
  115. VOID vAssertModeBrushCache(PDev* ppdev, BOOL bEnable);
  116. VOID vDisableBrushCache(PDev* ppdev);
  117. VOID vRealizeDitherPattern(HDEV hdev, RBrush* prb, ULONG ulRGBToDither);
  118. #endif