comparison src/video/photon/SDL_ph_video.c @ 821:30168104389f

Date: Sat, 14 Feb 2004 14:52:40 +0200 From: "Mike Gorchak" Subject: Batch of the QNX6 fixes for the SDL 1. Updated readme.QNX 2. Fixed crashes during intensive window updating under fast machines (got over 200 rectangles for update). 3. Fixed double-buffered fullscreen modes, now it works as needed. 4. Fixed Photon detection algorithm. 5. Fixed HWSURFACE update function. 6. Added SDL_PHOTON_FULLSCREEN_REFRESH environment variable support for control refresh rates under Photon. 7. Added 640x400 fullscreen mode emulation via 640x480 (if videodriver not supports original 640x400 mode of course) shifted by 40 vertical pixels from begin, to center it. It's needed for some old DOS games which ran in doubled 320x200 mode. 8. Added available video ram amount support. 8. Added hardware surface allocation/deallocation support if current videomode and videodriver supports it. 9. Added hardware filling support. 10. Added hardware blits support (simple and colorkeyed). And I've added to testvidinfo test color-keyed blits benchmark (maybe need to add alpha blits benchmark too ?). Currently Photon not supporting any alpha hardware blittings (all drivers lack of alpha blitting code support, only software alpha blitting exist in photon, which is hundreds times slowest than the SDL's one). So I've not added the alpha support. I suppose new QNX 6.3 will have the hardware alpha support, so when it will be done, I'll add alpha support.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 14 Feb 2004 20:22:21 +0000
parents b8d311d90021
children 4bc7e16a13ed
comparison
equal deleted inserted replaced
820:0b9b4bf3c1e7 821:30168104389f
66 66
67 static int phstatus=-1; 67 static int phstatus=-1;
68 68
69 static int ph_Available(void) 69 static int ph_Available(void)
70 { 70 {
71 if (phstatus==-1) 71 if (phstatus!=0)
72 { 72 {
73 phstatus=PtInit(NULL); 73 phstatus=PtInit(NULL);
74 if (phstatus==0) 74 if (phstatus==0)
75 { 75 {
76 return 1; 76 return 1;
114 device->UpdateMouse = ph_UpdateMouse; 114 device->UpdateMouse = ph_UpdateMouse;
115 device->SetColors = ph_SetColors; 115 device->SetColors = ph_SetColors;
116 device->UpdateRects = NULL; /* set up in ph_SetupUpdateFunction */ 116 device->UpdateRects = NULL; /* set up in ph_SetupUpdateFunction */
117 device->VideoQuit = ph_VideoQuit; 117 device->VideoQuit = ph_VideoQuit;
118 device->AllocHWSurface = ph_AllocHWSurface; 118 device->AllocHWSurface = ph_AllocHWSurface;
119 device->CheckHWBlit = NULL; 119 device->CheckHWBlit = ph_CheckHWBlit;
120 device->FillHWRect = NULL; 120 device->FillHWRect = ph_FillHWRect;
121 device->SetHWColorKey = NULL; 121 device->SetHWColorKey = ph_SetHWColorKey;
122 device->SetHWAlpha = NULL; 122 device->SetHWAlpha = ph_SetHWAlpha;
123 device->LockHWSurface = ph_LockHWSurface; 123 device->LockHWSurface = ph_LockHWSurface;
124 device->UnlockHWSurface = ph_UnlockHWSurface; 124 device->UnlockHWSurface = ph_UnlockHWSurface;
125 device->FlipHWSurface = ph_FlipHWSurface; 125 device->FlipHWSurface = ph_FlipHWSurface;
126 device->FreeHWSurface = ph_FreeHWSurface; 126 device->FreeHWSurface = ph_FreeHWSurface;
127 device->SetCaption = ph_SetCaption; 127 device->SetCaption = ph_SetCaption;
252 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH); 252 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
253 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY); 253 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
254 } 254 }
255 else 255 else
256 { 256 {
257 if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE)
258 {
259 PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
260 }
261 else
262 {
263 PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
264 }
257 if (!currently_maximized) 265 if (!currently_maximized)
258 { 266 {
259 windowpos = getenv("SDL_VIDEO_WINDOW_POS"); 267 windowpos = getenv("SDL_VIDEO_WINDOW_POS");
260 iscentered = getenv("SDL_VIDEO_CENTERED"); 268 iscentered = getenv("SDL_VIDEO_CENTERED");
261 269
291 } 299 }
292 } 300 }
293 } 301 }
294 } 302 }
295 303
296 PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
297
298 /* if window is maximized render it as maximized */ 304 /* if window is maximized render it as maximized */
299 if (currently_maximized) 305 if (currently_maximized)
300 { 306 {
301 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX); 307 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX);
302 } 308 }
309 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY); 315 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
310 316
311 /* bring the focus to the window */ 317 /* bring the focus to the window */
312 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS); 318 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS);
313 319
314 /* allow to catch hide events */ 320 /* allow to catch hide event */
315 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE); 321 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
316 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE); 322 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
317 } 323 }
318 324
319 PtSetResources(window, nargs, args); 325 PtSetResources(window, nargs, args);
320 PtRealizeWidget(window); 326 PtRealizeWidget(window);
321 PtWindowToFront(window); 327 PtWindowToFront(window);
328
329 #if 0 /* FIXME */
330 PtGetResource(window, Pt_ARG_POS, &olddim, 0);
331 fprintf(stderr, "POSITION: %d, %d\n", olddim->w, olddim->h);
332 #endif
322 333
323 return 0; 334 return 0;
324 } 335 }
325 336
326 static const struct ColourMasks* ph_GetColourMasks(int bpp) 337 static const struct ColourMasks* ph_GetColourMasks(int bpp)
348 return &phColorMasks[4]; 359 return &phColorMasks[4];
349 } 360 }
350 return NULL; 361 return NULL;
351 } 362 }
352 363
353 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat) 364 static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat)
354 { 365 {
355 PgHWCaps_t my_hwcaps; 366 PgHWCaps_t hwcaps;
356 int i; 367 int i;
357 368
358 window=NULL; 369 window=NULL;
359 desktoppal=SDLPH_PAL_NONE; 370 desktoppal=SDLPH_PAL_NONE;
360 371
389 if (SDL_BlankCursor == NULL) 400 if (SDL_BlankCursor == NULL)
390 { 401 {
391 return -1; 402 return -1;
392 } 403 }
393 404
394 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0) 405 if (PgGetGraphicsHWCaps(&hwcaps) < 0)
395 { 406 {
396 SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n"); 407 SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n");
397 this->FreeWMCursor(this, SDL_BlankCursor); 408 this->FreeWMCursor(this, SDL_BlankCursor);
398 return -1; 409 return -1;
399 } 410 }
400 411
401 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &desktop_mode) < 0) 412 if (PgGetVideoModeInfo(hwcaps.current_video_mode, &desktop_mode) < 0)
402 { 413 {
403 SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n"); 414 SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n");
404 this->FreeWMCursor(this, SDL_BlankCursor); 415 this->FreeWMCursor(this, SDL_BlankCursor);
405 return -1; 416 return -1;
406 } 417 }
435 OCImage.offscreen_backcontext = NULL; 446 OCImage.offscreen_backcontext = NULL;
436 OCImage.oldDC = NULL; 447 OCImage.oldDC = NULL;
437 OCImage.CurrentFrameData = NULL; 448 OCImage.CurrentFrameData = NULL;
438 OCImage.FrameData0 = NULL; 449 OCImage.FrameData0 = NULL;
439 OCImage.FrameData1 = NULL; 450 OCImage.FrameData1 = NULL;
451 videomode_emulatemode = 0;
440 452
453 this->info.video_mem=hwcaps.currently_available_video_ram/1024;
441 this->info.wm_available = 1; 454 this->info.wm_available = 1;
455 this->info.hw_available = 1;
456 this->info.blit_fill = 1;
457 this->info.blit_hw = 1;
458 this->info.blit_hw_A = 0;
459 this->info.blit_hw_CC = 1;
442 460
443 return 0; 461 return 0;
444 } 462 }
445 463
446 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, 464 static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
447 int width, int height, int bpp, Uint32 flags) 465 {
448 { 466 PgHWCaps_t hwcaps;
449 const struct ColourMasks* mask; 467 const struct ColourMasks* mask;
450 468
451 /* Lock the event thread, in multi-threading environments */ 469 /* Lock the event thread, in multi-threading environments */
452 SDL_Lock_EventThread(); 470 SDL_Lock_EventThread();
453 471
472 { 490 {
473 SDL_SetError("ph_SetVideoMode(): desired bpp is not supported by photon !\n"); 491 SDL_SetError("ph_SetVideoMode(): desired bpp is not supported by photon !\n");
474 return NULL; 492 return NULL;
475 } 493 }
476 494
477 #ifdef HAVE_OPENGL
478 if ((current->flags & SDL_OPENGL)==SDL_OPENGL) 495 if ((current->flags & SDL_OPENGL)==SDL_OPENGL)
479 { 496 {
480 #else 497 #if !defined(HAVE_OPENGL)
481 if ((current->flags & SDL_OPENGL)==SDL_OPENGL) /* if no built-in OpenGL support */ 498 if ((current->flags & SDL_OPENGL)==SDL_OPENGL)
482 { 499 {
483 SDL_SetError("ph_SetVideoMode(): no OpenGL support, try to recompile library.\n"); 500 /* if no built-in OpenGL support */
501 SDL_SetError("ph_SetVideoMode(): no OpenGL support, you need to recompile SDL.\n");
484 current->flags &= ~SDL_OPENGL; 502 current->flags &= ~SDL_OPENGL;
485 return NULL; 503 return NULL;
486 #endif /* HAVE_OPENGL */ 504 #endif /* HAVE_OPENGL */
487 } 505 }
488 else 506 else
498 current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */ 516 current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */
499 current->flags |= SDL_HWSURFACE; 517 current->flags |= SDL_HWSURFACE;
500 } 518 }
501 else 519 else
502 { 520 {
503 /* remove this if we'll support non-fullscreen sw/hw+doublebuf */ 521 /* remove this if we'll have support for the non-fullscreen sw/hw+doublebuf one day */
504 current->flags &= ~SDL_DOUBLEBUF; 522 current->flags &= ~SDL_DOUBLEBUF;
505 523
506 /* Use offscreen memory if SDL_HWSURFACE flag is set */ 524 /* Use offscreen memory if SDL_HWSURFACE flag is set */
507 if ((current->flags & SDL_HWSURFACE) == SDL_HWSURFACE) 525 if ((current->flags & SDL_HWSURFACE) == SDL_HWSURFACE)
508 { 526 {
509
510 if (desktopbpp!=bpp) 527 if (desktopbpp!=bpp)
511 { 528 {
512 current->flags &= ~SDL_HWSURFACE; 529 current->flags &= ~SDL_HWSURFACE;
513 } 530 }
514 } 531 }
554 else 571 else
555 { 572 {
556 PgFlush(); 573 PgFlush();
557 } 574 }
558 575
576 visualbpp=bpp;
577
578 if (PgGetGraphicsHWCaps(&hwcaps) < 0)
579 {
580 SDL_SetError("ph_SetVideoMode(): GetGraphicsHWCaps function failed !\n");
581 return NULL;
582 }
583 this->info.video_mem=hwcaps.currently_available_video_ram/1024;
584
559 SDL_Unlock_EventThread(); 585 SDL_Unlock_EventThread();
560 586
561 /* We're done! */ 587 /* We've done! */
562 return (current); 588 return (current);
563 } 589 }
564 590
565 static void ph_VideoQuit(_THIS) 591 static void ph_VideoQuit(_THIS)
566 { 592 {