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.

69 lines
2.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // palette.h
  4. //
  5. // Structures and prototypes ramp palette code.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. #ifndef _RAMPPALETTE_H_
  11. #define _RAMPPALETTE_H_
  12. #include "colall.h"
  13. typedef void (*RLDDIPaletteSetColorMethod)(void*, int index,
  14. int red, int green, int blue);
  15. typedef int (*RLDDIPaletteAllocateColorMethod)(void*,
  16. int red, int green, int blue);
  17. typedef void (*RLDDIPaletteFreeColorMethod)(void*, int index);
  18. typedef struct _RLDDIPaletteEntry RLDDIPaletteEntry;
  19. typedef enum _PaletteState
  20. {
  21. PALETTE_FREE, /* not used, allocatable */
  22. PALETTE_UNUSED, /* not used, not allocatable */
  23. PALETTE_USED /* used, allocatable */
  24. } PaletteState;
  25. struct _RLDDIPaletteEntry {
  26. LIST_MEMBER(_RLDDIPaletteEntry) list;
  27. int usage; /* how many users (0 => free) */
  28. unsigned char red, green, blue, pad1; /* intensity values */
  29. PaletteState state;
  30. };
  31. #define HASH_SIZE 257
  32. #define RGB_HASH(red, green, blue) (((red) << 8) ^ ((green) << 4) ^ (blue))
  33. #define ENTRY_TO_INDEX(pal, entry) ((int)((entry) - (pal)->entries))
  34. #define INDEX_TO_ENTRY(pal, index) (&(pal)->entries[index])
  35. typedef struct _RLDDIPalette {
  36. RLDDIPaletteEntry* entries; /* palette entries */
  37. size_t size; /* number of entries in palette */
  38. LIST_ROOT(name3, _RLDDIPaletteEntry) free; /* free list */
  39. LIST_ROOT(name4, _RLDDIPaletteEntry) unused; /* colors not to use */
  40. LIST_ROOT(name5, _RLDDIPaletteEntry) hash[HASH_SIZE];
  41. void* priv;
  42. RLDDIPaletteAllocateColorMethod allocate_color;
  43. RLDDIPaletteFreeColorMethod free_color;
  44. RLDDIPaletteSetColorMethod set_color;
  45. /*
  46. * A color allocator for use with RLDDIColormap.
  47. */
  48. RLDDIColorAllocator alloc;
  49. } RLDDIPalette;
  50. RLDDIPalette* RLDDICreatePalette(PD3DI_RASTCTX pCtx, size_t size);
  51. void RLDDIPaletteSetColor(RLDDIPalette* pal,
  52. int index, int red, int green, int blue);
  53. int RLDDIPaletteAllocateColor(RLDDIPalette* pal,
  54. int red, int green, int blue);
  55. void RLDDIPaletteFreeColor(RLDDIPalette* pal, int index);
  56. void RLDDIDestroyPalette(RLDDIPalette* pal);
  57. #endif // _RAMPPALETTE_H_