From 11801618dffd9be27a45bd81a247e9a890a61403 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 27 Sep 2022 15:28:57 +0200 Subject: [PATCH] add (commented out) clipper support to dds_blt --- inc/ddsurface.h | 2 ++ src/ddsurface.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/inc/ddsurface.h b/inc/ddsurface.h index b5ab814..8a3583c 100644 --- a/inc/ddsurface.h +++ b/inc/ddsurface.h @@ -7,6 +7,8 @@ #include "IDirectDrawSurface.h" #include "IDirectDraw.h" +#define DDBLT_NO_CLIP (1 << 31) + /* enables redraw via blt/unlock if there wasn't any flip for X ms */ #define FLIP_REDRAW_TIMEOUT 1000 / 10 diff --git a/src/ddsurface.c b/src/ddsurface.c index fb4c6fb..f960be5 100644 --- a/src/ddsurface.c +++ b/src/ddsurface.c @@ -20,8 +20,8 @@ HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl* This, IDirectDrawSurfaceI if (!This->backbuffer) { - lpDDSurface->caps |= DDSCAPS_BACKBUFFER; - This->backbuffer = lpDDSurface; +lpDDSurface->caps |= DDSCAPS_BACKBUFFER; +This->backbuffer = lpDDSurface; } } @@ -140,6 +140,45 @@ HRESULT dds_Blt( BOOL mirror_left_right = got_fx && (lpDDBltFx->dwDDFX & DDBLTFX_MIRRORLEFTRIGHT); BOOL mirror_up_down = got_fx && (lpDDBltFx->dwDDFX & DDBLTFX_MIRRORUPDOWN); + /* keep this commented out until tested and confirmed working + if (This->clipper && !(dwFlags & DDBLT_NO_CLIP)) + { + DWORD size = 0; + + if (SUCCEEDED(IDirectDrawClipper_GetClipList(This->clipper, &dst_rect, NULL, &size)) && size > 0) + { + RGNDATA* list = (RGNDATA*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + + if (list) + { + if (SUCCEEDED(IDirectDrawClipper_GetClipList(This->clipper, &dst_rect, list, &size))) + { + float scale_w = (float)src_w / dst_w; + float scale_h = (float)src_h / dst_h; + + RECT* dst_c_rect = (RECT*)list->Buffer; + + for (int i = 0; i < list->rdh.nCount; ++i) + { + RECT src_c_rect = src_rect; + + src_c_rect.left += (LONG)((dst_c_rect[i].left - dst_rect.left) * scale_w); + src_c_rect.top += (LONG)((dst_c_rect[i].top - dst_rect.top) * scale_h); + src_c_rect.right -= (LONG)((dst_rect.right - dst_c_rect[i].right) * scale_w); + src_c_rect.bottom -= (LONG)((dst_rect.bottom - dst_c_rect[i].bottom) * scale_h); + + dds_Blt(This, &dst_c_rect[i], src_surface, &src_c_rect, dwFlags | DDBLT_NO_CLIP, lpDDBltFx); + } + } + + HeapFree(GetProcessHeap(), 0, list); + + return DD_OK; + } + } + } + */ + if (This->bpp != src_surface->bpp) { TRACE_EXT(" NOT_IMPLEMENTED This->bpp=%u, src_surface->bpp=%u\n", This->bpp, src_surface->bpp);