Changes since SDL 1.2.0 release

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402
This commit is contained in:
Sam Lantinga 2001-04-26 16:50:19 +00:00
parent 2f110628a7
commit 9b6cc5a90d
40 changed files with 1225 additions and 105 deletions

View file

@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libvideo.la
# Define which subdirectories need to be built
SUBDIRS = @VIDEO_SUBDIRS@
DIST_SUBDIRS = x11 dga fbcon svga ggi aalib \
DIST_SUBDIRS = dummy x11 dga fbcon svga ggi aalib \
wincommon windib windx5 \
maccommon macdsp macrom bwindow photon cybergfx

View file

@ -109,12 +109,21 @@ static char rcsid =
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#define PIXEL_COPY(to, from, len, bpp) \
do { \
if(bpp == 4) { \
SDL_memcpy4(to, from, (unsigned)(len)); \
} else { \
SDL_memcpy(to, from, (unsigned)(len) * (bpp)); \
} \
} while(0)
/*
* Various colorkey blit methods, for opaque and per-surface alpha
*/
#define OPAQUE_BLIT(to, from, length, bpp, alpha) \
SDL_memcpy(to, from, (unsigned)(length * bpp))
PIXEL_COPY(to, from, length, bpp)
/*
* For 32bpp pixels on the form 0x00rrggbb:
@ -657,9 +666,9 @@ static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *dst,
if(crun > right - cofs) \
crun = right - cofs; \
if(crun > 0) \
SDL_memcpy(dstbuf + cofs * sizeof(Ptype), \
PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \
srcbuf + (cofs - ofs) * sizeof(Ptype), \
(unsigned)crun * sizeof(Ptype)); \
(unsigned)crun, sizeof(Ptype)); \
srcbuf += run * sizeof(Ptype); \
ofs += run; \
} else if(!ofs) \
@ -816,8 +825,8 @@ int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect,
run = ((Ctype *)srcbuf)[1]; \
srcbuf += 2 * sizeof(Ctype); \
if(run) { \
SDL_memcpy(dstbuf + ofs * sizeof(Ptype), srcbuf, \
run * sizeof(Ptype)); \
PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \
run, sizeof(Ptype)); \
srcbuf += run * sizeof(Ptype); \
ofs += run; \
} else if(!ofs) \

View file

@ -195,8 +195,8 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
}
}
/* fast RGB888->(A)RGB888 blending with surface alpha */
static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
/* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
@ -204,32 +204,58 @@ static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
int srcskip = info->s_skip >> 2;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip >> 2;
SDL_PixelFormat *srcfmt = info->src;
unsigned alpha = srcfmt->alpha;
while(height--) {
DUFFS_LOOP4({
Uint32 s;
Uint32 d;
Uint32 s1;
Uint32 d1;
s = *srcp;
d = *dstp;
s1 = s & 0xff00ff;
d1 = d & 0xff00ff;
d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
s &= 0xff00;
d &= 0xff00;
d = (d + ((s - d) * alpha >> 8)) & 0xff00;
*dstp = d1 | d | 0xff000000;
++srcp;
++dstp;
Uint32 s = *srcp++;
Uint32 d = *dstp;
*dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
+ (s & d & 0x00010101)) | 0xff000000;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
/* fast RGB888->(A)RGB888 blending with surface alpha */
static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
{
unsigned alpha = info->src->alpha;
if(alpha == 128) {
BlitRGBtoRGBSurfaceAlpha128(info);
} else {
int width = info->d_width;
int height = info->d_height;
Uint32 *srcp = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip >> 2;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip >> 2;
while(height--) {
DUFFS_LOOP4({
Uint32 s;
Uint32 d;
Uint32 s1;
Uint32 d1;
s = *srcp;
d = *dstp;
s1 = s & 0xff00ff;
d1 = d & 0xff00ff;
d1 = (d1 + ((s1 - d1) * alpha >> 8))
& 0xff00ff;
s &= 0xff00;
d &= 0xff00;
d = (d + ((s - d) * alpha >> 8)) & 0xff00;
*dstp = d1 | d | 0xff000000;
++srcp;
++dstp;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast ARGB888->(A)RGB888 blending with pixel alpha */
static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
{
@ -277,8 +303,18 @@ static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
}
}
/* fast RGB565->RGB565 blending with surface alpha */
static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
/* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */
/* blend a single 16 bit pixel at 50% */
#define BLEND16_50(d, s, mask) \
((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff)))
/* blend two 16 bit pixels at 50% */
#define BLEND2x16_50(d, s, mask) \
(((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \
+ (s & d & (~(mask | mask << 16))))
static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
{
int width = info->d_width;
int height = info->d_height;
@ -286,56 +322,163 @@ static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
unsigned alpha = info->src->alpha >> 3; /* downscale alpha to 5 bits */
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
* shift out the middle component (green) to the high 16
* bits, and process all three RGB components at the same
* time.
*/
s = (s | s << 16) & 0x07e0f81f;
d = (d | d << 16) & 0x07e0f81f;
d += (s - d) * alpha >> 5;
d &= 0x07e0f81f;
*dstp++ = d | d >> 16;
}, width);
srcp += srcskip;
dstp += dstskip;
if(((unsigned long)srcp ^ (unsigned long)dstp) & 2) {
/*
* Source and destination not aligned, pipeline it.
* This is mostly a win for big blits but no loss for
* small ones
*/
Uint32 prev_sw;
int w = width;
/* handle odd destination */
if((unsigned long)dstp & 2) {
Uint16 d = *dstp, s = *srcp;
*dstp = BLEND16_50(d, s, mask);
dstp++;
srcp++;
w--;
}
srcp++; /* srcp is now 32-bit aligned */
/* bootstrap pipeline with first halfword */
prev_sw = ((Uint32 *)srcp)[-1];
while(w > 1) {
Uint32 sw, dw, s;
sw = *(Uint32 *)srcp;
dw = *(Uint32 *)dstp;
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
s = (prev_sw << 16) + (sw >> 16);
else
s = (prev_sw >> 16) + (sw << 16);
prev_sw = sw;
*(Uint32 *)dstp = BLEND2x16_50(dw, s, mask);
dstp += 2;
srcp += 2;
w -= 2;
}
/* final pixel if any */
if(w) {
Uint16 d = *dstp, s;
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
s = prev_sw;
else
s = prev_sw >> 16;
*dstp = BLEND16_50(d, s, mask);
srcp++;
dstp++;
}
srcp += srcskip - 1;
dstp += dstskip;
} else {
/* source and destination are aligned */
int w = width;
/* first odd pixel? */
if((unsigned long)srcp & 2) {
Uint16 d = *dstp, s = *srcp;
*dstp = BLEND16_50(d, s, mask);
srcp++;
dstp++;
w--;
}
/* srcp and dstp are now 32-bit aligned */
while(w > 1) {
Uint32 sw = *(Uint32 *)srcp;
Uint32 dw = *(Uint32 *)dstp;
*(Uint32 *)dstp = BLEND2x16_50(dw, sw, mask);
srcp += 2;
dstp += 2;
w -= 2;
}
/* last odd pixel? */
if(w) {
Uint16 d = *dstp, s = *srcp;
*dstp = BLEND16_50(d, s, mask);
srcp++;
dstp++;
}
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast RGB565->RGB565 blending with surface alpha */
static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
{
unsigned alpha = info->src->alpha;
if(alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xf7de);
} else {
int width = info->d_width;
int height = info->d_height;
Uint16 *srcp = (Uint16 *)info->s_pixels;
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
alpha >>= 3; /* downscale alpha to 5 bits */
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
* shift out the middle component (green) to
* the high 16 bits, and process all three RGB
* components at the same time.
*/
s = (s | s << 16) & 0x07e0f81f;
d = (d | d << 16) & 0x07e0f81f;
d += (s - d) * alpha >> 5;
d &= 0x07e0f81f;
*dstp++ = d | d >> 16;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast RGB555->RGB555 blending with surface alpha */
static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint16 *srcp = (Uint16 *)info->s_pixels;
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
unsigned alpha = info->src->alpha >> 3; /* downscale alpha to 5 bits */
unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */
if(alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xfbde);
} else {
int width = info->d_width;
int height = info->d_height;
Uint16 *srcp = (Uint16 *)info->s_pixels;
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
alpha >>= 3; /* downscale alpha to 5 bits */
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
* shift out the middle component (green) to the high 16
* bits, and process all three RGB components at the same
* time.
*/
s = (s | s << 16) & 0x03e07c1f;
d = (d | d << 16) & 0x03e07c1f;
d += (s - d) * alpha >> 5;
d &= 0x03e07c1f;
*dstp++ = d | d >> 16;
}, width);
srcp += srcskip;
dstp += dstskip;
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
* shift out the middle component (green) to
* the high 16 bits, and process all three RGB
* components at the same time.
*/
s = (s | s << 16) & 0x03e07c1f;
d = (d | d << 16) & 0x03e07c1f;
d += (s - d) * alpha >> 5;
d &= 0x03e07c1f;
*dstp++ = d | d >> 16;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
}

View file

@ -723,7 +723,9 @@ void SDL_EraseCursor(SDL_Surface *screen)
SDL_Rect area;
SDL_MouseRect(&area);
video->UpdateRects(this, 1, &area);
if ( video->UpdateRects ) {
video->UpdateRects(this, 1, &area);
}
}
}

View file

@ -53,6 +53,17 @@ do { \
: "memory" ); \
} while(0)
#define SDL_memcpy4(dst, src, len) \
do { \
int ecx, edi, esi; \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep ; movsl" \
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \
: "memory" ); \
} while(0)
#define SDL_revcpy(dst, src, len) \
do { \
int u0, u1, u2; \
@ -104,9 +115,15 @@ do { \
#ifndef SDL_memcpy
#define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
#endif
#ifndef SDL_memcpy4
#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len) << 2)
#endif
#ifndef SDL_revcpy
#define SDL_revcpy(dst, src, len) memmove(dst, src, len)
#endif
#ifndef SDL_memset4
#define SDL_memset4(dst, val, len) \
do { \

View file

@ -355,6 +355,9 @@ extern VideoBootStrap DIRECTX_bootstrap;
#ifdef ENABLE_BWINDOW
extern VideoBootStrap BWINDOW_bootstrap;
#endif
#ifdef ENABLE_DUMMYVIDEO
extern VideoBootStrap DUMMY_bootstrap;
#endif
/* MacOS X gets the proper defines from configure */
#if defined(macintosh) && !defined(MACOSX)
#define ENABLE_TOOLBOX

View file

@ -83,6 +83,9 @@ static VideoBootStrap *bootstrap[] = {
#endif
#ifdef ENABLE_CYBERGRAPHICS
&CGX_bootstrap,
#endif
#ifdef ENABLE_DUMMYVIDEO
&DUMMY_bootstrap,
#endif
NULL
};

View file

@ -50,6 +50,10 @@ public:
xoff = x;
yoff = y;
}
virtual void GetXYOffset(int &x, int &y) {
x = xoff;
y = yoff;
}
/* The view changed size. If it means we're in fullscreen, we
* draw a nice black box in the entire view to get black borders.
*/

View file

@ -156,6 +156,16 @@ public:
#endif
SDL_View->SetXYOffset(x, y);
}
virtual void GetXYOffset(int &x, int &y) {
#ifdef HAVE_OPENGL
if ( the_view == SDL_GLView ) {
x = 0;
y = 0;
return;
}
#endif
SDL_View->GetXYOffset(x, y);
}
virtual bool BeginDraw(void) {
return(Lock());
}

View file

@ -262,7 +262,12 @@ void BE_PumpEvents(_THIS)
/* Check for mouse motion */
if ( point != last_point ) {
SDL_PrivateMouseMotion(0, 0, (int)point.x, (int)point.y);
int x, y;
SDL_Win->GetXYOffset(x, y);
x = (int)point.x - x;
y = (int)point.y - y;
SDL_PrivateMouseMotion(0, 0, x, y);
}
last_point = point;

View file

@ -0,0 +1,15 @@
## Makefile.am for SDL using the null video driver
noinst_LTLIBRARIES = libvideo_null.la
libvideo_null_la_SOURCES = $(NULL_SRCS)
# The SDL null video driver sources
NULL_SRCS = \
SDL_nullvideo.h \
SDL_nullevents.c \
SDL_nullevents_c.h \
SDL_nullmouse.c \
SDL_nullmouse_c.h \
SDL_nullvideo.c

View file

@ -0,0 +1,48 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/* Being a null driver, there's no event stream. We just define stubs for
most of the API. */
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "SDL_nullvideo.h"
#include "SDL_nullevents_c.h"
void DUMMY_PumpEvents(_THIS)
{
/* do nothing. */
}
void DUMMY_InitOSKeymap(_THIS)
{
/* do nothing. */
}
/* end of SDL_nullevents.c ... */

View file

@ -0,0 +1,37 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#include "SDL_nullvideo.h"
/* Variables and functions exported by SDL_sysevents.c to other parts
of the native video subsystem (SDL_sysvideo.c)
*/
extern void DUMMY_InitOSKeymap(_THIS);
extern void DUMMY_PumpEvents(_THIS);
/* end of SDL_nullevents_c.h ... */

View file

@ -0,0 +1,40 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#include <stdio.h>
#include "SDL_error.h"
#include "SDL_mouse.h"
#include "SDL_events_c.h"
#include "SDL_nullmouse_c.h"
/* The implementation dependent data for the window manager cursor */
struct WMcursor {
int unused;
};

View file

@ -0,0 +1,30 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#include "SDL_nullvideo.h"
/* Functions to be exported */

View file

@ -0,0 +1,245 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/* Dummy SDL video driver implementation; this is just enough to make an
* SDL-based application THINK it's got a working video driver, for
* applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
* and also for use as a collection of stubs when porting SDL to a new
* platform for which you haven't yet written a valid video driver.
*
* This is also a great way to determine bottlenecks: if you think that SDL
* is a performance problem for a given platform, enable this driver, and
* then see if your application runs faster without video overhead.
*
* Initial work by Ryan C. Gordon (icculus@linuxgames.com). A good portion
* of this was cut-and-pasted from Stephane Peter's work in the AAlib
* SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
*/
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
#include "SDL_pixels_c.h"
#include "SDL_events_c.h"
#include "SDL_nullvideo.h"
#include "SDL_nullevents_c.h"
#include "SDL_nullmouse_c.h"
/* Initialization/Query functions */
static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat);
static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
static void DUMMY_VideoQuit(_THIS);
/* Hardware surface functions */
static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface);
static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface);
static int DUMMY_FlipHWSurface(_THIS, SDL_Surface *surface);
static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface);
static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface);
/* etc. */
static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
/* DUMMY driver bootstrap functions */
static int DUMMY_Available(void)
{
return 1; /* Always available ! */
}
static void DUMMY_DeleteDevice(SDL_VideoDevice *device)
{
free(device->hidden);
free(device);
}
static SDL_VideoDevice *DUMMY_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
if ( device ) {
memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *)
malloc((sizeof *device->hidden));
}
if ( (device == NULL) || (device->hidden == NULL) ) {
SDL_OutOfMemory();
if ( device ) {
free(device);
}
return(0);
}
memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the function pointers */
device->VideoInit = DUMMY_VideoInit;
device->ListModes = DUMMY_ListModes;
device->SetVideoMode = DUMMY_SetVideoMode;
device->CreateYUVOverlay = NULL;
device->SetColors = DUMMY_SetColors;
device->UpdateRects = DUMMY_UpdateRects;
device->VideoQuit = DUMMY_VideoQuit;
device->AllocHWSurface = DUMMY_AllocHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->LockHWSurface = DUMMY_LockHWSurface;
device->UnlockHWSurface = DUMMY_UnlockHWSurface;
device->FlipHWSurface = NULL;
device->FreeHWSurface = DUMMY_FreeHWSurface;
device->SetCaption = NULL;
device->SetIcon = NULL;
device->IconifyWindow = NULL;
device->GrabInput = NULL;
device->GetWMInfo = NULL;
device->InitOSKeymap = DUMMY_InitOSKeymap;
device->PumpEvents = DUMMY_PumpEvents;
device->free = DUMMY_DeleteDevice;
return device;
}
VideoBootStrap DUMMY_bootstrap = {
"dummy", "SDL dummy video driver",
DUMMY_Available, DUMMY_CreateDevice
};
int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n");
/* Determine the screen depth (use default 8-bit depth) */
/* we change this during the SDL_SetVideoMode implementation... */
vformat->BitsPerPixel = 8;
vformat->BytesPerPixel = 1;
/* We're done! */
return(0);
}
SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
{
return (SDL_Rect **) -1;
}
SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current,
int width, int height, int bpp, Uint32 flags)
{
if ( this->hidden->buffer ) {
free( this->hidden->buffer );
}
this->hidden->buffer = malloc(width * height * (bpp / 8));
if ( ! this->hidden->buffer ) {
SDL_SetError("Couldn't allocate buffer for requested mode");
return(NULL);
}
/* printf("Setting mode %dx%d\n", width, height); */
memset(this->hidden->buffer, 0, width * height * (bpp / 8));
/* Allocate the new pixel format for the screen */
if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
free(this->hidden->buffer);
this->hidden->buffer = NULL;
SDL_SetError("Couldn't allocate new pixel format for requested mode");
return(NULL);
}
/* Set up the new mode framebuffer */
current->flags = flags & SDL_FULLSCREEN;
this->hidden->w = current->w = width;
this->hidden->h = current->h = height;
current->pitch = current->w * (bpp / 8);
current->pixels = this->hidden->buffer;
/* We're done */
return(current);
}
/* We don't actually allow hardware surfaces other than the main one */
static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface)
{
return(-1);
}
static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface)
{
return;
}
/* We need to wait for vertical retrace on page flipped displays */
static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface)
{
return(0);
}
static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface)
{
return;
}
static int DUMMY_FlipHWSurface(_THIS, SDL_Surface *surface)
{
return(0);
}
static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
{
/* do nothing. */
}
int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
/* do nothing of note. */
return(1);
}
/* Note: If we are terminated, this could be called in the middle of
another SDL video routine -- notably UpdateRects.
*/
void DUMMY_VideoQuit(_THIS)
{
if (this->screen->pixels != NULL)
{
free(this->screen->pixels);
this->screen->pixels = NULL;
}
}

View file

@ -0,0 +1,46 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#ifndef _SDL_nullvideo_h
#define _SDL_nullvideo_h
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
#include "SDL_mutex.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
/* Private display data */
struct SDL_PrivateVideoData {
int w, h;
void *buffer;
};
#endif /* _SDL_nullvideo_h */

View file

@ -370,6 +370,10 @@ SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current,
/* Set up the new mode framebuffer */
current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
if ( bpp == 8 ) {
/* FIXME: What about DirectColor? */
current->flags |= SDL_HWPALETTE;
}
current->w = width;
current->h = height;
current->pitch = modeinfo->linewidth;

View file

@ -134,10 +134,10 @@ static void WIN_GetKeyboardState(void)
if ( keyboard[VK_RMENU] & 0x80) {
state |= KMOD_RALT;
}
if ( keyboard[VK_NUMLOCK] & 0x80) {
if ( keyboard[VK_NUMLOCK] & 0x01) {
state |= KMOD_NUM;
}
if ( keyboard[VK_CAPITAL] & 0x80) {
if ( keyboard[VK_CAPITAL] & 0x01) {
state |= KMOD_CAPS;
}
}

View file

@ -1684,6 +1684,7 @@ static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface)
return(DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE));
}
#ifdef DDRAW_DEBUG
void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags)
{
DDSURFACEDESC ddsd;
@ -1717,6 +1718,7 @@ void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags)
ddsd.ddpfPixelFormat.dwBBitMask);
#endif
}
#endif /* DDRAW_DEBUG */
static int DX5_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)