Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c123c2f8
Commit
c123c2f8
authored
Jan 10, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winex11: Fix support for PALETTEINDEX mapping and get rid of DIBINDEX support.
parent
b88b6b74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
105 deletions
+61
-105
palette.c
dlls/winex11.drv/palette.c
+61
-105
No files found.
dlls/winex11.drv/palette.c
View file @
c123c2f8
...
...
@@ -882,39 +882,26 @@ static inline BOOL colour_is_brighter(RGBQUAD c1, RGBQUAD c2)
COLORREF
X11DRV_PALETTE_GetColor
(
X11DRV_PDEVICE
*
physDev
,
COLORREF
color
)
{
HPALETTE
hPal
=
GetCurrentObject
(
physDev
->
dev
.
hdc
,
OBJ_PAL
);
unsigned
char
spec_type
=
color
>>
24
;
unsigned
idx
=
color
&
0xffff
;
PALETTEENTRY
entry
;
RGBQUAD
quad
;
switch
(
spec_type
)
if
(
color
&
(
1
<<
24
))
/* PALETTEINDEX */
{
case
2
:
/* PALETTERGB */
idx
=
GetNearestPaletteIndex
(
hPal
,
color
);
/* fall through to PALETTEINDEX */
case
1
:
/* PALETTEINDEX */
if
(
!
GetPaletteEntries
(
hPal
,
idx
,
1
,
&
entry
))
{
WARN
(
"PALETTEINDEX(%x) : idx %d is out of bounds, assuming black
\n
"
,
color
,
idx
);
return
0
;
}
unsigned
int
idx
=
LOWORD
(
color
);
if
(
!
GetPaletteEntries
(
hPal
,
idx
,
1
,
&
entry
))
return
0
;
return
RGB
(
entry
.
peRed
,
entry
.
peGreen
,
entry
.
peBlue
);
}
case
0x10
:
/* DIBINDEX
*/
if
(
GetDIBColorTable
(
physDev
->
dev
.
hdc
,
idx
,
1
,
&
quad
)
!=
1
)
{
WARN
(
"DIBINDEX(%x) : idx %d is out of bounds, assuming black
\n
"
,
color
,
idx
);
return
0
;
}
return
RGB
(
quad
.
rgbRed
,
quad
.
rgbGreen
,
quad
.
rgbBlue
);
if
(
color
>>
24
==
2
)
/* PALETTERGB
*/
{
unsigned
int
idx
=
GetNearestPaletteIndex
(
hPal
,
color
&
0xffffff
);
if
(
!
GetPaletteEntries
(
hPal
,
idx
,
1
,
&
entry
))
return
0
;
return
RGB
(
entry
.
peRed
,
entry
.
peGreen
,
entry
.
peBlue
);
}
default:
color
&=
0xffffff
;
/* fall through to RGB */
if
(
color
>>
16
==
0x10ff
)
/* DIBINDEX */
return
0
;
case
0
:
/* RGB */
return
color
;
}
return
color
&
0xffffff
;
}
/***********************************************************************
...
...
@@ -926,7 +913,6 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
{
WORD
index
=
0
;
HPALETTE
hPal
=
GetCurrentObject
(
physDev
->
dev
.
hdc
,
OBJ_PAL
);
unsigned
char
spec_type
=
color
>>
24
;
int
*
mapping
=
palette_get_mapping
(
hPal
);
PALETTEENTRY
entry
;
ColorShifts
*
shifts
=
&
X11DRV_PALETTE_default_shifts
;
...
...
@@ -939,47 +925,35 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
/* there is no colormap limitation; we are going to have to compute
* the pixel value from the visual information stored earlier
*/
unsigned
long
red
,
green
,
blue
;
unsigned
long
red
,
green
,
blue
;
unsigned
idx
=
color
&
0xffff
;
switch
(
spec_type
)
if
(
color
&
(
1
<<
24
))
/* PALETTEINDEX */
{
case
0x10
:
/* DIBINDEX */
color
=
X11DRV_PALETTE_GetColor
(
physDev
,
color
);
break
;
case
1
:
/* PALETTEINDEX */
unsigned
int
idx
=
LOWORD
(
color
);
if
(
!
GetPaletteEntries
(
hPal
,
idx
,
1
,
&
entry
))
{
WARN
(
"PALETTEINDEX(%x) : idx %d is out of bounds, assuming black
\n
"
,
color
,
idx
);
return
0
;
}
if
(
mapping
)
return
mapping
[
idx
];
color
=
RGB
(
entry
.
peRed
,
entry
.
peGreen
,
entry
.
peBlue
);
break
;
default:
color
&=
0xffffff
;
/* fall through to RGB */
case
0
:
/* RGB */
if
(
physDev
->
depth
==
1
)
{
int
white
=
1
;
RGBQUAD
table
[
2
];
if
(
GetDIBColorTable
(
physDev
->
dev
.
hdc
,
0
,
2
,
table
)
==
2
)
{
if
(
!
colour_is_brighter
(
table
[
1
],
table
[
0
]))
white
=
0
;
}
return
(((
color
>>
16
)
&
0xff
)
+
((
color
>>
8
)
&
0xff
)
+
(
color
&
0xff
)
>
255
*
3
/
2
)
?
white
:
1
-
white
;
}
}
red
=
GetRValue
(
color
);
green
=
GetGValue
(
color
);
blue
=
GetBValue
(
color
);
red
=
entry
.
peRed
;
green
=
entry
.
peGreen
;
blue
=
entry
.
peBlue
;
}
else
if
(
color
>>
16
==
0x10ff
)
/* DIBINDEX */
{
return
0
;
}
else
/* RGB */
{
if
(
physDev
->
depth
==
1
)
return
(((
color
>>
16
)
&
0xff
)
+
((
color
>>
8
)
&
0xff
)
+
(
color
&
0xff
)
>
255
*
3
/
2
)
?
1
:
0
;
red
=
GetRValue
(
color
);
green
=
GetGValue
(
color
);
blue
=
GetBValue
(
color
);
}
if
(
X11DRV_PALETTE_Graymax
)
{
...
...
@@ -1013,51 +987,33 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
if
(
!
mapping
)
WARN
(
"Palette %p is not realized
\n
"
,
hPal
);
switch
(
spec_type
)
/* we have to peruse DC and system palette */
{
default:
color
&=
0xffffff
;
/* fall through to RGB */
case
0
:
/* RGB */
if
(
physDev
->
depth
==
1
)
{
int
white
=
1
;
RGBQUAD
table
[
2
];
if
(
GetDIBColorTable
(
physDev
->
dev
.
hdc
,
0
,
2
,
table
)
==
2
)
{
if
(
!
colour_is_brighter
(
table
[
1
],
table
[
0
]))
white
=
0
;
}
return
(((
color
>>
16
)
&
0xff
)
+
((
color
>>
8
)
&
0xff
)
+
(
color
&
0xff
)
>
255
*
3
/
2
)
?
white
:
1
-
white
;
}
EnterCriticalSection
(
&
palette_cs
);
index
=
X11DRV_SysPaletteLookupPixel
(
color
,
FALSE
);
if
(
X11DRV_PALETTE_PaletteToXPixel
)
index
=
X11DRV_PALETTE_PaletteToXPixel
[
index
];
LeaveCriticalSection
(
&
palette_cs
);
/* TRACE(palette,"RGB(%lx) -> pixel %i\n", color, index);
*/
break
;
case
1
:
/* PALETTEINDEX */
index
=
color
&
0xffff
;
if
(
!
GetPaletteEntries
(
hPal
,
index
,
1
,
&
entry
))
WARN
(
"PALETTEINDEX(%x) : index %i is out of bounds
\n
"
,
color
,
index
);
else
if
(
mapping
)
index
=
mapping
[
index
];
/* TRACE(palette,"PALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);
*/
break
;
case
2
:
/* PALETTERGB */
index
=
GetNearestPaletteIndex
(
hPal
,
color
);
if
(
mapping
)
index
=
mapping
[
index
];
/* TRACE(palette,"PALETTERGB(%lx) -> pixel %i\n", color, index);
*/
break
;
}
if
(
color
&
(
1
<<
24
))
/* PALETTEINDEX */
{
index
=
LOWORD
(
color
);
if
(
!
GetPaletteEntries
(
hPal
,
index
,
1
,
&
entry
))
WARN
(
"PALETTEINDEX(%x) : index %i is out of bounds
\n
"
,
color
,
index
);
else
if
(
mapping
)
index
=
mapping
[
index
];
}
else
if
(
color
>>
24
==
2
)
/* PALETTERGB */
{
index
=
GetNearestPaletteIndex
(
hPal
,
color
);
if
(
mapping
)
index
=
mapping
[
index
];
}
else
if
(
color
>>
16
==
0x10ff
)
/* DIBINDEX */
{
return
0
;
}
else
/* RGB */
{
if
(
physDev
->
depth
==
1
)
return
(((
color
>>
16
)
&
0xff
)
+
((
color
>>
8
)
&
0xff
)
+
(
color
&
0xff
)
>
255
*
3
/
2
)
?
1
:
0
;
EnterCriticalSection
(
&
palette_cs
);
index
=
X11DRV_SysPaletteLookupPixel
(
color
&
0xffffff
,
FALSE
);
if
(
X11DRV_PALETTE_PaletteToXPixel
)
index
=
X11DRV_PALETTE_PaletteToXPixel
[
index
];
LeaveCriticalSection
(
&
palette_cs
);
}
}
return
index
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment