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 / uberblit_base.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  3.0 KB  |  130 lines

  1. #ifndef f_VD2_KASUMI_UBERBLIT_BASE_H
  2. #define f_VD2_KASUMI_UBERBLIT_BASE_H
  3.  
  4. #include <vd2/system/vdstl.h>
  5. #include "uberblit.h"
  6.  
  7. class VDPixmapGenWindowBased : public IVDPixmapGen {
  8. public:
  9.     VDPixmapGenWindowBased()
  10.         : mWindowMinDY(0xffff)
  11.         , mWindowMaxDY(-0xffff) {}
  12.  
  13.     void SetOutputSize(sint32 w, sint32 h) {
  14.         mWidth = w;
  15.         mHeight = h;
  16.     }
  17.  
  18.     void AddWindowRequest(int minDY, int maxDY) {
  19.         if (mWindowMinDY > minDY)
  20.             mWindowMinDY = minDY;
  21.         if (mWindowMaxDY < maxDY)
  22.             mWindowMaxDY = maxDY;
  23.     }
  24.  
  25.     void StartWindow(uint32 rowbytes, int outputCount = 1) {
  26.         VDASSERT(mWindowMaxDY >= mWindowMinDY);
  27.         mWindowSize = mWindowMaxDY + 1 - mWindowMinDY;
  28.  
  29.         mWindowPitch = (rowbytes + 15) & ~15;
  30.         mWindowBuffer.resize(mWindowPitch * mWindowSize * outputCount);
  31.         mWindow.resize(mWindowSize * 2);
  32.  
  33.         for(sint32 i=0; i<mWindowSize; ++i)
  34.             mWindow[i] = mWindow[i + mWindowSize] = &mWindowBuffer[mWindowPitch * outputCount * i];
  35.  
  36.         mWindowIndex = 0;
  37.         mWindowLastY = -0x3FFFFFFF;
  38.     }
  39.  
  40.     sint32 GetWidth(int) const { return mWidth; }
  41.     sint32 GetHeight(int) const { return mHeight; }
  42.  
  43.     bool IsStateful() const {
  44.         return true;
  45.     }
  46.  
  47.     const void *GetRow(sint32 y, uint32 index) {
  48.         sint32 tostep = y - mWindowLastY;
  49.         VDASSERT(y >= mWindowLastY - (sint32)mWindowSize + 1);
  50.  
  51.         if (tostep >= mWindowSize) {
  52.             mWindowLastY = y - 1;
  53.             tostep = 1;
  54.         }
  55.  
  56.         while(tostep-- > 0) {
  57.             ++mWindowLastY;
  58.             Compute(mWindow[mWindowIndex], mWindowLastY);
  59.             if (++mWindowIndex >= mWindowSize)
  60.                 mWindowIndex = 0;
  61.         }
  62.  
  63.         return mWindow[y + mWindowSize - 1 - mWindowLastY + mWindowIndex];
  64.     }
  65.  
  66.     void ProcessRow(void *dst, sint32 y) {
  67.         Compute(dst, y);
  68.     }
  69.  
  70. protected:
  71.     virtual void Compute(void *dst0, sint32 y) = 0;
  72.  
  73.     vdfastvector<uint8> mWindowBuffer;
  74.     vdfastvector<uint8 *> mWindow;
  75.     sint32 mWindowPitch;
  76.     sint32 mWindowIndex;
  77.     sint32 mWindowMinDY;
  78.     sint32 mWindowMaxDY;
  79.     sint32 mWindowSize;
  80.     sint32 mWindowLastY;
  81.     sint32 mWidth;
  82.     sint32 mHeight;
  83. };
  84.  
  85. class VDPixmapGenWindowBasedOneSource : public VDPixmapGenWindowBased {
  86. public:
  87.     void InitSource(IVDPixmapGen *src, uint32 srcindex) {
  88.         mpSrc = src;
  89.         mSrcIndex = srcindex;
  90.         mSrcWidth = src->GetWidth(srcindex);
  91.         mSrcHeight = src->GetHeight(srcindex);
  92.         mWidth = mSrcWidth;
  93.         mHeight = mSrcHeight;
  94.     }
  95.  
  96.     void AddWindowRequest(int minDY, int maxDY) {
  97.         VDPixmapGenWindowBased::AddWindowRequest(minDY, maxDY);
  98.         mpSrc->AddWindowRequest(minDY, maxDY);
  99.     }
  100.  
  101.     void StartWindow(uint32 rowbytes, int outputCount = 1) {
  102.         mpSrc->Start();
  103.  
  104.         VDPixmapGenWindowBased::StartWindow(rowbytes, outputCount);
  105.     }
  106.  
  107.     uint32 GetType(uint32 output) const {
  108.         return mpSrc->GetType(mSrcIndex);
  109.     }
  110.  
  111. protected:
  112.     virtual void Compute(void *dst0, sint32 y) = 0;
  113.  
  114.     IVDPixmapGen *mpSrc;
  115.     uint32 mSrcIndex;
  116.     sint32 mSrcWidth;
  117.     sint32 mSrcHeight;
  118. };
  119.  
  120. class VDPixmapGenWindowBasedOneSourceSimple : public VDPixmapGenWindowBasedOneSource {
  121. public:
  122.     void Init(IVDPixmapGen *src, uint32 srcindex) {
  123.         InitSource(src, srcindex);
  124.  
  125.         src->AddWindowRequest(0, 0);
  126.     }
  127. };
  128.  
  129. #endif
  130.