From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 3 ++ dlls/wineandroid.drv/window.c | 47 ++++++++++--------- dlls/winemac.drv/surface.c | 7 ++- dlls/winex11.drv/bitblt.c | 85 +++++++++++++++++++---------------- include/wine/gdi_driver.h | 3 ++ 5 files changed, 79 insertions(+), 66 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 145bf2c5237..7fb4bbeef62 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -204,6 +204,9 @@ W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct w surface->ref = 1; surface->hwnd = hwnd; surface->rect = *rect; + surface->color_key = CLR_INVALID; + surface->alpha_bits = -1; + surface->alpha_mask = 0; pthread_mutex_init( &surface->mutex, NULL ); reset_bounds( &surface->bounds );
diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 6d2e51ee070..8fa87b57807 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -562,11 +562,8 @@ struct android_window_surface { struct window_surface header; ANativeWindow *window; - BOOL byteswap; UINT clip_count; RECT *clip_rects; - BYTE alpha; - COLORREF color_key; BITMAPINFO info; /* variable size, must be last */ };
@@ -660,6 +657,9 @@ static BOOL android_surface_flush( struct window_surface *window_surface, const if (!surface->window->perform( surface->window, NATIVE_WINDOW_LOCK, &buffer, &rc )) { const RECT *rgn_rect = surface->clip_rects, *end = surface->clip_rects + surface->clip_count; + UINT alpha_mask = window_surface->alpha_mask, alpha_bits = window_surface->alpha_bits; + COLORREF color_key = window_surface->color_key; + BYTE alpha = alpha_bits >> 24; DWORD *src, *dst; int x, y, width; RECT locked; @@ -677,19 +677,19 @@ static BOOL android_surface_flush( struct window_surface *window_surface, const
for (y = locked.top; y < min( buffer.height, locked.bottom ); y++) { - if (surface->info.bmiHeader.biCompression == BI_RGB) + if (alpha_mask) memcpy( dst, src, width * sizeof(*dst) ); - else if (surface->alpha == 255) + else if (alpha == 255) for (x = 0; x < width; x++) dst[x] = src[x] | 0xff000000; else for (x = 0; x < width; x++) - dst[x] = ((surface->alpha << 24) | - (((BYTE)(src[x] >> 16) * surface->alpha / 255) << 16) | - (((BYTE)(src[x] >> 8) * surface->alpha / 255) << 8) | - (((BYTE)src[x] * surface->alpha / 255))); + dst[x] = ((alpha << 24) | + (((BYTE)(src[x] >> 16) * alpha / 255) << 16) | + (((BYTE)(src[x] >> 8) * alpha / 255) << 8) | + (((BYTE)src[x] * alpha / 255)));
- if (surface->color_key != CLR_INVALID) - for (x = 0; x < width; x++) if ((src[x] & 0xffffff) == surface->color_key) dst[x] = 0; + if (color_key != CLR_INVALID) + for (x = 0; x < width; x++) if ((src[x] & 0xffffff) == color_key) dst[x] = 0;
if (rgn_rect) { @@ -732,8 +732,7 @@ static const struct window_surface_funcs android_surface_funcs =
static BOOL is_argb_surface( struct window_surface *surface ) { - return surface && surface->funcs == &android_surface_funcs && - get_android_surface( surface )->info.bmiHeader.biCompression == BI_RGB; + return surface && surface->funcs == &android_surface_funcs && !!surface->alpha_mask; }
/*********************************************************************** @@ -742,17 +741,17 @@ static BOOL is_argb_surface( struct window_surface *surface ) static void set_color_key( struct android_window_surface *surface, COLORREF key ) { if (key == CLR_INVALID) - surface->color_key = CLR_INVALID; + surface->header.color_key = CLR_INVALID; else if (surface->info.bmiHeader.biBitCount <= 8) - surface->color_key = CLR_INVALID; + surface->header.color_key = CLR_INVALID; else if (key & (1 << 24)) /* PALETTEINDEX */ - surface->color_key = 0; + surface->header.color_key = 0; else if (key >> 16 == 0x10ff) /* DIBINDEX */ - surface->color_key = 0; + surface->header.color_key = 0; else if (surface->info.bmiHeader.biBitCount == 24) - surface->color_key = key; + surface->header.color_key = key; else - surface->color_key = (GetRValue(key) << 16) | (GetGValue(key) << 8) | GetBValue(key); + surface->header.color_key = (GetRValue(key) << 16) | (GetGValue(key) << 8) | GetBValue(key); }
/*********************************************************************** @@ -779,7 +778,7 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = get_ioctl_window( hwnd ); - surface->alpha = alpha; + surface->header.alpha_bits = (UINT)alpha << 24; set_color_key( surface, color_key );
TRACE( "created %p hwnd %p %s bits %p-%p\n", surface, hwnd, wine_dbgstr_rect(rect), @@ -804,11 +803,11 @@ static void set_surface_layered( struct window_surface *window_surface, BYTE alp if (window_surface->funcs != &android_surface_funcs) return; /* we may get the null surface */
window_surface_lock( window_surface ); - prev_key = surface->color_key; - prev_alpha = surface->alpha; - surface->alpha = alpha; + prev_key = surface->header.color_key; + prev_alpha = surface->header.alpha_bits; + surface->header.alpha_bits = (UINT)alpha << 24; set_color_key( surface, color_key ); - if (alpha != prev_alpha || surface->color_key != prev_key) /* refresh */ + if (alpha != prev_alpha || surface->header.color_key != prev_key) /* refresh */ window_surface->bounds = surface->header.rect; window_surface_unlock( window_surface ); } diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 80926760fdf..af0042bea39 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -58,7 +58,6 @@ struct macdrv_window_surface { struct window_surface header; macdrv_window window; - BOOL use_alpha; CGDataProviderRef provider; BITMAPINFO info; /* variable size, must be last */ }; @@ -105,7 +104,7 @@ static void macdrv_surface_set_clip(struct window_surface *window_surface, const static BOOL macdrv_surface_flush(struct window_surface *window_surface, const RECT *rect, const RECT *dirty) { struct macdrv_window_surface *surface = get_mac_surface(window_surface); - CGImageAlphaInfo alpha_info = (surface->use_alpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst); + CGImageAlphaInfo alpha_info = (window_surface->alpha_mask ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst); BITMAPINFO *color_info = &surface->info; CGColorSpaceRef colorspace; CGImageRef image; @@ -197,7 +196,7 @@ static struct window_surface *create_surface(HWND hwnd, macdrv_window window, co
surface->window = window; if (old_surface) surface->header.bounds = old_surface->bounds; - surface->use_alpha = use_alpha; + surface->header.alpha_mask = use_alpha ? 0xff000000 : 0; surface->provider = provider;
window_background = macdrv_window_background_color(); @@ -221,7 +220,7 @@ failed: void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha) { struct macdrv_window_surface *surface = get_mac_surface(window_surface); - if (surface) surface->use_alpha = use_alpha; + if (surface) surface->header.alpha_mask = use_alpha ? 0xff000000 : 0; }
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 0bc0f02ffd5..2103949b850 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1589,9 +1589,6 @@ struct x11drv_window_surface GC gc; struct x11drv_image *image; BOOL byteswap; - BOOL is_argb; - DWORD alpha_bits; - COLORREF color_key; BITMAPINFO info; /* variable size, must be last */ };
@@ -1634,7 +1631,8 @@ static inline void add_row( HRGN rgn, RGNDATA *data, int x, int y, int len ) /*********************************************************************** * update_surface_region */ -static void update_surface_region( struct x11drv_window_surface *surface, const void *color_bits ) +static void update_surface_region( struct x11drv_window_surface *surface, const void *color_bits, + COLORREF color_key, UINT alpha_mask ) { #ifdef HAVE_LIBXSHAPE char buffer[4096]; @@ -1646,7 +1644,7 @@ static void update_surface_region( struct x11drv_window_surface *surface, const
if (!shape_layered_windows) return;
- if (!surface->is_argb && surface->color_key == CLR_INVALID) + if (!alpha_mask && color_key == CLR_INVALID) { XShapeCombineMask( gdi_display, surface->window, ShapeBounding, 0, 0, None, ShapeSet ); return; @@ -1673,9 +1671,9 @@ static void update_surface_region( struct x11drv_window_surface *surface, const x = 0; while (x < width) { - while (x < width && (bits[x] & mask) == surface->color_key) x++; + while (x < width && (bits[x] & mask) == color_key) x++; start = x; - while (x < width && (bits[x] & mask) != surface->color_key) x++; + while (x < width && (bits[x] & mask) != color_key) x++; add_row( rgn, data, surface->header.rect.left + start, y, x - start ); } } @@ -1692,15 +1690,15 @@ static void update_surface_region( struct x11drv_window_surface *surface, const while (x < width) { while (x < width && - (bits[x * 3] == GetBValue(surface->color_key)) && - (bits[x * 3 + 1] == GetGValue(surface->color_key)) && - (bits[x * 3 + 2] == GetRValue(surface->color_key))) + (bits[x * 3] == GetBValue(color_key)) && + (bits[x * 3 + 1] == GetGValue(color_key)) && + (bits[x * 3 + 2] == GetRValue(color_key))) x++; start = x; while (x < width && - ((bits[x * 3] != GetBValue(surface->color_key)) || - (bits[x * 3 + 1] != GetGValue(surface->color_key)) || - (bits[x * 3 + 2] != GetRValue(surface->color_key)))) + ((bits[x * 3] != GetBValue(color_key)) || + (bits[x * 3 + 1] != GetGValue(color_key)) || + (bits[x * 3 + 2] != GetRValue(color_key)))) x++; add_row( rgn, data, surface->header.rect.left + start, y, x - start ); } @@ -1719,12 +1717,12 @@ static void update_surface_region( struct x11drv_window_surface *surface, const while (x < width) { while (x < width && - ((bits[x] & 0xffffff) == surface->color_key || - (surface->is_argb && !(bits[x] & 0xff000000)))) x++; + ((bits[x] & 0xffffff) == color_key || + (alpha_mask && !(bits[x] & alpha_mask)))) x++; start = x; while (x < width && - !((bits[x] & 0xffffff) == surface->color_key || - (surface->is_argb && !(bits[x] & 0xff000000)))) x++; + !((bits[x] & 0xffffff) == color_key || + (alpha_mask && !(bits[x] & alpha_mask)))) x++; add_row( rgn, data, surface->header.rect.left + start, y, x - start ); } } @@ -1737,9 +1735,9 @@ static void update_surface_region( struct x11drv_window_surface *surface, const x = 0; while (x < width) { - while (x < width && (bits[x] & mask) == surface->color_key) x++; + while (x < width && (bits[x] & mask) == color_key) x++; start = x; - while (x < width && (bits[x] & mask) != surface->color_key) x++; + while (x < width && (bits[x] & mask) != color_key) x++; add_row( rgn, data, surface->header.rect.left + start, y, x - start ); } } @@ -1771,21 +1769,21 @@ static void set_color_key( struct x11drv_window_surface *surface, COLORREF key ) UINT *masks = (UINT *)surface->info.bmiColors;
if (key == CLR_INVALID) - surface->color_key = CLR_INVALID; + surface->header.color_key = CLR_INVALID; else if (surface->info.bmiHeader.biBitCount <= 8) - surface->color_key = CLR_INVALID; + surface->header.color_key = CLR_INVALID; else if (key & (1 << 24)) /* PALETTEINDEX */ - surface->color_key = 0; + surface->header.color_key = 0; else if (key >> 16 == 0x10ff) /* DIBINDEX */ - surface->color_key = 0; + surface->header.color_key = 0; else if (surface->info.bmiHeader.biBitCount == 24) - surface->color_key = key; + surface->header.color_key = key; else if (surface->info.bmiHeader.biCompression == BI_RGB) - surface->color_key = (GetRValue(key) << 16) | (GetGValue(key) << 8) | GetBValue(key); + surface->header.color_key = (GetRValue(key) << 16) | (GetGValue(key) << 8) | GetBValue(key); else - surface->color_key = get_color_component( GetRValue(key), masks[0] ) | - get_color_component( GetGValue(key), masks[1] ) | - get_color_component( GetBValue(key), masks[2] ); + surface->header.color_key = get_color_component( GetRValue(key), masks[0] ) | + get_color_component( GetGValue(key), masks[1] ) | + get_color_component( GetBValue(key), masks[2] ); }
#ifdef HAVE_LIBXXSHM @@ -1993,12 +1991,26 @@ static void x11drv_surface_set_clip( struct window_surface *window_surface, cons */ static BOOL x11drv_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty ) { + UINT alpha_mask = window_surface->alpha_mask, alpha_bits = window_surface->alpha_bits; struct x11drv_window_surface *surface = get_x11_surface( window_surface ); + COLORREF color_key = window_surface->color_key; + const BITMAPINFO *color_info = &surface->info; XImage *ximage = surface->image->ximage; unsigned char *src = window_surface->color_bits; unsigned char *dst = (unsigned char *)ximage->data;
- if (surface->is_argb || surface->color_key != CLR_INVALID) update_surface_region( surface, window_surface->color_bits ); + if (alpha_mask || color_key != CLR_INVALID) update_surface_region( surface, window_surface->color_bits, color_key, alpha_mask ); + + if (alpha_bits == -1) + { + if (alpha_mask || color_info->bmiHeader.biBitCount != 32) alpha_bits = 0; + else if (color_info->bmiHeader.biCompression == BI_RGB) alpha_bits = 0xff000000; + else + { + DWORD *colors = (DWORD *)color_info->bmiColors; + alpha_bits = ~(colors[0] | colors[1] | colors[2]); + } + }
if (src != dst) { @@ -2008,16 +2020,16 @@ static BOOL x11drv_surface_flush( struct window_surface *window_surface, const R src += dirty->top * width_bytes; dst += dirty->top * width_bytes; copy_image_byteswap( &surface->info, src, dst, width_bytes, width_bytes, dirty->bottom - dirty->top, - surface->byteswap, mapping, ~0u, surface->alpha_bits ); + surface->byteswap, mapping, ~0u, alpha_bits ); } - else if (surface->alpha_bits) + else if (alpha_bits) { int x, y, stride = ximage->bytes_per_line / sizeof(ULONG); ULONG *ptr = (ULONG *)dst + dirty->top * stride;
for (y = dirty->top; y < dirty->bottom; y++, ptr += stride) for (x = dirty->left; x < dirty->right; x++) - ptr[x] |= surface->alpha_bits; + ptr[x] |= alpha_bits; }
if (!put_shm_image( ximage, &surface->image->shminfo, surface->window, surface->gc, rect, dirty )) @@ -2120,15 +2132,12 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = window; - surface->is_argb = (use_alpha && vis->depth == 32 && info->bmiHeader.biCompression == BI_RGB); + if (use_alpha && vis->depth == 32 && info->bmiHeader.biCompression == BI_RGB) surface->header.alpha_mask = 0xff000000; set_color_key( surface, color_key );
surface->gc = XCreateGC( gdi_display, window, 0, NULL ); XSetSubwindowMode( gdi_display, surface->gc, IncludeInferiors );
- if (vis->depth == 32 && !surface->is_argb) - surface->alpha_bits = ~(vis->red_mask | vis->green_mask | vis->blue_mask); - TRACE( "created %p for %lx %s bits %p-%p image %p\n", surface, window, wine_dbgstr_rect(rect), surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage, surface->image->ximage->data ); @@ -2151,9 +2160,9 @@ void set_surface_color_key( struct window_surface *window_surface, COLORREF colo if (window_surface->funcs != &x11drv_surface_funcs) return; /* we may get the null surface */
window_surface_lock( window_surface ); - prev = surface->color_key; + prev = surface->header.color_key; set_color_key( surface, color_key ); - if (surface->color_key != prev) update_surface_region( surface, window_surface->color_bits ); + if (surface->header.color_key != prev) update_surface_region( surface, window_surface->color_bits, surface->header.color_key, surface->header.alpha_mask ); window_surface_unlock( window_surface ); }
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index d835e45af3f..b7c9f273d95 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -229,6 +229,9 @@ struct window_surface RECT bounds; /* dirty area rectangle */ HRGN clip_region; /* visible region of the surface, fully visible if 0 */ DWORD draw_start_ticks; /* start ticks of fresh draw */ + COLORREF color_key; /* layered window surface color key, invalid if CLR_INVALID */ + UINT alpha_bits; /* layered window global alpha bits, invalid if -1 */ + UINT alpha_mask; /* layered window per-pixel alpha mask, invalid if 0 */ HBITMAP color_bitmap; /* bitmap for the surface colors */ void *color_bits; /* pixel bits of the color bitmap */ /* driver-specific fields here */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 56 ++++++++++++++++++++++++++++++++++ dlls/wineandroid.drv/window.c | 53 +++++--------------------------- dlls/winemac.drv/surface.c | 15 +++------ dlls/winemac.drv/window.c | 4 +-- dlls/winex11.drv/bitblt.c | 57 +++-------------------------------- dlls/winex11.drv/window.c | 4 +-- dlls/winex11.drv/x11drv.h | 1 - include/wine/gdi_driver.h | 1 + 8 files changed, 76 insertions(+), 115 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 7fb4bbeef62..d5c7eaac101 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -193,6 +193,32 @@ void create_offscreen_window_surface( HWND hwnd, const RECT *surface_rect, struc
/* window surface common helpers */
+static UINT get_color_component( UINT color, UINT mask ) +{ + int shift; + for (shift = 0; !(mask & 1); shift++) mask >>= 1; + return (color * mask / 255) << shift; +} + +static COLORREF get_color_key( const BITMAPINFO *info, COLORREF color_key ) +{ + if (color_key == CLR_INVALID) return CLR_INVALID; + if (info->bmiHeader.biBitCount <= 8) return CLR_INVALID; + if (color_key & (1 << 24)) /* PALETTEINDEX */ return 0; + if (color_key >> 16 == 0x10ff) /* DIBINDEX */ return 0; + + if (info->bmiHeader.biBitCount == 24) return color_key; + if (info->bmiHeader.biCompression == BI_BITFIELDS) + { + UINT *masks = (UINT *)info->bmiColors; + return get_color_component( GetRValue( color_key ), masks[0] ) | + get_color_component( GetGValue( color_key ), masks[1] ) | + get_color_component( GetBValue( color_key ), masks[2] ); + } + + return (GetRValue( color_key ) << 16) | (GetGValue( color_key ) << 8) | GetBValue( color_key ); +} + W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, HWND hwnd, const RECT *rect, BITMAPINFO *info, HBITMAP bitmap ) { @@ -265,6 +291,36 @@ W32KAPI void window_surface_flush( struct window_surface *surface ) window_surface_unlock( surface ); }
+W32KAPI void window_surface_set_layered( struct window_surface *surface, COLORREF color_key, UINT alpha_bits, UINT alpha_mask ) +{ + char color_buf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *color_info = (BITMAPINFO *)color_buf; + + window_surface_lock( surface ); + surface->funcs->get_info( surface, color_info ); + + color_key = get_color_key( color_info, color_key ); + if (color_key != surface->color_key) + { + surface->color_key = color_key; + surface->bounds = surface->rect; + } + if (alpha_bits != surface->alpha_bits) + { + surface->alpha_bits = alpha_bits; + surface->bounds = surface->rect; + } + if (alpha_mask != surface->alpha_mask) + { + surface->alpha_mask = alpha_mask; + surface->bounds = surface->rect; + } + + window_surface_unlock( surface ); + + window_surface_flush( surface ); +} + W32KAPI void window_surface_set_clip( struct window_surface *surface, HRGN clip_region ) { window_surface_lock( surface ); diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 8fa87b57807..a8e05832cd9 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -735,25 +735,6 @@ static BOOL is_argb_surface( struct window_surface *surface ) return surface && surface->funcs == &android_surface_funcs && !!surface->alpha_mask; }
-/*********************************************************************** - * set_color_key - */ -static void set_color_key( struct android_window_surface *surface, COLORREF key ) -{ - if (key == CLR_INVALID) - surface->header.color_key = CLR_INVALID; - else if (surface->info.bmiHeader.biBitCount <= 8) - surface->header.color_key = CLR_INVALID; - else if (key & (1 << 24)) /* PALETTEINDEX */ - surface->header.color_key = 0; - else if (key >> 16 == 0x10ff) /* DIBINDEX */ - surface->header.color_key = 0; - else if (surface->info.bmiHeader.biBitCount == 24) - surface->header.color_key = key; - else - surface->header.color_key = (GetRValue(key) << 16) | (GetGValue(key) << 8) | GetBValue(key); -} - /*********************************************************************** * create_surface */ @@ -777,13 +758,14 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, if (!window_surface_init( &surface->header, &android_surface_funcs, hwnd, rect, info, 0 )) goto failed; memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
- surface->window = get_ioctl_window( hwnd ); - surface->header.alpha_bits = (UINT)alpha << 24; - set_color_key( surface, color_key ); + surface->window = get_ioctl_window( hwnd );
TRACE( "created %p hwnd %p %s bits %p-%p\n", surface, hwnd, wine_dbgstr_rect(rect), surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage );
+ if (src_alpha) window_surface_set_layered( &surface->header, color_key, -1, 0xff000000 ); + else window_surface_set_layered( &surface->header, color_key, alpha << 24, 0 ); + return &surface->header;
failed: @@ -791,27 +773,6 @@ failed: return NULL; }
-/*********************************************************************** - * set_surface_layered - */ -static void set_surface_layered( struct window_surface *window_surface, BYTE alpha, COLORREF color_key ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - COLORREF prev_key; - BYTE prev_alpha; - - if (window_surface->funcs != &android_surface_funcs) return; /* we may get the null surface */ - - window_surface_lock( window_surface ); - prev_key = surface->header.color_key; - prev_alpha = surface->header.alpha_bits; - surface->header.alpha_bits = (UINT)alpha << 24; - set_color_key( surface, color_key ); - if (alpha != prev_alpha || surface->header.color_key != prev_key) /* refresh */ - window_surface->bounds = surface->header.rect; - window_surface_unlock( window_surface ); -} - /*********************************************************************** * get_mono_icon_argb * @@ -1342,7 +1303,7 @@ void ANDROID_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style ) if (data->surface) window_surface_release( data->surface ); data->surface = NULL; } - else if (data->surface) set_surface_layered( data->surface, 255, CLR_INVALID ); + else if (data->surface) window_surface_set_layered( data->surface, CLR_INVALID, -1, 0 ); } release_win_data( data ); } @@ -1360,7 +1321,7 @@ void ANDROID_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DW
if ((data = get_win_data( hwnd ))) { - if (data->surface) set_surface_layered( data->surface, alpha, key ); + if (data->surface) window_surface_set_layered( data->surface, key, alpha << 24, 0 ); release_win_data( data ); } } @@ -1394,7 +1355,7 @@ BOOL ANDROID_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF c if (surface) window_surface_release( surface ); surface = data->surface; } - else set_surface_layered( surface, 255, color_key ); + else window_surface_set_layered( surface, color_key, -1, 0xff000000 );
if ((*window_surface = surface)) window_surface_add_ref( surface ); release_win_data( data ); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index af0042bea39..e3abe7d2753 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -196,7 +196,6 @@ static struct window_surface *create_surface(HWND hwnd, macdrv_window window, co
surface->window = window; if (old_surface) surface->header.bounds = old_surface->bounds; - surface->header.alpha_mask = use_alpha ? 0xff000000 : 0; surface->provider = provider;
window_background = macdrv_window_background_color(); @@ -205,6 +204,9 @@ static struct window_surface *create_surface(HWND hwnd, macdrv_window window, co TRACE("created %p for %p %s color_bits %p-%p\n", surface, window, wine_dbgstr_rect(rect), surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage);
+ if (use_alpha) window_surface_set_layered( &surface->header, CLR_INVALID, -1, 0xff000000 ); + else window_surface_set_layered( &surface->header, CLR_INVALID, -1, 0 ); + return &surface->header;
failed: @@ -214,15 +216,6 @@ failed: return NULL; }
-/*********************************************************************** - * set_surface_use_alpha - */ -void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha) -{ - struct macdrv_window_surface *surface = get_mac_surface(window_surface); - if (surface) surface->header.alpha_mask = use_alpha ? 0xff000000 : 0; -} -
/*********************************************************************** * CreateWindowSurface (MACDRV.@) @@ -287,7 +280,7 @@ BOOL macdrv_CreateLayeredWindow(HWND hwnd, const RECT *window_rect, COLORREF col data->unminimized_surface = NULL; } } - else set_surface_use_alpha(surface, TRUE); + else window_surface_set_layered(surface, color_key, -1, 0xff000000);
if ((*window_surface = surface)) window_surface_add_ref(surface);
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index e772adf29b3..0bbb7e4fc34 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1683,7 +1683,7 @@ void macdrv_SetLayeredWindowAttributes(HWND hwnd, COLORREF key, BYTE alpha, DWOR { data->layered = TRUE; data->ulw_layered = FALSE; - if (data->surface) set_surface_use_alpha(data->surface, FALSE); + if (data->surface) window_surface_set_layered(data->surface, key, alpha << 24, 0); if (data->cocoa_window) { sync_window_opacity(data, key, alpha, FALSE, flags); @@ -1782,7 +1782,7 @@ void macdrv_SetWindowStyle(HWND hwnd, INT offset, STYLESTRUCT *style) data->layered = FALSE; data->ulw_layered = FALSE; sync_window_opacity(data, 0, 0, FALSE, 0); - if (data->surface) set_surface_use_alpha(data->surface, FALSE); + if (data->surface) window_surface_set_layered(data->surface, CLR_INVALID, -1, 0); }
if (offset == GWL_EXSTYLE && (changed & WS_EX_LAYOUTRTL)) diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 2103949b850..fd350fc6a65 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1597,13 +1597,6 @@ static struct x11drv_window_surface *get_x11_surface( struct window_surface *sur return (struct x11drv_window_surface *)surface; }
-static inline UINT get_color_component( UINT color, UINT mask ) -{ - int shift; - for (shift = 0; !(mask & 1); shift++) mask >>= 1; - return (color * mask / 255) << shift; -} - #ifdef HAVE_LIBXSHAPE static inline void flush_rgn_data( HRGN rgn, RGNDATA *data ) { @@ -1761,31 +1754,6 @@ static void update_surface_region( struct x11drv_window_surface *surface, const #endif }
-/*********************************************************************** - * set_color_key - */ -static void set_color_key( struct x11drv_window_surface *surface, COLORREF key ) -{ - UINT *masks = (UINT *)surface->info.bmiColors; - - if (key == CLR_INVALID) - surface->header.color_key = CLR_INVALID; - else if (surface->info.bmiHeader.biBitCount <= 8) - surface->header.color_key = CLR_INVALID; - else if (key & (1 << 24)) /* PALETTEINDEX */ - surface->header.color_key = 0; - else if (key >> 16 == 0x10ff) /* DIBINDEX */ - surface->header.color_key = 0; - else if (surface->info.bmiHeader.biBitCount == 24) - surface->header.color_key = key; - else if (surface->info.bmiHeader.biCompression == BI_RGB) - surface->header.color_key = (GetRValue(key) << 16) | (GetGValue(key) << 8) | GetBValue(key); - else - surface->header.color_key = get_color_component( GetRValue(key), masks[0] ) | - get_color_component( GetGValue(key), masks[1] ) | - get_color_component( GetBValue(key), masks[2] ); -} - #ifdef HAVE_LIBXXSHM static int xshm_error_handler( Display *display, XErrorEvent *event, void *arg ) { @@ -2132,9 +2100,6 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = window; - if (use_alpha && vis->depth == 32 && info->bmiHeader.biCompression == BI_RGB) surface->header.alpha_mask = 0xff000000; - set_color_key( surface, color_key ); - surface->gc = XCreateGC( gdi_display, window, 0, NULL ); XSetSubwindowMode( gdi_display, surface->gc, IncludeInferiors );
@@ -2142,6 +2107,9 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage, surface->image->ximage->data );
+ if (use_alpha) window_surface_set_layered( &surface->header, color_key, -1, 0xff000000 ); + else window_surface_set_layered( &surface->header, color_key, -1, 0 ); + return &surface->header;
failed: @@ -2149,23 +2117,6 @@ failed: return NULL; }
-/*********************************************************************** - * set_surface_color_key - */ -void set_surface_color_key( struct window_surface *window_surface, COLORREF color_key ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - COLORREF prev; - - if (window_surface->funcs != &x11drv_surface_funcs) return; /* we may get the null surface */ - - window_surface_lock( window_surface ); - prev = surface->header.color_key; - set_color_key( surface, color_key ); - if (surface->header.color_key != prev) update_surface_region( surface, window_surface->color_bits, surface->header.color_key, surface->header.alpha_mask ); - window_surface_unlock( window_surface ); -} - /*********************************************************************** * expose_surface */ @@ -2263,7 +2214,7 @@ BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF co if (surface) window_surface_release( surface ); surface = data->surface; } - else set_surface_color_key( surface, color_key ); + else window_surface_set_layered( surface, color_key, -1, 0xff000000 );
if ((*window_surface = surface)) window_surface_add_ref( surface ); release_win_data( data ); diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 2a84bc49620..7416164bbb1 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1917,7 +1917,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style ) data->layered = FALSE; set_window_visual( data, &default_visual, FALSE ); sync_window_opacity( data->display, data->whole_window, 0, 0, 0 ); - if (data->surface) set_surface_color_key( data->surface, CLR_INVALID ); + if (data->surface) window_surface_set_layered( data->surface, CLR_INVALID, -1, 0 ); } done: release_win_data( data ); @@ -2889,7 +2889,7 @@ void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWO if (data->whole_window) sync_window_opacity( data->display, data->whole_window, key, alpha, flags ); if (data->surface) - set_surface_color_key( data->surface, (flags & LWA_COLORKEY) ? key : CLR_INVALID ); + window_surface_set_layered( data->surface, (flags & LWA_COLORKEY) ? key : CLR_INVALID, alpha << 24, 0 );
data->layered = TRUE; if (!data->mapped) /* mapping is delayed until attributes are set */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 4a9bdafd449..49e4f039b18 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -266,7 +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 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 );
extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index b7c9f273d95..d1e4b304323 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -243,6 +243,7 @@ W32KAPI void window_surface_add_ref( struct window_surface *surface ); W32KAPI void window_surface_release( struct window_surface *surface ); W32KAPI void window_surface_lock( struct window_surface *surface ); W32KAPI void window_surface_unlock( struct window_surface *surface ); +W32KAPI void window_surface_set_layered( struct window_surface *surface, COLORREF color_key, UINT alpha_bits, UINT alpha_mask ); W32KAPI void window_surface_flush( struct window_surface *surface ); W32KAPI void window_surface_set_clip( struct window_surface *surface, HRGN clip_region );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 12 +++++++++--- dlls/wineandroid.drv/window.c | 7 ++++--- dlls/winemac.drv/surface.c | 8 ++++---- dlls/winewayland.drv/window_surface.c | 14 ++++++++------ dlls/winex11.drv/bitblt.c | 15 +++++++-------- include/wine/gdi_driver.h | 3 ++- 6 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index d5c7eaac101..4020fb833ac 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -79,7 +79,8 @@ static void dummy_surface_set_clip( struct window_surface *window_surface, const /* nothing to do */ }
-static BOOL dummy_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty ) +static BOOL dummy_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits ) { /* nothing to do */ return TRUE; @@ -135,7 +136,8 @@ static void offscreen_window_surface_set_clip( struct window_surface *base, cons { }
-static BOOL offscreen_window_surface_flush( struct window_surface *base, const RECT *rect, const RECT *dirty ) +static BOOL offscreen_window_surface_flush( struct window_surface *base, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits ) { return TRUE; } @@ -276,16 +278,20 @@ W32KAPI void window_surface_unlock( struct window_surface *surface )
W32KAPI void window_surface_flush( struct window_surface *surface ) { + char color_buf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *color_info = (BITMAPINFO *)color_buf; RECT dirty = surface->rect; + void *color_bits;
window_surface_lock( surface ); + color_bits = surface->funcs->get_info( surface, color_info );
OffsetRect( &dirty, -dirty.left, -dirty.top ); if (intersect_rect( &dirty, &dirty, &surface->bounds )) { TRACE( "Flushing hwnd %p, surface %p %s, bounds %s, dirty %s\n", surface->hwnd, surface, wine_dbgstr_rect( &surface->rect ), wine_dbgstr_rect( &surface->bounds ), wine_dbgstr_rect( &dirty ) ); - if (surface->funcs->flush( surface, &surface->rect, &dirty )) reset_bounds( &surface->bounds ); + if (surface->funcs->flush( surface, &surface->rect, &dirty, color_info, color_bits )) reset_bounds( &surface->bounds ); }
window_surface_unlock( surface ); diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index a8e05832cd9..225c6668103 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -643,7 +643,8 @@ static void android_surface_set_clip( struct window_surface *window_surface, con /*********************************************************************** * android_surface_flush */ -static BOOL android_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty ) +static BOOL android_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits ) { struct android_window_surface *surface = get_android_surface( window_surface ); ANativeWindow_Buffer buffer; @@ -670,7 +671,7 @@ static BOOL android_surface_flush( struct window_surface *window_surface, const locked.bottom = rc.bottom; intersect_rect( &locked, &locked, rect );
- src = (DWORD *)window_surface->color_bits + (locked.top - rect->top) * surface->info.bmiHeader.biWidth + + src = (DWORD *)color_bits + (locked.top - rect->top) * color_info->bmiHeader.biWidth + (locked.left - rect->left); dst = (DWORD *)buffer.bits + locked.top * buffer.stride + locked.left; width = min( locked.right - locked.left, buffer.stride ); @@ -697,7 +698,7 @@ static BOOL android_surface_flush( struct window_surface *window_surface, const apply_line_region( dst, width, locked.left, y, rgn_rect, end ); }
- src += surface->info.bmiHeader.biWidth; + src += color_info->bmiHeader.biWidth; dst += buffer.stride; } surface->window->perform( surface->window, NATIVE_WINDOW_UNLOCK_AND_POST ); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index e3abe7d2753..bfd0cb25414 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -101,11 +101,11 @@ static void macdrv_surface_set_clip(struct window_surface *window_surface, const /*********************************************************************** * macdrv_surface_flush */ -static BOOL macdrv_surface_flush(struct window_surface *window_surface, const RECT *rect, const RECT *dirty) +static BOOL macdrv_surface_flush(struct window_surface *window_surface, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits) { struct macdrv_window_surface *surface = get_mac_surface(window_surface); CGImageAlphaInfo alpha_info = (window_surface->alpha_mask ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst); - BITMAPINFO *color_info = &surface->info; CGColorSpaceRef colorspace; CGImageRef image;
@@ -199,10 +199,10 @@ static struct window_surface *create_surface(HWND hwnd, macdrv_window window, co surface->provider = provider;
window_background = macdrv_window_background_color(); - memset_pattern4(surface->header.color_bits, &window_background, info->bmiHeader.biSizeImage); + memset_pattern4(bits, &window_background, info->bmiHeader.biSizeImage);
TRACE("created %p for %p %s color_bits %p-%p\n", surface, window, wine_dbgstr_rect(rect), - surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage); + bits, (char *)bits + info->bmiHeader.biSizeImage);
if (use_alpha) window_surface_set_layered( &surface->header, CLR_INVALID, -1, 0xff000000 ); else window_surface_set_layered( &surface->header, CLR_INVALID, -1, 0 ); diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index d1ac582e7ec..5523e18e4f6 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -254,7 +254,7 @@ RGNDATA *get_region_data(HRGN region) /********************************************************************** * copy_pixel_region */ -static void copy_pixel_region(char *src_pixels, RECT *src_rect, +static void copy_pixel_region(const char *src_pixels, RECT *src_rect, char *dst_pixels, RECT *dst_rect, HRGN region) { @@ -274,7 +274,8 @@ static void copy_pixel_region(char *src_pixels, RECT *src_rect,
for (;rgn_rect < rgn_rect_end; rgn_rect++) { - char *src, *dst; + const char *src; + char *dst; int y, width_bytes, height; RECT rc;
@@ -310,7 +311,7 @@ static void copy_pixel_region(char *src_pixels, RECT *src_rect, * wayland_shm_buffer_copy_data */ static void wayland_shm_buffer_copy_data(struct wayland_shm_buffer *buffer, - char *bits, RECT *rect, + const char *bits, RECT *rect, HRGN region) { RECT buffer_rect = {0, 0, buffer->width, buffer->height}; @@ -331,8 +332,10 @@ static void wayland_shm_buffer_copy(struct wayland_shm_buffer *src, /*********************************************************************** * wayland_window_surface_flush */ -static BOOL wayland_window_surface_flush(struct window_surface *window_surface, const RECT *rect, const RECT *dirty) +static BOOL wayland_window_surface_flush(struct window_surface *window_surface, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits) { + RECT surface_rect = {.right = color_info->bmiHeader.biWidth, .bottom = abs(color_info->bmiHeader.biHeight)}; struct wayland_window_surface *wws = wayland_window_surface_cast(window_surface); struct wayland_shm_buffer *shm_buffer = NULL; BOOL flushed = FALSE; @@ -394,8 +397,7 @@ static BOOL wayland_window_surface_flush(struct window_surface *window_surface, copy_from_window_region = shm_buffer->damage_region; }
- wayland_shm_buffer_copy_data(shm_buffer, window_surface->color_bits, - &window_surface->rect, copy_from_window_region); + wayland_shm_buffer_copy_data(shm_buffer, color_bits, &surface_rect, copy_from_window_region);
pthread_mutex_lock(&wws->wayland_surface->mutex); if (wayland_surface_reconfigure(wws->wayland_surface)) diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index fd350fc6a65..8ac1ffead17 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1079,7 +1079,7 @@ static inline BOOL image_needs_byteswap( XImage *image, BOOL is_r8g8b8, int bit_ }
/* copy image bits with byte swapping and/or pixel mapping */ -static void copy_image_byteswap( BITMAPINFO *info, const unsigned char *src, unsigned char *dst, +static void copy_image_byteswap( const BITMAPINFO *info, const unsigned char *src, unsigned char *dst, int src_stride, int dst_stride, int height, BOOL byteswap, const int *mapping, unsigned int zeropad_mask, unsigned int alpha_bits ) { @@ -1624,13 +1624,12 @@ static inline void add_row( HRGN rgn, RGNDATA *data, int x, int y, int len ) /*********************************************************************** * update_surface_region */ -static void update_surface_region( struct x11drv_window_surface *surface, const void *color_bits, +static void update_surface_region( struct x11drv_window_surface *surface, const BITMAPINFO *info, const void *color_bits, COLORREF color_key, UINT alpha_mask ) { #ifdef HAVE_LIBXSHAPE char buffer[4096]; RGNDATA *data = (RGNDATA *)buffer; - BITMAPINFO *info = &surface->info; UINT *masks = (UINT *)info->bmiColors; int x, y, start, width; HRGN rgn; @@ -1957,17 +1956,17 @@ static void x11drv_surface_set_clip( struct window_surface *window_surface, cons /*********************************************************************** * x11drv_surface_flush */ -static BOOL x11drv_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty ) +static BOOL x11drv_surface_flush( struct window_surface *window_surface, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits ) { UINT alpha_mask = window_surface->alpha_mask, alpha_bits = window_surface->alpha_bits; struct x11drv_window_surface *surface = get_x11_surface( window_surface ); COLORREF color_key = window_surface->color_key; - const BITMAPINFO *color_info = &surface->info; XImage *ximage = surface->image->ximage; - unsigned char *src = window_surface->color_bits; + const unsigned char *src = color_bits; unsigned char *dst = (unsigned char *)ximage->data;
- if (alpha_mask || color_key != CLR_INVALID) update_surface_region( surface, window_surface->color_bits, color_key, alpha_mask ); + if (alpha_mask || color_key != CLR_INVALID) update_surface_region( surface, color_info, color_bits, color_key, alpha_mask );
if (alpha_bits == -1) { @@ -1987,7 +1986,7 @@ static BOOL x11drv_surface_flush( struct window_surface *window_surface, const R
src += dirty->top * width_bytes; dst += dirty->top * width_bytes; - copy_image_byteswap( &surface->info, src, dst, width_bytes, width_bytes, dirty->bottom - dirty->top, + copy_image_byteswap( color_info, src, dst, width_bytes, width_bytes, dirty->bottom - dirty->top, surface->byteswap, mapping, ~0u, alpha_bits ); } else if (alpha_bits) diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index d1e4b304323..4b1ea3c7e33 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -213,7 +213,8 @@ struct window_surface_funcs { void* (*get_info)( struct window_surface *surface, BITMAPINFO *info ); void (*set_clip)( struct window_surface *surface, const RECT *rects, UINT count ); - BOOL (*flush)( struct window_surface *surface, const RECT *rect, const RECT *dirty ); + BOOL (*flush)( struct window_surface *surface, const RECT *rect, const RECT *dirty, + const BITMAPINFO *color_info, const void *color_bits ); void (*destroy)( struct window_surface *surface ); };
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 101 ++++++++++++-------------- dlls/win32u/dibdrv/dc.c | 2 +- dlls/wineandroid.drv/window.c | 16 +--- dlls/winemac.drv/surface.c | 25 +------ dlls/winewayland.drv/window_surface.c | 18 +---- dlls/winex11.drv/bitblt.c | 17 +---- include/wine/gdi_driver.h | 3 +- 7 files changed, 58 insertions(+), 124 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 4020fb833ac..5481246faa3 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -56,24 +56,6 @@ static pthread_mutex_t surfaces_lock = PTHREAD_MUTEX_INITIALIZER; * Dummy window surface for windows that shouldn't get painted. */
-static void *dummy_surface_get_bitmap_info( struct window_surface *window_surface, BITMAPINFO *info ) -{ - static DWORD dummy_data; - - info->bmiHeader.biSize = sizeof( info->bmiHeader ); - info->bmiHeader.biWidth = dummy_surface.rect.right; - info->bmiHeader.biHeight = dummy_surface.rect.bottom; - info->bmiHeader.biPlanes = 1; - info->bmiHeader.biBitCount = 32; - info->bmiHeader.biCompression = BI_RGB; - info->bmiHeader.biSizeImage = 0; - info->bmiHeader.biXPelsPerMeter = 0; - info->bmiHeader.biYPelsPerMeter = 0; - info->bmiHeader.biClrUsed = 0; - info->bmiHeader.biClrImportant = 0; - return &dummy_data; -} - static void dummy_surface_set_clip( struct window_surface *window_surface, const RECT *rects, UINT count ) { /* nothing to do */ @@ -93,7 +75,6 @@ static void dummy_surface_destroy( struct window_surface *window_surface )
static const struct window_surface_funcs dummy_surface_funcs = { - dummy_surface_get_bitmap_info, dummy_surface_set_clip, dummy_surface_flush, dummy_surface_destroy @@ -125,13 +106,6 @@ static struct offscreen_window_surface *impl_from_window_surface( struct window_ return CONTAINING_RECORD( base, struct offscreen_window_surface, header ); }
-static void *offscreen_window_surface_get_bitmap_info( struct window_surface *base, BITMAPINFO *info ) -{ - struct offscreen_window_surface *impl = impl_from_window_surface( base ); - info->bmiHeader = impl->info.bmiHeader; - return base->color_bits; -} - static void offscreen_window_surface_set_clip( struct window_surface *base, const RECT *rects, UINT count ) { } @@ -150,7 +124,6 @@ static void offscreen_window_surface_destroy( struct window_surface *base )
static const struct window_surface_funcs offscreen_window_surface_funcs = { - offscreen_window_surface_get_bitmap_info, offscreen_window_surface_set_clip, offscreen_window_surface_flush, offscreen_window_surface_destroy @@ -224,10 +197,6 @@ static COLORREF get_color_key( const BITMAPINFO *info, COLORREF color_key ) W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, HWND hwnd, const RECT *rect, BITMAPINFO *info, HBITMAP bitmap ) { - struct bitblt_coords coords = {0}; - struct gdi_image_bits bits; - BITMAPOBJ *bmp; - surface->funcs = funcs; surface->ref = 1; surface->hwnd = hwnd; @@ -239,10 +208,7 @@ W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct w reset_bounds( &surface->bounds );
if (!bitmap) bitmap = NtGdiCreateDIBSection( 0, NULL, 0, info, DIB_RGB_COLORS, 0, 0, 0, NULL ); - if (!(surface->color_bitmap = bitmap) || !(bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ))) return FALSE; - get_image_from_bitmap( bmp, info, &bits, &coords ); - surface->color_bits = bits.ptr; - GDI_ReleaseObj( bitmap ); + if (!(surface->color_bitmap = bitmap)) return FALSE;
return TRUE; } @@ -276,6 +242,31 @@ W32KAPI void window_surface_unlock( struct window_surface *surface ) pthread_mutex_unlock( &surface->mutex ); }
+W32KAPI BOOL window_surface_get_color( struct window_surface *surface, BITMAPINFO *info, void **bits ) +{ + struct bitblt_coords coords = {0}; + struct gdi_image_bits gdi_bits; + BITMAPOBJ *bmp; + + if (surface == &dummy_surface) + { + static BITMAPINFOHEADER header = {.biSize = sizeof(header), .biWidth = 1, .biHeight = 1, + .biPlanes = 1, .biBitCount = 32, .biCompression = BI_RGB}; + static DWORD dummy_data; + + info->bmiHeader = header; + if (bits) *bits = &dummy_data; + return TRUE; + } + + if (!(bmp = GDI_GetObjPtr( surface->color_bitmap, NTGDI_OBJ_BITMAP ))) return FALSE; + get_image_from_bitmap( bmp, info, &gdi_bits, &coords ); + if (bits) *bits = gdi_bits.ptr; + GDI_ReleaseObj( surface->color_bitmap ); + + return TRUE; +} + W32KAPI void window_surface_flush( struct window_surface *surface ) { char color_buf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; @@ -284,10 +275,9 @@ W32KAPI void window_surface_flush( struct window_surface *surface ) void *color_bits;
window_surface_lock( surface ); - color_bits = surface->funcs->get_info( surface, color_info );
OffsetRect( &dirty, -dirty.left, -dirty.top ); - if (intersect_rect( &dirty, &dirty, &surface->bounds )) + if (intersect_rect( &dirty, &dirty, &surface->bounds ) && window_surface_get_color( surface, color_info, &color_bits )) { TRACE( "Flushing hwnd %p, surface %p %s, bounds %s, dirty %s\n", surface->hwnd, surface, wine_dbgstr_rect( &surface->rect ), wine_dbgstr_rect( &surface->bounds ), wine_dbgstr_rect( &dirty ) ); @@ -301,27 +291,28 @@ W32KAPI void window_surface_set_layered( struct window_surface *surface, COLORRE { char color_buf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *color_info = (BITMAPINFO *)color_buf; + void *color_bits;
window_surface_lock( surface ); - surface->funcs->get_info( surface, color_info ); - - color_key = get_color_key( color_info, color_key ); - if (color_key != surface->color_key) - { - surface->color_key = color_key; - surface->bounds = surface->rect; - } - if (alpha_bits != surface->alpha_bits) + if (window_surface_get_color( surface, color_info, &color_bits )) { - surface->alpha_bits = alpha_bits; - surface->bounds = surface->rect; - } - if (alpha_mask != surface->alpha_mask) - { - surface->alpha_mask = alpha_mask; - surface->bounds = surface->rect; + color_key = get_color_key( color_info, color_key ); + if (color_key != surface->color_key) + { + surface->color_key = color_key; + surface->bounds = surface->rect; + } + if (alpha_bits != surface->alpha_bits) + { + surface->alpha_bits = alpha_bits; + surface->bounds = surface->rect; + } + if (alpha_mask != surface->alpha_mask) + { + surface->alpha_mask = alpha_mask; + surface->bounds = surface->rect; + } } - window_surface_unlock( surface );
window_surface_flush( surface ); @@ -1293,8 +1284,8 @@ void move_window_bits_surface( HWND hwnd, const RECT *window_rect, struct window OffsetRect( &src, -old_visible_rect->left, -old_visible_rect->top ); OffsetRect( &dst, -window_rect->left, -window_rect->top );
- bits = old_surface->funcs->get_info( old_surface, info ); window_surface_lock( old_surface ); + window_surface_get_color( old_surface, info, &bits ); NtGdiSetDIBitsToDeviceInternal( hdc, dst.left, dst.top, dst.right - dst.left, dst.bottom - dst.top, src.left - old_surface->rect.left, old_surface->rect.bottom - src.bottom, 0, old_surface->rect.bottom - old_surface->rect.top, diff --git a/dlls/win32u/dibdrv/dc.c b/dlls/win32u/dibdrv/dc.c index ea7512b01ca..51750098a7f 100644 --- a/dlls/win32u/dibdrv/dc.c +++ b/dlls/win32u/dibdrv/dc.c @@ -816,7 +816,7 @@ void dibdrv_set_window_surface( DC *dc, struct window_surface *surface ) physdev->surface = surface;
dibdrv = physdev->dibdrv; - bits = surface->funcs->get_info( surface, info ); + window_surface_get_color( surface, info, &bits ); init_dib_info_from_bitmapinfo( &dibdrv->dib, info, bits ); dibdrv->dib.rect = dc->attr->vis_rect; OffsetRect( &dibdrv->dib.rect, -dc->device_rect.left, -dc->device_rect.top ); diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 225c6668103..f8bfa5ae5ac 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -614,17 +614,6 @@ static void apply_line_region( DWORD *dst, int width, int x, int y, const RECT * if (width > 0) memset( dst, 0, width * sizeof(*dst) ); }
-/*********************************************************************** - * android_surface_get_bitmap_info - */ -static void *android_surface_get_bitmap_info( struct window_surface *window_surface, BITMAPINFO *info ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - - memcpy( info, &surface->info, get_dib_info_size( &surface->info, DIB_RGB_COLORS )); - return window_surface->color_bits; -} - /*********************************************************************** * android_surface_set_clip */ @@ -725,7 +714,6 @@ static void android_surface_destroy( struct window_surface *window_surface )
static const struct window_surface_funcs android_surface_funcs = { - android_surface_get_bitmap_info, android_surface_set_clip, android_surface_flush, android_surface_destroy @@ -746,6 +734,7 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, int width = rect->right - rect->left, height = rect->bottom - rect->top; char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *info = (BITMAPINFO *)buffer; + void *bits;
memset( info, 0, sizeof(*info) ); set_color_info( info, src_alpha ); @@ -757,12 +746,13 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, surface = calloc( 1, FIELD_OFFSET( struct android_window_surface, info.bmiColors[3] )); if (!surface) return NULL; if (!window_surface_init( &surface->header, &android_surface_funcs, hwnd, rect, info, 0 )) goto failed; + if (!window_surface_get_color( &surface->header, info, &bits )) goto failed; memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = get_ioctl_window( hwnd );
TRACE( "created %p hwnd %p %s bits %p-%p\n", surface, hwnd, wine_dbgstr_rect(rect), - surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage ); + bits, (char *)bits + info->bmiHeader.biSizeImage );
if (src_alpha) window_surface_set_layered( &surface->header, color_key, -1, 0xff000000 ); else window_surface_set_layered( &surface->header, color_key, alpha << 24, 0 ); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index bfd0cb25414..2f135dc6d7f 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -31,17 +31,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(bitblt);
- -/* only for use on sanitized BITMAPINFO structures */ -static inline int get_dib_info_size(const BITMAPINFO *info, UINT coloruse) -{ - if (info->bmiHeader.biCompression == BI_BITFIELDS) - return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD); - if (coloruse == DIB_PAL_COLORS) - return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD); - return FIELD_OFFSET(BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed]); -} - static inline int get_dib_stride(int width, int bpp) { return ((width * bpp + 31) >> 3) & ~3; @@ -79,18 +68,6 @@ static CGDataProviderRef data_provider_create(size_t size, void **bits) return provider; }
-/*********************************************************************** - * macdrv_surface_get_bitmap_info - */ -static void *macdrv_surface_get_bitmap_info(struct window_surface *window_surface, - BITMAPINFO *info) -{ - struct macdrv_window_surface *surface = get_mac_surface(window_surface); - - memcpy(info, &surface->info, get_dib_info_size(&surface->info, DIB_RGB_COLORS)); - return window_surface->color_bits; -} - /*********************************************************************** * macdrv_surface_set_clip */ @@ -135,7 +112,6 @@ static void macdrv_surface_destroy(struct window_surface *window_surface)
static const struct window_surface_funcs macdrv_surface_funcs = { - macdrv_surface_get_bitmap_info, macdrv_surface_set_clip, macdrv_surface_flush, macdrv_surface_destroy, @@ -192,6 +168,7 @@ static struct window_surface *create_surface(HWND hwnd, macdrv_window window, co
if (!(surface = calloc(1, FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3])))) goto failed; if (!window_surface_init(&surface->header, &macdrv_surface_funcs, hwnd, rect, info, bitmap)) goto failed; + if (!window_surface_get_color(&surface->header, info, &bits)) goto failed; memcpy(&surface->info, info, offsetof(BITMAPINFO, bmiColors[3]));
surface->window = window; diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 5523e18e4f6..19fecf8aa3c 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -209,19 +209,6 @@ static void wayland_buffer_queue_add_damage(struct wayland_buffer_queue *queue, } }
-/*********************************************************************** - * wayland_window_surface_get_bitmap_info - */ -static void *wayland_window_surface_get_bitmap_info(struct window_surface *window_surface, - BITMAPINFO *info) -{ - struct wayland_window_surface *surface = wayland_window_surface_cast(window_surface); - /* We don't store any additional information at the end of our BITMAPINFO, so - * just copy the structure itself. */ - memcpy(info, &surface->info, sizeof(*info)); - return window_surface->color_bits; -} - /*********************************************************************** * wayland_window_surface_set_clip */ @@ -443,7 +430,6 @@ static void wayland_window_surface_destroy(struct window_surface *window_surface
static const struct window_surface_funcs wayland_window_surface_funcs = { - wayland_window_surface_get_bitmap_info, wayland_window_surface_set_clip, wayland_window_surface_flush, wayland_window_surface_destroy @@ -459,6 +445,7 @@ static struct window_surface *wayland_window_surface_create(HWND hwnd, const REC struct wayland_window_surface *wws; int width = rect->right - rect->left; int height = rect->bottom - rect->top; + void *bits;
TRACE("hwnd %p rect %s\n", hwnd, wine_dbgstr_rect(rect));
@@ -474,10 +461,11 @@ static struct window_surface *wayland_window_surface_create(HWND hwnd, const REC wws = calloc(1, sizeof(*wws)); if (!wws) return NULL; if (!window_surface_init(&wws->header, &wayland_window_surface_funcs, hwnd, rect, info, 0)) goto failed; + if (!window_surface_get_color(&wws->header, info, &bits)) goto failed; wws->info = *info;
TRACE("created %p hwnd %p %s bits [%p,%p)\n", wws, hwnd, wine_dbgstr_rect(rect), - wws->header.color_bits, (char *)wws->header.color_bits + wws->info.bmiHeader.biSizeImage); + bits, (char *)bits + info->bmiHeader.biSizeImage);
return &wws->header;
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 8ac1ffead17..068517a0161 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1905,17 +1905,6 @@ failed: return NULL; }
-/*********************************************************************** - * x11drv_surface_get_bitmap_info - */ -static void *x11drv_surface_get_bitmap_info( struct window_surface *window_surface, BITMAPINFO *info ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - - memcpy( info, &surface->info, get_dib_info_size( &surface->info, DIB_RGB_COLORS )); - return window_surface->color_bits; -} - static XRectangle *xrectangles_from_rects( const RECT *rects, UINT count ) { XRectangle *xrects; @@ -2024,7 +2013,6 @@ static void x11drv_surface_destroy( struct window_surface *window_surface )
static const struct window_surface_funcs x11drv_surface_funcs = { - x11drv_surface_get_bitmap_info, x11drv_surface_set_clip, x11drv_surface_flush, x11drv_surface_destroy @@ -2046,6 +2034,7 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV D3DDDIFORMAT d3d_format; HBITMAP bitmap = 0; BOOL byteswap; + void *bits; UINT size, status;
memset( info, 0, sizeof(*info) ); @@ -2096,6 +2085,7 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV surface->byteswap = byteswap;
if (!window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, rect, info, bitmap )) goto failed; + if (!window_surface_get_color( &surface->header, info, &bits )) goto failed; memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = window; @@ -2103,8 +2093,7 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV XSetSubwindowMode( gdi_display, surface->gc, IncludeInferiors );
TRACE( "created %p for %lx %s bits %p-%p image %p\n", surface, window, wine_dbgstr_rect(rect), - surface->header.color_bits, (char *)surface->header.color_bits + info->bmiHeader.biSizeImage, - surface->image->ximage->data ); + bits, (char *)bits + info->bmiHeader.biSizeImage, surface->image->ximage->data );
if (use_alpha) window_surface_set_layered( &surface->header, color_key, -1, 0xff000000 ); else window_surface_set_layered( &surface->header, color_key, -1, 0 ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 4b1ea3c7e33..87ced3f8296 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -211,7 +211,6 @@ struct window_surface;
struct window_surface_funcs { - void* (*get_info)( struct window_surface *surface, BITMAPINFO *info ); void (*set_clip)( struct window_surface *surface, const RECT *rects, UINT count ); BOOL (*flush)( struct window_surface *surface, const RECT *rect, const RECT *dirty, const BITMAPINFO *color_info, const void *color_bits ); @@ -234,7 +233,6 @@ struct window_surface UINT alpha_bits; /* layered window global alpha bits, invalid if -1 */ UINT alpha_mask; /* layered window per-pixel alpha mask, invalid if 0 */ HBITMAP color_bitmap; /* bitmap for the surface colors */ - void *color_bits; /* pixel bits of the color bitmap */ /* driver-specific fields here */ };
@@ -244,6 +242,7 @@ W32KAPI void window_surface_add_ref( struct window_surface *surface ); W32KAPI void window_surface_release( struct window_surface *surface ); W32KAPI void window_surface_lock( struct window_surface *surface ); W32KAPI void window_surface_unlock( struct window_surface *surface ); +W32KAPI BOOL window_surface_get_color( struct window_surface *surface, BITMAPINFO *info, void **bits ); W32KAPI void window_surface_set_layered( struct window_surface *surface, COLORREF color_key, UINT alpha_bits, UINT alpha_mask ); W32KAPI void window_surface_flush( struct window_surface *surface ); W32KAPI void window_surface_set_clip( struct window_surface *surface, HRGN clip_region );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 51 ++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 5481246faa3..244eda705f9 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -92,34 +92,19 @@ struct window_surface dummy_surface = * Off-screen window surface. */
-struct offscreen_window_surface -{ - struct window_surface header; - BITMAPINFO info; -}; - -static const struct window_surface_funcs offscreen_window_surface_funcs; - -static struct offscreen_window_surface *impl_from_window_surface( struct window_surface *base ) -{ - if (!base || base->funcs != &offscreen_window_surface_funcs) return NULL; - return CONTAINING_RECORD( base, struct offscreen_window_surface, header ); -} - -static void offscreen_window_surface_set_clip( struct window_surface *base, const RECT *rects, UINT count ) +static void offscreen_window_surface_set_clip( struct window_surface *surface, const RECT *rects, UINT count ) { }
-static BOOL offscreen_window_surface_flush( struct window_surface *base, const RECT *rect, const RECT *dirty, +static BOOL offscreen_window_surface_flush( struct window_surface *surface, const RECT *rect, const RECT *dirty, const BITMAPINFO *color_info, const void *color_bits ) { return TRUE; }
-static void offscreen_window_surface_destroy( struct window_surface *base ) +static void offscreen_window_surface_destroy( struct window_surface *surface ) { - struct offscreen_window_surface *impl = impl_from_window_surface( base ); - free( impl ); + free( surface ); }
static const struct window_surface_funcs offscreen_window_surface_funcs = @@ -129,22 +114,19 @@ static const struct window_surface_funcs offscreen_window_surface_funcs = offscreen_window_surface_destroy };
-void create_offscreen_window_surface( HWND hwnd, const RECT *surface_rect, struct window_surface **surface ) +void create_offscreen_window_surface( HWND hwnd, const RECT *surface_rect, struct window_surface **window_surface ) { char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *info = (BITMAPINFO *)buffer; - struct offscreen_window_surface *impl; + struct window_surface *surface, *previous;
- TRACE( "hwnd %p, surface_rect %s, surface %p.\n", hwnd, wine_dbgstr_rect( surface_rect ), surface ); + TRACE( "hwnd %p, surface_rect %s, window_surface %p.\n", hwnd, wine_dbgstr_rect( surface_rect ), window_surface );
/* check that old surface is an offscreen_window_surface, or release it */ - if ((impl = impl_from_window_surface( *surface ))) - { - /* if the rect didn't change, keep the same surface */ - if (EqualRect( surface_rect, &impl->header.rect )) return; - window_surface_release( &impl->header ); - } - else if (*surface) window_surface_release( *surface ); + if ((previous = *window_surface) && previous->funcs == &offscreen_window_surface_funcs && + EqualRect( surface_rect, &previous->rect )) return; + if (previous) window_surface_release( previous ); + *window_surface = NULL;
memset( info, 0, sizeof(*info) ); info->bmiHeader.biSize = sizeof(info->bmiHeader); @@ -156,14 +138,11 @@ void create_offscreen_window_surface( HWND hwnd, const RECT *surface_rect, struc info->bmiHeader.biCompression = BI_RGB;
/* create a new window surface */ - *surface = NULL; - if (!(impl = calloc(1, sizeof(*impl)))) return; - window_surface_init( &impl->header, &offscreen_window_surface_funcs, hwnd, surface_rect, info, 0 ); - impl->info = *info; - - TRACE( "created window surface %p\n", &impl->header ); + if (!(surface = calloc(1, sizeof(*surface)))) return; + window_surface_init( surface, &offscreen_window_surface_funcs, hwnd, surface_rect, info, 0 );
- *surface = &impl->header; + TRACE( "created window surface %p\n", surface ); + *window_surface = surface; }
/* window surface common helpers */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/surface.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 2f135dc6d7f..a9ec74b27ad 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -48,7 +48,6 @@ struct macdrv_window_surface struct window_surface header; macdrv_window window; CGDataProviderRef provider; - BITMAPINFO info; /* variable size, must be last */ };
static struct macdrv_window_surface *get_mac_surface(struct window_surface *surface); @@ -166,10 +165,9 @@ static struct window_surface *create_surface(HWND hwnd, macdrv_window window, co } if (desc.hDeviceDc) NtUserReleaseDC(hwnd, desc.hDeviceDc);
- if (!(surface = calloc(1, FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3])))) goto failed; + if (!(surface = calloc(1, sizeof(*surface)))) goto failed; if (!window_surface_init(&surface->header, &macdrv_surface_funcs, hwnd, rect, info, bitmap)) goto failed; if (!window_surface_get_color(&surface->header, info, &bits)) goto failed; - memcpy(&surface->info, info, offsetof(BITMAPINFO, bmiColors[3]));
surface->window = window; if (old_surface) surface->header.bounds = old_surface->bounds;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wineandroid.drv/window.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index f8bfa5ae5ac..4bc7daf320f 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -70,16 +70,6 @@ static inline int context_idx( HWND hwnd ) return LOWORD( hwnd ) >> 1; }
-/* only for use on sanitized BITMAPINFO structures */ -static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse ) -{ - if (info->bmiHeader.biCompression == BI_BITFIELDS) - return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD); - if (coloruse == DIB_PAL_COLORS) - return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD); - return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] ); -} - static inline int get_dib_stride( int width, int bpp ) { return ((width * bpp + 31) >> 3) & ~3; @@ -564,7 +554,6 @@ struct android_window_surface ANativeWindow *window; UINT clip_count; RECT *clip_rects; - BITMAPINFO info; /* variable size, must be last */ };
static struct android_window_surface *get_android_surface( struct window_surface *surface ) @@ -743,11 +732,9 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, info->bmiHeader.biPlanes = 1; info->bmiHeader.biSizeImage = get_dib_image_size( info );
- surface = calloc( 1, FIELD_OFFSET( struct android_window_surface, info.bmiColors[3] )); - if (!surface) return NULL; + if (!(surface = calloc( 1, sizeof(*surface) ))) return NULL; if (!window_surface_init( &surface->header, &android_surface_funcs, hwnd, rect, info, 0 )) goto failed; if (!window_surface_get_color( &surface->header, info, &bits )) goto failed; - memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = get_ioctl_window( hwnd );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/window_surface.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 19fecf8aa3c..eb1d6d6ed60 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -45,7 +45,6 @@ struct wayland_window_surface struct window_surface header; struct wayland_surface *wayland_surface; struct wayland_buffer_queue *wayland_buffer_queue; - BITMAPINFO info; };
static struct wayland_window_surface *wayland_window_surface_cast( @@ -462,7 +461,6 @@ static struct window_surface *wayland_window_surface_create(HWND hwnd, const REC if (!wws) return NULL; if (!window_surface_init(&wws->header, &wayland_window_surface_funcs, hwnd, rect, info, 0)) goto failed; if (!window_surface_get_color(&wws->header, info, &bits)) goto failed; - wws->info = *info;
TRACE("created %p hwnd %p %s bits [%p,%p)\n", wws, hwnd, wine_dbgstr_rect(rect), bits, (char *)bits + info->bmiHeader.biSizeImage);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/bitblt.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 068517a0161..0e2e08c11f0 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1589,7 +1589,6 @@ struct x11drv_window_surface GC gc; struct x11drv_image *image; BOOL byteswap; - BITMAPINFO info; /* variable size, must be last */ };
static struct x11drv_window_surface *get_x11_surface( struct window_surface *surface ) @@ -2029,13 +2028,12 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV BITMAPINFO *info = (BITMAPINFO *)buffer; struct x11drv_window_surface *surface; int width = rect->right - rect->left, height = rect->bottom - rect->top; - int colors = format->bits_per_pixel <= 8 ? 1 << format->bits_per_pixel : 3; struct x11drv_image *image; D3DDDIFORMAT d3d_format; HBITMAP bitmap = 0; BOOL byteswap; void *bits; - UINT size, status; + UINT status;
memset( info, 0, sizeof(*info) ); info->bmiHeader.biSize = sizeof(info->bmiHeader); @@ -2046,7 +2044,6 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV info->bmiHeader.biSizeImage = get_dib_image_size( info ); if (format->bits_per_pixel > 8) set_color_info( vis, info, use_alpha );
- size = FIELD_OFFSET( struct x11drv_window_surface, info.bmiColors[colors] ); if (!(image = x11drv_image_create( info, vis ))) return NULL;
/* wrap the XImage data in a HBITMAP if we can write to the surface pixels directly */ @@ -2075,7 +2072,7 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV if (desc.hDeviceDc) NtUserReleaseDC( hwnd, desc.hDeviceDc ); }
- if (!(surface = calloc( 1, size ))) + if (!(surface = calloc( 1, sizeof(*surface) ))) { if (bitmap) NtGdiDeleteObjectApp( bitmap ); x11drv_image_destroy( image ); @@ -2086,7 +2083,6 @@ static struct window_surface *create_surface( HWND hwnd, Window window, const XV
if (!window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, rect, info, bitmap )) goto failed; if (!window_surface_get_color( &surface->header, info, &bits )) goto failed; - memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = window; surface->gc = XCreateGC( gdi_display, window, 0, NULL );