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.

195 lines
5.7 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1999-2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * Alpha-blender
  8. *
  9. * Abstract:
  10. *
  11. * A class which alpha-blends a source scanline in either sRGB or
  12. * sRGB64 format, to a destination of arbitrary format.
  13. *
  14. * The operation can be either a SrcOver or a SrcCopy.
  15. * A quality hint can be used to make the "SrcOver using sRGB source" case
  16. * do a higher-quality blend in the sRGB64 color space.
  17. *
  18. * Created:
  19. *
  20. * 01/03/2000 agodfrey
  21. * Created it.
  22. * 02/22/2001 agodfrey
  23. * Expanded it for different scan types (needed for ClearType).
  24. * Simplified the Initialize() parameters by adding a
  25. * DpContext parameter.
  26. *
  27. \**************************************************************************/
  28. #ifndef _ALPHABLENDER_HPP
  29. #define _ALPHABLENDER_HPP
  30. //--------------------------------------------------------------------------
  31. // The different Scan types:
  32. //
  33. // Blend: The typical alpha-blending operation.
  34. // Context->CompositingMode specifies the blend mode.
  35. //
  36. // Opaque: Opaque can be used in place of Blend, when all the input pixels
  37. // are opaque. This applies to both SrcCopy and SrcOver blends.
  38. // (But right now, EpAlphaBlender doesn't distinguish properly
  39. // between Opaque and SrcCopy. See bug #127412.)
  40. //
  41. // OpaqueSolidFill is a further specialized version of Opaque, in which all
  42. // the input pixels are the same color. Disabled until the back-end supports
  43. // these kinds of scan.
  44. //
  45. // CT and CTSolidFill are the ClearType blends - with an arbitrary brush,
  46. // or a solid (single-color) one, respectively.
  47. //
  48. // Note: We depend on these values starting at 0 and being consecutive -
  49. // we use them as array indices.
  50. //
  51. // Max: Counts the number of "real" scan types.
  52. // Unknown: Used where we don't know the type. This allows us to specify
  53. // the scan type either in Start(), or in NextBuffer(), depending on
  54. // the situation.
  55. //
  56. //--------------------------------------------------------------------------
  57. enum EpScanType
  58. {
  59. EpScanTypeBlend,
  60. EpScanTypeOpaque,
  61. // EpScanTypeOpaqueSolidFill,
  62. EpScanTypeCT,
  63. EpScanTypeCTSolidFill,
  64. // End of "real" scan types.
  65. EpScanTypeMax,
  66. EpScanTypeUnknown = EpScanTypeMax
  67. };
  68. #include "ScanOperation.hpp"
  69. // !!! [asecchia] This include needs to be cleaned up when we fix
  70. // the imaging.h mess.
  71. #include "..\..\privinc\pixelformats.h"
  72. class EpAlphaBlender
  73. {
  74. public:
  75. EpAlphaBlender()
  76. {
  77. Initialized = FALSE;
  78. ConvertBlendingScan = FALSE;
  79. }
  80. ~EpAlphaBlender() {}
  81. // Right now, everyone sets "dither16bpp" to TRUE.
  82. // I can see it being useful, perhaps renamed to "shouldDither",
  83. // to support an API to make us quantize & dither the way GDI does.
  84. VOID
  85. Initialize(
  86. EpScanType scanType,
  87. PixelFormatID dstFormat,
  88. PixelFormatID srcFormat,
  89. const DpContext *context,
  90. const ColorPalette *dstpal,
  91. VOID **tempBuffers,
  92. BOOL dither16bpp,
  93. BOOL useRMW,
  94. ARGB solidColor
  95. );
  96. VOID Blend(
  97. VOID *dst,
  98. VOID *src,
  99. UINT width,
  100. INT dither_x,
  101. INT dither_y,
  102. BYTE *ctBuffer
  103. );
  104. VOID UpdatePalette(const ColorPalette *dstpal, const EpPaletteMap *paletteMap);
  105. // Returns true if EpAlphaBlender knows how to convert
  106. // the specified pixelFormat.
  107. static BOOL IsSupportedPixelFormat(PixelFormatID pixelFormat)
  108. {
  109. return (
  110. pixelFormat != PixelFormatUndefined &&
  111. pixelFormat != PixelFormatMulti &&
  112. pixelFormat != PixelFormat1bppIndexed &&
  113. pixelFormat != PixelFormat4bppIndexed &&
  114. pixelFormat != PixelFormat16bppGrayScale &&
  115. pixelFormat != PixelFormat16bppARGB1555
  116. );
  117. }
  118. private:
  119. // Records whether Initialize() has been called yet
  120. BOOL Initialized;
  121. ScanOperation::OtherParams OperationParameters;
  122. // An internal helper class, used only by Initialize().
  123. class Builder;
  124. // The IA64 compiler seems to need some convincing:
  125. friend class Builder;
  126. // ConvertBlendingScan:
  127. // TRUE: The pipeline will convert the blending scan to another
  128. // format before using it
  129. // FALSE: The pipeline will use the original passed-in blending scan
  130. // (this is the common case).
  131. BOOL ConvertBlendingScan;
  132. // We represent the pipeline with an array of PipelineItem structures.
  133. // Src - the source buffer for the operation. Can also be
  134. // BLENDER_USE_SOURCE or BLENDER_USE_DESTINATION. (q.v.)
  135. // Dst - the destination buffer for the operation. For the final
  136. // operation of the pipeline, and only then,
  137. // Dst == BLENDER_USE_DESTINATION.
  138. struct PipelineItem
  139. {
  140. ScanOperation::ScanOpFunc Op;
  141. VOID *Src;
  142. VOID *Dst;
  143. PipelineItem() {}
  144. PipelineItem(
  145. ScanOperation::ScanOpFunc op,
  146. VOID *src,
  147. VOID *dst
  148. )
  149. {
  150. Op = op;
  151. Src = src;
  152. Dst = dst;
  153. }
  154. };
  155. enum
  156. {
  157. MAX_ITEMS = 20
  158. };
  159. // !!! [agodfrey]: MAX_ITEMS was 8. I'm boosting it until we know what the
  160. // maximum really should be, so that I can hack in the meantime.
  161. PipelineItem Pipeline[MAX_ITEMS]; // the scan operation pipeline
  162. };
  163. #endif