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.

160 lines
4.6 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: xlateddi.cxx
  3. *
  4. * This provides the interface for device drivers to call functions
  5. * for xlate objects.
  6. *
  7. * Created: 26-Nov-1990 16:40:24
  8. * Author: Patrick Haluptzok patrickh
  9. *
  10. * Copyright (c) 1990-1999 Microsoft Corporation
  11. \**************************************************************************/
  12. #include "precomp.hxx"
  13. /******************************Public*Routine******************************\
  14. * XLATEOBJ_piVector
  15. *
  16. * Returns the translation vector if one exists.
  17. *
  18. * History:
  19. * 03-May-1991 -by- Patrick Haluptzok patrickh
  20. * Wrote it.
  21. \**************************************************************************/
  22. PULONG XLATEOBJ_piVector(XLATEOBJ *pxlo)
  23. {
  24. //
  25. // This is really strange to have a call back, but the theory was that
  26. // it could be lazily computed and some drivers would choose to compute
  27. // it themselves (maybe with hardware help). Anyhow we know of no driver
  28. // or hardware that would benefit from this so we just compute it up
  29. // front every time anyhow. Drivers are written to check for NULL first
  30. // and call this routine if it's NULL.
  31. //
  32. return(pxlo->pulXlate);
  33. }
  34. /******************************Public*Routine******************************\
  35. * XLATEOBJ_cGetPalette
  36. *
  37. * Used to retrieve information about the palettes used in the blt.
  38. *
  39. * History:
  40. * 03-May-1991 -by- Patrick Haluptzok patrickh
  41. * Wrote it.
  42. \**************************************************************************/
  43. ULONG XLATEOBJ_cGetPalette(
  44. XLATEOBJ *pxlo,
  45. ULONG iPal,
  46. ULONG cPal,
  47. PULONG ppal)
  48. {
  49. ULONG ulRet = 0; // Assume failure
  50. ASSERTGDI((iPal == XO_SRCPALETTE) ||
  51. (iPal == XO_DESTPALETTE) ||
  52. (iPal == XO_SRCBITFIELDS) ||
  53. (iPal == XO_DESTBITFIELDS),
  54. "ERROR XLATEOBJ_cGetPalette passed undefined iPal");
  55. if (pxlo != NULL)
  56. {
  57. XLATE *pxl = (XLATE *) pxlo;
  58. if ((iPal == XO_SRCBITFIELDS) || (iPal == XO_DESTBITFIELDS))
  59. {
  60. XEPALOBJ pal((iPal == XO_SRCBITFIELDS) ? pxl->ppalSrc : pxl->ppalDst);
  61. if ((pal.bValid()) && // Must be valid
  62. (pal.cEntries() == 0) && // Must be RGB
  63. (cPal == 3)) // Must have room for 3 entries
  64. {
  65. ulRet = 3;
  66. *(ppal) = pal.flRed();
  67. *(ppal + 1) = pal.flGre();
  68. *(ppal + 2) = pal.flBlu();
  69. }
  70. else
  71. {
  72. WARNING("XLATEOBJ_cGetPalette failed - not bitfields, or cPal != 3");
  73. }
  74. }
  75. else
  76. {
  77. XEPALOBJ pal((iPal == XO_SRCPALETTE) ? pxl->ppalSrc : pxl->ppalDst);
  78. if (pal.bValid())
  79. {
  80. ulRet = pal.ulGetEntries(0, cPal, (LPPALETTEENTRY) ppal, TRUE);
  81. }
  82. }
  83. }
  84. else
  85. {
  86. WARNING("XLATEOBJ_cGetPalette failed - xlate invalid or identiy, no palette informinformation\n");
  87. }
  88. return(ulRet);
  89. }
  90. /******************************Public*Routine******************************\
  91. * XLATEOBJ_hGetColorTransform
  92. *
  93. * returns color transform handle.
  94. *
  95. * History:
  96. * 03-Feb-1997 -by- Hideyuki Nagase [hideyukn]
  97. * Wrote it.
  98. \**************************************************************************/
  99. HANDLE
  100. XLATEOBJ_hGetColorTransform(XLATEOBJ *pxlo)
  101. {
  102. XLATE *pxl = (XLATE *) pxlo;
  103. ICMAPI(("XLATEOBJ_hGetColorTransform()\n"));
  104. //
  105. // Since our global identity xlate is invalid we need to check for
  106. // this case since drivers can't tell.
  107. //
  108. if (pxl == NULL)
  109. {
  110. WARNING("XLATEOBJ_hGetColorTransform() XLATEOBJ is NULL\n");
  111. return(NULL);
  112. }
  113. //
  114. // if ICM is not enabled for this XLATEOBJ. Or if ICM is done by host,
  115. // Color transform handle is for host ICM it is no meanings for device
  116. // driver. then just return NULL.
  117. //
  118. if (IS_ICM_DEVICE(pxl->lIcmMode))
  119. {
  120. if (pxl->hcmXform)
  121. {
  122. COLORTRANSFORMOBJ CXFormObj(pxl->hcmXform);
  123. if (CXFormObj.bValid())
  124. {
  125. return(CXFormObj.hGetDeviceColorTransform());
  126. }
  127. ICMMSG(("XLATEOBJ_hGetColorTransform() COLORTRANSFORMREF is invalid\n"));
  128. }
  129. else
  130. {
  131. ICMMSG(("XLATEOBJ_hGetColorTransform() Ident. color transform\n"));
  132. }
  133. }
  134. else
  135. {
  136. ICMMSG(("XLATEOBJ_hGetColorTransform() ICM on device is not enabled\n"));
  137. }
  138. return(NULL);
  139. }