1
0
mirror of https://github.com/wine-mirror/wine synced 2024-06-29 06:14:34 +00:00

winex11: Move window surface creation functions to bitblt.c.

This commit is contained in:
Rémi Bernon 2024-06-12 10:13:15 +02:00 committed by Alexandre Julliard
parent 2f5456316c
commit e9ca13a6f7
3 changed files with 99 additions and 100 deletions

View File

@ -2054,8 +2054,8 @@ static const struct window_surface_funcs x11drv_surface_funcs =
/***********************************************************************
* create_surface
*/
struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect,
COLORREF color_key, BOOL use_alpha )
static struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect,
COLORREF color_key, BOOL use_alpha )
{
const XPixmapFormatValues *format = pixmap_formats[vis->depth];
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
@ -2182,3 +2182,99 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect )
window_surface_unlock( window_surface );
return region;
}
BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect )
{
*surface_rect = NtUserGetVirtualScreenRect();
if (!intersect_rect( surface_rect, surface_rect, visible_rect )) return FALSE;
OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top );
surface_rect->left &= ~31;
surface_rect->top &= ~31;
surface_rect->right = max( surface_rect->left + 32, (surface_rect->right + 31) & ~31 );
surface_rect->bottom = max( surface_rect->top + 32, (surface_rect->bottom + 31) & ~31 );
return TRUE;
}
/***********************************************************************
* CreateWindowSurface (X11DRV.@)
*/
BOOL X11DRV_CreateWindowSurface( HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface )
{
struct x11drv_win_data *data;
RECT surface_rect;
DWORD flags;
COLORREF key;
BOOL layered = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
TRACE( "hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect( visible_rect ), surface );
if (!(data = get_win_data( hwnd ))) return TRUE; /* use default surface */
if (*surface) window_surface_release( *surface );
*surface = NULL; /* indicate that we want to draw directly to the window */
if (data->embedded) goto done; /* draw directly to the window */
if (data->whole_window == root_window) goto done; /* draw directly to the window */
if (data->client_window) goto done; /* draw directly to the window */
if (!client_side_graphics && !layered) goto done; /* draw directly to the window */
if (!get_surface_rect( visible_rect, &surface_rect )) goto done;
if (data->surface)
{
if (EqualRect( &data->surface->rect, &surface_rect ))
{
/* existing surface is good enough */
window_surface_add_ref( data->surface );
*surface = data->surface;
goto done;
}
}
else if (!(swp_flags & SWP_SHOWWINDOW) && !(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done;
if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY))
key = CLR_INVALID;
*surface = create_surface( data->hwnd, data->whole_window, &data->vis, &surface_rect, key, FALSE );
done:
release_win_data( data );
return TRUE;
}
/*****************************************************************************
* CreateLayeredWindow (X11DRV.@)
*/
BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **window_surface )
{
struct window_surface *surface;
struct x11drv_win_data *data;
RECT rect;
if (!(data = get_win_data( hwnd ))) return FALSE;
data->layered = TRUE;
if (!data->embedded && argb_visual.visualid) set_window_visual( data, &argb_visual, TRUE );
rect = *window_rect;
OffsetRect( &rect, -window_rect->left, -window_rect->top );
surface = data->surface;
if (!surface || !EqualRect( &surface->rect, &rect ))
{
data->surface = create_surface( data->hwnd, data->whole_window, &data->vis, &rect,
color_key, data->use_alpha );
if (surface) window_surface_release( surface );
surface = data->surface;
}
else set_surface_color_key( surface, color_key );
if ((*window_surface = surface)) window_surface_add_ref( surface );
release_win_data( data );
return TRUE;
}

View File

@ -2576,20 +2576,6 @@ done:
}
static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect )
{
*surface_rect = NtUserGetVirtualScreenRect();
if (!intersect_rect( surface_rect, surface_rect, visible_rect )) return FALSE;
OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top );
surface_rect->left &= ~31;
surface_rect->top &= ~31;
surface_rect->right = max( surface_rect->left + 32, (surface_rect->right + 31) & ~31 );
surface_rect->bottom = max( surface_rect->top + 32, (surface_rect->bottom + 31) & ~31 );
return TRUE;
}
/***********************************************************************
* WindowPosChanging (X11DRV.@)
*/
@ -2626,53 +2612,6 @@ done:
}
/***********************************************************************
* CreateWindowSurface (X11DRV.@)
*/
BOOL X11DRV_CreateWindowSurface( HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface )
{
struct x11drv_win_data *data;
RECT surface_rect;
DWORD flags;
COLORREF key;
BOOL layered = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
TRACE( "hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect( visible_rect ), surface );
if (!(data = get_win_data( hwnd ))) return TRUE; /* use default surface */
if (*surface) window_surface_release( *surface );
*surface = NULL; /* indicate that we want to draw directly to the window */
if (data->embedded) goto done; /* draw directly to the window */
if (data->whole_window == root_window) goto done; /* draw directly to the window */
if (data->client_window) goto done; /* draw directly to the window */
if (!client_side_graphics && !layered) goto done; /* draw directly to the window */
if (!get_surface_rect( visible_rect, &surface_rect )) goto done;
if (data->surface)
{
if (EqualRect( &data->surface->rect, &surface_rect ))
{
/* existing surface is good enough */
window_surface_add_ref( data->surface );
*surface = data->surface;
goto done;
}
}
else if (!(swp_flags & SWP_SHOWWINDOW) && !(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done;
if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY))
key = CLR_INVALID;
*surface = create_surface( data->hwnd, data->whole_window, &data->vis, &surface_rect, key, FALSE );
done:
release_win_data( data );
return TRUE;
}
/***********************************************************************
* WindowPosChanged (X11DRV.@)
*/
@ -2983,41 +2922,6 @@ void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWO
}
/*****************************************************************************
* CreateLayeredWindow (X11DRV.@)
*/
BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **window_surface )
{
struct window_surface *surface;
struct x11drv_win_data *data;
RECT rect;
if (!(data = get_win_data( hwnd ))) return FALSE;
data->layered = TRUE;
if (!data->embedded && argb_visual.visualid) set_window_visual( data, &argb_visual, TRUE );
rect = *window_rect;
OffsetRect( &rect, -window_rect->left, -window_rect->top );
surface = data->surface;
if (!surface || !EqualRect( &surface->rect, &rect ))
{
data->surface = create_surface( data->hwnd, data->whole_window, &data->vis, &rect,
color_key, data->use_alpha );
if (surface) window_surface_release( surface );
surface = data->surface;
}
else set_surface_color_key( surface, color_key );
if ((*window_surface = surface)) window_surface_add_ref( surface );
release_win_data( data );
return TRUE;
}
/***********************************************************************
* UpdateLayeredWindow (X11DRV.@)
*/

View File

@ -266,8 +266,6 @@ extern Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const B
const struct gdi_image_bits *bits, UINT coloruse );
extern DWORD get_pixmap_image( Pixmap pixmap, int width, int height, const XVisualInfo *vis,
BITMAPINFO *info, struct gdi_image_bits *bits );
extern struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect,
COLORREF color_key, BOOL use_alpha );
extern void set_surface_color_key( struct window_surface *window_surface, COLORREF color_key );
extern HRGN expose_surface( struct window_surface *window_surface, const RECT *rect );
@ -687,6 +685,7 @@ typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void
extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg );
extern int X11DRV_check_error(void);
extern BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect );
extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy );
extern POINT virtual_screen_to_root( INT x, INT y );
extern POINT root_to_virtual_screen( INT x, INT y );