Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 7526:e3ca9e707857
- fix new afm/vfm support
- fix fullscreen with xv
- add cache support
author | pontscho |
---|---|
date | Sat, 28 Sep 2002 18:03:34 +0000 |
parents | c4434bdf6e51 |
children | e4e70b0e1786 |
rev | line source |
---|---|
100 | 1 |
2 //#define SHOW_TIME | |
1 | 3 |
4 /* | |
5 * video_out_xmga.c | |
6 * | |
7 * Copyright (C) Zoltan Ponekker - Jan 2001 | |
8 * | |
9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
10 * | |
11 * mpeg2dec is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2, or (at your option) | |
14 * any later version. | |
15 * | |
16 * mpeg2dec is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with GNU Make; see the file COPYING. If not, write to | |
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 */ | |
26 | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 | |
31 #include "config.h" | |
6296 | 32 #include "mp_msg.h" |
33 | |
1 | 34 #include "video_out.h" |
35 #include "video_out_internal.h" | |
36 | |
37 LIBVO_EXTERN( xmga ) | |
38 | |
39 #include <sys/ioctl.h> | |
40 #include <unistd.h> | |
41 #include <fcntl.h> | |
42 #include <sys/mman.h> | |
43 | |
44 #include "drivers/mga_vid.h" | |
45 | |
46 #include <X11/Xlib.h> | |
47 #include <X11/Xutil.h> | |
48 #include <errno.h> | |
49 | |
4017 | 50 #ifdef HAVE_XINERAMA |
51 #include <X11/extensions/Xinerama.h> | |
52 #endif | |
53 | |
31 | 54 #include "x11_common.h" |
616 | 55 #include "sub.h" |
2057 | 56 #include "aspect.h" |
31 | 57 |
182 | 58 #ifdef SHOW_TIME |
100 | 59 #include "../linux/timer.h" |
60 static unsigned int timer=0; | |
61 static unsigned int timerd=0; | |
62 #endif | |
63 | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
64 #ifdef HAVE_NEW_GUI |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
65 #include "../Gui/interface.h" |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
66 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
67 |
1 | 68 static vo_info_t vo_info = |
69 { | |
4993 | 70 "X11 (Matrox G200/G4x0/G550 overlay in window using /dev/mga_vid)", |
1 | 71 "xmga", |
72 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
73 "" | |
74 }; | |
75 | |
76 static XGCValues wGCV; | |
77 | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7124
diff
changeset
|
78 static uint32_t mDepth; |
1 | 79 static XWindowAttributes attribs; |
80 static uint32_t fgColor; | |
81 | |
82 static uint32_t mvHeight; | |
83 static uint32_t mvWidth; | |
84 | |
85 static Window mRoot; | |
86 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; | |
4981 | 87 static uint32_t drwcX,drwcY,dwidth,dheight; |
1 | 88 |
89 static XSetWindowAttributes xWAttribs; | |
90 | |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
91 static int inited=0; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
92 |
4981 | 93 #define VO_XMGA |
1 | 94 #include "mga_common.c" |
4981 | 95 #undef VO_XMGA |
1 | 96 |
97 static void mDrawColorKey( void ) | |
98 { | |
4795 | 99 XSetBackground( mDisplay,vo_gc,0 ); |
100 XClearWindow( mDisplay,vo_window ); | |
101 XSetForeground( mDisplay,vo_gc,fgColor ); | |
4981 | 102 XFillRectangle( mDisplay,vo_window,vo_gc,drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight) ); |
1 | 103 XFlush( mDisplay ); |
104 } | |
105 | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
106 static void set_window( void ){ |
120 | 107 |
6043 | 108 if ( WinID ) |
109 { | |
110 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); | |
6296 | 111 mp_msg(MSGT_VO,MSGL_V,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight ); |
6043 | 112 drwX=0; drwY=0; |
113 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); | |
6296 | 114 mp_msg(MSGT_VO,MSGL_V,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
6043 | 115 } |
116 else { drwX=drwcX=vo_dx; drwY=drwcY=vo_dy; drwWidth=vo_dwidth; drwHeight=vo_dheight; } | |
1852 | 117 |
3558 | 118 aspect(&dwidth,&dheight,A_NOZOOM); |
4981 | 119 if ( vo_fs ) |
120 | 120 { |
3558 | 121 aspect(&dwidth,&dheight,A_ZOOM); |
120 | 122 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
123 drwcX+=drwX; | |
124 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; | |
125 drwcY+=drwY; | |
126 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); | |
127 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | |
6296 | 128 mp_msg(MSGT_VO,MSGL_V,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
120 | 129 } |
6307 | 130 vo_dwidth=drwWidth; vo_dheight=drwHeight; |
120 | 131 |
4017 | 132 #ifdef HAVE_XINERAMA |
133 if(XineramaIsActive(mDisplay)) | |
134 { | |
135 XineramaScreenInfo *screens; | |
136 int num_screens; | |
137 int i; | |
138 | |
139 screens = XineramaQueryScreens(mDisplay,&num_screens); | |
140 | |
141 /* find the screen we are on */ | |
142 i = 0; | |
143 while(!(screens[i].x_org <= drwcX && screens[i].y_org <= drwcY && | |
144 screens[i].x_org + screens[i].width >= drwcX && | |
145 screens[i].y_org + screens[i].height >= drwcY )) | |
146 { | |
147 i++; | |
148 } | |
149 | |
150 /* set drwcX and drwcY to the right values */ | |
151 drwcX = drwcX - screens[i].x_org; | |
152 drwcY = drwcY - screens[i].y_org; | |
153 XFree(screens); | |
154 } | |
155 | |
156 #endif | |
6307 | 157 |
158 mDrawColorKey(); | |
159 | |
120 | 160 mga_vid_config.x_org=drwcX; |
161 mga_vid_config.y_org=drwcY; | |
162 mga_vid_config.dest_width=drwWidth; | |
163 mga_vid_config.dest_height=drwHeight; | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
164 if ( vo_panscan > 0.0f && vo_fs ) |
6307 | 165 { |
166 drwX-=vo_panscan_x>>1; | |
167 drwY-=vo_panscan_y>>1; | |
168 drwWidth+=vo_panscan_x; | |
169 drwHeight+=vo_panscan_y; | |
170 | |
171 mga_vid_config.x_org-=vo_panscan_x>>1; | |
172 mga_vid_config.y_org-=vo_panscan_y>>1; | |
173 mga_vid_config.dest_width=drwWidth; | |
174 mga_vid_config.dest_height=drwHeight; | |
175 mDrawColorKey(); | |
176 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); | |
177 } | |
120 | 178 } |
179 | |
31 | 180 static void check_events(void) |
1 | 181 { |
4303 | 182 int e=vo_x11_check_events(mDisplay); |
183 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
184 set_window(); |
6043 | 185 mDrawColorKey(); |
6296 | 186 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); |
1 | 187 } |
188 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
189 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
190 { vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);} |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
191 |
31 | 192 static void flip_page(void){ |
182 | 193 #ifdef SHOW_TIME |
100 | 194 unsigned int t; |
195 t=GetTimer(); | |
6296 | 196 mp_msg(MSGT_VO,MSGL_STATUS," [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd); |
100 | 197 timerd=t-timer; |
198 timer=t; | |
182 | 199 #endif |
100 | 200 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
201 vo_mga_flip_page(); |
31 | 202 } |
1 | 203 |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6953
diff
changeset
|
204 static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 205 { |
206 char * mTitle=(title == NULL) ? "XMGA render" : title; | |
207 XVisualInfo vinfo; | |
208 | |
209 unsigned long xswamask; | |
210 | |
6016 | 211 if (!vo_init()) return -1; |
212 | |
5007 | 213 width+=width&1; |
214 | |
1 | 215 switch(format) |
216 { | |
182 | 217 case IMGFMT_YV12: |
5007 | 218 height+=height&1; |
5317 | 219 mga_vid_config.format=MGA_VID_FORMAT_IYUV; |
182 | 220 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; |
56 | 221 break; |
470 | 222 case IMGFMT_I420: |
223 case IMGFMT_IYUV: | |
5007 | 224 height+=height&1; |
5317 | 225 mga_vid_config.format=MGA_VID_FORMAT_YV12; |
470 | 226 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; |
227 break; | |
56 | 228 case IMGFMT_YUY2: |
229 mga_vid_config.format=MGA_VID_FORMAT_YUY2; | |
182 | 230 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2; |
56 | 231 break; |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
232 case IMGFMT_UYVY: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
233 mga_vid_config.format=MGA_VID_FORMAT_UYVY; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
234 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
235 break; |
6296 | 236 default: |
237 mp_msg(MSGT_VO,MSGL_ERR,"mga: invalid output format %0X\n",format); | |
238 return -1; | |
1 | 239 } |
240 | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
241 aspect_save_orig(width,height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
242 aspect_save_prescale(d_width,d_height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
243 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
244 |
1 | 245 mvWidth=width; mvHeight=height; |
246 | |
6307 | 247 vo_panscan_x=vo_panscan_y=vo_panscan_amount=0; |
248 | |
6043 | 249 vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2; |
4981 | 250 vo_dwidth=d_width; vo_dheight=d_height; |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
251 vo_mouse_autohide=1; |
1 | 252 |
253 switch ( vo_depthonscreen ) | |
254 { | |
255 case 32: | |
256 case 24: fgColor=0x00ff00ffL; break; | |
257 case 16: fgColor=0xf81fL; break; | |
258 case 15: fgColor=0x7c1fL; break; | |
6296 | 259 default: mp_msg(MSGT_VO,MSGL_ERR,"Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; |
1 | 260 } |
261 | |
5158 | 262 inited=1; |
263 | |
6016 | 264 aspect(&vo_dwidth,&vo_dheight,A_NOZOOM); |
5985 | 265 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
266 #ifdef HAVE_NEW_GUI |
5985 | 267 if(use_gui) |
268 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window | |
269 else | |
270 #endif | |
723 | 271 { |
2039 | 272 #ifdef X11_FULLSCREEN |
6043 | 273 if ( flags&1 ) aspect(&dwidth,&dheight,A_ZOOM); |
2039 | 274 #endif |
723 | 275 |
6043 | 276 XGetWindowAttributes( mDisplay,mRootWin,&attribs ); |
723 | 277 mDepth=attribs.depth; |
278 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; | |
279 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); | |
6043 | 280 xWAttribs.colormap=XCreateColormap( mDisplay,mRootWin,vinfo.visual,AllocNone ); |
723 | 281 xWAttribs.background_pixel=0; |
282 xWAttribs.border_pixel=0; | |
6043 | 283 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask | |
284 ((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PropertyChangeMask)); | |
723 | 285 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
1 | 286 |
3847 | 287 if ( WinID>=0 ){ |
6043 | 288 |
289 vo_window = WinID ? ((Window)WinID) : mRootWin; | |
290 if ( WinID ) | |
291 { | |
292 XUnmapWindow( mDisplay,vo_window ); | |
293 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs); | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6755
diff
changeset
|
294 vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask ); |
6043 | 295 } else XSelectInput( mDisplay,vo_window,ExposureMask ); |
296 | |
3847 | 297 } else |
6043 | 298 { |
299 vo_window=XCreateWindow( mDisplay,mRootWin, | |
300 vo_dx,vo_dy, | |
301 vo_dwidth,vo_dheight, | |
302 xWAttribs.border_pixel, | |
303 mDepth, | |
304 InputOutput, | |
305 vinfo.visual,xswamask,&xWAttribs ); | |
306 | |
307 vo_x11_classhint( mDisplay,vo_window,"xmga" ); | |
308 vo_hidecursor(mDisplay,vo_window); | |
309 vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight,0 ); | |
723 | 310 |
6043 | 311 XStoreName( mDisplay,vo_window,mTitle ); |
312 XMapWindow( mDisplay,vo_window ); | |
313 | |
314 if ( flags&1 ) vo_x11_fullscreen(); | |
5999 | 315 |
3990 | 316 #ifdef HAVE_XINERAMA |
6043 | 317 vo_x11_xinerama_move(mDisplay,vo_window); |
3990 | 318 #endif |
6043 | 319 } |
320 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV ); | |
5985 | 321 } |
1 | 322 |
6043 | 323 if ( ( flags&1 )&&( !WinID ) ) { vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; vo_fs=1; } |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
324 |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
325 panscan_calc(); |
6043 | 326 |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
327 set_window(); |
1 | 328 |
6755 | 329 saver_off(mDisplay); |
330 | |
331 XFlush( mDisplay ); | |
332 XSync( mDisplay,False ); | |
333 | |
1 | 334 mga_vid_config.src_width=width; |
335 mga_vid_config.src_height=height; | |
336 | |
337 mga_vid_config.colkey_on=1; | |
338 mga_vid_config.colkey_red=255; | |
339 mga_vid_config.colkey_green=0; | |
340 mga_vid_config.colkey_blue=255; | |
6755 | 341 |
342 mga_vid_config.version=MGA_VID_VERSION; | |
1 | 343 |
6755 | 344 return mga_init(); |
1 | 345 } |
346 | |
347 static const vo_info_t* get_info( void ) | |
348 { return &vo_info; } | |
349 | |
350 | |
351 static void | |
352 uninit(void) | |
353 { | |
5158 | 354 if(!inited) return; |
355 inited=0; | |
356 mga_uninit(); | |
4316 | 357 saver_on(mDisplay); |
6095 | 358 vo_x11_uninit(); |
6296 | 359 mp_msg(MSGT_VO,MSGL_V,"vo: uninit!\n"); |
1 | 360 } |
4352 | 361 |