diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index e45fe1791ed..069b0719f15 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -467,13 +467,21 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot, swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot, }; + RECT src_rect = + { + 0, 0, + swapchain->device->cursor_texture->resource.width, + swapchain->device->cursor_texture->resource.height + }; + const RECT clip_rect = {0, 0, back_buffer->resource.width, back_buffer->resource.height}; TRACE("Rendering the software cursor.\n"); if (swapchain->desc.windowed) MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&destRect, 2); - wined3d_surface_blt(back_buffer, &destRect, cursor, NULL, WINEDDBLT_ALPHATEST, - NULL, WINED3D_TEXF_POINT); + if (wined3d_clip_blit(&clip_rect, &destRect, &src_rect)) + wined3d_surface_blt(back_buffer, &destRect, cursor, &src_rect, WINEDDBLT_ALPHATEST, + NULL, WINED3D_TEXF_POINT); } TRACE("Presenting HDC %p.\n", context->hdc); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 17ac29daf0c..440606704df 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4994,3 +4994,25 @@ void wined3d_release_dc(HWND window, HDC dc) else if (!ReleaseDC(window, dc)) ERR("Failed to release device context %p, last error %#x.\n", dc, GetLastError()); } + +BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) +{ + RECT orig = *clipped; + float scale_x = (float)(orig.right - orig.left) / (float)(other->right - other->left); + float scale_y = (float)(orig.bottom - orig.top) / (float)(other->bottom - other->top); + + IntersectRect(clipped, clipped, clip_rect); + + if (IsRectEmpty(clipped)) + { + SetRectEmpty(other); + return FALSE; + } + + other->left += (LONG)((clipped->left - orig.left) / scale_x); + other->top += (LONG)((clipped->top - orig.top) / scale_y); + other->right -= (LONG)((orig.right - clipped->right) / scale_x); + other->bottom -= (LONG)((orig.bottom - clipped->bottom) / scale_y); + + return TRUE; +} diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 464bdf6d309..53ef63e0326 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1396,6 +1396,7 @@ extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN; extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN; extern const struct blit_shader cpu_blit DECLSPEC_HIDDEN; +BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN; const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info, enum wined3d_blit_op blit_op, const RECT *src_rect, DWORD src_usage, enum wined3d_pool src_pool, const struct wined3d_format *src_format,