mirror of
https://github.com/reactos/reactos.git
synced 2025-05-22 10:35:54 +00:00
[WIN32K]
- Modify NtGdiSelectBitmap to correctly handle the case of pdc->dclevel.pSurface == 0 - Small code improvement without functional change for rtlstr functions svn path=/trunk/; revision=55636
This commit is contained in:
parent
a49c373b0c
commit
7816af6cb9
2 changed files with 53 additions and 40 deletions
|
@ -3,7 +3,6 @@
|
|||
* FILE: subsystems/win32/win32k/misc/rtlstr.c
|
||||
* PURPOSE: Large Strings
|
||||
* PROGRAMMER:
|
||||
* UPDATE HISTORY:
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -12,11 +11,13 @@
|
|||
#include <win32k.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString,
|
||||
IN PCSZ SourceString,
|
||||
IN INT Unknown)
|
||||
RtlInitLargeAnsiString(
|
||||
IN OUT PLARGE_ANSI_STRING DestinationString,
|
||||
IN PCSZ SourceString,
|
||||
IN INT Unknown)
|
||||
{
|
||||
ULONG DestSize;
|
||||
|
||||
|
@ -38,9 +39,10 @@ RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString,
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString,
|
||||
IN PCWSTR SourceString,
|
||||
IN INT Unknown)
|
||||
RtlInitLargeUnicodeString(
|
||||
IN OUT PLARGE_UNICODE_STRING DestinationString,
|
||||
IN PCWSTR SourceString,
|
||||
IN INT Unknown)
|
||||
{
|
||||
ULONG DestSize;
|
||||
|
||||
|
@ -62,21 +64,29 @@ RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString,
|
|||
|
||||
BOOL
|
||||
NTAPI
|
||||
RtlLargeStringToUnicodeString( PUNICODE_STRING DestinationString,
|
||||
PLARGE_STRING SourceString)
|
||||
RtlLargeStringToUnicodeString(
|
||||
PUNICODE_STRING DestinationString,
|
||||
PLARGE_STRING SourceString)
|
||||
{
|
||||
ANSI_STRING AnsiString;
|
||||
ANSI_STRING AnsiString;
|
||||
|
||||
RtlInitUnicodeString(DestinationString, NULL);
|
||||
if (DestinationString && SourceString && SourceString->bAnsi)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer);
|
||||
return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString, TRUE));
|
||||
}
|
||||
else if (DestinationString && SourceString)
|
||||
{
|
||||
return RtlCreateUnicodeString(DestinationString, SourceString->Buffer);
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
/* Check parameters */
|
||||
if (!DestinationString || !SourceString) return FALSE;
|
||||
|
||||
/* Check if size if ok */
|
||||
// We can't do this atm and truncate the string instead.
|
||||
//if (SourceString->Length > 0xffff) return FALSE;
|
||||
|
||||
RtlInitUnicodeString(DestinationString, NULL);
|
||||
|
||||
if (SourceString->bAnsi)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer);
|
||||
return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString, TRUE));
|
||||
}
|
||||
else
|
||||
{
|
||||
return RtlCreateUnicodeString(DestinationString, SourceString->Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ NtGdiSelectBitmap(
|
|||
PDC pdc;
|
||||
PDC_ATTR pdcattr;
|
||||
HBITMAP hbmpOld;
|
||||
PSURFACE psurfNew;
|
||||
PSURFACE psurfNew, psurfOld;
|
||||
HRGN hVisRgn;
|
||||
SIZEL sizlBitmap = {1, 1};
|
||||
HDC hdcOld;
|
||||
|
@ -287,17 +287,8 @@ NtGdiSelectBitmap(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Check if there was a bitmap selected before */
|
||||
if (pdc->dclevel.pSurface)
|
||||
{
|
||||
/* Return its handle */
|
||||
hbmpOld = pdc->dclevel.pSurface->BaseObject.hHmgr;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return default bitmap */
|
||||
hbmpOld = StockObjects[DEFAULT_BITMAP];
|
||||
}
|
||||
/* Save the old bitmap */
|
||||
psurfOld = pdc->dclevel.pSurface;
|
||||
|
||||
/* Check if the default bitmap was passed */
|
||||
if (hbmp == StockObjects[DEFAULT_BITMAP])
|
||||
|
@ -342,14 +333,26 @@ NtGdiSelectBitmap(
|
|||
}
|
||||
}
|
||||
|
||||
/* Select the new surface, release the old */
|
||||
DC_vSelectSurface(pdc, psurfNew);
|
||||
/* Select the new bitmap */
|
||||
pdc->dclevel.pSurface = psurfNew;
|
||||
|
||||
/* Set the new size */
|
||||
pdc->dclevel.sizl = sizlBitmap;
|
||||
/* Check if there was a bitmap selected before */
|
||||
if (psurfOld)
|
||||
{
|
||||
/* Get the old bitmap's handle */
|
||||
hbmpOld = psurfOld->BaseObject.hHmgr;
|
||||
|
||||
/* Release one reference we added */
|
||||
SURFACE_ShareUnlockSurface(psurfNew);
|
||||
/* Reset hdc of the old bitmap,it isn't selected anymore */
|
||||
psurfOld->hdc = NULL;
|
||||
|
||||
/* Dereference the old bitmap */
|
||||
SURFACE_ShareUnlockSurface(psurfOld);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return default bitmap */
|
||||
hbmpOld = StockObjects[DEFAULT_BITMAP];
|
||||
}
|
||||
|
||||
/* Mark the dc brushes invalid */
|
||||
pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;
|
||||
|
|
Loading…
Reference in a new issue