SDL_UpdateRect now uses partial update information too; fixed "crossfades

not finished" problem; scalers now alter dimensions of passed
rectangle directly


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@750 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2003-02-14 23:03:05 +00:00
parent 59ce67a39d
commit 39b2c5abe4
9 changed files with 77 additions and 66 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.2:
- Pure mode partial screen updates are now more efficient;
fixed 'crossfades not finished' problem -Mika
- Graduated colours for crew in shipyard, from Nic
- Alien dialog fixes: Talking Pet, Utwig, Mycon, Syreen -fOSSiL
- Updated all game, menu, melee and weapon sounds to original 3DO
+44 -36
View File
@@ -286,7 +286,7 @@ Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
const int w = src->w, h = src->h, dw = dst->w;
int xend, yend;
int dsrc, ddst;
SDL_Rect region = *r;
SDL_Rect *region = r;
SDL_Rect limits;
SDL_PixelFormat *fmt = dst->format;
@@ -297,12 +297,12 @@ Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
limits.y = 0;
limits.w = src->w;
limits.h = src->h;
Scale_ExpandRect (&region, 2, &limits);
Scale_ExpandRect (region, 2, &limits);
xend = region.x + region.w;
yend = region.y + region.h;
dsrc = w - region.w;
ddst = (dw - region.w) * 2;
xend = region->x + region->w;
yend = region->y + region->h;
dsrc = w - region->w;
ddst = (dw - region->w) * 2;
switch (fmt->BytesPerPixel)
{
@@ -316,12 +316,12 @@ Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
Uint32 pixval_tl, pixval_tr, pixval_bl, pixval_br;
// move ptrs to the first updated pixel
src_p += w * region.y + region.x;
dst_p += (dw * region.y + region.x) * 2;
src_p += w * region->y + region->x;
dst_p += (dw * region->y + region->x) * 2;
for (y = region.y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
for (y = region->y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
{
for (x = region.x; x < xend; ++x, ++src_p, ++dst_p)
for (x = region->x; x < xend; ++x, ++src_p, ++dst_p)
{
pixval_tl = BIADAPT_GETPIX (src_p);
@@ -514,12 +514,12 @@ Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
Uint32 pixval_tl, pixval_tr, pixval_bl, pixval_br;
// move ptrs to the first updated pixel
src_p += w * region.y + region.x;
dst_p += (dw * region.y + region.x) * 2;
src_p += w * region->y + region->x;
dst_p += (dw * region->y + region->x) * 2;
for (y = region.y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
for (y = region->y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
{
for (x = region.x; x < xend; ++x, ++src_p, ++dst_p)
for (x = region->x; x < xend; ++x, ++src_p, ++dst_p)
{
pixval_tl = BIADAPT_GETPIX (src_p);
@@ -712,12 +712,12 @@ Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
Uint32 pixval_tl, pixval_tr, pixval_bl, pixval_br;
// move ptrs to the first updated pixel
src_p += w * region.y + region.x;
dst_p += (dw * region.y + region.x) * 2;
src_p += w * region->y + region->x;
dst_p += (dw * region->y + region->x) * 2;
for (y = region.y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
for (y = region->y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
{
for (x = region.x; x < xend; ++x, ++src_p, ++dst_p)
for (x = region->x; x < xend; ++x, ++src_p, ++dst_p)
{
pixval_tl = BIADAPT_GETPIX (src_p);
@@ -912,7 +912,7 @@ Scale_BiAdaptAdvFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
const int w = src->w, h = src->h, dw = dst->w;
int xend, yend;
int dsrc, ddst;
SDL_Rect region = *r;
SDL_Rect *region = r;
SDL_Rect limits;
SDL_PixelFormat *fmt = dst->format;
// for clarity purposes, the 'pixels' array here is transposed
@@ -960,12 +960,12 @@ Scale_BiAdaptAdvFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
limits.y = 0;
limits.w = src->w;
limits.h = src->h;
Scale_ExpandRect (&region, 2, &limits);
Scale_ExpandRect (region, 2, &limits);
xend = region.x + region.w;
yend = region.y + region.h;
dsrc = w - region.w;
ddst = (dw - region.w) * 2;
xend = region->x + region->w;
yend = region->y + region->h;
dsrc = w - region->w;
ddst = (dw - region->w) * 2;
switch (fmt->BytesPerPixel)
{
@@ -977,12 +977,12 @@ Scale_BiAdaptAdvFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
BIADAPT_BUF *src_p = (BIADAPT_BUF *)src->pixels;
BIADAPT_BUF *dst_p = (BIADAPT_BUF *)dst->pixels;
src_p += w * region.y + region.x;
dst_p += (dw * region.y + region.x) * 2;
src_p += w * region->y + region->x;
dst_p += (dw * region->y + region->x) * 2;
for (y = region.y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
for (y = region->y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
{
for (x = region.x; x < xend; ++x, ++src_p, ++dst_p)
for (x = region->x; x < xend; ++x, ++src_p, ++dst_p)
{
// pixel eqaulity counter
int cmatch;
@@ -1429,12 +1429,12 @@ Scale_BiAdaptAdvFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
BIADAPT_BUF *src_p = (BIADAPT_BUF *)src->pixels;
BIADAPT_BUF *dst_p = (BIADAPT_BUF *)dst->pixels;
src_p += w * region.y + region.x;
dst_p += (dw * region.y + region.x) * 2;
src_p += w * region->y + region->x;
dst_p += (dw * region->y + region->x) * 2;
for (y = region.y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
for (y = region->y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
{
for (x = region.x; x < xend; ++x, ++src_p, ++dst_p)
for (x = region->x; x < xend; ++x, ++src_p, ++dst_p)
{
// pixel eqaulity counter
int cmatch;
@@ -1881,12 +1881,12 @@ Scale_BiAdaptAdvFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
BIADAPT_BUF *src_p = (BIADAPT_BUF *)src->pixels;
BIADAPT_BUF *dst_p = (BIADAPT_BUF *)dst->pixels;
src_p += w * region.y + region.x;
dst_p += (dw * region.y + region.x) * 2;
src_p += w * region->y + region->x;
dst_p += (dw * region->y + region->x) * 2;
for (y = region.y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
for (y = region->y; y < yend; ++y, dst_p += ddst, src_p += dsrc)
{
for (x = region.x; x < xend; ++x, ++src_p, ++dst_p)
for (x = region->x; x < xend; ++x, ++src_p, ++dst_p)
{
// pixel eqaulity counter
int cmatch;
@@ -2435,6 +2435,14 @@ void Scale_BilinearFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r)
const int w = dst->w, h = dst->h;
SDL_PixelFormat *fmt = dst->format;
// TODO: support for partial updates, expand weight matrix in the code
// so that compiler can optimize the mults?
r->x = 0;
r->y = 0;
r->w = src->w;
r->h = src->h;
switch (dst->format->BytesPerPixel)
{
case 2:
@@ -19,7 +19,6 @@
#define _2XSCALERS_H_
void Scale_PrepYUV (void);
void Scale_ExpandRect (SDL_Rect* rect, int expansion, SDL_Rect* limits);
void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_BilinearFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
+1 -9
View File
@@ -269,7 +269,7 @@ TFB_GL_DrawQuad (void)
}
void
TFB_GL_SwapBuffers (void)
TFB_GL_SwapBuffers (int force_full_redraw)
{
int fade_amount;
int transition_amount;
@@ -296,19 +296,11 @@ TFB_GL_SwapBuffers (void)
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
{
SDL_Rect limits;
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT)
Scale_BiAdaptFilter (SDL_Screen, scaled_display, &updated);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
Scale_BiAdaptAdvFilter (SDL_Screen, scaled_display, &updated);
limits.x = 0;
limits.y = 0;
limits.w = ScreenWidth;
limits.h = ScreenHeight;
Scale_ExpandRect (&updated, 2, &limits);
glPixelStorei (GL_UNPACK_ROW_LENGTH, ScreenWidth * 2);
glPixelStorei (GL_UNPACK_SKIP_ROWS, updated.y * 2);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, updated.x * 2);
+1 -1
View File
@@ -23,7 +23,7 @@
int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp);
void TFB_GL_UploadTransitionScreen (void);
void TFB_GL_SwapBuffers (void);
void TFB_GL_SwapBuffers (int force_full_redraw);
SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface);
+15 -5
View File
@@ -25,6 +25,7 @@ static SDL_Surface *fade_black;
static SDL_Surface *fade_white;
static SDL_Surface *fade_temp;
static int gfx_flags;
static int last_fade_amount = 255, last_transition_amount = 255;
static SDL_Surface *
Create_Screen (SDL_Surface *template)
@@ -220,18 +221,25 @@ static void ScanLines (SDL_Surface *dst)
}
void
TFB_Pure_SwapBuffers ()
TFB_Pure_SwapBuffers (int force_full_redraw)
{
int fade_amount = FadeAmount;
int transition_amount = TransitionAmount;
SDL_Rect updated;
if (last_fade_amount != 255 || last_transition_amount != 255)
force_full_redraw = 1;
last_fade_amount = fade_amount;
last_transition_amount = transition_amount;
if (!force_full_redraw)
{
updated.x = TFB_BBox.region.corner.x;
updated.y = TFB_BBox.region.corner.y;
updated.w = TFB_BBox.region.extent.width;
updated.h = TFB_BBox.region.extent.height;
if ((transition_amount != 255) || (fade_amount != 255))
}
else
{
updated.x = updated.y = 0;
updated.w = ScreenWidth;
@@ -291,6 +299,8 @@ TFB_Pure_SwapBuffers ()
SDL_UnlockSurface (backbuffer);
SDL_UnlockSurface (SDL_Video);
SDL_UpdateRect (SDL_Video, updated.x * 2, updated.y * 2, updated.w * 2, updated.h * 2);
}
else
{
@@ -317,9 +327,9 @@ TFB_Pure_SwapBuffers ()
SDL_BlitSurface (fade_white, NULL, SDL_Video, NULL);
}
}
}
SDL_UpdateRect (SDL_Video, 0, 0, 0, 0);
SDL_UpdateRect (SDL_Video, updated.x, updated.y, updated.w, updated.h);
}
}
#endif
+1 -1
View File
@@ -22,6 +22,6 @@
#include "libs/graphics/sdl/sdl_common.h"
int TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp);
void TFB_Pure_SwapBuffers ();
void TFB_Pure_SwapBuffers (int force_full_redraw);
#endif
@@ -120,7 +120,7 @@ TFB_ProcessEvents ()
// TODO
break;
case SDL_VIDEOEXPOSE: /* Screen needs to be redrawn */
TFB_SwapBuffers ();
TFB_SwapBuffers (1);
break;
default:
break;
@@ -129,15 +129,15 @@ TFB_ProcessEvents ()
}
void
TFB_SwapBuffers ()
TFB_SwapBuffers (int force_full_redraw)
{
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
TFB_GL_SwapBuffers ();
TFB_GL_SwapBuffers (force_full_redraw);
else
TFB_Pure_SwapBuffers ();
TFB_Pure_SwapBuffers (force_full_redraw);
#else
TFB_Pure_SwapBuffers ();
TFB_Pure_SwapBuffers (force_full_redraw);
#endif
}
@@ -460,7 +460,7 @@ TFB_FlushGraphics () // Only call from main thread!!
if ((current_fade != 255 && current_fade != last_fade) ||
(current_transition != 255 && current_transition != last_transition))
{
TFB_SwapBuffers(); // if fading, redraw every frame
TFB_SwapBuffers (1); // if fading, redraw every frame
}
else
{
@@ -664,7 +664,7 @@ TFB_FlushGraphics () // Only call from main thread!!
Unlock_DCQ ();
}
TFB_SwapBuffers ();
TFB_SwapBuffers (0);
RenderedFrames++;
BroadcastCondVar (RenderingCond);
}
@@ -46,7 +46,7 @@ extern int GfxFlags;
void ScreenOrigin (FRAME Display, COORD sx, COORD sy);
void LoadDisplay (PDISPLAY_INTERFACE *pDisplay);
void TFB_SwapBuffers ();
void TFB_SwapBuffers (int force_full_redraw);
SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface);
void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
SDL_Rect *dstrect, int blend_numer, int blend_denom);