Skip to content

Commit

Permalink
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slouken committed Dec 16, 2003
1 parent 449da93 commit d4ab227
Show file tree
Hide file tree
Showing 6 changed files with 430 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/video/bwindow/Makefile.am
Expand Up @@ -15,5 +15,7 @@ BWINDOW_SRCS = \
SDL_sysmouse_c.h \
SDL_sysvideo.cc \
SDL_syswm.cc \
SDL_syswm_c.h
SDL_syswm_c.h \
SDL_sysyuv.cc \
SDL_sysyuv.h

5 changes: 5 additions & 0 deletions src/video/bwindow/SDL_BView.h
Expand Up @@ -20,6 +20,9 @@
slouken@libsdl.org
*/

#ifndef _SDL_BView_h
#define _SDL_BView_h

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
Expand Down Expand Up @@ -109,3 +112,5 @@ class SDL_BView : public BView
BBitmap *image;
int xoff, yoff;
};

#endif /* _SDL_BView_h */
4 changes: 4 additions & 0 deletions src/video/bwindow/SDL_lowvideo.h
Expand Up @@ -28,6 +28,7 @@ static char rcsid =
#ifndef _SDL_lowvideo_h
#define _SDL_lowvideo_h

#include "SDL_BWin.h"
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"

Expand Down Expand Up @@ -55,6 +56,8 @@ struct SDL_PrivateVideoData {
/* Keyboard state variables */
int key_flip;
struct key_info keyinfo[2];

SDL_Overlay *overlay;
};
/* Old variable names */
#define SDL_Win (_this->hidden->SDL_Win)
Expand All @@ -66,5 +69,6 @@ struct SDL_PrivateVideoData {
#define last_point (_this->hidden->last_point)
#define key_flip (_this->hidden->key_flip)
#define keyinfo (_this->hidden->keyinfo)
#define current_overlay (_this->hidden->overlay)

#endif /* _SDL_lowvideo_h */
18 changes: 18 additions & 0 deletions src/video/bwindow/SDL_sysvideo.cc
Expand Up @@ -47,6 +47,8 @@ extern "C" {
#include "SDL_events_c.h"
#include "SDL_syswm_c.h"
#include "SDL_lowvideo.h"
#include "SDL_yuvfuncs.h"
#include "SDL_sysyuv.h"

#define BEOS_HIDDEN_SIZE 32 /* starting hidden window size */

Expand All @@ -65,6 +67,7 @@ static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface);
static void BE_FreeHWSurface(_THIS, SDL_Surface *surface);

static int BE_ToggleFullScreen(_THIS, int fullscreen);
static SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);

/* OpenGL functions */
#ifdef HAVE_OPENGL
Expand Down Expand Up @@ -136,6 +139,7 @@ static SDL_VideoDevice *BE_CreateDevice(int devindex)

device->free = BE_DeleteDevice;
device->ToggleFullScreen = BE_ToggleFullScreen;
device->CreateYUVOverlay = BE_CreateYUVOverlay;

/* Set the driver flags */
device->handles_any_size = 1;
Expand Down Expand Up @@ -330,6 +334,11 @@ static bool BE_FindClosestFSMode(_THIS, int width, int height, int bpp,
uint32 i, nmodes;
SDL_Rect **modes;
display_mode *dmodes;
display_mode current;
float current_refresh;
bscreen.GetMode(&current);
current_refresh = (1000 * current.timing.pixel_clock) /
(current.timing.h_total * current.timing.v_total);

modes = SDL_modelist[((bpp+7)/8)-1];
for ( i=0; modes[i] && (modes[i]->w > width) &&
Expand All @@ -351,6 +360,15 @@ static bool BE_FindClosestFSMode(_THIS, int width, int height, int bpp,
}
if ( i != nmodes ) {
*mode = dmodes[i];
if ((mode->virtual_width <= current.virtual_width) &&
(mode->virtual_height <= current.virtual_height)) {
float new_refresh = (1000 * mode->timing.pixel_clock) /
(mode->timing.h_total * mode->timing.v_total);
if (new_refresh < current_refresh) {
mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total)
* current_refresh / 1000);
}
}
return true;
} else {
return false;
Expand Down

0 comments on commit d4ab227

Please sign in to comment.