From 457976d88d4e323b0ec5b79b5fa2d1006297e979 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 20 Dec 2007 14:05:08 +0000 Subject: [PATCH] - Fixed: DCanvas::Blit unlocked the destination twice instead of unlocking both dest and src. Also changed this function so that it is owned by the destination canvas of the operation which is necessary if it needs to be overridden by subclasses. SVN r607 (trunk) --- docs/rh-log.txt | 4 ++++ src/m_menu.cpp | 4 ++-- src/v_video.cpp | 26 +++++++++++++------------- src/v_video.h | 4 ++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 28f793b51..b28dba941 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ December 20, 2007 (Changes by Graf Zahl) +- Fixed: DCanvas::Blit unlocked the destination twice instead of unlocking + both dest and src. Also changed this function so that it is owned by the + destination canvas of the operation which is necessary if it needs to + be overridden by subclasses. - Fixed: The StrifePlayer defined the wrong color range for its translations. December 19, 2007 diff --git a/src/m_menu.cpp b/src/m_menu.cpp index d46baed74..620e5cdec 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -1077,8 +1077,8 @@ static void M_DrawSaveLoadCommon () M_DrawFrame (savepicLeft, savepicTop, savepicWidth, savepicHeight); if (SavePic != NULL) { - SavePic->Blit (0, 0, SavePic->GetWidth(), SavePic->GetHeight(), - screen, savepicLeft, savepicTop, savepicWidth, savepicHeight); + screen->Blit(savepicLeft, savepicTop, savepicWidth, savepicHeight, + SavePic, 0, 0, SavePic->GetWidth(), SavePic->GetHeight()); } else { diff --git a/src/v_video.cpp b/src/v_video.cpp index e7ef1d255..f2fed2caa 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -515,13 +515,13 @@ static void BuildTransTable (const PalEntry *palette) Col2RGB8_LessPrecision[64] = Col2RGB8[64]; } -void DCanvas::Blit (int srcx, int srcy, int srcwidth, int srcheight, - DCanvas *dest, int destx, int desty, int destwidth, int destheight) +void DCanvas::Blit (int destx, int desty, int destwidth, int destheight, DCanvas *src, + int srcx, int srcy, int srcwidth, int srcheight) { fixed_t fracxstep, fracystep; fixed_t fracx, fracy; int x, y; - bool lockthis, lockdest; + bool lockthis, locksrc; if ( (lockthis = (LockCount == 0)) ) { @@ -532,9 +532,9 @@ void DCanvas::Blit (int srcx, int srcy, int srcwidth, int srcheight, } } - if ( (lockdest = (dest->LockCount == 0)) ) + if ( (locksrc = (src->LockCount == 0)) ) { - dest->Lock (); + src->Lock (); } fracy = srcy << FRACBITS; @@ -542,15 +542,15 @@ void DCanvas::Blit (int srcx, int srcy, int srcwidth, int srcheight, fracxstep = (srcwidth << FRACBITS) / destwidth; BYTE *destline, *srcline; - BYTE *destbuffer = dest->Buffer; - BYTE *srcbuffer = Buffer; + BYTE *destbuffer = Buffer; + BYTE *srcbuffer = src->Buffer; if (fracxstep == FRACUNIT) { for (y = desty; y < desty + destheight; y++, fracy += fracystep) { - memcpy (destbuffer + y * dest->Pitch + destx, - srcbuffer + (fracy >> FRACBITS) * Pitch + srcx, + memcpy (destbuffer + y * Pitch + destx, + srcbuffer + (fracy >> FRACBITS) * src->Pitch + srcx, destwidth); } } @@ -558,8 +558,8 @@ void DCanvas::Blit (int srcx, int srcy, int srcwidth, int srcheight, { for (y = desty; y < desty + destheight; y++, fracy += fracystep) { - srcline = srcbuffer + (fracy >> FRACBITS) * Pitch + srcx; - destline = destbuffer + y * dest->Pitch + destx; + srcline = srcbuffer + (fracy >> FRACBITS) * src->Pitch + srcx; + destline = destbuffer + y * Pitch + destx; for (x = fracx = 0; x < destwidth; x++, fracx += fracxstep) { destline[x] = srcline[fracx >> FRACBITS]; @@ -571,9 +571,9 @@ void DCanvas::Blit (int srcx, int srcy, int srcwidth, int srcheight, { Unlock (); } - if (lockdest) + if (locksrc) { - Unlock (); + src->Unlock (); } } diff --git a/src/v_video.h b/src/v_video.h index 13a7d63ec..c1c8b6796 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -145,7 +145,7 @@ public: virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked // Copy blocks from one canvas to another - virtual void Blit (int srcx, int srcy, int srcwidth, int srcheight, DCanvas *dest, int destx, int desty, int destwidth, int destheight); + virtual void Blit (int destx, int desty, int destwidth, int destheight, DCanvas *src, int srcx, int srcy, int srcwidth, int srcheight); // Draw a linear block of pixels into the canvas virtual void DrawBlock (int x, int y, int width, int height, const BYTE *src) const; @@ -217,7 +217,7 @@ protected: }; bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const; - void STACK_ARGS DrawTextureV (FTexture *img, int x, int y, uint32 tag, va_list tags); + virtual void STACK_ARGS DrawTextureV (FTexture *img, int x, int y, uint32 tag, va_list tags); bool ParseDrawTextureTags (FTexture *img, int x, int y, uint32 tag, va_list tags, DrawParms *parms) const; DCanvas() {}