]> git.vomp.tv Git - vompclient.git/blob - windowsosd.h
Split OsdWin into OsdWinPixel and WindowsOsd as preparation for Vector
[vompclient.git] / windowsosd.h
1 /*
2         Copyright 2004-2005 Marten Richter
3
4         This file is part of VOMP.
5
6         VOMP is free software; you can redistribute it and/or modify
7         it under the terms of the GNU General Public License as published by
8         the Free Software Foundation; either version 2 of the License, or
9         (at your option) any later version.
10
11         VOMP is distributed in the hope that it will be useful,
12         but WITHOUT ANY WARRANTY; without even the implied warranty of
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14         GNU General Public License for more details.
15
16         You should have received a copy of the GNU General Public License
17         along with VOMP; if not, write to the Free Software
18         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef WINDOWSOSD_H
22 #define WINDOWSOSD_H
23
24 #include <winsock2.h>
25 #include <d3d9.h>
26 #include <Dxva2api.h>
27 #include "threadwin.h"
28
29 class DsAllocator;
30
31 struct OSDVERTEX
32 {
33         FLOAT x, y, z, rhw;
34         DWORD c;
35         FLOAT u, v;
36 };
37
38 #define D3DFVF_OSDVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE| D3DFVF_TEX1)
39
40
41 // This class defines all necessary interfaces
42 // for windows osd to communicate with other windows base classes
43
44 class WindowsOsd : public ThreadWin {
45 public:
46         WindowsOsd();
47         virtual ~WindowsOsd();
48
49         bool IsEvrSupported() { return evrsupported; };
50         void setExternalDriving(DsAllocator* dsall, DWORD width, DWORD height);
51
52
53         DWORD getFilterType(){ return filter_type; };
54         void setFilterType(D3DTEXTUREFILTERTYPE type) { filter_type = type; };
55
56         LPDIRECT3DDEVICE9 getD3dDev();
57         LPDIRECT3D9 getD3d();
58         IDirect3DDeviceManager9 * getD3dMan() { return d3ddevman; };
59         DWORD getFilterCaps();
60         HWND getWindow() { return window; };
61         void setWindow(HWND twnd) { window = twnd; };
62
63         // This function is called  in order to get Screen updates
64         void Render();
65         void RenderDS(LPDIRECT3DSURFACE9 present);
66         void Blank();
67         void BeginPainting();
68         void EndPainting();
69
70         virtual int isInitialized()=0;
71
72         void threadMethod();
73         void threadPostStopCleanup();
74
75
76         enum EVR_state {
77                 EVR_pres_off = 0,
78                 EVR_pres_started,
79                 EVR_pres_pause
80         };
81
82         void SetEVRStatus(EVR_state new_state){ evrstate = new_state; };
83 protected:
84
85         int createDirect3D9Objects();
86         void shutdownDirect3D9Objects();
87         void startRenderLoop();
88         void InternalRendering(LPDIRECT3DSURFACE9 present);
89         bool DoLost();
90         virtual void lostDestroyObjects()=0;
91         virtual void lostRecreateObjects()=0;
92
93         void LockDevice();
94         void UnlockDevice();
95         
96         virtual LPDIRECT3DTEXTURE9 getNextOsdTexture()=0;
97
98         LPDIRECT3DVERTEXBUFFER9 InitVertexBuffer(DWORD width, DWORD height);
99         OSDVERTEX osdvertices[4];
100
101         bool evrsupported;
102         EVR_state evrstate;
103         D3DTEXTUREFILTERTYPE filter_type;
104
105         LPDIRECT3D9 d3d;
106         LPDIRECT3DDEVICE9 d3ddevice;
107         LPDIRECT3DSWAPCHAIN9 swappy;
108         LPDIRECT3DSURFACE9 swapsurf;
109         LPDIRECT3DSURFACE9 d3drtsurf;
110
111         UINT dxvatoken;
112         IDirect3DDeviceManager9 *d3ddevman;
113         HANDLE  dxvadevicehandle;
114
115         DsAllocator* dsallocator;
116
117         bool external_driving;
118         HANDLE d3dmutex;
119         HANDLE event;
120         DWORD lastrendertime;
121         HWND window;
122
123 };
124
125
126
127 #endif