home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / Kasumi / h / blt_setup.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  2.1 KB  |  63 lines

  1. #ifndef f_VD2_KASUMI_BLT_SETUP_H
  2. #define f_VD2_KASUMI_BLT_SETUP_H
  3.  
  4. #include <vd2/Kasumi/pixmap.h>
  5. #include <vd2/Kasumi/pixmaputils.h>
  6.  
  7. typedef void (*VDPixmapPalettedBlitterFn)(void *dst, ptrdiff_t dstpitch, const void *src, ptrdiff_t srcpitch, vdpixsize w, vdpixsize h, const void *pal);
  8. typedef void (*VDPixmapChunkyBlitterFn)(void *dst, ptrdiff_t dstpitch, const void *src, ptrdiff_t srcpitch, vdpixsize w, vdpixsize h);
  9.  
  10. void VDPixmapBltDirectPalettedConversion(const VDPixmap& dst, const VDPixmap& src, vdpixsize w, vdpixsize h, VDPixmapPalettedBlitterFn pBlitter);
  11.  
  12. template<VDPixmapPalettedBlitterFn palettedBlitter>
  13. void VDPixmapBlitterPalettedAdapter(const VDPixmap& dst, const VDPixmap& src, vdpixsize w, vdpixsize h)
  14. {
  15.     if (dst.format == nsVDPixmap::kPixFormat_XRGB8888)
  16.         palettedBlitter(dst.data, dst.pitch, src.data, src.pitch, w, h, src.palette);
  17.     else
  18.         VDPixmapBltDirectPalettedConversion(dst, src, w, h, palettedBlitter);
  19. }
  20.  
  21. template<VDPixmapChunkyBlitterFn chunkyBlitter>
  22. void VDPixmapBlitterChunkyAdapter(const VDPixmap& dst, const VDPixmap& src, vdpixsize w, vdpixsize h)
  23. {
  24.     chunkyBlitter(dst.data, dst.pitch, src.data, src.pitch, w, h);
  25. }
  26.  
  27. struct VDPixmapFormatSubset {
  28. public:
  29.     VDPixmapFormatSubset() : mFormatCount(0) {}
  30.  
  31.     VDPixmapFormatSubset& operator=(int format) {
  32.         mFormatCount = 0;
  33.         mFormats[mFormatCount++] = format;
  34.         return *this;
  35.     }
  36.  
  37.     VDPixmapFormatSubset& operator,(int format) {
  38.         VDASSERT(mFormatCount < nsVDPixmap::kPixFormat_Max_Standard);
  39.         mFormats[mFormatCount++] = format;
  40.         return *this;
  41.     }
  42.  
  43.     int mFormatCount;
  44.     int mFormats[nsVDPixmap::kPixFormat_Max_Standard];
  45. };
  46.  
  47. class VDPixmapBlitterTable {
  48. public:
  49.     void Clear();
  50.     void AddBlitter(int srcFormat, int dstFormat, VDPixmapBlitterFn blitter);
  51.     void AddBlitter(const VDPixmapFormatSubset& srcFormats, VDPixmapFormatSubset& dstFormats, VDPixmapBlitterFn blitter);
  52.  
  53.     VDPixmapBlitterFn mTable[nsVDPixmap::kPixFormat_Max_Standard][nsVDPixmap::kPixFormat_Max_Standard];
  54. };
  55.  
  56. inline void VDPixmapBlitterTable::AddBlitter(int srcFormat, int dstFormat, VDPixmapBlitterFn blitter) {
  57.     mTable[srcFormat][dstFormat] = blitter;
  58. }
  59.  
  60.  
  61.  
  62. #endif
  63.