2 Copyright 2004-2005 Chris Tallon
\r
3 Portions copyright 2004 Jon Gettler
\r
5 This file is part of VOMP.
\r
7 VOMP is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 VOMP is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with VOMP; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
22 #ifndef SURFACEMVP_H
\r
23 #define SURFACEMVP_H
\r
28 #include <sys/mman.h>
\r
29 #include <sys/ioctl.h>
\r
33 #include <jpeglib.h>
\r
36 #include "defines.h"
\r
37 #include "surface.h"
\r
39 // Structures for surface management
\r
44 unsigned long unknown[4];
\r
45 unsigned long width;
\r
46 unsigned long height;
\r
52 unsigned long unknown;
\r
53 unsigned long win_unknown;
\r
56 unsigned long unknown2;
\r
57 unsigned long width;
\r
58 unsigned long height;
\r
59 unsigned long unknown3;
\r
60 unsigned long unknown4;
\r
61 unsigned long width2;
\r
62 unsigned long unknown5;
\r
63 unsigned long unknown6;
\r
64 } stbgfx_map_item_t;
\r
67 stbgfx_map_item_t map[3];
\r
68 unsigned long other[2];
\r
73 unsigned long handle; /* surface handle */
\r
74 unsigned long width;
\r
75 unsigned long height;
\r
76 unsigned long flags;
\r
77 long unknown; //unsigned long
\r
78 unsigned long depth; /* number of subplanes */
\r
83 stbgfx_display_t display;
\r
86 unsigned char *base[3];
\r
90 // Structures for surface drawing
\r
94 unsigned long handle;
\r
97 unsigned long width;
\r
98 unsigned long height;
\r
99 unsigned long colour;
\r
103 unsigned long dst_handle;
\r
104 unsigned long dst_x;
\r
105 unsigned long dst_y;
\r
106 unsigned long width;
\r
107 unsigned long height;
\r
108 unsigned long src_handle;
\r
109 unsigned long src_x;
\r
110 unsigned long src_y;
\r
118 #define GFX_FB_SFC_ALLOC _IOWR(0xfb,1,int*)
\r
119 #define GFX_FB_SFC_FREE _IOW(0xfb,2,int)
\r
120 #define GFX_FB_MAP _IOWR(0xfb,3,int*)
\r
121 #define GFX_FB_SFC_UNMAP _IOW(0xfb,4,int)
\r
122 #define GFX_FB_SET_PAL_1 _IOWR(0xfb,5,int*)
\r
123 #define GFX_FB_SET_PAL_2 _IOW(0xfb,6,int*)
\r
124 #define GFX_FB_OSD_SURFACE _IO(0xfb,7)
\r
125 #define GFX_FB_SFC_SET_SHARE _IOW(0xfb,8,int)
\r
126 #define GFX_FB_OSD_CUR_SETATTR _IOW(0xfb,9,int*)
\r
127 #define GFX_FB_ATTACH _IOW(0xfb,11,int)
\r
128 #define GFX_FB_SFC_DETACH _IOW(0xfb,12,int*)
\r
129 #define GFX_FB_MOVE_DISPLAY _IOWR(0xfb,13,int)
\r
130 #define GFX_FB_SET_DISPLAY _IOW(0xfb,14,int)
\r
131 #define GFX_FB_OSD_CUR_MOVE_1 _IOW(0xfb,15,int*)
\r
132 #define GFX_FB_OSD_CUR_MOVE_2 _IOW(0xfb,16,int)
\r
133 #define GFX_FB_SET_OSD _IOW(0xfb,18,int)
\r
134 #define GFX_FB_SET_DISP_CTRL _IOW(0xfb,21,int*)
\r
135 #define GFX_FB_GET_DISP_CTRL _IOWR(0xfb,22,int*)
\r
136 #define GFX_FB_SET_VIS_DEV_CTL _IOWR(0xfb,23,int*)
\r
137 #define GFX_FB_GET_VIS_DEV_CTL _IOWR(0xfb,24,int*)
\r
138 #define GFX_FB_OSD_BITBLT _IOW(0xfb,51,osd_bitblt_t*)
\r
139 #define GFX_FB_OSD_FILLBLT _IOW(0xfb,53,osd_fillblt_t*)
\r
140 #define GFX_FB_OSD_ADVFILLBLT _IOW(0xfb,54,osd_afillblt_t*)
\r
141 #define GFX_FB_OSD_BLEND _IOW(0xfb,55,int*)
\r
142 #define GFX_FB_OSD_ADVBLEND _IOW(0xfb,56,int*)
\r
143 #define GFX_FB_OSD_RESIZE _IOW(0xfb,58,int*)
\r
144 #define GFX_FB_ENGINE_WAIT _IOW(0xfb,60,int)
\r
145 #define GFX_FB_RESET_ENGINE _IO(0xfb,61)
\r
146 #define GFX_FB_SET_ENGINE_MODE _IOW(0xfb,62,int)
\r
147 #define GFX_FB_GET_ENGINE_MODE _IO(0xfb,63)
\r
148 #define GFX_FB_GET_SFC_INFO _IO(0xfb,64,int*)
\r
149 #define GFX_FB_OSD_SFC_CLIP _IOW(0xfb,65,osd_clip_rec_t*)
\r
150 #define GFX_FB_OSD_COLOURKEY _IOW(0xfb,67,int*)
\r
151 #define GFX_FB_GET_SFC_PSEUDO _IOWR(0xfb,68,int*)
\r
153 class SurfaceMVP : public Surface
\r
156 SurfaceMVP(int id = 0);
\r
157 virtual ~SurfaceMVP();
\r
159 int create(UINT width, UINT height);
\r
161 unsigned long getSurfaceHandle();
\r
163 int fillblt(int x, int y, int width, int height, const DrawStyle& c);
\r
165 void drawHorzLine(int x1, int x2, int y, const DrawStyle& c);
\r
166 void drawVertLine(int x, int y1, int y2, const DrawStyle& c);
\r
167 void drawBitmap(int x, int y, const Bitmap& bm, const DisplayRegion& region);
\r
168 int updateToScreen(int sx, int sy, int w, int h, int dx, int dy);
\r
169 void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
\r
170 void screenShot(const char* fileName);
\r
172 static void initConversionTables()
\r
174 initConversionTables(100,100,100);
\r
176 //init tables with factors for R,G,B - each in percent
\r
177 static void initConversionTables(int r, int g, int b);
\r
179 int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy);
\r
183 osd_surface_t surface;
\r
185 void yuv2rgb(int y, int u, int v, unsigned char* pr, unsigned char* pg, unsigned char* pb);
\r
187 * rgb2yuv() - convert an RGB pixel to YUV
\r
189 inline void rgb2yuv(unsigned char r, unsigned char g, unsigned char b, unsigned char *y, unsigned char *u, unsigned char *v)
\r
193 Y = conv_YB[b] + conv_YG[g] + conv_YR[r];
\r
194 U = conv_UB[b] + conv_UG[g] + conv_UR[r] + 128;
\r
195 V = conv_VB[b] + conv_VG[g] + conv_VR[r] + 128;
\r
216 // Implicit inlines
\r
217 void c2rgba(unsigned long c, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
\r
219 *a = (c & 0xff000000) >> 24;
\r
220 *r = (c & 0x00ff0000) >> 16;
\r
221 *g = (c & 0x0000ff00) >> 8;
\r
222 *b = (c & 0x000000ff);
\r
225 static int conv_YB[256];
\r
226 static int conv_YG[256];
\r
227 static int conv_YR[256];
\r
228 static int conv_UB[256];
\r
229 static int conv_UG[256];
\r
230 static int conv_UR[256];
\r
231 static int conv_VB[256];
\r
232 static int conv_VG[256];
\r
233 static int conv_VR[256];
\r
235 static int conv_BY[256];
\r
236 static int conv_GY[256];
\r
237 static int conv_RY[256];
\r
238 static int conv_BU[256];
\r
239 static int conv_GU[256];
\r
240 static int conv_RU[256];
\r
241 static int conv_BV[256];
\r
242 static int conv_GV[256];
\r
243 static int conv_RV[256];
\r
245 void drawPixel(int x, int y, unsigned int c, bool fastdraw=false);
\r
246 void drawPixel(int x, int y, Colour& c, bool fastdraw=false);
\r