mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:12:56 +00:00
- Don't create XLATEOBJ for BitBlt and StretchBlt operations that don't use source DC.
svn path=/trunk/; revision=10015
This commit is contained in:
parent
bce67c86c4
commit
226251dab1
1 changed files with 110 additions and 99 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: bitmaps.c,v 1.77 2004/07/03 17:40:27 navaraf Exp $ */
|
/* $Id: bitmaps.c,v 1.78 2004/07/07 16:36:08 navaraf Exp $ */
|
||||||
#include <w32k.h>
|
#include <w32k.h>
|
||||||
|
|
||||||
#define IN_RECT(r,x,y) \
|
#define IN_RECT(r,x,y) \
|
||||||
|
@ -139,34 +139,17 @@ NtGdiBitBlt(
|
||||||
BrushObj = NULL;
|
BrushObj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DCDest->w.hPalette != 0)
|
/* Create the XLATEOBJ. */
|
||||||
DestPalette = DCDest->w.hPalette;
|
if (UsesSource)
|
||||||
|
|
||||||
if (UsesSource && DCSrc->w.hPalette != 0)
|
|
||||||
SourcePalette = DCSrc->w.hPalette;
|
|
||||||
|
|
||||||
PalSourceGDI = PALETTE_LockPalette(SourcePalette);
|
|
||||||
if (NULL == PalSourceGDI)
|
|
||||||
{
|
{
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
if (DCDest->w.hPalette != 0)
|
||||||
{
|
DestPalette = DCDest->w.hPalette;
|
||||||
DC_UnlockDc(hDCSrc);
|
|
||||||
}
|
|
||||||
DC_UnlockDc(hDCDest);
|
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
SourceMode = PalSourceGDI->Mode;
|
|
||||||
PALETTE_UnlockPalette(SourcePalette);
|
|
||||||
|
|
||||||
if (DestPalette == SourcePalette)
|
if (DCSrc->w.hPalette != 0)
|
||||||
{
|
SourcePalette = DCSrc->w.hPalette;
|
||||||
DestMode = SourceMode;
|
|
||||||
}
|
PalSourceGDI = PALETTE_LockPalette(SourcePalette);
|
||||||
else
|
if (NULL == PalSourceGDI)
|
||||||
{
|
|
||||||
PalDestGDI = PALETTE_LockPalette(DestPalette);
|
|
||||||
if (NULL == PalDestGDI)
|
|
||||||
{
|
{
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
if (UsesSource && hDCSrc != hDCDest)
|
||||||
{
|
{
|
||||||
|
@ -176,56 +159,78 @@ NtGdiBitBlt(
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
DestMode = PalDestGDI->Mode;
|
SourceMode = PalSourceGDI->Mode;
|
||||||
PALETTE_UnlockPalette(DestPalette);
|
PALETTE_UnlockPalette(SourcePalette);
|
||||||
}
|
|
||||||
|
|
||||||
/* KB41464 details how to convert between mono and color */
|
if (DestPalette == SourcePalette)
|
||||||
if (DCDest->w.bitsPerPixel == 1)
|
|
||||||
{
|
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateMonoXlate(SourceMode, DestPalette,
|
|
||||||
SourcePalette, DCSrc->w.backgroundColor);
|
|
||||||
}
|
|
||||||
else if (UsesSource && 1 == DCSrc->w.bitsPerPixel)
|
|
||||||
{
|
|
||||||
ULONG Colors[2];
|
|
||||||
|
|
||||||
Colors[0] = DCSrc->w.textColor;
|
|
||||||
Colors[1] = DCSrc->w.backgroundColor;
|
|
||||||
Mono = PALETTE_AllocPaletteIndexedRGB(2, (RGBQUAD*)Colors);
|
|
||||||
if (NULL != Mono)
|
|
||||||
{
|
{
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(DestMode, PAL_INDEXED, DestPalette, Mono);
|
DestMode = SourceMode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XlateObj = NULL;
|
PalDestGDI = PALETTE_LockPalette(DestPalette);
|
||||||
|
if (NULL == PalDestGDI)
|
||||||
|
{
|
||||||
|
if (UsesSource && hDCSrc != hDCDest)
|
||||||
|
{
|
||||||
|
DC_UnlockDc(hDCSrc);
|
||||||
|
}
|
||||||
|
DC_UnlockDc(hDCDest);
|
||||||
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
DestMode = PalDestGDI->Mode;
|
||||||
|
PALETTE_UnlockPalette(DestPalette);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
/* KB41464 details how to convert between mono and color */
|
||||||
{
|
if (DCDest->w.bitsPerPixel == 1)
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
|
|
||||||
}
|
|
||||||
if (NULL == XlateObj)
|
|
||||||
{
|
|
||||||
if (NULL != Mono)
|
|
||||||
{
|
{
|
||||||
EngDeletePalette(Mono);
|
XlateObj = (XLATEOBJ*)IntEngCreateMonoXlate(SourceMode, DestPalette,
|
||||||
|
SourcePalette, DCSrc->w.backgroundColor);
|
||||||
}
|
}
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
else if (DCSrc->w.bitsPerPixel == 1)
|
||||||
{
|
{
|
||||||
DC_UnlockDc(hDCSrc);
|
ULONG Colors[2];
|
||||||
|
|
||||||
|
Colors[0] = DCSrc->w.textColor;
|
||||||
|
Colors[1] = DCSrc->w.backgroundColor;
|
||||||
|
Mono = PALETTE_AllocPaletteIndexedRGB(2, (RGBQUAD*)Colors);
|
||||||
|
if (NULL != Mono)
|
||||||
|
{
|
||||||
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate(DestMode, PAL_INDEXED, DestPalette, Mono);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XlateObj = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
|
||||||
|
}
|
||||||
|
if (NULL == XlateObj)
|
||||||
|
{
|
||||||
|
if (NULL != Mono)
|
||||||
|
{
|
||||||
|
EngDeletePalette(Mono);
|
||||||
|
}
|
||||||
|
if (UsesSource && hDCSrc != hDCDest)
|
||||||
|
{
|
||||||
|
DC_UnlockDc(hDCSrc);
|
||||||
|
}
|
||||||
|
DC_UnlockDc(hDCDest);
|
||||||
|
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
DC_UnlockDc(hDCDest);
|
|
||||||
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the bitblt operation */
|
/* Perform the bitblt operation */
|
||||||
Status = IntEngBitBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip, XlateObj,
|
Status = IntEngBitBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip, XlateObj,
|
||||||
&DestRect, &SourcePoint, NULL, &BrushObj->BrushObject, &BrushOrigin, ROP);
|
&DestRect, &SourcePoint, NULL, &BrushObj->BrushObject, &BrushOrigin, ROP);
|
||||||
|
|
||||||
EngDeleteXlate(XlateObj);
|
if (UsesSource)
|
||||||
|
EngDeleteXlate(XlateObj);
|
||||||
BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
|
BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
|
||||||
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
|
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
|
||||||
{
|
{
|
||||||
|
@ -1140,34 +1145,17 @@ NtGdiStretchBlt(
|
||||||
BrushObj = NULL;
|
BrushObj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DCDest->w.hPalette != 0)
|
/* Create the XLATEOBJ. */
|
||||||
DestPalette = DCDest->w.hPalette;
|
if (UsesSource)
|
||||||
|
|
||||||
if (UsesSource && DCSrc->w.hPalette != 0)
|
|
||||||
SourcePalette = DCSrc->w.hPalette;
|
|
||||||
|
|
||||||
PalSourceGDI = PALETTE_LockPalette(SourcePalette);
|
|
||||||
if (NULL == PalSourceGDI)
|
|
||||||
{
|
{
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
if (DCDest->w.hPalette != 0)
|
||||||
{
|
DestPalette = DCDest->w.hPalette;
|
||||||
DC_UnlockDc(hDCSrc);
|
|
||||||
}
|
|
||||||
DC_UnlockDc(hDCDest);
|
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
SourceMode = PalSourceGDI->Mode;
|
|
||||||
PALETTE_UnlockPalette(SourcePalette);
|
|
||||||
|
|
||||||
if (DestPalette == SourcePalette)
|
if (DCSrc->w.hPalette != 0)
|
||||||
{
|
SourcePalette = DCSrc->w.hPalette;
|
||||||
DestMode = SourceMode;
|
|
||||||
}
|
PalSourceGDI = PALETTE_LockPalette(SourcePalette);
|
||||||
else
|
if (NULL == PalSourceGDI)
|
||||||
{
|
|
||||||
PalDestGDI = PALETTE_LockPalette(DestPalette);
|
|
||||||
if (NULL == PalDestGDI)
|
|
||||||
{
|
{
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
if (UsesSource && hDCSrc != hDCDest)
|
||||||
{
|
{
|
||||||
|
@ -1177,27 +1165,50 @@ NtGdiStretchBlt(
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
DestMode = PalDestGDI->Mode;
|
SourceMode = PalSourceGDI->Mode;
|
||||||
PALETTE_UnlockPalette(DestPalette);
|
PALETTE_UnlockPalette(SourcePalette);
|
||||||
}
|
|
||||||
|
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
|
if (DestPalette == SourcePalette)
|
||||||
if (NULL == XlateObj)
|
|
||||||
{
|
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
|
||||||
{
|
{
|
||||||
DC_UnlockDc(hDCSrc);
|
DestMode = SourceMode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PalDestGDI = PALETTE_LockPalette(DestPalette);
|
||||||
|
if (NULL == PalDestGDI)
|
||||||
|
{
|
||||||
|
if (UsesSource && hDCSrc != hDCDest)
|
||||||
|
{
|
||||||
|
DC_UnlockDc(hDCSrc);
|
||||||
|
}
|
||||||
|
DC_UnlockDc(hDCDest);
|
||||||
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
DestMode = PalDestGDI->Mode;
|
||||||
|
PALETTE_UnlockPalette(DestPalette);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Use the same logic for create XLATEOBJ as in NtGdiBitBlt. */
|
||||||
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
|
||||||
|
if (NULL == XlateObj)
|
||||||
|
{
|
||||||
|
if (UsesSource && hDCSrc != hDCDest)
|
||||||
|
{
|
||||||
|
DC_UnlockDc(hDCSrc);
|
||||||
|
}
|
||||||
|
DC_UnlockDc(hDCDest);
|
||||||
|
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
DC_UnlockDc(hDCDest);
|
|
||||||
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the bitblt operation */
|
/* Perform the bitblt operation */
|
||||||
Status = IntEngStretchBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip,
|
Status = IntEngStretchBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip,
|
||||||
XlateObj, &DestRect, &SourceRect, NULL, NULL, NULL, COLORONCOLOR);
|
XlateObj, &DestRect, &SourceRect, NULL, NULL, NULL, COLORONCOLOR);
|
||||||
|
|
||||||
EngDeleteXlate(XlateObj);
|
if (UsesSource)
|
||||||
|
EngDeleteXlate(XlateObj);
|
||||||
BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
|
BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
|
||||||
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
|
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue