Increase ParseScript cache from 30 to 90 seconds
[xy_vsfilter.git] / src / subpic / DX9SubPic.h
blobef40d6b16191a921ae5063353072ceb7a3df5b93
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.
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 "SubPicImpl.h"
25 #include "SubPicAllocatorPresenterImpl.h"
26 #include <d3d9.h>
28 // CDX9SubPic
30 class CVirtualLock
32 public:
33 virtual void Lock() = 0;
34 virtual void Unlock() = 0;
36 typedef void (FLock)(void *_pLock);
37 class CScopeLock
39 void *m_pLock;
40 FLock *m_pUnlockFunc;
41 public:
42 CScopeLock() {}; // let's make cppcheck happy
43 template <typename t_Lock>
44 class TCLocker
46 public:
47 static void fs_Locker(void *_pLock) {
48 ((t_Lock *)_pLock)->Unlock();
51 template <typename t_Lock>
52 CScopeLock(t_Lock &_Lock) {
53 _Lock.Lock();
54 m_pLock = &_Lock;
55 m_pUnlockFunc = TCLocker<t_Lock>::fs_Locker;
57 ~CScopeLock() {
58 m_pUnlockFunc(m_pLock);
61 class CDX9SubPicAllocator;
62 class CDX9SubPic : public CSubPicImpl
64 CComPtr<IDirect3DSurface9> m_pSurface;
66 protected:
67 STDMETHODIMP_(void*) GetObject() const; // returns IDirect3DTexture9*
69 public:
70 CDX9SubPicAllocator *m_pAllocator;
71 bool m_bExternalRenderer;
72 CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator *pAllocator, bool bExternalRenderer);
73 ~CDX9SubPic();
75 // ISubPic
76 STDMETHODIMP GetDesc(SubPicDesc& spd) const;
77 STDMETHODIMP CopyTo(ISubPic* pSubPic);
78 STDMETHODIMP ClearDirtyRect(DWORD color);
79 STDMETHODIMP Lock(SubPicDesc& spd);
80 STDMETHODIMP Unlock(RECT* pDirtyRect);
81 STDMETHODIMP AlphaBlt(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
84 // CDX9SubPicAllocator
86 class CDX9SubPicAllocator : public CSubPicAllocatorImpl, public CCritSec
88 CComPtr<IDirect3DDevice9> m_pD3DDev;
89 CSize m_maxsize;
90 bool m_bExternalRenderer;
92 bool Alloc(bool fStatic, ISubPic** ppSubPic);
94 public:
95 static CCritSec ms_SurfaceQueueLock;
96 CAtlList<CComPtr<IDirect3DSurface9> > m_FreeSurfaces;
97 CAtlList<CDX9SubPic *> m_AllocatedSurfaces;
98 void GetStats(int &_nFree, int &_nAlloc);
99 CDX9SubPicAllocator(IDirect3DDevice9* pD3DDev, SIZE maxsize, bool fPow2Textures, bool bExternalRenderer);
100 ~CDX9SubPicAllocator();
101 void ClearCache();
103 // ISubPicAllocator
104 STDMETHODIMP ChangeDevice(IUnknown* pDev);
105 STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize);