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