Merge MPC-HC code(01b8dbf34d6a486fa1cd02d7a123249fec1e4160) [PART 2] (HdmvSub)
[xy_vsfilter.git] / src / subpic / SubPicImpl.h
blobdd93518f0ec36cfa9e31b1b4e546bcc89484aadb
1 /*
2 * $Id: SubPicImpl.h 2786 2010-12-17 16:42:55Z XhmikosR $
4 * (C) 2003-2006 Gabest
5 * (C) 2006-2010 see AUTHORS
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 * http://www.gnu.org/copyleft/gpl.html
24 #pragma once
26 #include "ISubPic.h"
28 class CSubPicImplHelper
30 protected:
31 REFERENCE_TIME m_rtStart, m_rtStop;
32 REFERENCE_TIME m_rtSegmentStart, m_rtSegmentStop;
34 CRect m_rcDirty;
36 CSize m_maxsize, m_size;
37 CRect m_vidrect;
38 CSize m_VirtualTextureSize;
39 CPoint m_VirtualTextureTopLeft;
43 Texture
44 +-------+---------------------------------+
45 | . | .
46 | . m_maxsize | .
47 TextureTopLeft .<=============================== |======> . Video
48 | . . . +-------------------------------- | -----+ +-----------------------------------+
49 | | . | | | m_vidrect |
50 | | . | | | |
51 | | . | | | |
52 | | +-----------+ . | | | |
53 | | | m_rcDirty | . | | | |
54 | | | | . | | | |
55 | | +-----------+ . | | | |
56 | +-------------------------------- | -----+ | |
57 | m_size | | |
58 | <=========================> | | |
59 | | | |
60 | | +-----------------------------------+
61 | | .
62 | | .
63 | | .
64 +-----------------------------------------+
65 m_VirtualTextureSize
66 <=========================================>
70 CSubPicImplHelper();
72 // ISubPic
74 STDMETHODIMP_(REFERENCE_TIME) GetStart() const;
75 STDMETHODIMP_(REFERENCE_TIME) GetStop() const;
76 STDMETHODIMP_(void) SetStart(REFERENCE_TIME rtStart);
77 STDMETHODIMP_(void) SetStop(REFERENCE_TIME rtStop);
79 //STDMETHODIMP GetDesc(SubPicDesc& spd) const = 0;
80 STDMETHODIMP CopyTo(ISubPic* pSubPic);
82 //STDMETHODIMP ClearDirtyRect(DWORD color) = 0;
83 STDMETHODIMP GetDirtyRect(RECT* pDirtyRect) const;
84 STDMETHODIMP SetDirtyRect(RECT* pDirtyRect /*[in]*/);
86 STDMETHODIMP GetMaxSize(SIZE* pMaxSize) const;
87 STDMETHODIMP SetSize(SIZE size, RECT vidrect);
89 //STDMETHODIMP Lock(SubPicDesc& spd) = 0;
90 //STDMETHODIMP Unlock(RECT* pDirtyRect /*[in]*/) = 0;
92 //STDMETHODIMP AlphaBlt(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget) = 0;
94 STDMETHODIMP SetVirtualTextureSize (const SIZE pSize, const POINT pTopLeft);
95 STDMETHODIMP GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* pRcDest);
97 STDMETHODIMP_(REFERENCE_TIME) GetSegmentStart();
98 STDMETHODIMP_(REFERENCE_TIME) GetSegmentStop();
99 STDMETHODIMP_(void) SetSegmentStart(REFERENCE_TIME rtStart);
100 STDMETHODIMP_(void) SetSegmentStop(REFERENCE_TIME rtStop);
103 class CSubPicImpl : public CUnknown, public CSubPicImplHelper, public ISubPic
105 public:
106 CSubPicImpl();
108 DECLARE_IUNKNOWN;
109 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
111 // ISubPic
113 STDMETHODIMP_(REFERENCE_TIME) GetStart() const
115 return CSubPicImplHelper::GetStart();
117 STDMETHODIMP_(REFERENCE_TIME) GetStop() const
119 return CSubPicImplHelper::GetStop();
121 STDMETHODIMP_(void) SetStart(REFERENCE_TIME rtStart)
123 return CSubPicImplHelper::SetStart(rtStart);
125 STDMETHODIMP_(void) SetStop(REFERENCE_TIME rtStop)
127 return CSubPicImplHelper::SetStop(rtStop);
130 STDMETHODIMP GetDesc(SubPicDesc& spd) const = 0;
131 STDMETHODIMP CopyTo(ISubPic* pSubPic)
133 return CSubPicImplHelper::CopyTo(pSubPic);
136 STDMETHODIMP ClearDirtyRect(DWORD color) = 0;
137 STDMETHODIMP GetDirtyRect(RECT* pDirtyRect) const
139 return CSubPicImplHelper::GetDirtyRect(pDirtyRect);
141 STDMETHODIMP SetDirtyRect(RECT* pDirtyRect /*[in]*/)
143 return CSubPicImplHelper::SetDirtyRect(pDirtyRect);
146 STDMETHODIMP GetMaxSize(SIZE* pMaxSize) const
148 return CSubPicImplHelper::GetMaxSize(pMaxSize);
150 STDMETHODIMP SetSize(SIZE size, RECT vidrect)
152 return CSubPicImplHelper::SetSize(size, vidrect);
155 STDMETHODIMP Lock(SubPicDesc& spd) = 0;
156 STDMETHODIMP Unlock(RECT* pDirtyRect /*[in]*/) = 0;
158 STDMETHODIMP AlphaBlt(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget) = 0;
160 STDMETHODIMP SetVirtualTextureSize (const SIZE pSize, const POINT pTopLeft)
162 return CSubPicImplHelper::SetVirtualTextureSize(pSize, pTopLeft);
164 STDMETHODIMP GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* pRcDest)
166 return CSubPicImplHelper::GetSourceAndDest(pSize, pRcSource, pRcDest);
169 STDMETHODIMP_(REFERENCE_TIME) GetSegmentStart()
171 return CSubPicImplHelper::GetSegmentStart();
173 STDMETHODIMP_(REFERENCE_TIME) GetSegmentStop()
175 return CSubPicImplHelper::GetSegmentStop();
177 STDMETHODIMP_(void) SetSegmentStart(REFERENCE_TIME rtStart)
179 return CSubPicImplHelper::SetSegmentStart(rtStart);
181 STDMETHODIMP_(void) SetSegmentStop(REFERENCE_TIME rtStop)
183 return CSubPicImplHelper::SetSegmentStop(rtStop);
187 class CSubPicExImpl : public CUnknown, public CSubPicImplHelper, public ISubPicEx
189 protected:
190 CAtlList<CRect> m_rectListDirty;
192 public:
193 CSubPicExImpl();
195 DECLARE_IUNKNOWN;
196 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
198 // ISubPic
200 STDMETHODIMP_(REFERENCE_TIME) GetStart() const
202 return CSubPicImplHelper::GetStart();
204 STDMETHODIMP_(REFERENCE_TIME) GetStop() const
206 return CSubPicImplHelper::GetStop();
208 STDMETHODIMP_(void) SetStart(REFERENCE_TIME rtStart)
210 return CSubPicImplHelper::SetStart(rtStart);
212 STDMETHODIMP_(void) SetStop(REFERENCE_TIME rtStop)
214 return CSubPicImplHelper::SetStop(rtStop);
217 STDMETHODIMP GetDesc(SubPicDesc& spd) const = 0;
218 STDMETHODIMP CopyTo(ISubPic* pSubPic)
220 return CSubPicImplHelper::CopyTo(pSubPic);
223 STDMETHODIMP ClearDirtyRect(DWORD color) = 0;
224 STDMETHODIMP GetDirtyRect(RECT* pDirtyRect) const
226 return CSubPicImplHelper::GetDirtyRect(pDirtyRect);
228 STDMETHODIMP SetDirtyRect(RECT* pDirtyRect /*[in]*/);
230 STDMETHODIMP GetMaxSize(SIZE* pMaxSize) const
232 return CSubPicImplHelper::GetMaxSize(pMaxSize);
234 STDMETHODIMP SetSize(SIZE size, RECT vidrect)
236 return CSubPicImplHelper::SetSize(size, vidrect);
239 STDMETHODIMP Lock(SubPicDesc& spd) = 0;
240 STDMETHODIMP Unlock(RECT* pDirtyRect /*[in]*/);
242 STDMETHODIMP AlphaBlt(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget) = 0;
244 STDMETHODIMP SetVirtualTextureSize (const SIZE pSize, const POINT pTopLeft)
246 return CSubPicImplHelper::SetVirtualTextureSize(pSize, pTopLeft);
248 STDMETHODIMP GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* pRcDest)
250 return CSubPicImplHelper::GetSourceAndDest(pSize, pRcSource, pRcDest);
253 STDMETHODIMP_(REFERENCE_TIME) GetSegmentStart()
255 return CSubPicImplHelper::GetSegmentStart();
257 STDMETHODIMP_(REFERENCE_TIME) GetSegmentStop()
259 return CSubPicImplHelper::GetSegmentStop();
261 STDMETHODIMP_(void) SetSegmentStart(REFERENCE_TIME rtStart)
263 return CSubPicImplHelper::SetSegmentStart(rtStart);
265 STDMETHODIMP_(void) SetSegmentStop(REFERENCE_TIME rtStop)
267 return CSubPicImplHelper::SetSegmentStop(rtStop);
270 // ISubPicEx
271 STDMETHODIMP CopyTo(ISubPicEx* pSubPicEx);
273 STDMETHODIMP GetDirtyRects(CAtlList<const CRect>& dirtyRectList /*[out]*/) const;
274 STDMETHODIMP SetDirtyRectEx(CAtlList<CRect>* dirtyRectList /*[in]*/);
276 STDMETHODIMP Unlock(CAtlList<CRect>* dirtyRectList /*[in]*/) = 0;
279 class CSubPicAllocatorImpl : public CUnknown, public ISubPicAllocator
281 CComPtr<ISubPic> m_pStatic;
283 private:
284 CSize m_cursize;
285 CRect m_curvidrect;
286 bool m_fDynamicWriteOnly;
288 virtual bool Alloc(bool fStatic, ISubPic** ppSubPic) = 0;
289 protected:
290 bool m_fPow2Textures;
291 public:
292 CSubPicAllocatorImpl(SIZE cursize, bool fDynamicWriteOnly, bool fPow2Textures);
294 DECLARE_IUNKNOWN;
295 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
297 // ISubPicAllocator
299 STDMETHODIMP SetCurSize(SIZE cursize);
300 STDMETHODIMP SetCurVidRect(RECT curvidrect);
301 STDMETHODIMP GetStatic(ISubPic** ppSubPic);
302 STDMETHODIMP AllocDynamic(ISubPic** ppSubPic);
303 STDMETHODIMP_(bool) IsDynamicWriteOnly();
304 STDMETHODIMP ChangeDevice(IUnknown* pDev);
305 STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize) {
306 return E_NOTIMPL;
310 class CSubPicExAllocatorImpl : public CUnknown, public ISubPicExAllocator
312 private:
313 CSize m_cursize;
314 CRect m_curvidrect;
315 bool m_fDynamicWriteOnly;
317 bool Alloc(bool fStatic, ISubPic** ppSubPic);
319 virtual bool AllocEx(bool fStatic, ISubPicEx** ppSubPic) = 0;
320 protected:
321 CComPtr<ISubPicEx> m_pStatic;
322 bool m_fPow2Textures;
323 public:
324 CSubPicExAllocatorImpl(SIZE cursize, bool fDynamicWriteOnly, bool fPow2Textures);
326 DECLARE_IUNKNOWN;
327 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
329 // ISubPicAllocator
331 STDMETHODIMP SetCurSize(SIZE cursize);
332 STDMETHODIMP SetCurVidRect(RECT curvidrect);
333 STDMETHODIMP GetStatic(ISubPic** ppSubPic);
334 STDMETHODIMP AllocDynamic(ISubPic** ppSubPic);
335 STDMETHODIMP_(bool) IsDynamicWriteOnly();
336 STDMETHODIMP ChangeDevice(IUnknown* pDev);
337 STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize) {
338 return E_NOTIMPL;
341 // ISubPicExAllocator
342 STDMETHODIMP_(bool) IsSpdColorTypeSupported(int type);
343 STDMETHODIMP_(int) SetSpdColorType(int color_type);
345 STDMETHODIMP GetStaticEx(ISubPicEx** ppSubPic);
346 STDMETHODIMP AllocDynamicEx(ISubPicEx** ppSubPic);