Add workaround for corrupted surface on exposure event.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2519
This commit is contained in:
parent
6c7c289c62
commit
af25c4382d
3 changed files with 28 additions and 19 deletions
|
@ -19,7 +19,13 @@
|
|||
#ifndef DOSBOX_VIDEO_H
|
||||
#define DOSBOX_VIDEO_H
|
||||
|
||||
typedef void (* GFX_ResetCallBack)( bool stopIt );
|
||||
typedef enum {
|
||||
GFX_CallBackReset,
|
||||
GFX_CallBackStop,
|
||||
GFX_CallBackRedraw,
|
||||
} GFX_CallBackFunctions_t;
|
||||
|
||||
typedef void (*GFX_CallBack_t)( GFX_CallBackFunctions_t function );
|
||||
|
||||
struct GFX_PalEntry {
|
||||
Bit8u r;
|
||||
|
@ -49,7 +55,7 @@ void GFX_Events(void);
|
|||
void GFX_SetPalette(Bitu start,Bitu count,GFX_PalEntry * entries);
|
||||
Bitu GFX_GetBestMode(Bitu flags);
|
||||
Bitu GFX_GetRGB(Bit8u red,Bit8u green,Bit8u blue);
|
||||
Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_ResetCallBack cb_reset);
|
||||
Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_CallBack_t cb);
|
||||
|
||||
void GFX_ResetScreen(void);
|
||||
void GFX_Start(void);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: render.cpp,v 1.42 2006-02-13 08:22:17 harekiet Exp $ */
|
||||
/* $Id: render.cpp,v 1.43 2006-02-26 16:04:35 qbix79 Exp $ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
@ -183,14 +183,20 @@ static Bitu MakeAspectTable(Bitu height,double scaley,Bitu miny) {
|
|||
return linesadded;
|
||||
}
|
||||
|
||||
void RENDER_ReInit( bool stopIt ) {
|
||||
void RENDER_CallBack( GFX_CallBackFunctions_t function ) {
|
||||
if (render.updating) {
|
||||
/* Still updating the current screen, shut it down correctly */
|
||||
RENDER_EndUpdate( false );
|
||||
}
|
||||
|
||||
if (stopIt)
|
||||
if (function == GFX_CallBackStop)
|
||||
return;
|
||||
|
||||
if (function == GFX_CallBackRedraw) {
|
||||
//LOG_MSG("redraw");
|
||||
render.scale.clearCache = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Bitu width=render.src.width;
|
||||
Bitu height=render.src.height;
|
||||
|
@ -318,7 +324,7 @@ forcenormal:
|
|||
}
|
||||
}
|
||||
/* Setup the scaler variables */
|
||||
gfx_flags=GFX_SetSize(width,height,gfx_flags,gfx_scalew,gfx_scaleh,&RENDER_ReInit);;
|
||||
gfx_flags=GFX_SetSize(width,height,gfx_flags,gfx_scalew,gfx_scaleh,&RENDER_CallBack);
|
||||
if (gfx_flags & GFX_CAN_8)
|
||||
render.scale.outMode = scalerMode8;
|
||||
else if (gfx_flags & GFX_CAN_15)
|
||||
|
@ -397,7 +403,7 @@ void RENDER_SetSize(Bitu width,Bitu height,Bitu bpp,float fps,double ratio,bool
|
|||
render.src.dblh=dblh;
|
||||
render.src.fps=fps;
|
||||
render.src.ratio=ratio;
|
||||
RENDER_ReInit( false );
|
||||
RENDER_CallBack( GFX_CallBackReset );
|
||||
}
|
||||
|
||||
extern void GFX_SetTitle(Bits cycles, Bits frameskip,bool paused);
|
||||
|
@ -457,7 +463,7 @@ void RENDER_Init(Section * sec) {
|
|||
|
||||
//If something changed that needs a ReInit
|
||||
if(running && (render.aspect != aspect || render.scale.op != scaleOp))
|
||||
RENDER_ReInit( false );
|
||||
RENDER_CallBack( GFX_CallBackReset );
|
||||
if(!running) render.updating=true;
|
||||
running = true;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: sdlmain.cpp,v 1.107 2006-02-15 14:48:41 qbix79 Exp $ */
|
||||
/* $Id: sdlmain.cpp,v 1.108 2006-02-26 16:04:35 qbix79 Exp $ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
@ -142,14 +142,13 @@ enum PRIORITY_LEVELS {
|
|||
struct SDL_Block {
|
||||
bool active; //If this isn't set don't draw
|
||||
bool updating;
|
||||
bool exposeEvent;
|
||||
struct {
|
||||
Bit32u width;
|
||||
Bit32u height;
|
||||
Bit32u bpp;
|
||||
Bitu flags;
|
||||
double scalex,scaley;
|
||||
GFX_ResetCallBack reset;
|
||||
GFX_CallBack_t callback;
|
||||
} draw;
|
||||
bool wait_on_error;
|
||||
struct {
|
||||
|
@ -314,7 +313,7 @@ check_gotbpp:
|
|||
|
||||
void GFX_ResetScreen(void) {
|
||||
GFX_Stop();
|
||||
if (sdl.draw.reset) (sdl.draw.reset)( false );
|
||||
if (sdl.draw.callback) (sdl.draw.callback)( GFX_CallBackReset );
|
||||
GFX_Start();
|
||||
}
|
||||
|
||||
|
@ -370,13 +369,13 @@ static SDL_Surface * GFX_SetupSurfaceScaled(Bit32u sdl_flags, Bit32u bpp) {
|
|||
}
|
||||
}
|
||||
|
||||
Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_ResetCallBack reset) {
|
||||
Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_CallBack_t callback) {
|
||||
if (sdl.updating)
|
||||
GFX_EndUpdate( 0 );
|
||||
|
||||
sdl.draw.width=width;
|
||||
sdl.draw.height=height;
|
||||
sdl.draw.reset=reset;
|
||||
sdl.draw.callback=callback;
|
||||
sdl.draw.scalex=scalex;
|
||||
sdl.draw.scaley=scaley;
|
||||
|
||||
|
@ -704,7 +703,7 @@ void GFX_EndUpdate( const Bit16u *changedLines ) {
|
|||
SDL_UnlockSurface(sdl.surface);
|
||||
}
|
||||
SDL_Flip(sdl.surface);
|
||||
} else if (changedLines && !sdl.exposeEvent) {
|
||||
} else if (changedLines) {
|
||||
Bitu y = 0, index = 0, rectCount = 0;
|
||||
while (y < sdl.draw.height) {
|
||||
if (!(index & 1)) {
|
||||
|
@ -727,7 +726,6 @@ void GFX_EndUpdate( const Bit16u *changedLines ) {
|
|||
if (rectCount)
|
||||
SDL_UpdateRects( sdl.surface, rectCount, sdl.updateRects );
|
||||
} else {
|
||||
sdl.exposeEvent = false;
|
||||
SDL_Flip(sdl.surface);
|
||||
}
|
||||
break;
|
||||
|
@ -844,7 +842,7 @@ void GFX_Start() {
|
|||
|
||||
static void GUI_ShutDown(Section * sec) {
|
||||
GFX_Stop();
|
||||
if (sdl.draw.reset) (sdl.draw.reset)( true );
|
||||
if (sdl.draw.callback) (sdl.draw.callback)( GFX_CallBackStop );
|
||||
if (sdl.mouse.locked) GFX_CaptureMouse();
|
||||
if (sdl.desktop.fullscreen) GFX_SwitchFullScreen();
|
||||
}
|
||||
|
@ -1159,7 +1157,6 @@ static void HandleMouseButton(SDL_MouseButtonEvent * button) {
|
|||
static Bit8u laltstate = SDL_KEYUP;
|
||||
static Bit8u raltstate = SDL_KEYUP;
|
||||
|
||||
|
||||
void GFX_Events() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
|
@ -1200,7 +1197,7 @@ void GFX_Events() {
|
|||
throw(0);
|
||||
break;
|
||||
case SDL_VIDEOEXPOSE:
|
||||
sdl.exposeEvent = true;
|
||||
if (sdl.draw.callback) sdl.draw.callback( GFX_CallBackRedraw );
|
||||
break;
|
||||
#ifdef WIN32
|
||||
case SDL_KEYDOWN:
|
||||
|
|
Loading…
Add table
Reference in a new issue