Merge with MPC-HC 6d1472b2f18266d92e5bc068667de348c0cd3b3b.
[xy_vsfilter.git] / src / subtitles / libssf / Rasterizer.h
blob25a929aac5bef465c7b4ec5302aa0d77c17565a2
1 /*
2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #pragma once
24 #include <atlcoll.h>
25 #include "SubtitleFile.h"
26 #include "Array.h"
27 #include "GlyphPath.h"
28 #include "..\..\SubPic\ISubPic.h"
30 namespace ssf
32 class Rasterizer
34 bool fFirstSet;
35 CPoint firstp, lastp;
37 private:
38 int mWidth, mHeight;
40 union Span
42 struct {int x1, y1, x2, y2;};
43 struct {unsigned __int64 first, second;};
44 union Span() {}
45 union Span(int _x1, int _y1, int _x2, int _y2) {x1 = _x1; y1 = _y1; x2 = _x2; y2 = _y2;}
46 union Span(unsigned __int64 _first, unsigned __int64 _second) {first = _first; second = _second;}
49 Array<Span> mOutline, mWideOutline, mWideOutlineTmp;
50 int mWideBorder;
52 struct Edge {int next, posandflag;}* mpEdgeBuffer;
53 unsigned int mEdgeHeapSize;
54 unsigned int mEdgeNext;
55 unsigned int* mpScanBuffer;
57 protected:
58 BYTE* mpOverlayBuffer;
59 int mOverlayWidth, mOverlayHeight;
60 int mPathOffsetX, mPathOffsetY;
61 int mOffsetX, mOffsetY;
63 private:
64 void _TrashOverlay();
65 void _ReallocEdgeBuffer(int edges);
66 void _EvaluateBezier(const CPoint& p0, const CPoint& p1, const CPoint& p2, const CPoint& p3);
67 void _EvaluateLine(CPoint p0, CPoint p1);
68 void _OverlapRegion(Array<Span>& dst, Array<Span>& src, int dx, int dy);
70 public:
71 Rasterizer();
72 virtual ~Rasterizer();
74 bool ScanConvert(GlyphPath& path, const CRect& bbox);
75 bool CreateWidenedRegion(int r);
76 bool Rasterize(int xsub, int ysub);
77 void Reuse(Rasterizer& r);
79 void Blur(float n, int plane);
80 CRect Draw(const SubPicDesc& spd, const CRect& clip, int xsub, int ysub, const DWORD* switchpts, int plane);