Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sam Joan Roque-Worcel
wine
Commits
6add87e6
Commit
6add87e6
authored
23 years ago
by
Francois Gouget
Committed by
Alexandre Julliard
23 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Handle more than 8 bits per color component.
parent
de02bdf3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
graphics/x11drv/palette.c
+77
-41
77 additions, 41 deletions
graphics/x11drv/palette.c
with
77 additions
and
41 deletions
graphics/x11drv/palette.c
+
77
−
41
View file @
6add87e6
...
...
@@ -50,16 +50,20 @@ extern const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS];
Colormap
X11DRV_PALETTE_PaletteXColormap
=
0
;
UINT16
X11DRV_PALETTE_PaletteFlags
=
0
;
static
int
X11DRV_PALETTE_Redshift
=
0
;
/* to handle abortive X11DRV_PALETTE_VIRTUAL visuals */
static
int
X11DRV_PALETTE_Redscale
=
0
;
static
int
X11DRV_PALETTE_Redmax
=
0
;
static
int
X11DRV_PALETTE_Greenshift
=
0
;
static
int
X11DRV_PALETTE_Greenscale
=
0
;
static
int
X11DRV_PALETTE_Greenmax
=
0
;
static
int
X11DRV_PALETTE_Blueshift
=
0
;
static
int
X11DRV_PALETTE_Bluescale
=
0
;
static
int
X11DRV_PALETTE_Bluemax
=
0
;
static
int
X11DRV_PALETTE_Graymax
=
0
;
typedef
struct
{
int
shift
;
int
scale
;
int
max
;
}
ColorShifts
;
/* initialize to zero to handle abortive X11DRV_PALETTE_VIRTUAL visuals */
static
ColorShifts
X11DRV_PALETTE_PRed
=
{
0
,
0
,
0
};
static
ColorShifts
X11DRV_PALETTE_LRed
=
{
0
,
0
,
0
};
static
ColorShifts
X11DRV_PALETTE_PGreen
=
{
0
,
0
,
0
};
static
ColorShifts
X11DRV_PALETTE_LGreen
=
{
0
,
0
,
0
};
static
ColorShifts
X11DRV_PALETTE_PBlue
=
{
0
,
0
,
0
};
static
ColorShifts
X11DRV_PALETTE_LBlue
=
{
0
,
0
,
0
};
static
int
X11DRV_PALETTE_Graymax
=
0
;
static
int
palette_size
;
...
...
@@ -87,7 +91,7 @@ int *X11DRV_PALETTE_XPixelToPalette = NULL;
static
BOOL
X11DRV_PALETTE_BuildPrivateMap
(
void
);
static
BOOL
X11DRV_PALETTE_BuildSharedMap
(
void
);
static
void
X11DRV_PALETTE_ComputeShifts
(
unsigned
long
maskbits
,
int
*
shift
,
int
*
max
,
int
*
s
cal
e
);
static
void
X11DRV_PALETTE_ComputeShifts
(
unsigned
long
maskbits
,
ColorShifts
*
physical
,
ColorShifts
*
to_logi
cal
);
static
void
X11DRV_PALETTE_FillDefaultColors
(
void
);
static
void
X11DRV_PALETTE_FormatSystemPalette
(
void
);
static
BOOL
X11DRV_PALETTE_CheckSysColor
(
COLORREF
c
);
...
...
@@ -191,10 +195,10 @@ int X11DRV_PALETTE_Init(void)
X11DRV_PALETTE_PaletteXColormap
=
TSXCreateColormap
(
gdi_display
,
root_window
,
visual
,
AllocNone
);
X11DRV_PALETTE_PaletteFlags
|=
X11DRV_PALETTE_FIXED
;
X11DRV_PALETTE_ComputeShifts
(
visual
->
red_mask
,
&
X11DRV_PALETTE_Red
shift
,
&
X11DRV_PALETTE_Redmax
,
&
X11DRV_PALETTE_Red
scale
);
X11DRV_PALETTE_ComputeShifts
(
visual
->
green_mask
,
&
X11DRV_PALETTE_
Greenshift
,
&
X11DRV_PALETTE_
Green
max
,
&
X11DRV_PALETTE_Green
scale
);
X11DRV_PALETTE_ComputeShifts
(
visual
->
blue_mask
,
&
X11DRV_PALETTE_Blue
shift
,
&
X11DRV_PALETTE_Blu
emax
,
&
X11DRV_PALETTE_Bluescal
e
);
break
;
X11DRV_PALETTE_ComputeShifts
(
visual
->
red_mask
,
&
X11DRV_PALETTE_
P
Red
,
&
X11DRV_PALETTE_
L
Red
);
X11DRV_PALETTE_ComputeShifts
(
visual
->
green_mask
,
&
X11DRV_PALETTE_
P
Green
,
&
X11DRV_PALETTE_
L
Green
);
X11DRV_PALETTE_ComputeShifts
(
visual
->
blue_mask
,
&
X11DRV_PALETTE_
P
Blue
,
&
X11DRV_PALETTE_
L
Blue
);
break
;
}
}
...
...
@@ -240,26 +244,45 @@ void X11DRV_PALETTE_Cleanup(void)
*
* Calculate conversion parameters for direct mapped visuals
*/
static
void
X11DRV_PALETTE_ComputeShifts
(
unsigned
long
maskbits
,
int
*
shift
,
int
*
max
,
int
*
s
cal
e
)
static
void
X11DRV_PALETTE_ComputeShifts
(
unsigned
long
maskbits
,
ColorShifts
*
physical
,
ColorShifts
*
to_logi
cal
)
{
int
i
;
if
(
maskbits
==
0
)
{
*
shift
=
0
;
*
max
=
0
;
physical
->
shift
=
0
;
physical
->
scale
=
0
;
physical
->
max
=
0
;
to_logical
->
shift
=
0
;
to_logical
->
scale
=
0
;
to_logical
->
max
=
0
;
return
;
}
for
(
i
=
0
;
!
(
maskbits
&
1
);
i
++
)
maskbits
>>=
1
;
*
shift
=
i
;
*
max
=
maskbits
;
physical
->
shift
=
i
;
physical
->
max
=
maskbits
;
for
(
i
=
0
;
maskbits
!=
0
;
i
++
)
maskbits
>>=
1
;
*
scale
=
i
;
physical
->
scale
=
i
;
if
(
physical
->
scale
>
8
)
{
/* On FreeBSD, VNC's default 32bpp mode is bgrabb (ffc00000,3ff800,7ff)!
* So we adjust the shifts to also normalize the color fields to
* the Win32 standard of 8 bits per color.
*/
to_logical
->
shift
=
physical
->
shift
+
(
physical
->
scale
-
8
);
to_logical
->
scale
=
8
;
to_logical
->
max
=
0xff
;
}
else
{
to_logical
->
shift
=
physical
->
shift
;
to_logical
->
scale
=
physical
->
scale
;
to_logical
->
max
=
physical
->
max
;
}
}
/***********************************************************************
...
...
@@ -625,11 +648,11 @@ static void X11DRV_PALETTE_FillDefaultColors(void)
if
(
X11DRV_PALETTE_PaletteFlags
&
X11DRV_PALETTE_VIRTUAL
)
{
if
(
X11DRV_PALETTE_Redmax
!=
255
)
no_r
=
(
red
*
X11DRV_PALETTE_Redmax
)
/
255
;
if
(
X11DRV_PALETTE_Greenmax
!=
255
)
no_g
=
(
green
*
X11DRV_PALETTE_Greenmax
)
/
255
;
if
(
X11DRV_PALETTE_Bluemax
!=
255
)
no_b
=
(
blue
*
X11DRV_PALETTE_Bluemax
)
/
255
;
if
(
X11DRV_PALETTE_
P
Red
.
max
!=
255
)
no_r
=
(
red
*
X11DRV_PALETTE_
P
Red
.
max
)
/
255
;
if
(
X11DRV_PALETTE_
P
Green
.
max
!=
255
)
no_g
=
(
green
*
X11DRV_PALETTE_
P
Green
.
max
)
/
255
;
if
(
X11DRV_PALETTE_
P
Blue
.
max
!=
255
)
no_b
=
(
blue
*
X11DRV_PALETTE_
P
Blue
.
max
)
/
255
;
X11DRV_PALETTE_PaletteToXPixel
[
idx
]
=
(
no_r
<<
X11DRV_PALETTE_Redshift
)
|
(
no_g
<<
X11DRV_PALETTE_Greenshift
)
|
(
no_b
<<
X11DRV_PALETTE_Blueshift
);
X11DRV_PALETTE_PaletteToXPixel
[
idx
]
=
(
no_r
<<
X11DRV_PALETTE_
P
Red
.
shift
)
|
(
no_g
<<
X11DRV_PALETTE_
P
Green
.
shift
)
|
(
no_b
<<
X11DRV_PALETTE_
P
Blue
.
shift
);
}
else
if
(
!
(
X11DRV_PALETTE_PaletteFlags
&
X11DRV_PALETTE_FIXED
)
)
{
...
...
@@ -696,15 +719,19 @@ COLORREF X11DRV_PALETTE_ToLogical(int pixel)
if
(
(
X11DRV_PALETTE_PaletteFlags
&
X11DRV_PALETTE_FIXED
)
&&
!
X11DRV_PALETTE_Graymax
)
{
color
.
red
=
(
pixel
>>
X11DRV_PALETTE_Redshift
)
&
X11DRV_PALETTE_Redmax
;
color
.
green
=
(
pixel
>>
X11DRV_PALETTE_Greenshift
)
&
X11DRV_PALETTE_Greenmax
;
color
.
blue
=
(
pixel
>>
X11DRV_PALETTE_Blueshift
)
&
X11DRV_PALETTE_Bluemax
;
return
RGB
(
color
.
red
<<
(
8
-
X11DRV_PALETTE_Redscale
)
|
color
.
red
>>
(
2
*
X11DRV_PALETTE_Redscale
-
8
),
color
.
green
<<
(
8
-
X11DRV_PALETTE_Greenscale
)
|
color
.
green
>>
(
2
*
X11DRV_PALETTE_Greenscale
-
8
),
color
.
blue
<<
(
8
-
X11DRV_PALETTE_Bluescale
)
|
color
.
blue
>>
(
2
*
X11DRV_PALETTE_Bluescale
-
8
));
color
.
red
=
(
pixel
>>
X11DRV_PALETTE_LRed
.
shift
)
&
X11DRV_PALETTE_LRed
.
max
;
if
(
X11DRV_PALETTE_LRed
.
scale
<
8
)
color
.
red
=
color
.
red
<<
(
8
-
X11DRV_PALETTE_LRed
.
scale
)
|
color
.
red
>>
(
2
*
X11DRV_PALETTE_LRed
.
scale
-
8
);
color
.
green
=
(
pixel
>>
X11DRV_PALETTE_LGreen
.
shift
)
&
X11DRV_PALETTE_LGreen
.
max
;
if
(
X11DRV_PALETTE_LGreen
.
scale
<
8
)
color
.
green
=
color
.
green
<<
(
8
-
X11DRV_PALETTE_LGreen
.
scale
)
|
color
.
green
>>
(
2
*
X11DRV_PALETTE_LGreen
.
scale
-
8
);
color
.
blue
=
(
pixel
>>
X11DRV_PALETTE_LBlue
.
shift
)
&
X11DRV_PALETTE_LBlue
.
max
;
if
(
X11DRV_PALETTE_LBlue
.
scale
<
8
)
color
.
blue
=
color
.
blue
<<
(
8
-
X11DRV_PALETTE_LBlue
.
scale
)
|
color
.
blue
>>
(
2
*
X11DRV_PALETTE_LBlue
.
scale
-
8
);
return
RGB
(
color
.
red
,
color
.
green
,
color
.
blue
);
}
/* check if we can bypass X */
...
...
@@ -789,15 +816,24 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
else
{
/* scale each individually and construct the TrueColor pixel value */
if
(
X11DRV_PALETTE_Redscale
!=
8
)
red
=
red
>>
(
8
-
X11DRV_PALETTE_Redscale
);
if
(
X11DRV_PALETTE_Greenscale
!=
8
)
green
=
green
>>
(
8
-
X11DRV_PALETTE_Greenscale
);
if
(
X11DRV_PALETTE_Bluescale
!=
8
)
blue
=
blue
>>
(
8
-
X11DRV_PALETTE_Bluescale
);
if
(
X11DRV_PALETTE_PRed
.
scale
<
8
)
red
=
red
>>
(
8
-
X11DRV_PALETTE_PRed
.
scale
);
else
if
(
X11DRV_PALETTE_PRed
.
scale
>
8
)
red
=
red
<<
(
X11DRV_PALETTE_PRed
.
scale
-
8
)
|
red
>>
(
16
-
X11DRV_PALETTE_PRed
.
scale
);
if
(
X11DRV_PALETTE_PGreen
.
scale
<
8
)
green
=
green
>>
(
8
-
X11DRV_PALETTE_PGreen
.
scale
);
else
if
(
X11DRV_PALETTE_PGreen
.
scale
>
8
)
green
=
green
<<
(
X11DRV_PALETTE_PGreen
.
scale
-
8
)
|
green
>>
(
16
-
X11DRV_PALETTE_PGreen
.
scale
);
if
(
X11DRV_PALETTE_PBlue
.
scale
<
8
)
blue
=
blue
>>
(
8
-
X11DRV_PALETTE_PBlue
.
scale
);
else
if
(
X11DRV_PALETTE_PBlue
.
scale
>
8
)
blue
=
blue
<<
(
X11DRV_PALETTE_PBlue
.
scale
-
8
)
|
blue
>>
(
16
-
X11DRV_PALETTE_PBlue
.
scale
);
GDI_ReleaseObj
(
hPal
);
return
(
red
<<
X11DRV_PALETTE_Redshift
)
|
(
green
<<
X11DRV_PALETTE_Greenshift
)
|
(
blue
<<
X11DRV_PALETTE_Blueshift
);
return
(
red
<<
X11DRV_PALETTE_
P
Red
.
shift
)
|
(
green
<<
X11DRV_PALETTE_
P
Green
.
shift
)
|
(
blue
<<
X11DRV_PALETTE_
P
Blue
.
shift
);
}
}
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment