[ros-dev] [ros-diffs] [jimtabor] 51835: [Win32k|User32] - Move creation of the scrollbar Gray brush from user32 to win32k. - Noticed a color and pattern (patchy white pattern) difference when using GreCreateBitmap and i...

Adam geekdundee at gmail.com
Sat May 21 13:26:07 UTC 2011


I was thinking that should actually be:


+    static const DWORD wPattern55AA[] = { 0x55555555, 0xAAAAAAAA,  
0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA };


Note that you need 8 hex digits for 32-bit numbers.


On Sat, 21 May 2011 23:23:01 +1000, Timo Kreuzer <timo.kreuzer at web.de>  
wrote:

> Hi,
>
> I suspect its an alignment issue, since GreCreateBitmap requires 32bit  
> alignment, while CreateBitmap uses 16 bit alignment.
> So changing
>
> +    static const WORD wPattern55AA[] = { 0x5555, 0xaaaa, 0x5555,  
> 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
>
> to
>
> +    static const DWORD wPattern55AA[] = { 0x5555, 0xaaaa, 0x5555,  
> 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
>
> Should do the trick.
>
>
> Am 21.05.2011 08:34, schrieb jimtabor at svn.reactos.org:
>> Author: jimtabor
>> Date: Sat May 21 06:34:02 2011
>> New Revision: 51835
>>
>> URL: http://svn.reactos.org/svn/reactos?rev=51835&view=rev
>> Log:
>> [Win32k|User32]
>> - Move creation of the scrollbar Gray brush from user32 to win32k.
>> - Noticed a color and pattern (patchy white pattern) difference when  
>> using GreCreateBitmap and it did not work the same as the main  
>> function. Correcting this fixed the Gray brush. Someone from YAROTOWS  
>> needs to look into this.
>>
>> Modified:
>>      trunk/reactos/dll/win32/user32/windows/defwnd.c
>>      trunk/reactos/subsystems/win32/win32k/include/brush.h
>>      trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
>>      trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
>>      trunk/reactos/subsystems/win32/win32k/objects/brush.c
>>
>> Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
>> URL:  
>> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/defwnd.c?rev=51835&r1=51834&r2=51835&view=diff
>> ==============================================================================
>> --- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1]  
>> (original)
>> +++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Sat  
>> May 21 06:34:02 2011
>> @@ -927,8 +927,8 @@
>>   HBRUSH
>>   DefWndControlColor(HDC hDC, UINT ctlType)
>>   {
>> -  if (CTLCOLOR_SCROLLBAR == ctlType)
>> -    {
>> +  if (ctlType == CTLCOLOR_SCROLLBAR)
>> +  {
>>         HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
>>         COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
>>         SetTextColor(hDC, GetSysColor(COLOR_3DFACE));
>> @@ -938,37 +938,24 @@
>>          * we better use 0x55aa bitmap brush to make scrollbar's  
>> background
>>          * look different from the window background.
>>          */
>> -      if (bk == GetSysColor(COLOR_WINDOW))
>> -	{
>> -          static const WORD wPattern55AA[] =
>> -          {
>> -              0x5555, 0xaaaa, 0x5555, 0xaaaa,
>> -              0x5555, 0xaaaa, 0x5555, 0xaaaa
>> -          };
>> -          static HBITMAP hPattern55AABitmap = NULL;
>> -          static HBRUSH hPattern55AABrush = NULL;
>> -          if (hPattern55AABrush == NULL)
>> -            {
>> -              hPattern55AABitmap = CreateBitmap(8, 8, 1, 1,  
>> wPattern55AA);
>> -              hPattern55AABrush =  
>> CreatePatternBrush(hPattern55AABitmap);
>> -            }
>> -          return hPattern55AABrush;
>> -	}
>> -      UnrealizeObject(hb);
>> +      if ( bk == GetSysColor(COLOR_WINDOW))
>> +          return gpsi->hbrGray;
>> +
>> +      UnrealizeObject( hb );
>>         return hb;
>> -    }
>> +  }
>>
>>     SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
>>
>> -  if ((CTLCOLOR_EDIT == ctlType) || (CTLCOLOR_LISTBOX == ctlType))
>> -    {
>> +  if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
>> +  {
>>         SetBkColor(hDC, GetSysColor(COLOR_WINDOW));
>> -    }
>> +  }
>>     else
>> -    {
>> +  {
>>         SetBkColor(hDC, GetSysColor(COLOR_3DFACE));
>>         return GetSysColorBrush(COLOR_3DFACE);
>> -    }
>> +  }
>>
>>     return GetSysColorBrush(COLOR_WINDOW);
>>   }
>>
>> Modified: trunk/reactos/subsystems/win32/win32k/include/brush.h
>> URL:  
>> http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/brush.h?rev=51835&r1=51834&r2=51835&view=diff
>> ==============================================================================
>> --- trunk/reactos/subsystems/win32/win32k/include/brush.h [iso-8859-1]  
>> (original)
>> +++ trunk/reactos/subsystems/win32/win32k/include/brush.h [iso-8859-1]  
>> Sat May 21 06:34:02 2011
>> @@ -129,3 +129,5 @@
>>   VOID FASTCALL FreeObjectAttr(PVOID);
>>
>>   BOOL FASTCALL IntGdiSetBrushOwner(PBRUSH,DWORD);
>> +BOOL FASTCALL GreSetBrushOwner(HBRUSH,DWORD);
>> +
>>
>> Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
>> URL:  
>> http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c?rev=51835&r1=51834&r2=51835&view=diff
>> ==============================================================================
>> --- trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1]  
>> (original)
>> +++ trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1]  
>> Sat May 21 06:34:02 2011
>> @@ -92,6 +92,8 @@
>>     HANDLE  hPowerRequestEvent,
>>     HANDLE  hMediaRequestEvent)
>>   {
>> +    static const WORD wPattern55AA[] = { 0x5555, 0xaaaa, 0x5555,  
>> 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
>> +    HBITMAP hPattern55AABitmap = NULL;
>>       NTSTATUS Status;
>>
>>   // Set W32PF_Flags |= (W32PF_READSCREENACCESSGRANTED | W32PF_IOWINSTA)
>> @@ -125,6 +127,14 @@
>>
>>       CsrInit();
>>
>> +    if (gpsi->hbrGray == NULL)
>> +    {
>> +       hPattern55AABitmap = GreCreateBitmap(8, 8, 1, 1,  
>> (LPBYTE)wPattern55AA);
>> +       gpsi->hbrGray = IntGdiCreatePatternBrush(hPattern55AABitmap);
>> +       GreDeleteObject(hPattern55AABitmap);
>> +       GreSetBrushOwner(gpsi->hbrGray, GDI_OBJ_HMGR_PUBLIC);
>> +    }
>> +
>>       return STATUS_SUCCESS;
>>   }
>>
>>
>> Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
>> URL:  
>> http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=51835&r1=51834&r2=51835&view=diff
>> ==============================================================================
>> --- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c  
>> [iso-8859-1] (original)
>> +++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c  
>> [iso-8859-1] Sat May 21 06:34:02 2011
>> @@ -154,15 +154,23 @@
>>       IN UINT cBitsPixel,
>>       IN OPTIONAL PVOID pvBits)
>>   {
>> +    HBITMAP hbmp;
>>       /* Call the extended function */
>> -    return GreCreateBitmapEx(nWidth,
>> +    hbmp = GreCreateBitmapEx(nWidth,
>>                                nHeight,
>>                                0, /* auto width */
>>                                BitmapFormat(cBitsPixel * cPlanes,  
>> BI_RGB),
>>                                0, /* no bitmap flags */
>>                                0, /* auto size */
>> -                             pvBits,
>> -							 DDB_SURFACE /* DDB */);
>> +                             NULL,
>> +                             DDB_SURFACE /* DDB */);
>> +    if (pvBits&&  hbmp)
>> +    {
>> +       PSURFACE psurf = SURFACE_ShareLockSurface(hbmp);
>> +       UnsafeSetBitmapBits(psurf, 0, pvBits);
>> +       SURFACE_ShareUnlockSurface(psurf);
>> +    }
>> +    return hbmp;
>>   }
>>
>>   HBITMAP
>>
>> Modified: trunk/reactos/subsystems/win32/win32k/objects/brush.c
>> URL:  
>> http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/brush.c?rev=51835&r1=51834&r2=51835&view=diff
>> ==============================================================================
>> --- trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1]  
>> (original)
>> +++ trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1]  
>> Sat May 21 06:34:02 2011
>> @@ -59,6 +59,19 @@
>>       GDIOBJ_vSetObjectOwner(&pbr->BaseObject, ulOwner);
>>
>>       return TRUE;
>> +}
>> +
>> +BOOL
>> +FASTCALL
>> +GreSetBrushOwner(HBRUSH hBrush, ULONG ulOwner)
>> +{
>> +    BOOL Ret;
>> +    PBRUSH pbrush;
>> +
>> +    pbrush = BRUSH_ShareLockBrush(hBrush);
>> +    Ret = IntGdiSetBrushOwner(pbrush, ulOwner);
>> +    BRUSH_ShareUnlockBrush(pbrush);
>> +    return Ret;
>>   }
>>
>>   BOOL
>>
>>
>>
>
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/



More information about the Ros-dev mailing list