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)
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
24 #include "SubPicImpl.h"
25 #include "SubPicAllocatorPresenterImpl.h"
33 virtual void Lock() = 0;
34 virtual void Unlock() = 0;
36 typedef void (FLock
)(void *_pLock
);
42 CScopeLock() {}; // let's make cppcheck happy
43 template <typename t_Lock
>
47 static void fs_Locker(void *_pLock
) {
48 ((t_Lock
*)_pLock
)->Unlock();
51 template <typename t_Lock
>
52 CScopeLock(t_Lock
&_Lock
) {
55 m_pUnlockFunc
= TCLocker
<t_Lock
>::fs_Locker
;
58 m_pUnlockFunc(m_pLock
);
61 class CDX9SubPicAllocator
;
62 class CDX9SubPic
: public CSubPicImpl
64 CComPtr
<IDirect3DSurface9
> m_pSurface
;
67 STDMETHODIMP_(void*) GetObject() const; // returns IDirect3DTexture9*
70 CDX9SubPicAllocator
*m_pAllocator
;
71 bool m_bExternalRenderer
;
72 CDX9SubPic(IDirect3DSurface9
* pSurface
, CDX9SubPicAllocator
*pAllocator
, bool bExternalRenderer
);
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
;
90 bool m_bExternalRenderer
;
92 bool Alloc(bool fStatic
, ISubPic
** ppSubPic
);
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();
104 STDMETHODIMP
ChangeDevice(IUnknown
* pDev
);
105 STDMETHODIMP
SetMaxTextureSize(SIZE MaxTextureSize
);