1996-11-17 19:59:11 +01:00
|
|
|
/*
|
|
|
|
* GDI bit-blit operations
|
|
|
|
*
|
|
|
|
* Copyright 1993, 1994 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1996-11-17 19:59:11 +01:00
|
|
|
*/
|
|
|
|
|
2021-09-29 14:09:21 +02:00
|
|
|
#if 0
|
|
|
|
#pragma makedep unix
|
|
|
|
#endif
|
|
|
|
|
2006-11-17 14:52:07 +01:00
|
|
|
#include <stdarg.h>
|
2011-12-05 16:27:28 +01:00
|
|
|
#include <limits.h>
|
2008-03-26 23:59:34 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
2006-11-17 14:52:07 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2021-07-09 15:28:26 +02:00
|
|
|
#include "ntgdi_private.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1996-11-17 19:59:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(bitblt);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2011-03-17 14:30:45 +01:00
|
|
|
static inline BOOL rop_uses_src( DWORD rop )
|
|
|
|
{
|
|
|
|
return ((rop >> 2) & 0x330000) != (rop & 0x330000);
|
|
|
|
}
|
1996-11-17 19:59:11 +01:00
|
|
|
|
2011-10-17 16:46:05 +02:00
|
|
|
BOOL intersect_vis_rectangles( struct bitblt_coords *dst, struct bitblt_coords *src )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
/* intersect the rectangles */
|
|
|
|
|
|
|
|
if ((src->width == dst->width) && (src->height == dst->height)) /* no stretching */
|
|
|
|
{
|
|
|
|
offset_rect( &src->visrect, dst->x - src->x, dst->y - src->y );
|
2011-12-08 10:32:26 +01:00
|
|
|
if (!intersect_rect( &rect, &src->visrect, &dst->visrect )) return FALSE;
|
2011-10-17 16:46:05 +02:00
|
|
|
src->visrect = dst->visrect = rect;
|
|
|
|
offset_rect( &src->visrect, src->x - dst->x, src->y - dst->y );
|
|
|
|
}
|
|
|
|
else /* stretching */
|
|
|
|
{
|
|
|
|
/* map source rectangle into destination coordinates */
|
|
|
|
rect = src->visrect;
|
2018-10-13 15:31:00 +02:00
|
|
|
offset_rect( &rect,
|
|
|
|
-src->x - (src->width < 0 ? 1 : 0),
|
|
|
|
-src->y - (src->height < 0 ? 1 : 0));
|
2018-10-13 15:31:02 +02:00
|
|
|
rect.left = rect.left * dst->width / src->width;
|
|
|
|
rect.top = rect.top * dst->height / src->height;
|
|
|
|
rect.right = rect.right * dst->width / src->width;
|
|
|
|
rect.bottom = rect.bottom * dst->height / src->height;
|
2018-10-11 17:35:34 +02:00
|
|
|
order_rect( &rect );
|
2011-10-17 16:46:05 +02:00
|
|
|
|
2018-10-13 15:31:02 +02:00
|
|
|
/* when the source rectangle needs to flip and it doesn't fit in the source device
|
|
|
|
area, the destination area isn't flipped. So, adjust destination coordinates */
|
|
|
|
if (src->width < 0 && dst->width > 0 &&
|
|
|
|
(src->x + src->width + 1 < src->visrect.left || src->x > src->visrect.right))
|
|
|
|
dst->x += (dst->width - rect.right) - rect.left;
|
|
|
|
else if (src->width > 0 && dst->width < 0 &&
|
|
|
|
(src->x < src->visrect.left || src->x + src->width > src->visrect.right))
|
|
|
|
dst->x -= rect.right - (dst->width - rect.left);
|
|
|
|
|
|
|
|
if (src->height < 0 && dst->height > 0 &&
|
|
|
|
(src->y + src->height + 1 < src->visrect.top || src->y > src->visrect.bottom))
|
|
|
|
dst->y += (dst->height - rect.bottom) - rect.top;
|
|
|
|
else if (src->height > 0 && dst->height < 0 &&
|
|
|
|
(src->y < src->visrect.top || src->y + src->height > src->visrect.bottom))
|
|
|
|
dst->y -= rect.bottom - (dst->height - rect.top);
|
|
|
|
|
|
|
|
offset_rect( &rect, dst->x, dst->y );
|
|
|
|
|
2011-10-17 16:46:05 +02:00
|
|
|
/* avoid rounding errors */
|
|
|
|
rect.left--;
|
|
|
|
rect.top--;
|
|
|
|
rect.right++;
|
|
|
|
rect.bottom++;
|
|
|
|
if (!intersect_rect( &dst->visrect, &rect, &dst->visrect )) return FALSE;
|
|
|
|
|
|
|
|
/* map destination rectangle back to source coordinates */
|
|
|
|
rect = dst->visrect;
|
2018-10-13 15:31:00 +02:00
|
|
|
offset_rect( &rect,
|
|
|
|
-dst->x - (dst->width < 0 ? 1 : 0),
|
|
|
|
-dst->y - (dst->height < 0 ? 1 : 0));
|
|
|
|
rect.left = src->x + rect.left * src->width / dst->width;
|
|
|
|
rect.top = src->y + rect.top * src->height / dst->height;
|
|
|
|
rect.right = src->x + rect.right * src->width / dst->width;
|
|
|
|
rect.bottom = src->y + rect.bottom * src->height / dst->height;
|
2018-10-11 17:35:34 +02:00
|
|
|
order_rect( &rect );
|
2011-10-17 16:46:05 +02:00
|
|
|
|
|
|
|
/* avoid rounding errors */
|
|
|
|
rect.left--;
|
|
|
|
rect.top--;
|
|
|
|
rect.right++;
|
|
|
|
rect.bottom++;
|
|
|
|
if (!intersect_rect( &src->visrect, &rect, &src->visrect )) return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-20 12:17:09 +02:00
|
|
|
static BOOL get_vis_rectangles( DC *dc_dst, struct bitblt_coords *dst,
|
2011-07-11 13:44:26 +02:00
|
|
|
DC *dc_src, struct bitblt_coords *src )
|
|
|
|
{
|
2011-12-06 12:57:30 +01:00
|
|
|
RECT rect;
|
2011-07-11 13:44:26 +02:00
|
|
|
|
|
|
|
/* get the destination visible rectangle */
|
|
|
|
|
|
|
|
rect.left = dst->log_x;
|
|
|
|
rect.top = dst->log_y;
|
|
|
|
rect.right = dst->log_x + dst->log_width;
|
|
|
|
rect.bottom = dst->log_y + dst->log_height;
|
2016-07-18 12:32:56 +02:00
|
|
|
lp_to_dp( dc_dst, (POINT *)&rect, 2 );
|
2011-07-11 13:44:26 +02:00
|
|
|
dst->x = rect.left;
|
|
|
|
dst->y = rect.top;
|
|
|
|
dst->width = rect.right - rect.left;
|
|
|
|
dst->height = rect.bottom - rect.top;
|
|
|
|
if (dst->layout & LAYOUT_RTL && dst->layout & LAYOUT_BITMAPORIENTATIONPRESERVED)
|
|
|
|
{
|
2011-10-11 13:49:53 +02:00
|
|
|
dst->x += dst->width;
|
|
|
|
dst->width = -dst->width;
|
2011-07-11 13:44:26 +02:00
|
|
|
}
|
2011-10-11 13:49:53 +02:00
|
|
|
get_bounding_rect( &rect, dst->x, dst->y, dst->width, dst->height );
|
2011-07-11 13:44:26 +02:00
|
|
|
|
2011-12-06 12:57:30 +01:00
|
|
|
clip_visrect( dc_dst, &dst->visrect, &rect );
|
2011-07-11 13:44:26 +02:00
|
|
|
|
|
|
|
/* get the source visible rectangle */
|
|
|
|
|
2011-07-20 12:17:09 +02:00
|
|
|
if (!src) return !is_rect_empty( &dst->visrect );
|
2011-07-11 13:44:26 +02:00
|
|
|
|
|
|
|
rect.left = src->log_x;
|
|
|
|
rect.top = src->log_y;
|
|
|
|
rect.right = src->log_x + src->log_width;
|
|
|
|
rect.bottom = src->log_y + src->log_height;
|
2016-07-18 12:32:56 +02:00
|
|
|
lp_to_dp( dc_src, (POINT *)&rect, 2 );
|
2011-07-11 13:44:26 +02:00
|
|
|
src->x = rect.left;
|
|
|
|
src->y = rect.top;
|
|
|
|
src->width = rect.right - rect.left;
|
|
|
|
src->height = rect.bottom - rect.top;
|
|
|
|
if (src->layout & LAYOUT_RTL && src->layout & LAYOUT_BITMAPORIENTATIONPRESERVED)
|
|
|
|
{
|
2011-10-11 13:49:53 +02:00
|
|
|
src->x += src->width;
|
|
|
|
src->width = -src->width;
|
2011-07-11 13:44:26 +02:00
|
|
|
}
|
2011-10-11 13:49:53 +02:00
|
|
|
get_bounding_rect( &rect, src->x, src->y, src->width, src->height );
|
2011-07-11 13:44:26 +02:00
|
|
|
|
2012-04-30 21:17:00 +02:00
|
|
|
if (!clip_device_rect( dc_src, &src->visrect, &rect )) return FALSE;
|
2011-07-20 12:17:09 +02:00
|
|
|
if (is_rect_empty( &dst->visrect )) return FALSE;
|
|
|
|
|
2011-10-17 16:46:05 +02:00
|
|
|
return intersect_vis_rectangles( dst, src );
|
2011-07-11 13:44:26 +02:00
|
|
|
}
|
|
|
|
|
2020-09-22 10:26:25 +02:00
|
|
|
void CDECL free_heap_bits( struct gdi_image_bits *bits )
|
2011-07-14 12:19:13 +02:00
|
|
|
{
|
2021-10-01 01:57:05 +02:00
|
|
|
free( bits->ptr );
|
2011-07-14 12:19:13 +02:00
|
|
|
}
|
|
|
|
|
2011-10-17 16:46:06 +02:00
|
|
|
DWORD convert_bits( const BITMAPINFO *src_info, struct bitblt_coords *src,
|
2012-10-10 17:19:42 +02:00
|
|
|
BITMAPINFO *dst_info, struct gdi_image_bits *bits )
|
2011-09-14 11:25:19 +02:00
|
|
|
{
|
|
|
|
void *ptr;
|
|
|
|
DWORD err;
|
2012-10-10 17:06:06 +02:00
|
|
|
BOOL top_down = dst_info->bmiHeader.biHeight < 0;
|
2011-09-14 11:25:19 +02:00
|
|
|
|
|
|
|
dst_info->bmiHeader.biWidth = src->visrect.right - src->visrect.left;
|
2012-10-10 17:06:06 +02:00
|
|
|
dst_info->bmiHeader.biHeight = src->visrect.bottom - src->visrect.top;
|
2011-12-10 13:27:16 +01:00
|
|
|
dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info );
|
2012-10-10 17:06:06 +02:00
|
|
|
if (top_down) dst_info->bmiHeader.biHeight = -dst_info->bmiHeader.biHeight;
|
2011-12-10 13:27:16 +01:00
|
|
|
|
2021-10-01 01:57:05 +02:00
|
|
|
if (!(ptr = malloc( dst_info->bmiHeader.biSizeImage )))
|
2011-09-14 11:25:19 +02:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
2012-10-10 17:19:42 +02:00
|
|
|
err = convert_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr );
|
2011-09-14 11:25:19 +02:00
|
|
|
if (bits->free) bits->free( bits );
|
|
|
|
bits->ptr = ptr;
|
|
|
|
bits->is_copy = TRUE;
|
|
|
|
bits->free = free_heap_bits;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-10-17 16:46:06 +02:00
|
|
|
DWORD stretch_bits( const BITMAPINFO *src_info, struct bitblt_coords *src,
|
|
|
|
BITMAPINFO *dst_info, struct bitblt_coords *dst,
|
|
|
|
struct gdi_image_bits *bits, int mode )
|
2011-09-14 11:25:19 +02:00
|
|
|
{
|
|
|
|
void *ptr;
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
dst_info->bmiHeader.biWidth = dst->visrect.right - dst->visrect.left;
|
|
|
|
dst_info->bmiHeader.biHeight = dst->visrect.bottom - dst->visrect.top;
|
2011-12-10 13:27:16 +01:00
|
|
|
dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info );
|
|
|
|
|
2011-09-14 11:25:19 +02:00
|
|
|
if (src_info->bmiHeader.biHeight < 0) dst_info->bmiHeader.biHeight = -dst_info->bmiHeader.biHeight;
|
2021-10-01 01:57:05 +02:00
|
|
|
if (!(ptr = malloc( dst_info->bmiHeader.biSizeImage )))
|
2011-09-14 11:25:19 +02:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
err = stretch_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr, dst, mode );
|
|
|
|
if (bits->free) bits->free( bits );
|
|
|
|
bits->ptr = ptr;
|
|
|
|
bits->is_copy = TRUE;
|
|
|
|
bits->free = free_heap_bits;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-10-17 13:25:05 +02:00
|
|
|
static DWORD blend_bits( const BITMAPINFO *src_info, const struct gdi_image_bits *src_bits,
|
|
|
|
struct bitblt_coords *src, BITMAPINFO *dst_info,
|
|
|
|
struct gdi_image_bits *dst_bits, struct bitblt_coords *dst, BLENDFUNCTION blend )
|
|
|
|
{
|
|
|
|
if (!dst_bits->is_copy)
|
|
|
|
{
|
2011-12-10 13:27:16 +01:00
|
|
|
int size = dst_info->bmiHeader.biSizeImage;
|
2021-10-01 01:57:05 +02:00
|
|
|
void *ptr = malloc( size );
|
2011-10-17 13:25:05 +02:00
|
|
|
if (!ptr) return ERROR_OUTOFMEMORY;
|
|
|
|
memcpy( ptr, dst_bits->ptr, size );
|
|
|
|
if (dst_bits->free) dst_bits->free( dst_bits );
|
|
|
|
dst_bits->ptr = ptr;
|
|
|
|
dst_bits->is_copy = TRUE;
|
|
|
|
dst_bits->free = free_heap_bits;
|
|
|
|
}
|
|
|
|
return blend_bitmapinfo( src_info, src_bits->ptr, src, dst_info, dst_bits->ptr, dst, blend );
|
|
|
|
}
|
|
|
|
|
2017-03-08 21:29:51 +01:00
|
|
|
static RGBQUAD get_dc_rgb_color( DC *dc, int color_table_size, COLORREF color )
|
2012-05-29 13:53:30 +02:00
|
|
|
{
|
2016-12-27 16:08:44 +01:00
|
|
|
RGBQUAD ret = { 0, 0, 0, 0 };
|
2012-05-29 13:53:30 +02:00
|
|
|
|
2016-12-27 16:08:44 +01:00
|
|
|
if (color & (1 << 24)) /* PALETTEINDEX */
|
|
|
|
{
|
|
|
|
PALETTEENTRY pal;
|
|
|
|
|
2021-08-16 10:27:30 +02:00
|
|
|
if (!get_palette_entries( dc->hPalette, LOWORD(color), 1, &pal ))
|
|
|
|
get_palette_entries( dc->hPalette, 0, 1, &pal );
|
2016-12-27 16:08:44 +01:00
|
|
|
ret.rgbRed = pal.peRed;
|
|
|
|
ret.rgbGreen = pal.peGreen;
|
|
|
|
ret.rgbBlue = pal.peBlue;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (color >> 16 == 0x10ff) /* DIBINDEX */
|
2012-05-29 13:53:30 +02:00
|
|
|
{
|
2017-03-08 21:29:51 +01:00
|
|
|
if (color_table_size)
|
|
|
|
{
|
|
|
|
if (LOWORD(color) >= color_table_size) color = 0x10ff0000; /* fallback to index 0 */
|
|
|
|
*(DWORD *)&ret = color;
|
|
|
|
}
|
2016-12-27 16:08:44 +01:00
|
|
|
return ret;
|
2012-05-29 13:53:30 +02:00
|
|
|
}
|
2016-12-27 16:08:44 +01:00
|
|
|
ret.rgbRed = GetRValue( color );
|
|
|
|
ret.rgbGreen = GetGValue( color );
|
|
|
|
ret.rgbBlue = GetBValue( color );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* helper to retrieve either both colors or only the background color for monochrome blits */
|
2017-03-08 21:29:51 +01:00
|
|
|
void get_mono_dc_colors( DC *dc, int color_table_size, BITMAPINFO *info, int count )
|
2016-12-27 16:08:44 +01:00
|
|
|
{
|
2021-07-28 11:39:37 +02:00
|
|
|
info->bmiColors[count - 1] = get_dc_rgb_color( dc, color_table_size, dc->attr->background_color );
|
2021-07-28 11:40:07 +02:00
|
|
|
if (count > 1) info->bmiColors[0] = get_dc_rgb_color( dc, color_table_size, dc->attr->text_color );
|
2012-05-29 13:53:30 +02:00
|
|
|
info->bmiHeader.biClrUsed = count;
|
|
|
|
}
|
|
|
|
|
2011-09-14 11:57:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* null driver fallback implementations
|
|
|
|
*/
|
|
|
|
|
2019-07-06 20:45:50 +02:00
|
|
|
BOOL CDECL nulldrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
|
|
|
|
PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop )
|
2011-03-18 12:59:26 +01:00
|
|
|
{
|
2016-07-29 16:09:36 +02:00
|
|
|
DC *dc_src = get_physdev_dc( src_dev ), *dc_dst = get_nulldrv_dc( dst_dev );
|
2011-07-14 12:19:13 +02:00
|
|
|
char src_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
char dst_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *src_info = (BITMAPINFO *)src_buffer;
|
|
|
|
BITMAPINFO *dst_info = (BITMAPINFO *)dst_buffer;
|
|
|
|
DWORD err;
|
2011-07-20 17:28:19 +02:00
|
|
|
struct gdi_image_bits bits;
|
2011-07-14 12:19:13 +02:00
|
|
|
|
|
|
|
src_dev = GET_DC_PHYSDEV( dc_src, pGetImage );
|
2012-05-30 22:55:30 +02:00
|
|
|
if (src_dev->funcs->pGetImage( src_dev, src_info, &bits, src ))
|
|
|
|
return FALSE;
|
2011-07-14 12:19:13 +02:00
|
|
|
|
|
|
|
dst_dev = GET_DC_PHYSDEV( dc_dst, pPutImage );
|
2011-10-27 14:19:44 +02:00
|
|
|
copy_bitmapinfo( dst_info, src_info );
|
2012-05-23 23:36:20 +02:00
|
|
|
err = dst_dev->funcs->pPutImage( dst_dev, 0, dst_info, &bits, src, dst, rop );
|
2011-07-14 12:19:13 +02:00
|
|
|
if (err == ERROR_BAD_FORMAT)
|
|
|
|
{
|
2012-05-29 13:53:30 +02:00
|
|
|
DWORD dst_colors = dst_info->bmiHeader.biClrUsed;
|
|
|
|
|
|
|
|
/* 1-bpp source without a color table uses the destination DC colors */
|
|
|
|
if (src_info->bmiHeader.biBitCount == 1 && !src_info->bmiHeader.biClrUsed)
|
2017-03-08 21:29:51 +01:00
|
|
|
get_mono_dc_colors( dc_dst, dst_info->bmiHeader.biClrUsed, src_info, 2 );
|
2012-05-29 13:53:30 +02:00
|
|
|
|
2017-03-08 21:03:59 +01:00
|
|
|
/* 1-bpp destination without a color table requires a fake 1-entry table
|
|
|
|
* that contains only the background color */
|
2012-05-29 13:53:30 +02:00
|
|
|
if (dst_info->bmiHeader.biBitCount == 1 && !dst_colors)
|
2017-03-08 21:29:51 +01:00
|
|
|
get_mono_dc_colors( dc_src, src_info->bmiHeader.biClrUsed, dst_info, 1 );
|
2011-07-19 14:11:04 +02:00
|
|
|
|
2012-10-10 17:19:42 +02:00
|
|
|
if (!(err = convert_bits( src_info, src, dst_info, &bits )))
|
2011-07-14 12:19:13 +02:00
|
|
|
{
|
2012-05-29 13:53:30 +02:00
|
|
|
/* get rid of the fake destination table */
|
|
|
|
dst_info->bmiHeader.biClrUsed = dst_colors;
|
2012-05-23 23:36:20 +02:00
|
|
|
err = dst_dev->funcs->pPutImage( dst_dev, 0, dst_info, &bits, src, dst, rop );
|
2011-07-14 12:19:13 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-20 17:28:19 +02:00
|
|
|
|
|
|
|
if (err == ERROR_TRANSFORM_NOT_SUPPORTED &&
|
|
|
|
((src->width != dst->width) || (src->height != dst->height)))
|
|
|
|
{
|
2011-10-27 14:19:44 +02:00
|
|
|
copy_bitmapinfo( src_info, dst_info );
|
2021-07-29 14:22:02 +02:00
|
|
|
err = stretch_bits( src_info, src, dst_info, dst, &bits, dc_dst->attr->stretch_blt_mode );
|
2012-05-23 23:36:20 +02:00
|
|
|
if (!err) err = dst_dev->funcs->pPutImage( dst_dev, 0, dst_info, &bits, src, dst, rop );
|
2011-07-20 17:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bits.free) bits.free( &bits );
|
2011-07-14 12:19:13 +02:00
|
|
|
return !err;
|
2011-03-18 12:59:26 +01:00
|
|
|
}
|
|
|
|
|
2011-09-14 11:57:45 +02:00
|
|
|
|
2019-07-06 20:45:50 +02:00
|
|
|
BOOL CDECL nulldrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
|
|
|
|
PHYSDEV src_dev, struct bitblt_coords *src, BLENDFUNCTION func )
|
2011-09-14 11:57:45 +02:00
|
|
|
{
|
2016-07-29 16:09:36 +02:00
|
|
|
DC *dc_src = get_physdev_dc( src_dev ), *dc_dst = get_nulldrv_dc( dst_dev );
|
2011-09-14 11:57:45 +02:00
|
|
|
char src_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
char dst_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *src_info = (BITMAPINFO *)src_buffer;
|
|
|
|
BITMAPINFO *dst_info = (BITMAPINFO *)dst_buffer;
|
|
|
|
DWORD err;
|
|
|
|
struct gdi_image_bits bits;
|
|
|
|
|
|
|
|
src_dev = GET_DC_PHYSDEV( dc_src, pGetImage );
|
2012-05-23 23:36:20 +02:00
|
|
|
err = src_dev->funcs->pGetImage( src_dev, src_info, &bits, src );
|
2011-10-11 12:03:18 +02:00
|
|
|
if (err) goto done;
|
2011-09-14 11:57:45 +02:00
|
|
|
|
|
|
|
dst_dev = GET_DC_PHYSDEV( dc_dst, pBlendImage );
|
2011-10-27 14:19:44 +02:00
|
|
|
copy_bitmapinfo( dst_info, src_info );
|
2011-09-14 11:57:45 +02:00
|
|
|
err = dst_dev->funcs->pBlendImage( dst_dev, dst_info, &bits, src, dst, func );
|
|
|
|
if (err == ERROR_BAD_FORMAT)
|
|
|
|
{
|
2012-10-10 17:19:42 +02:00
|
|
|
err = convert_bits( src_info, src, dst_info, &bits );
|
2011-09-14 11:57:45 +02:00
|
|
|
if (!err) err = dst_dev->funcs->pBlendImage( dst_dev, dst_info, &bits, src, dst, func );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err == ERROR_TRANSFORM_NOT_SUPPORTED &&
|
|
|
|
((src->width != dst->width) || (src->height != dst->height)))
|
|
|
|
{
|
2011-10-27 14:19:44 +02:00
|
|
|
copy_bitmapinfo( src_info, dst_info );
|
2011-09-14 11:57:45 +02:00
|
|
|
err = stretch_bits( src_info, src, dst_info, dst, &bits, COLORONCOLOR );
|
|
|
|
if (!err) err = dst_dev->funcs->pBlendImage( dst_dev, dst_info, &bits, src, dst, func );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bits.free) bits.free( &bits );
|
2011-10-11 12:03:18 +02:00
|
|
|
done:
|
|
|
|
if (err) SetLastError( err );
|
2011-09-14 11:57:45 +02:00
|
|
|
return !err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-06 20:45:50 +02:00
|
|
|
DWORD CDECL nulldrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const struct gdi_image_bits *bits,
|
|
|
|
struct bitblt_coords *src, struct bitblt_coords *dst, BLENDFUNCTION blend )
|
2011-10-17 13:25:05 +02:00
|
|
|
{
|
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *dst_info = (BITMAPINFO *)buffer;
|
|
|
|
struct gdi_image_bits dst_bits;
|
|
|
|
struct bitblt_coords orig_dst;
|
2012-10-10 17:08:05 +02:00
|
|
|
DWORD *masks = (DWORD *)info->bmiColors;
|
2011-10-17 13:25:05 +02:00
|
|
|
DC *dc = get_nulldrv_dc( dev );
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
if (info->bmiHeader.biPlanes != 1) goto update_format;
|
|
|
|
if (info->bmiHeader.biBitCount != 32) goto update_format;
|
|
|
|
if (info->bmiHeader.biCompression == BI_BITFIELDS)
|
|
|
|
{
|
2012-10-10 17:08:05 +02:00
|
|
|
if (blend.AlphaFormat & AC_SRC_ALPHA) return ERROR_INVALID_PARAMETER;
|
2011-10-17 13:25:05 +02:00
|
|
|
if (masks[0] != 0xff0000 || masks[1] != 0x00ff00 || masks[2] != 0x0000ff)
|
|
|
|
goto update_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bits) return ERROR_SUCCESS;
|
|
|
|
if ((src->width != dst->width) || (src->height != dst->height)) return ERROR_TRANSFORM_NOT_SUPPORTED;
|
|
|
|
|
|
|
|
dev = GET_DC_PHYSDEV( dc, pGetImage );
|
|
|
|
orig_dst = *dst;
|
2012-05-23 23:36:20 +02:00
|
|
|
err = dev->funcs->pGetImage( dev, dst_info, &dst_bits, dst );
|
2011-10-17 13:25:05 +02:00
|
|
|
if (err) return err;
|
|
|
|
|
|
|
|
dev = GET_DC_PHYSDEV( dc, pPutImage );
|
|
|
|
err = blend_bits( info, bits, src, dst_info, &dst_bits, dst, blend );
|
2012-05-23 23:36:20 +02:00
|
|
|
if (!err) err = dev->funcs->pPutImage( dev, 0, dst_info, &dst_bits, dst, &orig_dst, SRCCOPY );
|
2011-10-17 13:25:05 +02:00
|
|
|
|
|
|
|
if (dst_bits.free) dst_bits.free( &dst_bits );
|
|
|
|
return err;
|
|
|
|
|
|
|
|
update_format:
|
|
|
|
if (blend.AlphaFormat & AC_SRC_ALPHA) /* source alpha requires A8R8G8B8 format */
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biBitCount = 32;
|
2012-10-10 17:08:05 +02:00
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
2011-10-17 13:25:05 +02:00
|
|
|
info->bmiHeader.biClrUsed = 0;
|
2012-10-10 17:08:05 +02:00
|
|
|
masks[0] = 0xff0000;
|
|
|
|
masks[1] = 0x00ff00;
|
|
|
|
masks[2] = 0x0000ff;
|
2011-10-17 13:25:05 +02:00
|
|
|
return ERROR_BAD_FORMAT;
|
|
|
|
}
|
|
|
|
|
2019-07-06 20:45:50 +02:00
|
|
|
BOOL CDECL nulldrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert,
|
|
|
|
void * grad_array, ULONG ngrad, ULONG mode )
|
2011-11-30 12:21:35 +01:00
|
|
|
{
|
|
|
|
DC *dc = get_nulldrv_dc( dev );
|
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *info = (BITMAPINFO *)buffer;
|
|
|
|
struct bitblt_coords src, dst;
|
|
|
|
struct gdi_image_bits bits;
|
|
|
|
unsigned int i;
|
2011-12-05 16:27:28 +01:00
|
|
|
POINT *pts;
|
2012-01-02 21:46:46 +01:00
|
|
|
BOOL ret = FALSE;
|
2011-11-30 12:21:35 +01:00
|
|
|
DWORD err;
|
2011-12-05 16:27:28 +01:00
|
|
|
HRGN rgn;
|
2011-11-30 12:21:35 +01:00
|
|
|
|
2021-10-01 01:57:05 +02:00
|
|
|
if (!(pts = malloc( nvert * sizeof(*pts) ))) return FALSE;
|
2011-12-05 16:27:28 +01:00
|
|
|
for (i = 0; i < nvert; i++)
|
2011-11-30 12:21:35 +01:00
|
|
|
{
|
2011-12-05 16:27:28 +01:00
|
|
|
pts[i].x = vert_array[i].x;
|
|
|
|
pts[i].y = vert_array[i].y;
|
|
|
|
}
|
2016-07-18 12:32:56 +02:00
|
|
|
lp_to_dp( dc, pts, nvert );
|
2011-12-05 16:27:28 +01:00
|
|
|
|
|
|
|
/* compute bounding rect of all the rectangles/triangles */
|
2012-04-10 16:04:39 +02:00
|
|
|
reset_bounds( &dst.visrect );
|
2011-12-05 16:27:28 +01:00
|
|
|
for (i = 0; i < ngrad * (mode == GRADIENT_FILL_TRIANGLE ? 3 : 2); i++)
|
2011-11-30 12:21:35 +01:00
|
|
|
{
|
2011-12-05 16:27:28 +01:00
|
|
|
ULONG v = ((ULONG *)grad_array)[i];
|
|
|
|
dst.visrect.left = min( dst.visrect.left, pts[v].x );
|
|
|
|
dst.visrect.top = min( dst.visrect.top, pts[v].y );
|
|
|
|
dst.visrect.right = max( dst.visrect.right, pts[v].x );
|
|
|
|
dst.visrect.bottom = max( dst.visrect.bottom, pts[v].y );
|
|
|
|
}
|
2011-11-30 12:21:35 +01:00
|
|
|
|
2011-12-05 16:27:28 +01:00
|
|
|
dst.x = dst.visrect.left;
|
|
|
|
dst.y = dst.visrect.top;
|
|
|
|
dst.width = dst.visrect.right - dst.visrect.left;
|
|
|
|
dst.height = dst.visrect.bottom - dst.visrect.top;
|
2011-12-06 12:57:30 +01:00
|
|
|
if (!clip_visrect( dc, &dst.visrect, &dst.visrect )) goto done;
|
2011-12-05 16:27:28 +01:00
|
|
|
|
|
|
|
/* query the bitmap format */
|
|
|
|
info->bmiHeader.biSize = sizeof(info->bmiHeader);
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biBitCount = 0;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
info->bmiHeader.biClrImportant = 0;
|
|
|
|
info->bmiHeader.biWidth = dst.visrect.right - dst.visrect.left;
|
|
|
|
info->bmiHeader.biHeight = dst.visrect.bottom - dst.visrect.top;
|
2012-01-02 21:46:46 +01:00
|
|
|
info->bmiHeader.biSizeImage = 0;
|
2011-12-05 16:27:28 +01:00
|
|
|
dev = GET_DC_PHYSDEV( dc, pPutImage );
|
2012-05-23 23:36:20 +02:00
|
|
|
err = dev->funcs->pPutImage( dev, 0, info, NULL, NULL, NULL, 0 );
|
2012-01-02 21:46:46 +01:00
|
|
|
if (err && err != ERROR_BAD_FORMAT) goto done;
|
|
|
|
|
|
|
|
info->bmiHeader.biSizeImage = get_dib_image_size( info );
|
2021-10-01 01:57:05 +02:00
|
|
|
if (!(bits.ptr = calloc( 1, info->bmiHeader.biSizeImage )))
|
2011-12-05 16:27:28 +01:00
|
|
|
goto done;
|
|
|
|
bits.is_copy = TRUE;
|
|
|
|
bits.free = free_heap_bits;
|
|
|
|
|
|
|
|
/* make src and points relative to the bitmap */
|
|
|
|
src = dst;
|
|
|
|
src.x -= dst.visrect.left;
|
|
|
|
src.y -= dst.visrect.top;
|
|
|
|
offset_rect( &src.visrect, -dst.visrect.left, -dst.visrect.top );
|
|
|
|
for (i = 0; i < nvert; i++)
|
|
|
|
{
|
|
|
|
pts[i].x -= dst.visrect.left;
|
|
|
|
pts[i].y -= dst.visrect.top;
|
2011-11-30 12:21:35 +01:00
|
|
|
}
|
|
|
|
|
2021-07-07 15:02:38 +02:00
|
|
|
rgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
|
2011-12-05 16:27:28 +01:00
|
|
|
gradient_bitmapinfo( info, bits.ptr, vert_array, nvert, grad_array, ngrad, mode, pts, rgn );
|
2021-07-07 15:02:59 +02:00
|
|
|
NtGdiOffsetRgn( rgn, dst.visrect.left, dst.visrect.top );
|
2012-05-23 23:36:20 +02:00
|
|
|
ret = !dev->funcs->pPutImage( dev, rgn, info, &bits, &src, &dst, SRCCOPY );
|
2011-12-05 16:27:28 +01:00
|
|
|
|
|
|
|
if (bits.free) bits.free( &bits );
|
2021-09-03 14:59:52 +02:00
|
|
|
NtGdiDeleteObjectApp( rgn );
|
2011-12-05 16:27:28 +01:00
|
|
|
|
|
|
|
done:
|
2021-10-01 01:57:05 +02:00
|
|
|
free( pts );
|
2011-12-05 16:27:28 +01:00
|
|
|
return ret;
|
2011-11-30 12:21:35 +01:00
|
|
|
}
|
|
|
|
|
2019-07-06 20:45:50 +02:00
|
|
|
COLORREF CDECL nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
|
2011-12-12 20:53:50 +01:00
|
|
|
{
|
|
|
|
DC *dc = get_nulldrv_dc( dev );
|
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *info = (BITMAPINFO *)buffer;
|
|
|
|
struct bitblt_coords src;
|
|
|
|
struct gdi_image_bits bits;
|
|
|
|
COLORREF ret;
|
|
|
|
|
|
|
|
src.visrect.left = x;
|
|
|
|
src.visrect.top = y;
|
2016-07-18 12:32:56 +02:00
|
|
|
lp_to_dp( dc, (POINT *)&src.visrect, 1 );
|
2011-12-12 20:53:50 +01:00
|
|
|
src.visrect.right = src.visrect.left + 1;
|
|
|
|
src.visrect.bottom = src.visrect.top + 1;
|
|
|
|
src.x = src.visrect.left;
|
|
|
|
src.y = src.visrect.top;
|
|
|
|
src.width = src.height = 1;
|
|
|
|
|
|
|
|
if (!clip_visrect( dc, &src.visrect, &src.visrect )) return CLR_INVALID;
|
|
|
|
|
|
|
|
dev = GET_DC_PHYSDEV( dc, pGetImage );
|
2012-05-23 23:36:20 +02:00
|
|
|
if (dev->funcs->pGetImage( dev, info, &bits, &src )) return CLR_INVALID;
|
2011-12-12 20:53:50 +01:00
|
|
|
|
|
|
|
ret = get_pixel_bitmapinfo( info, bits.ptr, &src );
|
|
|
|
if (bits.free) bits.free( &bits );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-11-17 19:59:11 +01:00
|
|
|
/***********************************************************************
|
2021-08-03 12:56:49 +02:00
|
|
|
* NtGdiPatBlt (win32u.@)
|
1996-11-17 19:59:11 +01:00
|
|
|
*/
|
2021-08-03 12:56:49 +02:00
|
|
|
BOOL WINAPI NtGdiPatBlt( HDC hdc, INT left, INT top, INT width, INT height, DWORD rop )
|
1996-11-17 19:59:11 +01:00
|
|
|
{
|
2011-03-17 14:30:45 +01:00
|
|
|
DC * dc;
|
2011-07-11 13:59:05 +02:00
|
|
|
BOOL ret = FALSE;
|
2009-09-30 20:55:26 +02:00
|
|
|
|
2011-03-17 14:54:56 +01:00
|
|
|
if (rop_uses_src( rop )) return FALSE;
|
|
|
|
if ((dc = get_dc_ptr( hdc )))
|
2009-09-30 20:55:26 +02:00
|
|
|
{
|
2011-07-11 13:59:05 +02:00
|
|
|
struct bitblt_coords dst;
|
|
|
|
|
2009-09-30 20:55:26 +02:00
|
|
|
update_dc( dc );
|
2011-07-11 13:59:05 +02:00
|
|
|
|
|
|
|
dst.log_x = left;
|
|
|
|
dst.log_y = top;
|
|
|
|
dst.log_width = width;
|
|
|
|
dst.log_height = height;
|
2021-07-28 11:39:26 +02:00
|
|
|
dst.layout = dc->attr->layout;
|
2011-07-11 13:59:05 +02:00
|
|
|
if (rop & NOMIRRORBITMAP)
|
|
|
|
{
|
|
|
|
dst.layout |= LAYOUT_BITMAPORIENTATIONPRESERVED;
|
|
|
|
rop &= ~NOMIRRORBITMAP;
|
|
|
|
}
|
2011-07-20 12:17:09 +02:00
|
|
|
ret = !get_vis_rectangles( dc, &dst, NULL, NULL );
|
2011-07-11 13:59:05 +02:00
|
|
|
|
|
|
|
TRACE("dst %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s rop=%06x\n",
|
|
|
|
hdc, dst.log_x, dst.log_y, dst.log_width, dst.log_height,
|
|
|
|
dst.x, dst.y, dst.width, dst.height, wine_dbgstr_rect(&dst.visrect), rop );
|
|
|
|
|
2012-09-20 21:07:04 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pPatBlt );
|
|
|
|
ret = physdev->funcs->pPatBlt( physdev, &dst, rop );
|
|
|
|
}
|
2011-03-17 14:54:56 +01:00
|
|
|
release_dc_ptr( dc );
|
2009-09-30 20:55:26 +02:00
|
|
|
}
|
2011-07-11 13:59:05 +02:00
|
|
|
return ret;
|
1996-11-17 19:59:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2021-09-09 14:00:56 +02:00
|
|
|
* NtGdiBitBlt (win32u.@)
|
1996-11-17 19:59:11 +01:00
|
|
|
*/
|
2021-08-12 12:00:25 +02:00
|
|
|
BOOL WINAPI NtGdiBitBlt( HDC hdc_dst, INT x_dst, INT y_dst, INT width, INT height,
|
|
|
|
HDC hdc_src, INT x_src, INT y_src, DWORD rop, DWORD bk_color, FLONG fl )
|
1996-11-17 19:59:11 +01:00
|
|
|
{
|
2021-08-12 12:00:25 +02:00
|
|
|
return NtGdiStretchBlt( hdc_dst, x_dst, y_dst, width, height,
|
|
|
|
hdc_src, x_src, y_src, width, height, rop, bk_color );
|
1996-11-17 19:59:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2021-08-12 12:00:13 +02:00
|
|
|
* NtGdiStretchBlt (win32u.@)
|
1996-11-17 19:59:11 +01:00
|
|
|
*/
|
2021-08-12 12:00:13 +02:00
|
|
|
BOOL WINAPI NtGdiStretchBlt( HDC hdcDst, INT xDst, INT yDst, INT widthDst, INT heightDst,
|
|
|
|
HDC hdcSrc, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc,
|
|
|
|
DWORD rop, COLORREF bk_color )
|
1996-11-17 19:59:11 +01:00
|
|
|
{
|
2000-08-19 23:38:55 +02:00
|
|
|
BOOL ret = FALSE;
|
1996-11-17 19:59:11 +01:00
|
|
|
DC *dcDst, *dcSrc;
|
|
|
|
|
2021-08-12 12:00:13 +02:00
|
|
|
if (!rop_uses_src( rop )) return NtGdiPatBlt( hdcDst, xDst, yDst, widthDst, heightDst, rop );
|
2011-03-17 14:54:56 +01:00
|
|
|
|
2007-09-17 16:48:56 +02:00
|
|
|
if (!(dcDst = get_dc_ptr( hdcDst ))) return FALSE;
|
|
|
|
|
2011-03-18 12:59:26 +01:00
|
|
|
if ((dcSrc = get_dc_ptr( hdcSrc )))
|
2000-08-19 23:38:55 +02:00
|
|
|
{
|
2011-07-11 13:44:26 +02:00
|
|
|
struct bitblt_coords src, dst;
|
|
|
|
|
2011-03-18 12:59:26 +01:00
|
|
|
update_dc( dcSrc );
|
|
|
|
update_dc( dcDst );
|
2011-07-11 13:44:26 +02:00
|
|
|
|
|
|
|
src.log_x = xSrc;
|
|
|
|
src.log_y = ySrc;
|
|
|
|
src.log_width = widthSrc;
|
|
|
|
src.log_height = heightSrc;
|
2021-07-28 11:39:26 +02:00
|
|
|
src.layout = dcSrc->attr->layout;
|
2011-07-11 13:44:26 +02:00
|
|
|
dst.log_x = xDst;
|
|
|
|
dst.log_y = yDst;
|
|
|
|
dst.log_width = widthDst;
|
|
|
|
dst.log_height = heightDst;
|
2021-07-28 11:39:26 +02:00
|
|
|
dst.layout = dcDst->attr->layout;
|
2011-07-11 13:44:26 +02:00
|
|
|
if (rop & NOMIRRORBITMAP)
|
|
|
|
{
|
|
|
|
src.layout |= LAYOUT_BITMAPORIENTATIONPRESERVED;
|
|
|
|
dst.layout |= LAYOUT_BITMAPORIENTATIONPRESERVED;
|
|
|
|
rop &= ~NOMIRRORBITMAP;
|
|
|
|
}
|
2011-07-20 12:17:09 +02:00
|
|
|
ret = !get_vis_rectangles( dcDst, &dst, dcSrc, &src );
|
2011-07-11 13:59:05 +02:00
|
|
|
|
|
|
|
TRACE("src %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s dst %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s rop=%06x\n",
|
|
|
|
hdcSrc, src.log_x, src.log_y, src.log_width, src.log_height,
|
|
|
|
src.x, src.y, src.width, src.height, wine_dbgstr_rect(&src.visrect),
|
|
|
|
hdcDst, dst.log_x, dst.log_y, dst.log_width, dst.log_height,
|
|
|
|
dst.x, dst.y, dst.width, dst.height, wine_dbgstr_rect(&dst.visrect), rop );
|
|
|
|
|
2012-09-20 21:07:04 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
PHYSDEV src_dev = GET_DC_PHYSDEV( dcSrc, pStretchBlt );
|
|
|
|
PHYSDEV dst_dev = GET_DC_PHYSDEV( dcDst, pStretchBlt );
|
|
|
|
ret = dst_dev->funcs->pStretchBlt( dst_dev, &dst, src_dev, &src, rop );
|
|
|
|
}
|
2011-03-18 12:59:26 +01:00
|
|
|
release_dc_ptr( dcSrc );
|
2000-08-19 23:38:55 +02:00
|
|
|
}
|
2011-03-18 12:59:26 +01:00
|
|
|
release_dc_ptr( dcDst );
|
2000-08-19 23:38:55 +02:00
|
|
|
return ret;
|
1996-11-17 19:59:11 +01:00
|
|
|
}
|
|
|
|
|
2003-05-16 22:11:36 +02:00
|
|
|
#define FRGND_ROP3(ROP4) ((ROP4) & 0x00FFFFFF)
|
2004-08-11 20:51:10 +02:00
|
|
|
#define BKGND_ROP3(ROP4) (ROP3Table[((ROP4)>>24) & 0xFF])
|
1996-11-17 19:59:11 +01:00
|
|
|
|
1998-12-15 16:38:36 +01:00
|
|
|
/***********************************************************************
|
2021-09-09 14:00:56 +02:00
|
|
|
* NtGdiMaskBlt (win32u.@)
|
1998-12-15 16:38:36 +01:00
|
|
|
*/
|
2021-09-09 14:00:56 +02:00
|
|
|
BOOL WINAPI NtGdiMaskBlt( HDC hdcDest, INT nXDest, INT nYDest, INT nWidth, INT nHeight,
|
|
|
|
HDC hdcSrc, INT nXSrc, INT nYSrc, HBITMAP hbmMask,
|
|
|
|
INT xMask, INT yMask, DWORD dwRop, DWORD bk_color )
|
1998-12-15 16:38:36 +01:00
|
|
|
{
|
2004-08-11 20:51:10 +02:00
|
|
|
HBITMAP hBitmap1, hOldBitmap1, hBitmap2, hOldBitmap2;
|
|
|
|
HDC hDC1, hDC2;
|
|
|
|
HBRUSH hbrMask, hbrDst, hbrTmp;
|
|
|
|
|
2003-05-16 22:11:36 +02:00
|
|
|
static const DWORD ROP3Table[256] =
|
|
|
|
{
|
|
|
|
0x00000042, 0x00010289,
|
|
|
|
0x00020C89, 0x000300AA,
|
|
|
|
0x00040C88, 0x000500A9,
|
|
|
|
0x00060865, 0x000702C5,
|
|
|
|
0x00080F08, 0x00090245,
|
|
|
|
0x000A0329, 0x000B0B2A,
|
|
|
|
0x000C0324, 0x000D0B25,
|
|
|
|
0x000E08A5, 0x000F0001,
|
|
|
|
0x00100C85, 0x001100A6,
|
|
|
|
0x00120868, 0x001302C8,
|
|
|
|
0x00140869, 0x001502C9,
|
|
|
|
0x00165CCA, 0x00171D54,
|
|
|
|
0x00180D59, 0x00191CC8,
|
|
|
|
0x001A06C5, 0x001B0768,
|
|
|
|
0x001C06CA, 0x001D0766,
|
|
|
|
0x001E01A5, 0x001F0385,
|
|
|
|
0x00200F09, 0x00210248,
|
|
|
|
0x00220326, 0x00230B24,
|
|
|
|
0x00240D55, 0x00251CC5,
|
|
|
|
0x002606C8, 0x00271868,
|
|
|
|
0x00280369, 0x002916CA,
|
|
|
|
0x002A0CC9, 0x002B1D58,
|
|
|
|
0x002C0784, 0x002D060A,
|
|
|
|
0x002E064A, 0x002F0E2A,
|
|
|
|
0x0030032A, 0x00310B28,
|
|
|
|
0x00320688, 0x00330008,
|
|
|
|
0x003406C4, 0x00351864,
|
|
|
|
0x003601A8, 0x00370388,
|
|
|
|
0x0038078A, 0x00390604,
|
|
|
|
0x003A0644, 0x003B0E24,
|
|
|
|
0x003C004A, 0x003D18A4,
|
|
|
|
0x003E1B24, 0x003F00EA,
|
|
|
|
0x00400F0A, 0x00410249,
|
|
|
|
0x00420D5D, 0x00431CC4,
|
|
|
|
0x00440328, 0x00450B29,
|
|
|
|
0x004606C6, 0x0047076A,
|
|
|
|
0x00480368, 0x004916C5,
|
|
|
|
0x004A0789, 0x004B0605,
|
|
|
|
0x004C0CC8, 0x004D1954,
|
|
|
|
0x004E0645, 0x004F0E25,
|
|
|
|
0x00500325, 0x00510B26,
|
|
|
|
0x005206C9, 0x00530764,
|
|
|
|
0x005408A9, 0x00550009,
|
|
|
|
0x005601A9, 0x00570389,
|
|
|
|
0x00580785, 0x00590609,
|
|
|
|
0x005A0049, 0x005B18A9,
|
|
|
|
0x005C0649, 0x005D0E29,
|
|
|
|
0x005E1B29, 0x005F00E9,
|
|
|
|
0x00600365, 0x006116C6,
|
|
|
|
0x00620786, 0x00630608,
|
|
|
|
0x00640788, 0x00650606,
|
|
|
|
0x00660046, 0x006718A8,
|
|
|
|
0x006858A6, 0x00690145,
|
|
|
|
0x006A01E9, 0x006B178A,
|
|
|
|
0x006C01E8, 0x006D1785,
|
|
|
|
0x006E1E28, 0x006F0C65,
|
|
|
|
0x00700CC5, 0x00711D5C,
|
|
|
|
0x00720648, 0x00730E28,
|
|
|
|
0x00740646, 0x00750E26,
|
|
|
|
0x00761B28, 0x007700E6,
|
|
|
|
0x007801E5, 0x00791786,
|
|
|
|
0x007A1E29, 0x007B0C68,
|
|
|
|
0x007C1E24, 0x007D0C69,
|
|
|
|
0x007E0955, 0x007F03C9,
|
|
|
|
0x008003E9, 0x00810975,
|
|
|
|
0x00820C49, 0x00831E04,
|
|
|
|
0x00840C48, 0x00851E05,
|
|
|
|
0x008617A6, 0x008701C5,
|
|
|
|
0x008800C6, 0x00891B08,
|
|
|
|
0x008A0E06, 0x008B0666,
|
|
|
|
0x008C0E08, 0x008D0668,
|
|
|
|
0x008E1D7C, 0x008F0CE5,
|
|
|
|
0x00900C45, 0x00911E08,
|
|
|
|
0x009217A9, 0x009301C4,
|
|
|
|
0x009417AA, 0x009501C9,
|
|
|
|
0x00960169, 0x0097588A,
|
|
|
|
0x00981888, 0x00990066,
|
|
|
|
0x009A0709, 0x009B07A8,
|
|
|
|
0x009C0704, 0x009D07A6,
|
|
|
|
0x009E16E6, 0x009F0345,
|
|
|
|
0x00A000C9, 0x00A11B05,
|
|
|
|
0x00A20E09, 0x00A30669,
|
|
|
|
0x00A41885, 0x00A50065,
|
|
|
|
0x00A60706, 0x00A707A5,
|
|
|
|
0x00A803A9, 0x00A90189,
|
|
|
|
0x00AA0029, 0x00AB0889,
|
|
|
|
0x00AC0744, 0x00AD06E9,
|
|
|
|
0x00AE0B06, 0x00AF0229,
|
|
|
|
0x00B00E05, 0x00B10665,
|
|
|
|
0x00B21974, 0x00B30CE8,
|
|
|
|
0x00B4070A, 0x00B507A9,
|
|
|
|
0x00B616E9, 0x00B70348,
|
|
|
|
0x00B8074A, 0x00B906E6,
|
|
|
|
0x00BA0B09, 0x00BB0226,
|
|
|
|
0x00BC1CE4, 0x00BD0D7D,
|
|
|
|
0x00BE0269, 0x00BF08C9,
|
|
|
|
0x00C000CA, 0x00C11B04,
|
|
|
|
0x00C21884, 0x00C3006A,
|
|
|
|
0x00C40E04, 0x00C50664,
|
|
|
|
0x00C60708, 0x00C707AA,
|
|
|
|
0x00C803A8, 0x00C90184,
|
|
|
|
0x00CA0749, 0x00CB06E4,
|
|
|
|
0x00CC0020, 0x00CD0888,
|
|
|
|
0x00CE0B08, 0x00CF0224,
|
|
|
|
0x00D00E0A, 0x00D1066A,
|
|
|
|
0x00D20705, 0x00D307A4,
|
|
|
|
0x00D41D78, 0x00D50CE9,
|
|
|
|
0x00D616EA, 0x00D70349,
|
|
|
|
0x00D80745, 0x00D906E8,
|
|
|
|
0x00DA1CE9, 0x00DB0D75,
|
|
|
|
0x00DC0B04, 0x00DD0228,
|
|
|
|
0x00DE0268, 0x00DF08C8,
|
|
|
|
0x00E003A5, 0x00E10185,
|
|
|
|
0x00E20746, 0x00E306EA,
|
|
|
|
0x00E40748, 0x00E506E5,
|
|
|
|
0x00E61CE8, 0x00E70D79,
|
|
|
|
0x00E81D74, 0x00E95CE6,
|
|
|
|
0x00EA02E9, 0x00EB0849,
|
|
|
|
0x00EC02E8, 0x00ED0848,
|
|
|
|
0x00EE0086, 0x00EF0A08,
|
|
|
|
0x00F00021, 0x00F10885,
|
|
|
|
0x00F20B05, 0x00F3022A,
|
|
|
|
0x00F40B0A, 0x00F50225,
|
|
|
|
0x00F60265, 0x00F708C5,
|
|
|
|
0x00F802E5, 0x00F90845,
|
|
|
|
0x00FA0089, 0x00FB0A09,
|
|
|
|
0x00FC008A, 0x00FD0A0A,
|
|
|
|
0x00FE02A9, 0x00FF0062,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!hbmMask)
|
2021-09-09 14:00:56 +02:00
|
|
|
return NtGdiBitBlt( hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc,
|
|
|
|
nXSrc, nYSrc, FRGND_ROP3(dwRop), bk_color, 0 );
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2021-09-09 14:00:56 +02:00
|
|
|
hbrMask = NtGdiCreatePatternBrushInternal( hbmMask, FALSE, FALSE );
|
2021-09-03 14:59:51 +02:00
|
|
|
hbrDst = NtGdiSelectBrush( hdcDest, get_stock_object(NULL_BRUSH) );
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* make bitmap */
|
2021-07-30 13:02:47 +02:00
|
|
|
hDC1 = NtGdiCreateCompatibleDC( hdcDest );
|
2021-08-31 14:18:33 +02:00
|
|
|
hBitmap1 = NtGdiCreateCompatibleBitmap( hdcDest, nWidth, nHeight );
|
2021-07-02 12:41:27 +02:00
|
|
|
hOldBitmap1 = NtGdiSelectBitmap(hDC1, hBitmap1);
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* draw using bkgnd rop */
|
2021-09-09 14:00:56 +02:00
|
|
|
NtGdiBitBlt( hDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY, 0, 0 );
|
2021-07-02 12:41:27 +02:00
|
|
|
hbrTmp = NtGdiSelectBrush(hDC1, hbrDst);
|
2021-09-09 14:00:56 +02:00
|
|
|
NtGdiBitBlt( hDC1, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, BKGND_ROP3(dwRop), 0, 0 );
|
2021-07-02 12:41:27 +02:00
|
|
|
NtGdiSelectBrush(hDC1, hbrTmp);
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* make bitmap */
|
2021-07-30 13:02:47 +02:00
|
|
|
hDC2 = NtGdiCreateCompatibleDC( hdcDest );
|
2021-08-31 14:18:33 +02:00
|
|
|
hBitmap2 = NtGdiCreateCompatibleBitmap( hdcDest, nWidth, nHeight );
|
2021-07-02 12:41:27 +02:00
|
|
|
hOldBitmap2 = NtGdiSelectBitmap(hDC2, hBitmap2);
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* draw using foregnd rop */
|
2021-09-09 14:00:56 +02:00
|
|
|
NtGdiBitBlt( hDC2, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY, 0, 0 );
|
2021-07-02 12:41:27 +02:00
|
|
|
hbrTmp = NtGdiSelectBrush(hDC2, hbrDst);
|
2021-09-09 14:00:56 +02:00
|
|
|
NtGdiBitBlt( hDC2, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0, 0 );
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* combine both using the mask as a pattern brush */
|
2021-07-02 12:41:27 +02:00
|
|
|
NtGdiSelectBrush(hDC2, hbrMask);
|
2021-09-14 21:52:23 +02:00
|
|
|
NtGdiSetBrushOrg( hDC2, -xMask, -yMask, NULL );
|
2021-09-09 14:00:56 +02:00
|
|
|
/* (D & P) | (S & ~P) */
|
|
|
|
NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hDC1, 0, 0, 0xac0744, 0, 0 );
|
2021-07-02 12:41:27 +02:00
|
|
|
NtGdiSelectBrush(hDC2, hbrTmp);
|
2004-08-11 20:51:10 +02:00
|
|
|
|
|
|
|
/* blit to dst */
|
2021-09-09 14:00:56 +02:00
|
|
|
NtGdiBitBlt( hdcDest, nXDest, nYDest, nWidth, nHeight, hDC2, 0, 0, SRCCOPY, bk_color, 0 );
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* restore all objects */
|
2021-07-02 12:41:27 +02:00
|
|
|
NtGdiSelectBrush(hdcDest, hbrDst);
|
|
|
|
NtGdiSelectBitmap(hDC1, hOldBitmap1);
|
|
|
|
NtGdiSelectBitmap(hDC2, hOldBitmap2);
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2004-08-11 20:51:10 +02:00
|
|
|
/* delete all temp objects */
|
2021-09-03 14:59:52 +02:00
|
|
|
NtGdiDeleteObjectApp( hBitmap1 );
|
|
|
|
NtGdiDeleteObjectApp( hBitmap2 );
|
|
|
|
NtGdiDeleteObjectApp( hbrMask );
|
2003-05-16 22:11:36 +02:00
|
|
|
|
2021-08-23 13:51:01 +02:00
|
|
|
NtGdiDeleteObjectApp( hDC1 );
|
|
|
|
NtGdiDeleteObjectApp( hDC2 );
|
2003-05-16 22:11:36 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1998-12-15 16:38:36 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-02-03 00:10:35 +01:00
|
|
|
/******************************************************************************
|
2021-09-10 14:27:39 +02:00
|
|
|
* NtGdiTransparentBlt (win32u.@)
|
2004-02-03 00:10:35 +01:00
|
|
|
*/
|
2021-09-10 14:27:39 +02:00
|
|
|
BOOL WINAPI NtGdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest, int heightDest,
|
|
|
|
HDC hdcSrc, int xSrc, int ySrc, int widthSrc, int heightSrc,
|
|
|
|
UINT crTransparent )
|
2004-02-03 00:10:35 +01:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
HDC hdcWork;
|
|
|
|
HBITMAP bmpWork;
|
|
|
|
HGDIOBJ oldWork;
|
|
|
|
HDC hdcMask = NULL;
|
|
|
|
HBITMAP bmpMask = NULL;
|
|
|
|
HBITMAP oldMask = NULL;
|
|
|
|
COLORREF oldBackground;
|
|
|
|
COLORREF oldForeground;
|
|
|
|
int oldStretchMode;
|
2017-10-06 14:08:47 +02:00
|
|
|
DIBSECTION dib;
|
2021-09-17 13:44:16 +02:00
|
|
|
DC *dc_src;
|
2004-02-03 00:10:35 +01:00
|
|
|
|
|
|
|
if(widthDest < 0 || heightDest < 0 || widthSrc < 0 || heightSrc < 0) {
|
2005-05-06 17:44:31 +02:00
|
|
|
TRACE("Cannot mirror\n");
|
2004-02-03 00:10:35 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-09-17 13:44:16 +02:00
|
|
|
if (!(dc_src = get_dc_ptr( hdcSrc ))) return FALSE;
|
|
|
|
|
2021-09-10 14:27:39 +02:00
|
|
|
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetBkColor, RGB(255,255,255), &oldBackground );
|
|
|
|
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetTextColor, RGB(0,0,0), &oldForeground );
|
2004-02-03 00:10:35 +01:00
|
|
|
|
|
|
|
/* Stretch bitmap */
|
2021-09-17 13:44:16 +02:00
|
|
|
oldStretchMode = dc_src->attr->stretch_blt_mode;
|
|
|
|
if (oldStretchMode == BLACKONWHITE || oldStretchMode == WHITEONBLACK)
|
|
|
|
dc_src->attr->stretch_blt_mode = COLORONCOLOR;
|
2021-07-30 13:02:47 +02:00
|
|
|
hdcWork = NtGdiCreateCompatibleDC( hdcDest );
|
2021-09-14 21:51:51 +02:00
|
|
|
if ((get_gdi_object_type( hdcDest ) != NTGDI_OBJ_MEMDC ||
|
2021-09-10 14:27:39 +02:00
|
|
|
NtGdiExtGetObjectW( NtGdiGetDCObject( hdcDest, NTGDI_OBJ_SURF ),
|
|
|
|
sizeof(dib), &dib ) == sizeof(BITMAP)) &&
|
|
|
|
NtGdiGetDeviceCaps( hdcDest, BITSPIXEL ) == 32)
|
2017-07-12 11:43:50 +02:00
|
|
|
{
|
2017-10-06 14:08:47 +02:00
|
|
|
/* screen DCs or DDBs are not supposed to have an alpha channel, so use a 24-bpp bitmap as copy */
|
2017-07-12 11:43:50 +02:00
|
|
|
BITMAPINFO info;
|
|
|
|
info.bmiHeader.biSize = sizeof(info.bmiHeader);
|
|
|
|
info.bmiHeader.biWidth = widthDest;
|
|
|
|
info.bmiHeader.biHeight = heightDest;
|
|
|
|
info.bmiHeader.biPlanes = 1;
|
|
|
|
info.bmiHeader.biBitCount = 24;
|
|
|
|
info.bmiHeader.biCompression = BI_RGB;
|
2021-08-31 14:18:37 +02:00
|
|
|
bmpWork = NtGdiCreateDIBSection( 0, NULL, 0, &info, DIB_RGB_COLORS, 0, 0, 0, NULL );
|
2017-07-12 11:43:50 +02:00
|
|
|
}
|
2021-08-31 14:18:33 +02:00
|
|
|
else bmpWork = NtGdiCreateCompatibleBitmap( hdcDest, widthDest, heightDest );
|
2021-07-02 12:41:27 +02:00
|
|
|
oldWork = NtGdiSelectBitmap(hdcWork, bmpWork);
|
2021-09-10 14:27:39 +02:00
|
|
|
if (!NtGdiStretchBlt( hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc,
|
|
|
|
widthSrc, heightSrc, SRCCOPY, 0 ))
|
|
|
|
{
|
2004-02-03 00:10:35 +01:00
|
|
|
TRACE("Failed to stretch\n");
|
|
|
|
goto error;
|
|
|
|
}
|
2021-09-10 14:27:39 +02:00
|
|
|
NtGdiGetAndSetDCDword( hdcWork, NtGdiSetBkColor, crTransparent, NULL );
|
2004-02-03 00:10:35 +01:00
|
|
|
|
|
|
|
/* Create mask */
|
2021-07-30 13:02:47 +02:00
|
|
|
hdcMask = NtGdiCreateCompatibleDC( hdcDest );
|
2021-08-31 14:18:33 +02:00
|
|
|
bmpMask = NtGdiCreateCompatibleBitmap( hdcMask, widthDest, heightDest );
|
2021-07-02 12:41:27 +02:00
|
|
|
oldMask = NtGdiSelectBitmap(hdcMask, bmpMask);
|
2021-09-10 14:27:39 +02:00
|
|
|
if (!NtGdiBitBlt( hdcMask, 0, 0, widthDest, heightDest, hdcWork, 0, 0, SRCCOPY, 0, 0 ))
|
|
|
|
{
|
2004-02-03 00:10:35 +01:00
|
|
|
TRACE("Failed to create mask\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Replace transparent color with black */
|
2021-09-10 14:27:39 +02:00
|
|
|
NtGdiGetAndSetDCDword( hdcWork, NtGdiSetBkColor, RGB(0,0,0), NULL );
|
|
|
|
NtGdiGetAndSetDCDword( hdcWork, NtGdiSetTextColor, RGB(255,255,255), NULL );
|
|
|
|
if (!NtGdiBitBlt( hdcWork, 0, 0, widthDest, heightDest, hdcMask, 0, 0, SRCAND, 0, 0 ))
|
|
|
|
{
|
2004-02-03 00:10:35 +01:00
|
|
|
TRACE("Failed to mask out background\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Replace non-transparent area on destination with black */
|
2021-09-10 14:27:39 +02:00
|
|
|
if (!NtGdiBitBlt( hdcDest, xDest, yDest, widthDest, heightDest, hdcMask, 0, 0, SRCAND, 0, 0 ))
|
|
|
|
{
|
2004-02-03 00:10:35 +01:00
|
|
|
TRACE("Failed to clear destination area\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the image */
|
2021-09-10 14:27:39 +02:00
|
|
|
if (!NtGdiBitBlt( hdcDest, xDest, yDest, widthDest, heightDest, hdcWork, 0, 0, SRCPAINT, 0, 0 ))
|
|
|
|
{
|
2004-02-03 00:10:35 +01:00
|
|
|
TRACE("Failed to paint image\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
error:
|
2021-09-17 13:44:16 +02:00
|
|
|
dc_src->attr->stretch_blt_mode = oldStretchMode;
|
|
|
|
release_dc_ptr( dc_src );
|
2021-09-10 14:27:39 +02:00
|
|
|
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetBkColor, oldBackground, NULL );
|
|
|
|
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetTextColor, oldForeground, NULL );
|
2004-02-03 00:10:35 +01:00
|
|
|
if(hdcWork) {
|
2021-07-02 12:41:27 +02:00
|
|
|
NtGdiSelectBitmap(hdcWork, oldWork);
|
2021-08-23 13:51:01 +02:00
|
|
|
NtGdiDeleteObjectApp( hdcWork );
|
2004-02-03 00:10:35 +01:00
|
|
|
}
|
2021-09-03 14:59:52 +02:00
|
|
|
if(bmpWork) NtGdiDeleteObjectApp( bmpWork );
|
2004-02-03 00:10:35 +01:00
|
|
|
if(hdcMask) {
|
2021-07-02 12:41:27 +02:00
|
|
|
NtGdiSelectBitmap(hdcMask, oldMask);
|
2021-08-23 13:51:01 +02:00
|
|
|
NtGdiDeleteObjectApp( hdcMask );
|
2004-02-03 00:10:35 +01:00
|
|
|
}
|
2021-09-03 14:59:52 +02:00
|
|
|
if(bmpMask) NtGdiDeleteObjectApp( bmpMask );
|
2004-02-03 00:10:35 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-04-14 21:35:24 +02:00
|
|
|
/******************************************************************************
|
2021-08-12 12:00:31 +02:00
|
|
|
* NtGdiAlphaBlend (win32u.@)
|
2004-04-14 21:35:24 +02:00
|
|
|
*/
|
2021-08-12 12:00:31 +02:00
|
|
|
BOOL WINAPI NtGdiAlphaBlend( HDC hdcDst, int xDst, int yDst, int widthDst, int heightDst,
|
|
|
|
HDC hdcSrc, int xSrc, int ySrc, int widthSrc, int heightSrc,
|
|
|
|
BLENDFUNCTION blendFunction, HANDLE xform )
|
2004-04-14 21:35:24 +02:00
|
|
|
{
|
2004-08-02 20:54:54 +02:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DC *dcDst, *dcSrc;
|
|
|
|
|
2007-09-17 16:48:56 +02:00
|
|
|
dcSrc = get_dc_ptr( hdcSrc );
|
2009-09-18 13:42:11 +02:00
|
|
|
if (!dcSrc) return FALSE;
|
|
|
|
|
2007-09-17 16:48:56 +02:00
|
|
|
if ((dcDst = get_dc_ptr( hdcDst )))
|
2004-08-02 20:54:54 +02:00
|
|
|
{
|
2011-07-11 14:17:04 +02:00
|
|
|
struct bitblt_coords src, dst;
|
|
|
|
|
2009-09-18 13:42:11 +02:00
|
|
|
update_dc( dcSrc );
|
2007-09-17 16:48:56 +02:00
|
|
|
update_dc( dcDst );
|
2011-07-11 14:17:04 +02:00
|
|
|
|
|
|
|
src.log_x = xSrc;
|
|
|
|
src.log_y = ySrc;
|
|
|
|
src.log_width = widthSrc;
|
|
|
|
src.log_height = heightSrc;
|
2021-07-28 11:39:26 +02:00
|
|
|
src.layout = dcSrc->attr->layout;
|
2011-07-11 14:17:04 +02:00
|
|
|
dst.log_x = xDst;
|
|
|
|
dst.log_y = yDst;
|
|
|
|
dst.log_width = widthDst;
|
|
|
|
dst.log_height = heightDst;
|
2021-07-28 11:39:26 +02:00
|
|
|
dst.layout = dcDst->attr->layout;
|
2011-07-20 12:17:09 +02:00
|
|
|
ret = !get_vis_rectangles( dcDst, &dst, dcSrc, &src );
|
2011-07-11 14:17:04 +02:00
|
|
|
|
|
|
|
TRACE("src %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s dst %p log=%d,%d %dx%d phys=%d,%d %dx%d vis=%s blend=%02x/%02x/%02x/%02x\n",
|
|
|
|
hdcSrc, src.log_x, src.log_y, src.log_width, src.log_height,
|
|
|
|
src.x, src.y, src.width, src.height, wine_dbgstr_rect(&src.visrect),
|
|
|
|
hdcDst, dst.log_x, dst.log_y, dst.log_width, dst.log_height,
|
|
|
|
dst.x, dst.y, dst.width, dst.height, wine_dbgstr_rect(&dst.visrect),
|
|
|
|
blendFunction.BlendOp, blendFunction.BlendFlags,
|
|
|
|
blendFunction.SourceConstantAlpha, blendFunction.AlphaFormat );
|
|
|
|
|
2011-09-13 17:10:37 +02:00
|
|
|
if (src.x < 0 || src.y < 0 || src.width < 0 || src.height < 0 ||
|
2012-01-18 14:40:12 +01:00
|
|
|
src.log_width < 0 || src.log_height < 0 ||
|
2012-04-30 21:17:00 +02:00
|
|
|
(!is_rect_empty( &dcSrc->device_rect ) &&
|
2021-08-02 10:03:33 +02:00
|
|
|
(src.width > dcSrc->device_rect.right - dcSrc->attr->vis_rect.left - src.x ||
|
|
|
|
src.height > dcSrc->device_rect.bottom - dcSrc->attr->vis_rect.top - src.y)))
|
2011-09-13 17:10:37 +02:00
|
|
|
{
|
|
|
|
WARN( "Invalid src coords: (%d,%d), size %dx%d\n", src.x, src.y, src.width, src.height );
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2012-01-18 14:40:12 +01:00
|
|
|
else if (dst.log_width < 0 || dst.log_height < 0)
|
2011-09-13 17:10:37 +02:00
|
|
|
{
|
2012-01-18 14:40:12 +01:00
|
|
|
WARN( "Invalid dst coords: (%d,%d), size %dx%d\n",
|
|
|
|
dst.log_x, dst.log_y, dst.log_width, dst.log_height );
|
2011-09-13 17:10:37 +02:00
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
ret = FALSE;
|
2011-10-14 18:22:50 +02:00
|
|
|
}
|
|
|
|
else if (dcSrc == dcDst && src.x + src.width > dst.x && src.x < dst.x + dst.width &&
|
|
|
|
src.y + src.height > dst.y && src.y < dst.y + dst.height)
|
|
|
|
{
|
|
|
|
WARN( "Overlapping coords: (%d,%d), %dx%d and (%d,%d), %dx%d\n",
|
|
|
|
src.x, src.y, src.width, src.height, dst.x, dst.y, dst.width, dst.height );
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
ret = FALSE;
|
2011-09-13 17:10:37 +02:00
|
|
|
}
|
2012-09-20 21:07:04 +02:00
|
|
|
else if (!ret)
|
|
|
|
{
|
|
|
|
PHYSDEV src_dev = GET_DC_PHYSDEV( dcSrc, pAlphaBlend );
|
|
|
|
PHYSDEV dst_dev = GET_DC_PHYSDEV( dcDst, pAlphaBlend );
|
|
|
|
ret = dst_dev->funcs->pAlphaBlend( dst_dev, &dst, src_dev, &src, blendFunction );
|
|
|
|
}
|
2007-09-17 16:48:56 +02:00
|
|
|
release_dc_ptr( dcDst );
|
2004-08-02 20:54:54 +02:00
|
|
|
}
|
2009-09-18 13:42:11 +02:00
|
|
|
release_dc_ptr( dcSrc );
|
2004-08-02 20:54:54 +02:00
|
|
|
return ret;
|
2004-04-14 21:35:24 +02:00
|
|
|
}
|
|
|
|
|
1998-12-15 16:38:36 +01:00
|
|
|
/*********************************************************************
|
2021-09-09 14:01:02 +02:00
|
|
|
* NtGdiPlgBlt (win32u.@)
|
1998-12-15 16:38:36 +01:00
|
|
|
*/
|
2021-09-09 14:01:02 +02:00
|
|
|
BOOL WINAPI NtGdiPlgBlt( HDC hdcDest, const POINT *lpPoint, HDC hdcSrc, INT nXSrc, INT nYSrc,
|
|
|
|
INT nWidth, INT nHeight, HBITMAP hbmMask, INT xMask, INT yMask,
|
|
|
|
DWORD bk_color )
|
1998-12-15 16:38:36 +01:00
|
|
|
{
|
2021-08-31 14:18:34 +02:00
|
|
|
DWORD prev_mode;
|
2008-03-26 23:59:34 +01:00
|
|
|
/* parallelogram coords */
|
|
|
|
POINT plg[3];
|
|
|
|
/* rect coords */
|
|
|
|
POINT rect[3];
|
|
|
|
XFORM xf;
|
|
|
|
XFORM SrcXf;
|
|
|
|
XFORM oldDestXf;
|
2008-05-22 17:43:01 +02:00
|
|
|
double det;
|
2008-03-26 23:59:34 +01:00
|
|
|
|
|
|
|
/* save actual mode, set GM_ADVANCED */
|
2021-08-31 14:18:34 +02:00
|
|
|
if (!NtGdiGetAndSetDCDword( hdcDest, NtGdiSetGraphicsMode, GM_ADVANCED, &prev_mode ))
|
2008-03-26 23:59:34 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memcpy(plg,lpPoint,sizeof(POINT)*3);
|
|
|
|
rect[0].x = nXSrc;
|
|
|
|
rect[0].y = nYSrc;
|
|
|
|
rect[1].x = nXSrc + nWidth;
|
|
|
|
rect[1].y = nYSrc;
|
|
|
|
rect[2].x = nXSrc;
|
|
|
|
rect[2].y = nYSrc + nHeight;
|
|
|
|
/* calc XFORM matrix to transform hdcDest -> hdcSrc (parallelogram to rectangle) */
|
|
|
|
/* determinant */
|
2008-05-22 17:43:01 +02:00
|
|
|
det = rect[1].x*(rect[2].y - rect[0].y) - rect[2].x*(rect[1].y - rect[0].y) - rect[0].x*(rect[2].y - rect[1].y);
|
2008-03-26 23:59:34 +01:00
|
|
|
|
|
|
|
if (fabs(det) < 1e-5)
|
|
|
|
{
|
2021-08-31 14:18:34 +02:00
|
|
|
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetGraphicsMode, prev_mode, NULL );
|
2008-03-26 23:59:34 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("hdcSrc=%p %d,%d,%dx%d -> hdcDest=%p %d,%d,%d,%d,%d,%d\n",
|
|
|
|
hdcSrc, nXSrc, nYSrc, nWidth, nHeight, hdcDest, plg[0].x, plg[0].y, plg[1].x, plg[1].y, plg[2].x, plg[2].y);
|
|
|
|
|
|
|
|
/* X components */
|
|
|
|
xf.eM11 = (plg[1].x*(rect[2].y - rect[0].y) - plg[2].x*(rect[1].y - rect[0].y) - plg[0].x*(rect[2].y - rect[1].y)) / det;
|
|
|
|
xf.eM21 = (rect[1].x*(plg[2].x - plg[0].x) - rect[2].x*(plg[1].x - plg[0].x) - rect[0].x*(plg[2].x - plg[1].x)) / det;
|
|
|
|
xf.eDx = (rect[0].x*(rect[1].y*plg[2].x - rect[2].y*plg[1].x) -
|
|
|
|
rect[1].x*(rect[0].y*plg[2].x - rect[2].y*plg[0].x) +
|
|
|
|
rect[2].x*(rect[0].y*plg[1].x - rect[1].y*plg[0].x)
|
|
|
|
) / det;
|
|
|
|
|
|
|
|
/* Y components */
|
|
|
|
xf.eM12 = (plg[1].y*(rect[2].y - rect[0].y) - plg[2].y*(rect[1].y - rect[0].y) - plg[0].y*(rect[2].y - rect[1].y)) / det;
|
2014-06-26 13:56:49 +02:00
|
|
|
xf.eM22 = (rect[1].x*(plg[2].y - plg[0].y) - rect[2].x*(plg[1].y - plg[0].y) - rect[0].x*(plg[2].y - plg[1].y)) / det;
|
2008-03-26 23:59:34 +01:00
|
|
|
xf.eDy = (rect[0].x*(rect[1].y*plg[2].y - rect[2].y*plg[1].y) -
|
|
|
|
rect[1].x*(rect[0].y*plg[2].y - rect[2].y*plg[0].y) +
|
|
|
|
rect[2].x*(rect[0].y*plg[1].y - rect[1].y*plg[0].y)
|
|
|
|
) / det;
|
|
|
|
|
2021-09-09 14:01:02 +02:00
|
|
|
NtGdiGetTransform( hdcSrc, 0x203, &SrcXf );
|
2021-09-01 14:09:12 +02:00
|
|
|
combine_transform( &xf, &xf, &SrcXf );
|
2008-03-26 23:59:34 +01:00
|
|
|
|
|
|
|
/* save actual dest transform */
|
2021-09-09 14:01:02 +02:00
|
|
|
NtGdiGetTransform( hdcDest, 0x203, &oldDestXf );
|
2008-03-26 23:59:34 +01:00
|
|
|
|
2021-09-09 14:01:02 +02:00
|
|
|
NtGdiModifyWorldTransform( hdcDest, &xf, MWT_SET );
|
2008-03-26 23:59:34 +01:00
|
|
|
/* now destination and source DCs use same coords */
|
2021-09-09 14:01:02 +02:00
|
|
|
NtGdiMaskBlt( hdcDest, nXSrc, nYSrc, nWidth, nHeight, hdcSrc, nXSrc, nYSrc,
|
|
|
|
hbmMask, xMask, yMask, SRCCOPY, 0 );
|
2008-03-26 23:59:34 +01:00
|
|
|
/* restore dest DC */
|
2021-09-09 14:01:02 +02:00
|
|
|
NtGdiModifyWorldTransform( hdcDest, &oldDestXf, MWT_SET );
|
2021-08-31 14:18:34 +02:00
|
|
|
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetGraphicsMode, prev_mode, NULL );
|
2008-03-26 23:59:34 +01:00
|
|
|
|
|
|
|
return TRUE;
|
1998-12-15 16:38:36 +01:00
|
|
|
}
|