fix bugs of stretchblt

This commit is contained in:
Vincent Wei
2021-04-30 16:55:51 +08:00
parent 1340a8b81e
commit e88a3cd3d8
4 changed files with 18 additions and 11 deletions

View File

@@ -70,6 +70,7 @@
#endif
#define DISABLE_THREADS
#define GAL_mutex int
#define GAL_bool BOOL

View File

@@ -69,8 +69,8 @@
#define STACKCALL
typedef Uint32 int32;
#include "HeadMMX.h"
#include "HeadX86.h"
#include "hermes/HeadMMX.h"
#include "hermes/HeadX86.h"
#else

View File

@@ -376,13 +376,16 @@ static int GAL_StretchBltLegacy (GAL_Surface *src, GAL_Rect *srcrect,
clipped_dstrect = *dstrect;
}
else if (GAL_IntersectRect (dstrect, &dst->clip_rect, &clipped_dstrect)) {
float ratio_x = clipped_dstrect.w * 1.0f / dstrect->w;
float ratio_y = clipped_dstrect.h * 1.0f / dstrect->h;
float ratio_x = (dstrect->x + dstrect->w - clipped_dstrect.x) * 1.0f / dstrect->w;
float ratio_y = (dstrect->y + dstrect->h - clipped_dstrect.y) * 1.0f / dstrect->h;
clipped_srcrect.x = srcrect->x + srcrect->w * (1.0f - ratio_x);
clipped_srcrect.y = srcrect->y + srcrect->h * (1.0f - ratio_y);
ratio_x = (clipped_dstrect.w) * 1.0f / dstrect->w;
ratio_y = (clipped_dstrect.h) * 1.0f / dstrect->h;
clipped_srcrect.w = (srcrect->w * ratio_x);
clipped_srcrect.h = (srcrect->h * ratio_y);
clipped_srcrect.x = srcrect->x + (clipped_dstrect.x - dstrect->x) * ratio_x;
clipped_srcrect.y = srcrect->y + (clipped_dstrect.y - dstrect->y) * ratio_y;
if (clipped_srcrect.w <= 0 || clipped_srcrect.h <= 0 ||
clipped_dstrect.w <= 0 || clipped_dstrect.h <= 0)

View File

@@ -1419,6 +1419,7 @@ void GUIAPI StretchBltLegacy (HDC hsdc, int sx, int sy, int sw, int sh,
if (dy >= RECTH(pddc->DevRC))
goto error_ret;
#if 0
// shrink source and destination rectangles if dx < 0
if (dx < 0) {
// dx and overflow is negative
@@ -1456,6 +1457,7 @@ void GUIAPI StretchBltLegacy (HDC hsdc, int sx, int sy, int sw, int sh,
sh -= (int)(sh * overflow * 1.0f / dh + 0.5f);
dh -= overflow;
}
#endif
if (sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0)
goto error_ret;
@@ -1572,6 +1574,7 @@ void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
if (dy >= RECTH(pddc->DevRC))
goto error_ret;
#if 0
// shrink source and destination rectangles if dx < 0
if (dx < 0) {
// dx and overflow is negative
@@ -1609,6 +1612,7 @@ void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
sh -= (int)(sh * overflow * 1.0f / dh + 0.5f);
dh -= overflow;
}
#endif
if (sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0)
goto error_ret;
@@ -1616,12 +1620,12 @@ void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
SetRect (&srcOutput, sx, sy, sx + sw, sy + sh);
SetRect (&dstOutput, dx, dy, dx + dw, dy + dh);
if (pddc->surface == psdc->surface)
if (pddc->surface == psdc->surface)
GetBoundRect (&pddc->rc_output, &srcOutput, &dstOutput);
else
pddc->rc_output = dstOutput;
if (pddc->surface != psdc->surface && (psdc->surface == __gal_screen))
if (pddc->surface != psdc->surface && (psdc->surface == __gal_screen))
psdc->rc_output = srcOutput;
ENTER_DRAWING (pddc);
@@ -1629,13 +1633,12 @@ void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
if (pddc->surface != psdc->surface && IS_SCREEN_SURFACE (psdc))
kernel_ShowCursorForGDI (FALSE, psdc);
src.x = sx; src.y = sy; src.w = sw; src.h = sh;
dst.x = dx; dst.y = dy; dst.w = dw; dst.h = dh;
cliprect = pddc->ecrgn.head;
while(cliprect) {
if (IntersectRect (&eff_rc, &pddc->rc_output, &cliprect->rc)) {
SET_GAL_CLIPRECT (pddc, eff_rc);
src.x = sx; src.y = sy; src.w = sw; src.h = sh;
dst.x = dx; dst.y = dy; dst.w = dw; dst.h = dh;
GAL_StretchBlt (psdc->surface, &src, pddc->surface, &dst, dwRop);
}