From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 11 ++++------- dlls/wineandroid.drv/window.c | 8 ++------ dlls/winemac.drv/surface.c | 6 ++---- dlls/winewayland.drv/window_surface.c | 6 +----- dlls/winex11.drv/bitblt.c | 10 +--------- include/wine/gdi_driver.h | 3 ++- 6 files changed, 12 insertions(+), 32 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index f1a202f2e8b..5a8bfa0d854 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -159,7 +159,6 @@ void create_offscreen_window_surface( HWND hwnd, const RECT *visible_rect, struc char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *info = (BITMAPINFO *)buffer; struct offscreen_window_surface *impl; - SIZE_T size; RECT surface_rect = *visible_rect;
TRACE( "hwnd %p, visible_rect %s, surface %p.\n", hwnd, wine_dbgstr_rect( visible_rect ), surface ); @@ -187,11 +186,8 @@ void create_offscreen_window_surface( HWND hwnd, const RECT *visible_rect, struc
/* create a new window surface */ *surface = NULL; - size = info->bmiHeader.biSizeImage; - if (!(impl = calloc(1, offsetof( struct offscreen_window_surface, info.bmiColors[0] ) + size))) return; + if (!(impl = calloc(1, sizeof(*impl)))) return; window_surface_init( &impl->header, &offscreen_window_surface_funcs, hwnd, info, 0 ); - - impl->header.color_bits = (char *)&impl->info.bmiColors[0]; impl->info = *info;
TRACE( "created window surface %p\n", &impl->header ); @@ -215,8 +211,8 @@ W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct w pthread_mutex_init( &surface->mutex, NULL ); reset_bounds( &surface->bounds );
- if (!bitmap) return TRUE; - if (!(bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ))) return FALSE; + 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 ); @@ -236,6 +232,7 @@ W32KAPI void window_surface_release( struct window_surface *surface ) { if (surface != &dummy_surface) pthread_mutex_destroy( &surface->mutex ); if (surface->clip_region) NtGdiDeleteObjectApp( surface->clip_region ); + if (surface->color_bitmap) NtGdiDeleteObjectApp( surface->color_bitmap ); surface->funcs->destroy( surface ); } } diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 9b3ff2b456c..b52fe4dc33e 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -732,11 +732,10 @@ static void android_surface_destroy( struct window_surface *window_surface ) { struct android_window_surface *surface = get_android_surface( window_surface );
- TRACE( "freeing %p bits %p\n", surface, window_surface->color_bits ); + TRACE( "freeing %p\n", surface );
free( surface->clip_rects ); release_ioctl_window( surface->window ); - free( window_surface->color_bits ); free( surface ); }
@@ -799,10 +798,7 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, surface->alpha = alpha; set_color_key( surface, color_key );
- if (!(surface->header.color_bits = malloc( info->bmiHeader.biSizeImage ))) - goto failed; - - TRACE( "created %p hwnd %p %s color_bits %p-%p\n", surface, hwnd, wine_dbgstr_rect(rect), + 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 );
return &surface->header; diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 397d8e46ef3..0ec5f8e06d2 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -106,8 +106,7 @@ static void macdrv_surface_destroy(struct window_surface *window_surface) { struct macdrv_window_surface *surface = get_mac_surface(window_surface);
- TRACE("freeing %p bits %p\n", surface, window_surface->color_bits); - free(window_surface->color_bits); + TRACE("freeing %p\n", surface); free(surface); }
@@ -159,8 +158,7 @@ struct window_surface *create_surface(HWND hwnd, macdrv_window window, const REC surface->window = window; if (old_surface) surface->header.bounds = old_surface->bounds; surface->use_alpha = use_alpha; - surface->header.color_bits = malloc(info->bmiHeader.biSizeImage); - if (!surface->header.color_bits) goto failed; + window_background = macdrv_window_background_color(); memset_pattern4(surface->header.color_bits, &window_background, info->bmiHeader.biSizeImage);
diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 34523d8c54a..78d04f46413 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -435,7 +435,6 @@ static void wayland_window_surface_destroy(struct window_surface *window_surface
if (wws->wayland_buffer_queue) wayland_buffer_queue_destroy(wws->wayland_buffer_queue); - free(window_surface->color_bits); free(wws); }
@@ -473,10 +472,7 @@ struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect if (!window_surface_init(&wws->header, &wayland_window_surface_funcs, hwnd, info, 0)) goto failed; wws->info = *info;
- if (!(wws->header.color_bits = malloc(wws->info.bmiHeader.biSizeImage))) - goto failed; - - TRACE("created %p hwnd %p %s color_bits [%p,%p)\n", wws, hwnd, wine_dbgstr_rect(rect), + 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);
return &wws->header; diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 8e928bd491c..0de5eaf1e51 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1586,7 +1586,6 @@ struct x11drv_window_surface Window window; GC gc; struct x11drv_image *image; - HBITMAP bitmap; /* bitmap exposed to win32u */ BOOL is_argb; DWORD alpha_bits; COLORREF color_key; @@ -1914,15 +1913,10 @@ static struct x11drv_image *x11drv_image_create( const BITMAPINFO *info, const X /* allocate a separate storage otherwise to perform color conversion on flush */ if (!image->ximage->data) image->ximage->data = image->data = malloc( info->bmiHeader.biSizeImage ); if (!image->ximage->data) goto failed; - - if (!*bitmap) *bitmap = NtGdiCreateDIBSection( 0, NULL, 0, info, DIB_RGB_COLORS, 0, 0, 0, &bits ); - if (!*bitmap) goto failed; - return image;
failed: if (image) XDestroyImage( image->ximage ); - if (image) free( image->data ); free( image ); return NULL; } @@ -2029,10 +2023,9 @@ static void x11drv_surface_destroy( struct window_surface *window_surface ) { struct x11drv_window_surface *surface = get_x11_surface( window_surface );
- TRACE( "freeing %p bits %p\n", surface, window_surface->color_bits ); + TRACE( "freeing %p\n", surface ); if (surface->gc) XFreeGC( gdi_display, surface->gc ); if (surface->image) x11drv_image_destroy( surface->image ); - if (surface->bitmap) NtGdiDeleteObjectApp( surface->bitmap ); free( surface ); }
@@ -2077,7 +2070,6 @@ struct window_surface *create_surface( HWND hwnd, Window window, const XVisualIn return NULL; } surface->image = image; - surface->bitmap = bitmap;
if (!window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, info, bitmap )) goto failed; memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 556e33d1fa2..ce954a7f4d8 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -229,7 +229,8 @@ 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 */ - void *color_bits; /* pixel bits of the surface color */ + HBITMAP color_bitmap; /* bitmap for the surface colors */ + void *color_bits; /* pixel bits of the color bitmap */ /* driver-specific fields here */ };