|
Lines 1-5
Link Here
|
| 1 |
/* |
1 |
/* |
| 2 |
* Copyright (C) 2000-2003 the xine project |
2 |
* Copyright (C) 2000-2005 the xine project |
| 3 |
* |
3 |
* |
| 4 |
* This file is part of xine, a unix video player. |
4 |
* This file is part of xine, a unix video player. |
| 5 |
* |
5 |
* |
|
Lines 28-33
Link Here
|
| 28 |
#include <windows.h> |
28 |
#include <windows.h> |
| 29 |
#include <ddraw.h> |
29 |
#include <ddraw.h> |
| 30 |
|
30 |
|
|
|
31 |
#include <pthread.h> |
| 32 |
|
| 31 |
#include "xine.h" |
33 |
#include "xine.h" |
| 32 |
#include "video_out.h" |
34 |
#include "video_out.h" |
| 33 |
#include "alphablend.h" |
35 |
#include "alphablend.h" |
|
Lines 54-60
Link Here
|
| 54 |
* Defining them here allows us to get rid of the dxguid library during |
56 |
* Defining them here allows us to get rid of the dxguid library during |
| 55 |
* the linking stage. |
57 |
* the linking stage. |
| 56 |
*****************************************************************************/ |
58 |
*****************************************************************************/ |
| 57 |
#if 0 |
59 |
#if 1 |
| 58 |
static const GUID IID_IDirectDraw = { |
60 |
static const GUID IID_IDirectDraw = { |
| 59 |
0x6C14DB80,0xA733,0x11CE,{0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60} |
61 |
0x6C14DB80,0xA733,0x11CE,{0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60} |
| 60 |
}; |
62 |
}; |
|
Lines 66-72
Link Here
|
| 66 |
}; |
68 |
}; |
| 67 |
#endif |
69 |
#endif |
| 68 |
|
70 |
|
| 69 |
#if 1 |
71 |
#if 0 |
| 70 |
static const GUID IID_IDirectDraw4 = { |
72 |
static const GUID IID_IDirectDraw4 = { |
| 71 |
0x9C59509A,0x39BD,0x11D1,{0x8C,0x4A,0x00,0xC0,0x4F,0xD9,0x30,0xC5} |
73 |
0x9C59509A,0x39BD,0x11D1,{0x8C,0x4A,0x00,0xC0,0x4F,0xD9,0x30,0xC5} |
| 72 |
}; |
74 |
}; |
|
Lines 100-108
Link Here
|
| 100 |
|
102 |
|
| 101 |
xine_t *xine; |
103 |
xine_t *xine; |
| 102 |
|
104 |
|
| 103 |
LPDIRECTDRAW4 ddobj; /* direct draw object */ |
105 |
LPDIRECTDRAW ddobj; /* direct draw object */ |
| 104 |
LPDIRECTDRAWSURFACE4 primary; /* primary dd surface */ |
106 |
LPDIRECTDRAWSURFACE primary; /* primary dd surface */ |
| 105 |
LPDIRECTDRAWSURFACE4 secondary; /* secondary dd surface */ |
107 |
LPDIRECTDRAWSURFACE secondary; /* secondary dd surface */ |
| 106 |
LPDIRECTDRAWCLIPPER ddclipper; /* dd clipper object */ |
108 |
LPDIRECTDRAWCLIPPER ddclipper; /* dd clipper object */ |
| 107 |
uint8_t * contents; /* secondary contents */ |
109 |
uint8_t * contents; /* secondary contents */ |
| 108 |
win32_frame_t *current; /* current frame */ |
110 |
win32_frame_t *current; /* current frame */ |
|
Lines 137-143
Link Here
|
| 137 |
/* Display formatted error message in |
139 |
/* Display formatted error message in |
| 138 |
* popup message box.*/ |
140 |
* popup message box.*/ |
| 139 |
|
141 |
|
| 140 |
void Error( HWND hwnd, LPSTR szfmt, ... ) |
142 |
static void Error( HWND hwnd, LPSTR szfmt, ... ) |
| 141 |
{ |
143 |
{ |
| 142 |
char tempbuff[ 256 ]; |
144 |
char tempbuff[ 256 ]; |
| 143 |
*tempbuff = 0; |
145 |
*tempbuff = 0; |
|
Lines 148-154
Link Here
|
| 148 |
/* Update our drivers current knowledge |
150 |
/* Update our drivers current knowledge |
| 149 |
* of our windows video out posistion */ |
151 |
* of our windows video out posistion */ |
| 150 |
|
152 |
|
| 151 |
void UpdateRect( win32_visual_t * win32_visual ) |
153 |
static void UpdateRect( win32_visual_t * win32_visual ) |
| 152 |
{ |
154 |
{ |
| 153 |
if( win32_visual->FullScreen ) |
155 |
if( win32_visual->FullScreen ) |
| 154 |
{ |
156 |
{ |
|
Lines 172-181
Link Here
|
| 172 |
* window and will always have a pixel format |
174 |
* window and will always have a pixel format |
| 173 |
* identical to the current display mode. */ |
175 |
* identical to the current display mode. */ |
| 174 |
|
176 |
|
| 175 |
boolean CreatePrimary( win32_driver_t * win32_driver ) |
177 |
static boolean CreatePrimary( win32_driver_t * win32_driver ) |
| 176 |
{ |
178 |
{ |
| 177 |
LPDIRECTDRAW ddobj; |
179 |
LPDIRECTDRAW ddobj; |
| 178 |
DDSURFACEDESC2 ddsd; |
180 |
DDSURFACEDESC ddsd; |
| 179 |
HRESULT result; |
181 |
HRESULT result; |
| 180 |
|
182 |
|
| 181 |
/* create direct draw object */ |
183 |
/* create direct draw object */ |
|
Lines 193-208
Link Here
|
| 193 |
result = IDirectDraw_SetCooperativeLevel( ddobj, win32_driver->win32_visual->WndHnd, DDSCL_NORMAL ); |
195 |
result = IDirectDraw_SetCooperativeLevel( ddobj, win32_driver->win32_visual->WndHnd, DDSCL_NORMAL ); |
| 194 |
if( result != DD_OK ) |
196 |
if( result != DD_OK ) |
| 195 |
{ |
197 |
{ |
| 196 |
Error( 0, "SetCooperativeLevel : error %i", result ); |
198 |
Error( 0, "SetCooperativeLevel : error 0x%lx", result ); |
| 197 |
return 0; |
199 |
return 0; |
| 198 |
} |
200 |
} |
| 199 |
|
201 |
|
| 200 |
/* try to get new interface */ |
202 |
/* try to get new interface */ |
| 201 |
|
203 |
|
| 202 |
result = IDirectDraw_QueryInterface( ddobj, &IID_IDirectDraw4, (LPVOID *) &win32_driver->ddobj ); |
204 |
result = IDirectDraw_QueryInterface( ddobj, &IID_IDirectDraw, (LPVOID *) &win32_driver->ddobj ); |
| 203 |
if( result != DD_OK ) |
205 |
if( result != DD_OK ) |
| 204 |
{ |
206 |
{ |
| 205 |
Error( 0, "ddobj->QueryInterface : DirectX 4 or higher required" ); |
207 |
Error( 0, "ddobj->QueryInterface : DirectX required" ); |
| 206 |
return 0; |
208 |
return 0; |
| 207 |
} |
209 |
} |
| 208 |
|
210 |
|
|
Lines 217-235
Link Here
|
| 217 |
ddsd.dwFlags = DDSD_CAPS; |
219 |
ddsd.dwFlags = DDSD_CAPS; |
| 218 |
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
220 |
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
| 219 |
|
221 |
|
| 220 |
result = IDirectDraw4_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->primary, 0 ); |
222 |
result = IDirectDraw_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->primary, 0 ); |
| 221 |
if( result != DD_OK ) |
223 |
if( result != DD_OK ) |
| 222 |
{ |
224 |
{ |
| 223 |
Error( 0, "CreateSurface ( primary ) : error %i ", result ); |
225 |
Error( 0, "CreateSurface ( primary ) : error 0x%lx", result ); |
| 224 |
return 0; |
226 |
return 0; |
| 225 |
} |
227 |
} |
| 226 |
|
228 |
|
| 227 |
/* create our clipper object */ |
229 |
/* create our clipper object */ |
| 228 |
|
230 |
|
| 229 |
result = IDirectDraw4_CreateClipper( win32_driver->ddobj, 0, &win32_driver->ddclipper, 0 ); |
231 |
result = IDirectDraw_CreateClipper( win32_driver->ddobj, 0, &win32_driver->ddclipper, 0 ); |
| 230 |
if( result != DD_OK ) |
232 |
if( result != DD_OK ) |
| 231 |
{ |
233 |
{ |
| 232 |
Error( 0, "CreateClipper : error %i", result ); |
234 |
Error( 0, "CreateClipper : error 0x%lx", result ); |
| 233 |
return 0; |
235 |
return 0; |
| 234 |
} |
236 |
} |
| 235 |
|
237 |
|
|
Lines 238-253
Link Here
|
| 238 |
result = IDirectDrawClipper_SetHWnd( win32_driver->ddclipper, 0, win32_driver->win32_visual->WndHnd ); |
240 |
result = IDirectDrawClipper_SetHWnd( win32_driver->ddclipper, 0, win32_driver->win32_visual->WndHnd ); |
| 239 |
if( result != DD_OK ) |
241 |
if( result != DD_OK ) |
| 240 |
{ |
242 |
{ |
| 241 |
Error( 0, "ddclipper->SetHWnd : error %i", result ); |
243 |
Error( 0, "ddclipper->SetHWnd : error 0x%lx", result ); |
| 242 |
return 0; |
244 |
return 0; |
| 243 |
} |
245 |
} |
| 244 |
|
246 |
|
| 245 |
/* associate our primary surface with our clipper */ |
247 |
/* associate our primary surface with our clipper */ |
| 246 |
|
248 |
|
| 247 |
result = IDirectDrawSurface4_SetClipper( win32_driver->primary, win32_driver->ddclipper ); |
249 |
result = IDirectDrawSurface_SetClipper( win32_driver->primary, win32_driver->ddclipper ); |
| 248 |
if( result != DD_OK ) |
250 |
if( result != DD_OK ) |
| 249 |
{ |
251 |
{ |
| 250 |
Error( 0, "ddclipper->SetHWnd : error %i", result ); |
252 |
Error( 0, "ddclipper->SetHWnd : error 0x%lx", result ); |
| 251 |
return 0; |
253 |
return 0; |
| 252 |
} |
254 |
} |
| 253 |
|
255 |
|
|
Lines 268-276
Link Here
|
| 268 |
* as the primary surface. At least then we |
270 |
* as the primary surface. At least then we |
| 269 |
* can use h/w scaling if supported. */ |
271 |
* can use h/w scaling if supported. */ |
| 270 |
|
272 |
|
| 271 |
boolean CreateSecondary( win32_driver_t * win32_driver, int width, int height, int format ) |
273 |
static boolean CreateSecondary( win32_driver_t * win32_driver, int width, int height, int format ) |
| 272 |
{ |
274 |
{ |
| 273 |
DDSURFACEDESC2 ddsd; |
275 |
DDSURFACEDESC ddsd; |
|
|
276 |
HRESULT result; |
| 274 |
|
277 |
|
| 275 |
if( format == XINE_IMGFMT_YV12 ) |
278 |
if( format == XINE_IMGFMT_YV12 ) |
| 276 |
xprintf(win32_driver->xine, XINE_VERBOSITY_DEBUG, "vo_out_directx : switching to YV12 overlay type\n" ); |
279 |
xprintf(win32_driver->xine, XINE_VERBOSITY_DEBUG, "vo_out_directx : switching to YV12 overlay type\n" ); |
|
Lines 297-303
Link Here
|
| 297 |
* surface then release it */ |
300 |
* surface then release it */ |
| 298 |
|
301 |
|
| 299 |
if( win32_driver->secondary ) |
302 |
if( win32_driver->secondary ) |
| 300 |
IDirectDrawSurface4_Release( win32_driver->secondary ); |
303 |
IDirectDrawSurface_Release( win32_driver->secondary ); |
| 301 |
|
304 |
|
| 302 |
memset( &ddsd, 0, sizeof( ddsd ) ); |
305 |
memset( &ddsd, 0, sizeof( ddsd ) ); |
| 303 |
ddsd.dwSize = sizeof( ddsd ); |
306 |
ddsd.dwSize = sizeof( ddsd ); |
|
Lines 356-402
Link Here
|
| 356 |
} |
359 |
} |
| 357 |
#endif /* RGB_SUPPORT */ |
360 |
#endif /* RGB_SUPPORT */ |
| 358 |
|
361 |
|
| 359 |
lprintf("CreateSecondary() - IDirectDraw4_CreateSurface()\n"); |
362 |
lprintf("CreateSecondary() - IDirectDraw_CreateSurface()\n"); |
| 360 |
|
363 |
if( IDirectDraw_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->secondary, 0 ) == DD_OK ) |
| 361 |
if( IDirectDraw4_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->secondary, 0 ) == DD_OK ) |
|
|
| 362 |
return TRUE; |
364 |
return TRUE; |
| 363 |
|
365 |
|
| 364 |
/* Our fallback method is to create a back buffer |
366 |
/* Our fallback method is to create a back buffer |
| 365 |
* with the same image format as the primary surface */ |
367 |
* with the same image format as the primary surface */ |
| 366 |
|
368 |
|
| 367 |
lprintf("CreateSecondary() - Falling back to back buffer same as primary\n"); |
369 |
lprintf("CreateSecondary() - Falling back to back buffer same as primary\n"); |
|
|
370 |
lprintf("CreateSecondary() - act_format = (NATIVE) %d\n", IMGFMT_NATIVE); |
| 368 |
|
371 |
|
| 369 |
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; |
372 |
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; |
| 370 |
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; |
373 |
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; |
| 371 |
|
|
|
| 372 |
lprintf("CreateSecondary() - act_format = (NATIVE) %d\n", IMGFMT_NATIVE); |
| 373 |
|
| 374 |
win32_driver->act_format = IMGFMT_NATIVE; |
374 |
win32_driver->act_format = IMGFMT_NATIVE; |
| 375 |
|
375 |
|
| 376 |
if( IDirectDraw4_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->secondary, 0 ) == DD_OK ) |
376 |
if( IDirectDraw_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->secondary, 0 ) == DD_OK ) |
|
|
377 |
return TRUE; |
| 378 |
|
| 379 |
/* Our second fallback - all w/o HW acceleration */ |
| 380 |
lprintf("CreateSecondary() - Falling back, disabling HW acceleration \n"); |
| 381 |
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; |
| 382 |
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; |
| 383 |
if( (result = IDirectDraw_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->secondary, 0 )) == DD_OK ) |
| 377 |
return TRUE; |
384 |
return TRUE; |
| 378 |
|
385 |
|
| 379 |
/* This is bad. We cant even create a surface with |
386 |
/* This is bad. We cant even create a surface with |
| 380 |
* the same format as the primary surface. */ |
387 |
* the same format as the primary surface. */ |
| 381 |
|
388 |
Error( 0, "CreateSurface ( Secondary ) : unable to create a suitable rendering surface: 0x%08lX", result ); |
| 382 |
Error( 0, "CreateSurface ( Secondary ) : unable to create a suitable rendering surface" ); |
|
|
| 383 |
|
| 384 |
return FALSE; |
389 |
return FALSE; |
| 385 |
} |
390 |
} |
| 386 |
|
391 |
|
| 387 |
/* Destroy all direct draw driver allocated |
392 |
/* Destroy all direct draw driver allocated |
| 388 |
* resources. */ |
393 |
* resources. */ |
| 389 |
|
394 |
|
| 390 |
void Destroy( win32_driver_t * win32_driver ) |
395 |
static void Destroy( win32_driver_t * win32_driver ) |
| 391 |
{ |
396 |
{ |
| 392 |
if( win32_driver->ddclipper ) |
397 |
if( win32_driver->ddclipper ) |
| 393 |
IDirectDrawClipper_Release( win32_driver->ddclipper ); |
398 |
IDirectDrawClipper_Release( win32_driver->ddclipper ); |
| 394 |
|
399 |
|
| 395 |
if( win32_driver->primary ) |
400 |
if( win32_driver->primary ) |
| 396 |
IDirectDrawSurface4_Release( win32_driver->primary ); |
401 |
IDirectDrawSurface_Release( win32_driver->primary ); |
| 397 |
|
402 |
|
| 398 |
if( win32_driver->secondary ) |
403 |
if( win32_driver->secondary ) |
| 399 |
IDirectDrawSurface4_Release( win32_driver->secondary ); |
404 |
IDirectDrawSurface_Release( win32_driver->secondary ); |
| 400 |
|
405 |
|
| 401 |
if( win32_driver->ddobj ) |
406 |
if( win32_driver->ddobj ) |
| 402 |
IDirectDraw_Release( win32_driver->ddobj ); |
407 |
IDirectDraw_Release( win32_driver->ddobj ); |
|
Lines 411-417
Link Here
|
| 411 |
* the h/w does not support an overlay for |
416 |
* the h/w does not support an overlay for |
| 412 |
* the native frame format. */ |
417 |
* the native frame format. */ |
| 413 |
|
418 |
|
| 414 |
boolean CheckPixelFormat( win32_driver_t * win32_driver ) |
419 |
static boolean CheckPixelFormat( win32_driver_t * win32_driver ) |
| 415 |
{ |
420 |
{ |
| 416 |
DDPIXELFORMAT ddpf; |
421 |
DDPIXELFORMAT ddpf; |
| 417 |
HRESULT result; |
422 |
HRESULT result; |
|
Lines 420-429
Link Here
|
| 420 |
|
425 |
|
| 421 |
memset( &ddpf, 0, sizeof( DDPIXELFORMAT )); |
426 |
memset( &ddpf, 0, sizeof( DDPIXELFORMAT )); |
| 422 |
ddpf.dwSize = sizeof( DDPIXELFORMAT ); |
427 |
ddpf.dwSize = sizeof( DDPIXELFORMAT ); |
| 423 |
result = IDirectDrawSurface4_GetPixelFormat( win32_driver->primary, &ddpf ); |
428 |
result = IDirectDrawSurface_GetPixelFormat( win32_driver->primary, &ddpf ); |
| 424 |
if( result != DD_OK ) |
429 |
if( result != DD_OK ) |
| 425 |
{ |
430 |
{ |
| 426 |
Error( 0, "IDirectDrawSurface4_GetPixelFormat ( CheckPixelFormat ) : error %u", result ); |
431 |
Error( 0, "IDirectDrawSurface_GetPixelFormat ( CheckPixelFormat ) : error 0x%lx", result ); |
| 427 |
return 0; |
432 |
return 0; |
| 428 |
} |
433 |
} |
| 429 |
|
434 |
|
|
Lines 486-495
Link Here
|
| 486 |
* being pushed to the backend. */ |
491 |
* being pushed to the backend. */ |
| 487 |
|
492 |
|
| 488 |
|
493 |
|
| 489 |
LPDIRECTDRAWSURFACE4 CreateBMP( win32_driver_t * win32_driver, int resource ) |
494 |
static LPDIRECTDRAWSURFACE CreateBMP( win32_driver_t * win32_driver, int resource ) |
| 490 |
{ |
495 |
{ |
| 491 |
LPDIRECTDRAWSURFACE4 bmp_surf; |
496 |
LPDIRECTDRAWSURFACE bmp_surf; |
| 492 |
DDSURFACEDESC2 bmp_ddsd; |
497 |
DDSURFACEDESC bmp_ddsd; |
| 493 |
HBITMAP bmp_hndl; |
498 |
HBITMAP bmp_hndl; |
| 494 |
BITMAP bmp_head; |
499 |
BITMAP bmp_head; |
| 495 |
HDC hdc_dds; |
500 |
HDC hdc_dds; |
|
Lines 515-521
Link Here
|
| 515 |
bmp_ddsd.dwWidth = bmp_head.bmWidth; |
520 |
bmp_ddsd.dwWidth = bmp_head.bmWidth; |
| 516 |
bmp_ddsd.dwHeight = bmp_head.bmHeight; |
521 |
bmp_ddsd.dwHeight = bmp_head.bmHeight; |
| 517 |
|
522 |
|
| 518 |
if( IDirectDraw4_CreateSurface( win32_driver->ddobj, &bmp_ddsd, &bmp_surf, 0 ) != DD_OK ) |
523 |
if( IDirectDraw_CreateSurface( win32_driver->ddobj, &bmp_ddsd, &bmp_surf, 0 ) != DD_OK ) |
| 519 |
{ |
524 |
{ |
| 520 |
Error( 0, "CreateSurface ( bitmap ) : could not create dd surface" ); |
525 |
Error( 0, "CreateSurface ( bitmap ) : could not create dd surface" ); |
| 521 |
return 0; |
526 |
return 0; |
|
Lines 525-531
Link Here
|
| 525 |
* create a compat dc and load |
530 |
* create a compat dc and load |
| 526 |
* our bitmap into the compat dc */ |
531 |
* our bitmap into the compat dc */ |
| 527 |
|
532 |
|
| 528 |
IDirectDrawSurface4_GetDC( bmp_surf, &hdc_dds ); |
533 |
IDirectDrawSurface_GetDC( bmp_surf, &hdc_dds ); |
| 529 |
hdc_mem = CreateCompatibleDC( hdc_dds ); |
534 |
hdc_mem = CreateCompatibleDC( hdc_dds ); |
| 530 |
SelectObject( hdc_mem, bmp_hndl ); |
535 |
SelectObject( hdc_mem, bmp_hndl ); |
| 531 |
|
536 |
|
|
Lines 539-545
Link Here
|
| 539 |
|
544 |
|
| 540 |
DeleteDC( hdc_mem ); |
545 |
DeleteDC( hdc_mem ); |
| 541 |
DeleteObject( bmp_hndl ); |
546 |
DeleteObject( bmp_hndl ); |
| 542 |
IDirectDrawSurface4_ReleaseDC( bmp_surf, hdc_dds ); |
547 |
IDirectDrawSurface_ReleaseDC( bmp_surf, hdc_dds ); |
| 543 |
|
548 |
|
| 544 |
return bmp_surf; |
549 |
return bmp_surf; |
| 545 |
} |
550 |
} |
|
Lines 549-556
Link Here
|
| 549 |
* a h/w overlay of the current frame type |
554 |
* a h/w overlay of the current frame type |
| 550 |
* is supported. */ |
555 |
* is supported. */ |
| 551 |
|
556 |
|
| 552 |
boolean Overlay( LPDIRECTDRAWSURFACE4 src_surface, RECT * src_rect, |
557 |
static boolean Overlay( LPDIRECTDRAWSURFACE src_surface, RECT * src_rect, |
| 553 |
LPDIRECTDRAWSURFACE4 dst_surface, RECT * dst_rect, |
558 |
LPDIRECTDRAWSURFACE dst_surface, RECT * dst_rect, |
| 554 |
COLORREF color_key ) |
559 |
COLORREF color_key ) |
| 555 |
{ |
560 |
{ |
| 556 |
DWORD dw_color_key; |
561 |
DWORD dw_color_key; |
|
Lines 564-573
Link Here
|
| 564 |
|
569 |
|
| 565 |
memset( &ddpf, 0, sizeof( DDPIXELFORMAT )); |
570 |
memset( &ddpf, 0, sizeof( DDPIXELFORMAT )); |
| 566 |
ddpf.dwSize = sizeof( DDPIXELFORMAT ); |
571 |
ddpf.dwSize = sizeof( DDPIXELFORMAT ); |
| 567 |
result = IDirectDrawSurface4_GetPixelFormat( dst_surface, &ddpf ); |
572 |
result = IDirectDrawSurface_GetPixelFormat( dst_surface, &ddpf ); |
| 568 |
if( result != DD_OK ) |
573 |
if( result != DD_OK ) |
| 569 |
{ |
574 |
{ |
| 570 |
Error( 0, "IDirectDrawSurface4_GetPixelFormat : could not get surface pixel format" ); |
575 |
Error( 0, "IDirectDrawSurface_GetPixelFormat : could not get surface pixel format" ); |
| 571 |
return FALSE; |
576 |
return FALSE; |
| 572 |
} |
577 |
} |
| 573 |
|
578 |
|
|
Lines 585-603
Link Here
|
| 585 |
|
590 |
|
| 586 |
/* attempt to overlay the surface */ |
591 |
/* attempt to overlay the surface */ |
| 587 |
|
592 |
|
| 588 |
result = IDirectDrawSurface4_UpdateOverlay( src_surface, src_rect, dst_surface, dst_rect, flags, &ddofx ); |
593 |
result = IDirectDrawSurface_UpdateOverlay( src_surface, src_rect, dst_surface, dst_rect, flags, &ddofx ); |
| 589 |
if( result != DD_OK ) |
594 |
if( result != DD_OK ) |
| 590 |
{ |
595 |
{ |
| 591 |
if( result == DDERR_SURFACELOST ) |
596 |
if( result == DDERR_SURFACELOST ) |
| 592 |
{ |
597 |
{ |
| 593 |
IDirectDrawSurface4_Restore( src_surface ); |
598 |
IDirectDrawSurface_Restore( src_surface ); |
| 594 |
IDirectDrawSurface4_Restore( dst_surface ); |
599 |
IDirectDrawSurface_Restore( dst_surface ); |
| 595 |
|
600 |
|
| 596 |
IDirectDrawSurface4_UpdateOverlay( src_surface, src_rect, dst_surface, dst_rect, flags, &ddofx ); |
601 |
IDirectDrawSurface_UpdateOverlay( src_surface, src_rect, dst_surface, dst_rect, flags, &ddofx ); |
| 597 |
} |
602 |
} |
| 598 |
else |
603 |
else |
| 599 |
{ |
604 |
{ |
| 600 |
Error( 0, "IDirectDrawSurface4_UpdateOverlay : error %i", result ); |
605 |
Error( 0, "IDirectDrawSurface_UpdateOverlay : error 0x%lx", result ); |
| 601 |
return FALSE; |
606 |
return FALSE; |
| 602 |
} |
607 |
} |
| 603 |
} |
608 |
} |
|
Lines 610-617
Link Here
|
| 610 |
* h/w overlay of the current frame format is |
615 |
* h/w overlay of the current frame format is |
| 611 |
* not supported. */ |
616 |
* not supported. */ |
| 612 |
|
617 |
|
| 613 |
boolean BltCopy( LPDIRECTDRAWSURFACE4 src_surface, RECT * src_rect, |
618 |
static boolean BltCopy( LPDIRECTDRAWSURFACE src_surface, RECT * src_rect, |
| 614 |
LPDIRECTDRAWSURFACE4 dst_surface, RECT * dst_rect ) |
619 |
LPDIRECTDRAWSURFACE dst_surface, RECT * dst_rect ) |
| 615 |
{ |
620 |
{ |
| 616 |
DDSURFACEDESC ddsd_target; |
621 |
DDSURFACEDESC ddsd_target; |
| 617 |
HRESULT result; |
622 |
HRESULT result; |
|
Lines 621-639
Link Here
|
| 621 |
|
626 |
|
| 622 |
/* attempt to blt the surface sontents */ |
627 |
/* attempt to blt the surface sontents */ |
| 623 |
|
628 |
|
| 624 |
result = IDirectDrawSurface4_Blt( dst_surface, dst_rect, src_surface, src_rect, DDBLT_WAIT, 0 ); |
629 |
result = IDirectDrawSurface_Blt( dst_surface, dst_rect, src_surface, src_rect, DDBLT_WAIT, 0 ); |
| 625 |
if( result != DD_OK ) |
630 |
if( result != DD_OK ) |
| 626 |
{ |
631 |
{ |
| 627 |
if( result != DDERR_SURFACELOST ) |
632 |
if( result != DDERR_SURFACELOST ) |
| 628 |
{ |
633 |
{ |
| 629 |
IDirectDrawSurface4_Restore( src_surface ); |
634 |
IDirectDrawSurface_Restore( src_surface ); |
| 630 |
IDirectDrawSurface4_Restore( dst_surface ); |
635 |
IDirectDrawSurface_Restore( dst_surface ); |
| 631 |
|
636 |
|
| 632 |
IDirectDrawSurface4_Blt( dst_surface, dst_rect, src_surface, src_rect, DDBLT_WAIT, 0 ); |
637 |
IDirectDrawSurface_Blt( dst_surface, dst_rect, src_surface, src_rect, DDBLT_WAIT, 0 ); |
| 633 |
} |
638 |
} |
| 634 |
else |
639 |
else |
| 635 |
{ |
640 |
{ |
| 636 |
Error( 0, "IDirectDrawSurface4_Blt : error %i", result ); |
641 |
Error( 0, "IDirectDrawSurface_Blt : error 0x%lx", result ); |
| 637 |
return FALSE; |
642 |
return FALSE; |
| 638 |
} |
643 |
} |
| 639 |
} |
644 |
} |
|
Lines 647-653
Link Here
|
| 647 |
* moving the image contents contained in our |
652 |
* moving the image contents contained in our |
| 648 |
* secondary surface to our primary surface. */ |
653 |
* secondary surface to our primary surface. */ |
| 649 |
|
654 |
|
| 650 |
boolean DisplayFrame( win32_driver_t * win32_driver ) |
655 |
static boolean DisplayFrame( win32_driver_t * win32_driver ) |
| 651 |
{ |
656 |
{ |
| 652 |
int view_width; |
657 |
int view_width; |
| 653 |
int view_height; |
658 |
int view_height; |
|
Lines 752-761
Link Here
|
| 752 |
|
757 |
|
| 753 |
/* Lock our back buffer to update its contents. */ |
758 |
/* Lock our back buffer to update its contents. */ |
| 754 |
|
759 |
|
| 755 |
void * Lock( void * surface ) |
760 |
static void * Lock( void * surface ) |
| 756 |
{ |
761 |
{ |
| 757 |
LPDIRECTDRAWSURFACE4 lock_surface = ( LPDIRECTDRAWSURFACE4 ) surface; |
762 |
LPDIRECTDRAWSURFACE lock_surface = ( LPDIRECTDRAWSURFACE ) surface; |
| 758 |
DDSURFACEDESC2 ddsd; |
763 |
DDSURFACEDESC ddsd; |
| 759 |
HRESULT result; |
764 |
HRESULT result; |
| 760 |
|
765 |
|
| 761 |
if( !surface ) |
766 |
if( !surface ) |
|
Lines 764-774
Link Here
|
| 764 |
memset( &ddsd, 0, sizeof( ddsd ) ); |
769 |
memset( &ddsd, 0, sizeof( ddsd ) ); |
| 765 |
ddsd.dwSize = sizeof( ddsd ); |
770 |
ddsd.dwSize = sizeof( ddsd ); |
| 766 |
|
771 |
|
| 767 |
result = IDirectDrawSurface4_Lock( lock_surface, 0, &ddsd, DDLOCK_WAIT | DDLOCK_NOSYSLOCK, 0 ); |
772 |
result = IDirectDrawSurface_Lock( lock_surface, 0, &ddsd, DDLOCK_WAIT | DDLOCK_NOSYSLOCK, 0 ); |
| 768 |
if( result == DDERR_SURFACELOST ) |
773 |
if( result == DDERR_SURFACELOST ) |
| 769 |
{ |
774 |
{ |
| 770 |
IDirectDrawSurface4_Restore( lock_surface ); |
775 |
IDirectDrawSurface_Restore( lock_surface ); |
| 771 |
result = IDirectDrawSurface4_Lock( lock_surface, 0, &ddsd, DDLOCK_WAIT | DDLOCK_NOSYSLOCK, 0 ); |
776 |
result = IDirectDrawSurface_Lock( lock_surface, 0, &ddsd, DDLOCK_WAIT | DDLOCK_NOSYSLOCK, 0 ); |
| 772 |
|
777 |
|
| 773 |
if( result != DD_OK ) |
778 |
if( result != DD_OK ) |
| 774 |
return 0; |
779 |
return 0; |
|
Lines 784-803
Link Here
|
| 784 |
} |
789 |
} |
| 785 |
|
790 |
|
| 786 |
return ddsd.lpSurface; |
791 |
return ddsd.lpSurface; |
| 787 |
|
|
|
| 788 |
return 0; |
| 789 |
} |
792 |
} |
| 790 |
|
793 |
|
| 791 |
/* Unlock our back buffer to prepair for display. */ |
794 |
/* Unlock our back buffer to prepair for display. */ |
| 792 |
|
795 |
|
| 793 |
void Unlock( void * surface ) |
796 |
static void Unlock( void * surface ) |
| 794 |
{ |
797 |
{ |
| 795 |
LPDIRECTDRAWSURFACE4 lock_surface = ( LPDIRECTDRAWSURFACE4 ) surface; |
798 |
LPDIRECTDRAWSURFACE lock_surface = ( LPDIRECTDRAWSURFACE ) surface; |
| 796 |
|
799 |
|
| 797 |
if( !surface ) |
800 |
if( !surface ) |
| 798 |
return; |
801 |
return; |
| 799 |
|
802 |
|
| 800 |
IDirectDrawSurface4_Unlock( lock_surface, 0 ); |
803 |
IDirectDrawSurface_Unlock( lock_surface, 0 ); |
| 801 |
} |
804 |
} |
| 802 |
|
805 |
|
| 803 |
/* ----------------------------------------- |
806 |
/* ----------------------------------------- |
|
Lines 867-872
Link Here
|
| 867 |
if (!win32_frame) |
870 |
if (!win32_frame) |
| 868 |
return NULL; |
871 |
return NULL; |
| 869 |
|
872 |
|
|
|
873 |
pthread_mutex_init(&win32_frame->vo_frame.mutex, NULL); |
| 874 |
|
| 870 |
win32_frame->vo_frame.proc_slice = NULL; |
875 |
win32_frame->vo_frame.proc_slice = NULL; |
| 871 |
win32_frame->vo_frame.proc_frame = NULL; |
876 |
win32_frame->vo_frame.proc_frame = NULL; |
| 872 |
win32_frame->vo_frame.field = win32_frame_field; |
877 |
win32_frame->vo_frame.field = win32_frame_field; |
|
Lines 885-890
Link Here
|
| 885 |
|
890 |
|
| 886 |
/*printf("vo_out_directx : win32_update_frame_format() - width = %d, height=%d, ratio_code=%d, format=%d, flags=%d\n", width, height, ratio_code, format, flags);*/ |
891 |
/*printf("vo_out_directx : win32_update_frame_format() - width = %d, height=%d, ratio_code=%d, format=%d, flags=%d\n", width, height, ratio_code, format, flags);*/ |
| 887 |
|
892 |
|
|
|
893 |
|
| 888 |
if( ( win32_frame->format != format ) || |
894 |
if( ( win32_frame->format != format ) || |
| 889 |
( win32_frame->width != width ) || |
895 |
( win32_frame->width != width ) || |
| 890 |
( win32_frame->height != height ) ) |
896 |
( win32_frame->height != height ) ) |
|
Lines 936-941
Link Here
|
| 936 |
win32_frame->height = height; |
942 |
win32_frame->height = height; |
| 937 |
win32_frame->ratio = ratio; |
943 |
win32_frame->ratio = ratio; |
| 938 |
} |
944 |
} |
|
|
945 |
|
| 939 |
} |
946 |
} |
| 940 |
|
947 |
|
| 941 |
static void win32_display_frame( vo_driver_t * vo_driver, vo_frame_t * vo_frame ) |
948 |
static void win32_display_frame( vo_driver_t * vo_driver, vo_frame_t * vo_frame ) |
|
Lines 945-950
Link Here
|
| 945 |
int offset; |
952 |
int offset; |
| 946 |
int size; |
953 |
int size; |
| 947 |
|
954 |
|
|
|
955 |
|
| 948 |
/* if the required width, height or format has changed |
956 |
/* if the required width, height or format has changed |
| 949 |
* then recreate the secondary buffer */ |
957 |
* then recreate the secondary buffer */ |
| 950 |
|
958 |
|
|
Lines 1091-1096
Link Here
|
| 1091 |
vo_frame->free(&win32_driver->current->vo_frame); |
1099 |
vo_frame->free(&win32_driver->current->vo_frame); |
| 1092 |
} |
1100 |
} |
| 1093 |
win32_driver->current = (win32_frame_t *)vo_frame; |
1101 |
win32_driver->current = (win32_frame_t *)vo_frame; |
|
|
1102 |
|
| 1094 |
} |
1103 |
} |
| 1095 |
|
1104 |
|
| 1096 |
static void win32_overlay_blend( vo_driver_t * vo_driver, vo_frame_t * vo_frame, vo_overlay_t * vo_overlay ) |
1105 |
static void win32_overlay_blend( vo_driver_t * vo_driver, vo_frame_t * vo_frame, vo_overlay_t * vo_overlay ) |
|
Lines 1098-1103
Link Here
|
| 1098 |
win32_frame_t * win32_frame = ( win32_frame_t * ) vo_frame; |
1107 |
win32_frame_t * win32_frame = ( win32_frame_t * ) vo_frame; |
| 1099 |
win32_driver_t * win32_driver = ( win32_driver_t * ) vo_driver; |
1108 |
win32_driver_t * win32_driver = ( win32_driver_t * ) vo_driver; |
| 1100 |
|
1109 |
|
|
|
1110 |
|
| 1101 |
/* temporary overlay support, somthing more appropriate |
1111 |
/* temporary overlay support, somthing more appropriate |
| 1102 |
* for win32 will be devised at a later date */ |
1112 |
* for win32 will be devised at a later date */ |
| 1103 |
|
1113 |
|
|
Lines 1176-1181
Link Here
|
| 1176 |
directx_class_t *class = (directx_class_t *)class_gen; |
1186 |
directx_class_t *class = (directx_class_t *)class_gen; |
| 1177 |
win32_driver_t *win32_driver = ( win32_driver_t * ) xine_xmalloc ( sizeof( win32_driver_t ) ); |
1187 |
win32_driver_t *win32_driver = ( win32_driver_t * ) xine_xmalloc ( sizeof( win32_driver_t ) ); |
| 1178 |
|
1188 |
|
|
|
1189 |
|
| 1179 |
_x_alphablend_init(&win32_driver->alphablend_extra_data, class->xine); |
1190 |
_x_alphablend_init(&win32_driver->alphablend_extra_data, class->xine); |
| 1180 |
|
1191 |
|
| 1181 |
win32_driver->xine = class->xine; |
1192 |
win32_driver->xine = class->xine; |
|
Lines 1196-1207
Link Here
|
| 1196 |
win32_driver->vo_driver.dispose = win32_exit; |
1207 |
win32_driver->vo_driver.dispose = win32_exit; |
| 1197 |
win32_driver->vo_driver.redraw_needed = win32_redraw_needed; |
1208 |
win32_driver->vo_driver.redraw_needed = win32_redraw_needed; |
| 1198 |
|
1209 |
|
| 1199 |
CreatePrimary( win32_driver ); |
1210 |
if (!CreatePrimary( win32_driver )) { |
|
|
1211 |
Destroy( win32_driver ); |
| 1212 |
return NULL; |
| 1213 |
} |
| 1200 |
if( !CheckPixelFormat( win32_driver ) ) |
1214 |
if( !CheckPixelFormat( win32_driver ) ) |
| 1201 |
{ |
1215 |
{ |
| 1202 |
Error( 0, "vo_directx : Your screen pixel format is not supported" ); |
1216 |
Error( 0, "vo_directx : Your screen pixel format is not supported" ); |
| 1203 |
Destroy( win32_driver ); |
1217 |
Destroy( win32_driver ); |
| 1204 |
return 0; |
1218 |
return NULL; |
| 1205 |
} |
1219 |
} |
| 1206 |
|
1220 |
|
| 1207 |
#if (NEW_YUV) |
1221 |
#if (NEW_YUV) |
|
Lines 1212-1218
Link Here
|
| 1212 |
#endif |
1226 |
#endif |
| 1213 |
|
1227 |
|
| 1214 |
return ( vo_driver_t * ) win32_driver; |
1228 |
return ( vo_driver_t * ) win32_driver; |
| 1215 |
} |
1229 |
} |
| 1216 |
|
1230 |
|
| 1217 |
|
1231 |
|
| 1218 |
static char* get_identifier (video_driver_class_t *this_gen) { |
1232 |
static char* get_identifier (video_driver_class_t *this_gen) { |
|
Lines 1232-1238
Link Here
|
| 1232 |
static void *init_class (xine_t *xine, void *visual_gen) { |
1246 |
static void *init_class (xine_t *xine, void *visual_gen) { |
| 1233 |
|
1247 |
|
| 1234 |
directx_class_t *directx; |
1248 |
directx_class_t *directx; |
| 1235 |
|
1249 |
|
| 1236 |
/* |
1250 |
/* |
| 1237 |
* from this point on, nothing should go wrong anymore |
1251 |
* from this point on, nothing should go wrong anymore |
| 1238 |
*/ |
1252 |
*/ |