comparison src/video/bwindow/SDL_sysvideo.cc @ 756:10332c6fad2e

te: Mon, 15 Dec 2003 08:25:14 -0800 PST From: "Andrew Bachmann" Subject: libSDL patches for beos video I created some patches to SDL: 1. YUV overlay support 2. maintain high refresh rate when changing resolutions to a lower resolution
author Sam Lantinga <slouken@libsdl.org>
date Tue, 16 Dec 2003 13:04:44 +0000
parents f6ffac90895c
children b8d311d90021
comparison
equal deleted inserted replaced
755:b1595db396a7 756:10332c6fad2e
45 #include "SDL_sysmouse_c.h" 45 #include "SDL_sysmouse_c.h"
46 #include "SDL_sysevents_c.h" 46 #include "SDL_sysevents_c.h"
47 #include "SDL_events_c.h" 47 #include "SDL_events_c.h"
48 #include "SDL_syswm_c.h" 48 #include "SDL_syswm_c.h"
49 #include "SDL_lowvideo.h" 49 #include "SDL_lowvideo.h"
50 #include "SDL_yuvfuncs.h"
51 #include "SDL_sysyuv.h"
50 52
51 #define BEOS_HIDDEN_SIZE 32 /* starting hidden window size */ 53 #define BEOS_HIDDEN_SIZE 32 /* starting hidden window size */
52 54
53 /* Initialization/Query functions */ 55 /* Initialization/Query functions */
54 static int BE_VideoInit(_THIS, SDL_PixelFormat *vformat); 56 static int BE_VideoInit(_THIS, SDL_PixelFormat *vformat);
63 static int BE_LockHWSurface(_THIS, SDL_Surface *surface); 65 static int BE_LockHWSurface(_THIS, SDL_Surface *surface);
64 static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface); 66 static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface);
65 static void BE_FreeHWSurface(_THIS, SDL_Surface *surface); 67 static void BE_FreeHWSurface(_THIS, SDL_Surface *surface);
66 68
67 static int BE_ToggleFullScreen(_THIS, int fullscreen); 69 static int BE_ToggleFullScreen(_THIS, int fullscreen);
70 static SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
68 71
69 /* OpenGL functions */ 72 /* OpenGL functions */
70 #ifdef HAVE_OPENGL 73 #ifdef HAVE_OPENGL
71 static void BE_GL_SwapBuffers(_THIS); 74 static void BE_GL_SwapBuffers(_THIS);
72 #endif 75 #endif
134 device->InitOSKeymap = BE_InitOSKeymap; 137 device->InitOSKeymap = BE_InitOSKeymap;
135 device->PumpEvents = BE_PumpEvents; 138 device->PumpEvents = BE_PumpEvents;
136 139
137 device->free = BE_DeleteDevice; 140 device->free = BE_DeleteDevice;
138 device->ToggleFullScreen = BE_ToggleFullScreen; 141 device->ToggleFullScreen = BE_ToggleFullScreen;
142 device->CreateYUVOverlay = BE_CreateYUVOverlay;
139 143
140 /* Set the driver flags */ 144 /* Set the driver flags */
141 device->handles_any_size = 1; 145 device->handles_any_size = 1;
142 146
143 return device; 147 return device;
328 { 332 {
329 BScreen bscreen; 333 BScreen bscreen;
330 uint32 i, nmodes; 334 uint32 i, nmodes;
331 SDL_Rect **modes; 335 SDL_Rect **modes;
332 display_mode *dmodes; 336 display_mode *dmodes;
337 display_mode current;
338 float current_refresh;
339 bscreen.GetMode(&current);
340 current_refresh = (1000 * current.timing.pixel_clock) /
341 (current.timing.h_total * current.timing.v_total);
333 342
334 modes = SDL_modelist[((bpp+7)/8)-1]; 343 modes = SDL_modelist[((bpp+7)/8)-1];
335 for ( i=0; modes[i] && (modes[i]->w > width) && 344 for ( i=0; modes[i] && (modes[i]->w > width) &&
336 (modes[i]->h > height); ++i ) { 345 (modes[i]->h > height); ++i ) {
337 /* still looking */ 346 /* still looking */
349 break; 358 break;
350 } 359 }
351 } 360 }
352 if ( i != nmodes ) { 361 if ( i != nmodes ) {
353 *mode = dmodes[i]; 362 *mode = dmodes[i];
363 if ((mode->virtual_width <= current.virtual_width) &&
364 (mode->virtual_height <= current.virtual_height)) {
365 float new_refresh = (1000 * mode->timing.pixel_clock) /
366 (mode->timing.h_total * mode->timing.v_total);
367 if (new_refresh < current_refresh) {
368 mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total)
369 * current_refresh / 1000);
370 }
371 }
354 return true; 372 return true;
355 } else { 373 } else {
356 return false; 374 return false;
357 } 375 }
358 } 376 }