]> git.vomp.tv Git - vompclient.git/blob - osdwinvector.h
Windows fixes
[vompclient.git] / osdwinvector.h
1 /*
2     Copyright 2004-2005 Chris Tallon
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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef OSDWINVECTOR_H
21 #define OSDWINVECTOR_H
22
23 #include <queue>
24 #include <list>
25 #include <mutex>
26
27 #include "defines.h"
28 #include "windowsosd.h"
29
30
31 #include <d3d10_1.h>
32 #include <d2d1.h>
33 #include <dwrite.h>
34
35 #include "log.h"
36 #include "osdvector.h"
37
38 class OsdWinVector : public OsdVector, public WindowsOsd
39 {
40   friend class WICPictDecoder;
41   public:
42     OsdWinVector();
43     ~OsdWinVector();
44
45     int init();
46     int shutdown();
47
48         bool isInitialized() { return initted; }
49
50         void getScreenSize(int &width, int &height);
51         void getRealScreenSize(int &width, int &height);
52
53         float getFontHeight();
54         float getCharWidth(wchar_t c);
55
56         bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/);
57
58         int getFontNames(const char *** names, const char *** names_keys);
59
60         void setFont(const char * fontname);
61
62         float getPixelAspect() { return aspect_correction; };
63
64 protected:
65         LPDIRECT3DTEXTURE9 getNextOsdTexture();
66         void lostDestroyObjects();
67         void lostRecreateObjects();
68         void updateOsd();
69         void getTextureCoordinates(FLOAT*, FLOAT*);
70
71         /*osd vector implementation*/
72         void destroyImageRef(ImageIndex index);
73         ImageIndex createMonoBitmap(void *base, int width, int height);
74         ImageIndex createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data);
75         void createPicture(struct PictureInfo& pict_inf);
76         void destroyStyleRef(VectorHandle index);
77         VectorHandle createStyleRef(const DrawStyle &c);
78         bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length);
79
80
81         int  loadFont(bool fontchange);
82
83         std::map<unsigned int, float> font_exp_x;
84         std::vector<char*> fontnames;
85         //vector<char*> fontnames_keys;
86         wchar_t * cur_fontname;
87         bool is_direct_write_initted;
88         IDWriteFactory* dwritefac;
89         IDWriteFont* font;
90         IDWriteFontFace* fontface;
91         float fontheight;
92         float fontzero;
93         float fontaspect_corr;
94
95         struct TTIndex {
96                 unsigned char atlas;
97                 unsigned char position;
98         };
99
100         TTIndex loadTTchar(cTeletextChar c);
101
102         std::map<unsigned int, TTIndex> tt_font_chars;
103         std::vector<ID2D1Bitmap *> tt_atlas;
104         TTIndex ttchar_end;
105         ID2D1SolidColorBrush *ttbrush;
106
107
108         void executeDrawCommand(SVGCommand & command);
109         void drawSetTrans(SurfaceCommands & sc);
110
111         typedef struct {
112                 LPDIRECT3DTEXTURE9 surf9;
113                 IDirect3DQuery9 * query9;
114                 ID3D10Texture2D *surf10;
115                 IDXGISurface * surfdxgi;
116                 ID2D1RenderTarget *rendtarget2D;
117                 ID3D10Query * query10;
118                 HANDLE sharedhandle;
119         } SurfaceInfo;
120
121         std::queue<SurfaceInfo> d2dtod3d;
122         std::queue<SurfaceInfo> d3dtod2d;
123         std::list<SurfaceInfo> allsurfs;
124         SurfaceInfo currentosd_render;
125         SurfaceInfo currentosd_backbuffer;
126         ID2D1RenderTarget * LockOsdDrawing();
127         void UnlockOsdDrawing();
128
129         std::mutex queuemutex;
130
131         void initPaths();
132         void destroyPaths();
133         ID2D1PathGeometry *std_paths[PIPoint + 1];
134
135         ID3D10Device1 * d3ddevice10;
136         ID2D1Factory *d2dfactory;
137         IDXGIDevice * dxgidevice;
138         float aspect_correction;
139         float dpix, dpiy;
140
141         int clip_shift_x;
142         int clip_shift_y;
143
144         int num_clips;
145         
146 };
147
148 #endif