Module: wine Branch: master Commit: 1a5bfe13077dd6af85c939902de55263b6191e11 URL: https://gitlab.winehq.org/wine/wine/-/commit/1a5bfe13077dd6af85c939902de5526...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Nov 18 09:18:50 2022 +0100
winex11: Add a debug helper to print color values.
---
dlls/winex11.drv/brush.c | 4 ++-- dlls/winex11.drv/graphics.c | 2 +- dlls/winex11.drv/palette.c | 14 +++++++------- dlls/winex11.drv/x11drv.h | 10 ++++++++++ 4 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/dlls/winex11.drv/brush.c b/dlls/winex11.drv/brush.c index 2a2e8ef4e98..9ecb5ec5eda 100644 --- a/dlls/winex11.drv/brush.c +++ b/dlls/winex11.drv/brush.c @@ -170,11 +170,11 @@ static Pixmap BRUSH_DitherMono( COLORREF color ) static const char gray_dither[][2] = {{ 0x1, 0x0 }, /* DKGRAY */ { 0x2, 0x1 }, /* GRAY */ { 0x1, 0x3 }, /* LTGRAY */ - }; + }; int gray = (30 * GetRValue(color) + 59 * GetGValue(color) + 11 * GetBValue(color)) / 100; int idx = gray * (ARRAY_SIZE( gray_dither ) + 1)/256 - 1;
- TRACE("color=%06x -> gray=%x\n", color, gray); + TRACE("color=%s -> gray=%x\n", debugstr_color(color), gray); return XCreateBitmapFromData( gdi_display, root_window, gray_dither[idx], 2, 2 ); }
diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c index 22e1987b9fa..7adb79e181d 100644 --- a/dlls/winex11.drv/graphics.c +++ b/dlls/winex11.drv/graphics.c @@ -1445,7 +1445,7 @@ BOOL CDECL X11DRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT RECT rect, bounds; POINT pt;
- TRACE("X11DRV_ExtFloodFill %d,%d %06x %d\n", x, y, color, fillType ); + TRACE("X11DRV_ExtFloodFill %d,%d %s %d\n", x, y, debugstr_color(color), fillType );
pt.x = x; pt.y = y; diff --git a/dlls/winex11.drv/palette.c b/dlls/winex11.drv/palette.c index 7845985dbb0..0fb6c1cb90b 100644 --- a/dlls/winex11.drv/palette.c +++ b/dlls/winex11.drv/palette.c @@ -508,7 +508,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template
sysPixel[i] = color.pixel;
- TRACE("syscolor(%x) -> pixel %i\n", *(const COLORREF*)(sys_pal_template+i), + TRACE("syscolor %s -> pixel %i\n", debugstr_color(*(const COLORREF *)(sys_pal_template+i)), (int)color.pixel);
/* Set EGA mapping if color in the first or last eight */ @@ -932,7 +932,7 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
if (!get_palette_entries( hPal, idx, 1, &entry )) { - WARN("PALETTEINDEX(%x) : idx %d is out of bounds, assuming black\n", color, idx); + WARN("%s: out of bounds, assuming black\n", debugstr_color(color)); return 0; } if (mapping) return mapping[idx]; @@ -990,7 +990,7 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color ) { index = LOWORD( color ); if (!get_palette_entries( hPal, index, 1, &entry )) - WARN("PALETTEINDEX(%x) : index %i is out of bounds\n", color, index); + WARN("%s: out of bounds\n", debugstr_color(color)); else if (mapping) index = mapping[index]; } else if (color >> 24 == 2) /* PALETTERGB */ @@ -1287,7 +1287,7 @@ UINT CDECL X11DRV_RealizePalette( PHYSDEV dev, HPALETTE hpal, BOOL primary ) if( !prev_mapping || mapping[i] != index ) iRemapped++; mapping[i] = index;
- TRACE("entry %i (%x) -> pixel %i\n", i, *(COLORREF*)&entries[i], index); + TRACE("entry %i %s -> pixel %i\n", i, debugstr_color(*(COLORREF *)&entries[i]), index);
} pthread_mutex_unlock( &palette_mutex ); @@ -1334,7 +1334,7 @@ UINT CDECL X11DRV_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, entries[i].peGreen = COLOR_sysPal[start + i].peGreen; entries[i].peBlue = COLOR_sysPal[start + i].peBlue; entries[i].peFlags = 0; - TRACE("\tidx(%02x) -> RGB(%08x)\n", start + i, *(COLORREF*)(entries + i) ); + TRACE("\tidx(%02x) -> %s\n", start + i, debugstr_color(*(COLORREF *)(entries + i)) ); } pthread_mutex_unlock( &palette_mutex ); return count; @@ -1368,7 +1368,7 @@ COLORREF CDECL X11DRV_GetNearestColor( PHYSDEV dev, COLORREF color )
if (!get_palette_entries( hpal, index, 1, &entry )) { - WARN("RGB(%x) : idx %d is out of bounds, assuming NULL\n", color, index ); + WARN("%s: idx %d is out of bounds, assuming NULL\n", debugstr_color(color), index ); if (!get_palette_entries( hpal, 0, 1, &entry )) return CLR_INVALID; } color = RGB( entry.peRed, entry.peGreen, entry.peBlue ); @@ -1378,7 +1378,7 @@ COLORREF CDECL X11DRV_GetNearestColor( PHYSDEV dev, COLORREF color ) nearest = (0x00ffffff & *(COLORREF*)(COLOR_sysPal + X11DRV_SysPaletteLookupPixel(color, FALSE))); pthread_mutex_unlock( &palette_mutex );
- TRACE("(%06x): returning %06x\n", color, nearest ); + TRACE("(%s): returning %s\n", debugstr_color(color), debugstr_color(nearest) ); return nearest; }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a424eb112e8..d51df30c2d0 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -66,6 +66,7 @@ typedef int Status; #include "wine/gdi_driver.h" #include "unixlib.h" #include "wine/list.h" +#include "wine/debug.h"
#define MAX_DASHLEN 16
@@ -322,6 +323,15 @@ extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE *physDev, COLORREF color) DE extern COLORREF X11DRV_PALETTE_GetColor( X11DRV_PDEVICE *physDev, COLORREF color ) DECLSPEC_HIDDEN; extern int *get_window_surface_mapping( int bpp, int *mapping ) DECLSPEC_HIDDEN;
+static inline const char *debugstr_color( COLORREF color ) +{ + if (color & (1 << 24)) /* PALETTEINDEX */ + return wine_dbg_sprintf( "PALETTEINDEX(%u)", LOWORD(color) ); + if (color >> 16 == 0x10ff) /* DIBINDEX */ + return wine_dbg_sprintf( "DIBINDEX(%u)", LOWORD(color) ); + return wine_dbg_sprintf( "RGB(%02x,%02x,%02x)", GetRValue(color), GetGValue(color), GetBValue(color) ); +} + /* GDI escapes */
#define X11DRV_ESCAPE 6789