Rasterizer.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 #include <vector>
00025 #include "..\SubPic\ISubPic.h"
00026 
00027 #define PT_MOVETONC 0xfe
00028 #define PT_BSPLINETO 0xfc
00029 #define PT_BSPLINEPATCHTO 0xfa 
00030 
00031 class Rasterizer
00032 {
00033         bool fFirstSet;
00034         CPoint firstp, lastp;
00035 
00036 protected:
00037         BYTE* mpPathTypes;
00038         POINT* mpPathPoints;
00039         int mPathPoints;
00040 
00041 private:
00042         int mWidth, mHeight;
00043 
00044         typedef std::pair<unsigned __int64, unsigned __int64> tSpan;
00045         typedef std::vector<tSpan> tSpanBuffer;
00046 
00047         tSpanBuffer mOutline;
00048         tSpanBuffer mWideOutline;
00049         int mWideBorder;
00050 
00051         struct Edge {
00052                 int next;
00053                 int posandflag;
00054         } *mpEdgeBuffer;
00055         unsigned mEdgeHeapSize;
00056         unsigned mEdgeNext;
00057 
00058         unsigned int* mpScanBuffer;
00059 
00060         typedef unsigned char byte;
00061 
00062 protected:
00063         byte *mpOverlayBuffer;
00064         int mOverlayWidth, mOverlayHeight;
00065         int mPathOffsetX, mPathOffsetY;
00066         int mOffsetX, mOffsetY;
00067 
00068 private:
00069         void _TrashPath();
00070         void _TrashOverlay();
00071         void _ReallocEdgeBuffer(int edges);
00072         void _EvaluateBezier(int ptbase, bool fBSpline);
00073         void _EvaluateLine(int pt1idx, int pt2idx);
00074         void _EvaluateLine(int x0, int y0, int x1, int y1);
00075         static void _OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int dy);
00076 
00077 public:
00078         Rasterizer();
00079         virtual ~Rasterizer();
00080 
00081         bool BeginPath(HDC hdc);
00082         bool EndPath(HDC hdc);
00083         bool PartialBeginPath(HDC hdc, bool bClearPath);
00084         bool PartialEndPath(HDC hdc, long dx, long dy);
00085         bool ScanConvert();
00086         bool CreateWidenedRegion(int border);
00087         void DeleteOutlines();
00088         bool Rasterize(int xsub, int ysub, bool fBlur);
00089         CRect Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const long* switchpts, bool fBody, bool fBorder);
00090 };
00091 

Generated on Tue Dec 13 14:47:54 2005 for guliverkli by  doxygen 1.4.5