mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-30 05:31:39 +00:00
win32u: Create a HBITMAP backing the window surface pixels.
This commit is contained in:
parent
6ace92e0ca
commit
b6abacbb7b
|
@ -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 );
|
||||
|
@ -188,11 +187,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 );
|
||||
|
@ -216,8 +212,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 );
|
||||
|
@ -237,6 +233,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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -800,10 +799,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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -154,8 +153,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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -474,10 +473,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;
|
||||
|
|
|
@ -1588,7 +1588,6 @@ struct x11drv_window_surface
|
|||
Window window;
|
||||
GC gc;
|
||||
struct x11drv_image *image;
|
||||
HBITMAP bitmap; /* bitmap exposed to win32u */
|
||||
BOOL byteswap;
|
||||
BOOL is_argb;
|
||||
DWORD alpha_bits;
|
||||
|
@ -2026,10 +2025,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 );
|
||||
}
|
||||
|
||||
|
@ -2091,16 +2089,13 @@ struct window_surface *create_surface( HWND hwnd, Window window, const XVisualIn
|
|||
}
|
||||
}
|
||||
|
||||
if (!bitmap) bitmap = NtGdiCreateDIBSection( 0, NULL, 0, info, DIB_RGB_COLORS, 0, 0, 0, NULL );
|
||||
|
||||
if (!bitmap || !(surface = calloc( 1, size )))
|
||||
if (!(surface = calloc( 1, size )))
|
||||
{
|
||||
if (bitmap) NtGdiDeleteObjectApp( bitmap );
|
||||
x11drv_image_destroy( image );
|
||||
return NULL;
|
||||
}
|
||||
surface->image = image;
|
||||
surface->bitmap = bitmap;
|
||||
surface->byteswap = byteswap;
|
||||
|
||||
if (!window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, info, bitmap )) goto failed;
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue