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
1558391a
Commit
1558391a
authored
May 07, 2014
by
Stefan Dösinger
Committed by
Alexandre Julliard
May 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Store RGBQUADs in palettes.
parent
19f45af1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
75 deletions
+52
-75
palette.c
dlls/wined3d/palette.c
+26
-12
surface.c
dlls/wined3d/surface.c
+20
-57
utils.c
dlls/wined3d/utils.c
+5
-5
wined3d_private.h
dlls/wined3d/wined3d_private.h
+1
-1
No files found.
dlls/wined3d/palette.c
View file @
1558391a
...
...
@@ -53,6 +53,7 @@ ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette)
HRESULT
CDECL
wined3d_palette_get_entries
(
const
struct
wined3d_palette
*
palette
,
DWORD
flags
,
DWORD
start
,
DWORD
count
,
PALETTEENTRY
*
entries
)
{
unsigned
int
i
;
TRACE
(
"palette %p, flags %#x, start %u, count %u, entries %p.
\n
"
,
palette
,
flags
,
start
,
count
,
entries
);
...
...
@@ -64,13 +65,20 @@ HRESULT CDECL wined3d_palette_get_entries(const struct wined3d_palette *palette,
if
(
palette
->
flags
&
WINED3D_PALETTE_8BIT_ENTRIES
)
{
BYTE
*
entry
=
(
BYTE
*
)
entries
;
unsigned
int
i
;
for
(
i
=
start
;
i
<
count
+
start
;
++
i
)
*
entry
++
=
palette
->
palents
[
i
].
pe
Red
;
*
entry
++
=
palette
->
colors
[
i
].
rgb
Red
;
}
else
memcpy
(
entries
,
palette
->
palents
+
start
,
count
*
sizeof
(
*
entries
));
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
entries
[
i
].
peRed
=
palette
->
colors
[
i
+
start
].
rgbRed
;
entries
[
i
].
peGreen
=
palette
->
colors
[
i
+
start
].
rgbGreen
;
entries
[
i
].
peBlue
=
palette
->
colors
[
i
+
start
].
rgbBlue
;
entries
[
i
].
peFlags
=
palette
->
colors
[
i
+
start
].
rgbReserved
;
}
}
return
WINED3D_OK
;
}
...
...
@@ -79,6 +87,7 @@ HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette,
DWORD
flags
,
DWORD
start
,
DWORD
count
,
const
PALETTEENTRY
*
entries
)
{
struct
wined3d_resource
*
resource
;
unsigned
int
i
;
TRACE
(
"palette %p, flags %#x, start %u, count %u, entries %p.
\n
"
,
palette
,
flags
,
start
,
count
,
entries
);
...
...
@@ -87,26 +96,31 @@ HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette,
if
(
palette
->
flags
&
WINED3D_PALETTE_8BIT_ENTRIES
)
{
const
BYTE
*
entry
=
(
const
BYTE
*
)
entries
;
unsigned
int
i
;
for
(
i
=
start
;
i
<
count
+
start
;
++
i
)
palette
->
palents
[
i
].
pe
Red
=
*
entry
++
;
palette
->
colors
[
i
].
rgb
Red
=
*
entry
++
;
}
else
{
memcpy
(
palette
->
palents
+
start
,
entries
,
count
*
sizeof
(
*
palette
->
palents
));
for
(
i
=
0
;
i
<
count
;
++
i
)
{
palette
->
colors
[
i
+
start
].
rgbRed
=
entries
[
i
].
peRed
;
palette
->
colors
[
i
+
start
].
rgbGreen
=
entries
[
i
].
peGreen
;
palette
->
colors
[
i
+
start
].
rgbBlue
=
entries
[
i
].
peBlue
;
palette
->
colors
[
i
+
start
].
rgbReserved
=
entries
[
i
].
peFlags
;
}
/* When WINEDDCAPS_ALLOW256 isn't set we need to override entry 0 with black and 255 with white */
if
(
!
(
palette
->
flags
&
WINED3D_PALETTE_ALLOW_256
))
{
TRACE
(
"WINED3D_PALETTE_ALLOW_256 not set, overriding palette entry 0 with black and 255 with white.
\n
"
);
palette
->
palents
[
0
].
pe
Red
=
0
;
palette
->
palents
[
0
].
pe
Green
=
0
;
palette
->
palents
[
0
].
pe
Blue
=
0
;
palette
->
colors
[
0
].
rgb
Red
=
0
;
palette
->
colors
[
0
].
rgb
Green
=
0
;
palette
->
colors
[
0
].
rgb
Blue
=
0
;
palette
->
palents
[
255
].
pe
Red
=
255
;
palette
->
palents
[
255
].
pe
Green
=
255
;
palette
->
palents
[
255
].
pe
Blue
=
255
;
palette
->
colors
[
255
].
rgb
Red
=
255
;
palette
->
colors
[
255
].
rgb
Green
=
255
;
palette
->
colors
[
255
].
rgb
Blue
=
255
;
}
}
...
...
dlls/wined3d/surface.c
View file @
1558391a
...
...
@@ -789,19 +789,8 @@ static void surface_realize_palette(struct wined3d_surface *surface)
if
(
surface
->
flags
&
SFLAG_DIBSECTION
)
{
RGBQUAD
col
[
256
];
unsigned
int
i
;
TRACE
(
"Updating the DC's palette.
\n
"
);
for
(
i
=
0
;
i
<
256
;
++
i
)
{
col
[
i
].
rgbRed
=
palette
->
palents
[
i
].
peRed
;
col
[
i
].
rgbGreen
=
palette
->
palents
[
i
].
peGreen
;
col
[
i
].
rgbBlue
=
palette
->
palents
[
i
].
peBlue
;
col
[
i
].
rgbReserved
=
0
;
}
SetDIBColorTable
(
surface
->
hDC
,
0
,
256
,
col
);
SetDIBColorTable
(
surface
->
hDC
,
0
,
256
,
palette
->
colors
);
}
/* Propagate the changes to the drawable when we have a palette. */
...
...
@@ -1122,9 +1111,9 @@ static BOOL surface_convert_color_to_float(const struct wined3d_surface *surface
case
WINED3DFMT_P8_UINT
:
if
(
surface
->
palette
)
{
float_color
->
r
=
surface
->
palette
->
palents
[
color
].
pe
Red
/
255
.
0
f
;
float_color
->
g
=
surface
->
palette
->
palents
[
color
].
pe
Green
/
255
.
0
f
;
float_color
->
b
=
surface
->
palette
->
palents
[
color
].
pe
Blue
/
255
.
0
f
;
float_color
->
r
=
surface
->
palette
->
colors
[
color
].
rgb
Red
/
255
.
0
f
;
float_color
->
g
=
surface
->
palette
->
colors
[
color
].
rgb
Green
/
255
.
0
f
;
float_color
->
b
=
surface
->
palette
->
colors
[
color
].
rgb
Blue
/
255
.
0
f
;
}
else
{
...
...
@@ -1393,19 +1382,8 @@ static void gdi_surface_realize_palette(struct wined3d_surface *surface)
if
(
surface
->
flags
&
SFLAG_DIBSECTION
)
{
RGBQUAD
col
[
256
];
unsigned
int
i
;
TRACE
(
"Updating the DC's palette.
\n
"
);
for
(
i
=
0
;
i
<
256
;
++
i
)
{
col
[
i
].
rgbRed
=
palette
->
palents
[
i
].
peRed
;
col
[
i
].
rgbGreen
=
palette
->
palents
[
i
].
peGreen
;
col
[
i
].
rgbBlue
=
palette
->
palents
[
i
].
peBlue
;
col
[
i
].
rgbReserved
=
0
;
}
SetDIBColorTable
(
surface
->
hDC
,
0
,
256
,
col
);
SetDIBColorTable
(
surface
->
hDC
,
0
,
256
,
palette
->
colors
);
}
/* Update the image because of the palette change. Some games like e.g.
...
...
@@ -3177,11 +3155,11 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
/* GetDC on palettized formats is unsupported in D3D9, and the method
* is missing in D3D8, so this should only be used for DX <=7
* surfaces (with non-device palettes). */
const
PALETTEENTRY
*
pal
=
NULL
;
const
RGBQUAD
*
colors
=
NULL
;
if
(
surface
->
palette
)
{
pal
=
surface
->
palette
->
palent
s
;
colors
=
surface
->
palette
->
color
s
;
}
else
{
...
...
@@ -3189,23 +3167,11 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
struct
wined3d_surface
*
dds_primary
=
swapchain
->
front_buffer
;
if
(
dds_primary
&&
dds_primary
->
palette
)
pal
=
dds_primary
->
palette
->
palent
s
;
colors
=
dds_primary
->
palette
->
color
s
;
}
if
(
pal
)
{
RGBQUAD
col
[
256
];
unsigned
int
i
;
for
(
i
=
0
;
i
<
256
;
++
i
)
{
col
[
i
].
rgbRed
=
pal
[
i
].
peRed
;
col
[
i
].
rgbGreen
=
pal
[
i
].
peGreen
;
col
[
i
].
rgbBlue
=
pal
[
i
].
peBlue
;
col
[
i
].
rgbReserved
=
0
;
}
SetDIBColorTable
(
surface
->
hDC
,
0
,
256
,
col
);
}
if
(
colors
)
SetDIBColorTable
(
surface
->
hDC
,
0
,
256
,
colors
);
}
surface
->
flags
|=
SFLAG_DCINUSE
;
...
...
@@ -3417,20 +3383,17 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
* the index is stored in the alpha component so no conversion is needed. */
if
(
surface
->
resource
.
format
->
id
==
WINED3DFMT_P8_UINT
&&
!
swapchain_is_p8
(
context
->
swapchain
))
{
const
PALETTEENTRY
*
pal
=
NULL
;
const
RGBQUAD
*
colors
=
NULL
;
DWORD
width
=
pitch
/
3
;
int
x
,
y
,
c
;
if
(
surface
->
palette
)
{
pal
=
surface
->
palette
->
palents
;
}
else
if
(
!
surface
->
palette
)
{
ERR
(
"Palette is missing, cannot perform inverse palette lookup
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
return
;
}
colors
=
surface
->
palette
->
colors
;
for
(
y
=
0
;
y
<
surface
->
resource
.
height
;
y
++
)
{
...
...
@@ -3443,9 +3406,9 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
for
(
c
=
0
;
c
<
256
;
c
++
)
{
if
(
*
red
==
pal
[
c
].
pe
Red
&&
*
green
==
pal
[
c
].
pe
Green
&&
*
blue
==
pal
[
c
].
pe
Blue
)
if
(
*
red
==
colors
[
c
].
rgb
Red
&&
*
green
==
colors
[
c
].
rgb
Green
&&
*
blue
==
colors
[
c
].
rgb
Blue
)
{
*
((
BYTE
*
)
data
.
addr
+
y
*
width
+
x
)
=
c
;
break
;
...
...
@@ -3590,9 +3553,9 @@ void d3dfmt_p8_init_palette(const struct wined3d_surface *surface, BYTE table[25
/* Get the surface's palette */
for
(
i
=
0
;
i
<
256
;
++
i
)
{
table
[
i
][
0
]
=
pal
->
palents
[
i
].
pe
Red
;
table
[
i
][
1
]
=
pal
->
palents
[
i
].
pe
Green
;
table
[
i
][
2
]
=
pal
->
palents
[
i
].
pe
Blue
;
table
[
i
][
0
]
=
pal
->
colors
[
i
].
rgb
Red
;
table
[
i
][
1
]
=
pal
->
colors
[
i
].
rgb
Green
;
table
[
i
][
2
]
=
pal
->
colors
[
i
].
rgb
Blue
;
/* When index_in_alpha is set the palette index is stored in the
* alpha component. In case of a readback we can then read
...
...
@@ -3605,7 +3568,7 @@ void d3dfmt_p8_init_palette(const struct wined3d_surface *surface, BYTE table[25
else
if
(
colorkey
&&
color_in_range
(
&
surface
->
container
->
src_blt_color_key
,
i
))
table
[
i
][
3
]
=
0x00
;
else
if
(
pal
->
flags
&
WINED3D_PALETTE_ALPHA
)
table
[
i
][
3
]
=
pal
->
palents
[
i
].
peFlags
;
table
[
i
][
3
]
=
pal
->
colors
[
i
].
rgbReserved
;
else
table
[
i
][
3
]
=
0xff
;
}
...
...
dlls/wined3d/utils.c
View file @
1558391a
...
...
@@ -3089,7 +3089,7 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, c
if
(
format
->
id
==
WINED3DFMT_P8_UINT
)
{
PALETTEENTRY
*
e
;
const
RGBQUAD
*
e
;
BYTE
r
,
g
,
b
,
a
;
if
(
!
surface
->
palette
)
...
...
@@ -3103,16 +3103,16 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, c
b
=
(
BYTE
)((
color
->
b
*
255
.
0
f
)
+
0
.
5
f
);
a
=
(
BYTE
)((
color
->
a
*
255
.
0
f
)
+
0
.
5
f
);
e
=
&
surface
->
palette
->
palent
s
[
a
];
if
(
e
->
peRed
==
r
&&
e
->
peGreen
==
g
&&
e
->
pe
Blue
==
b
)
e
=
&
surface
->
palette
->
color
s
[
a
];
if
(
e
->
rgbRed
==
r
&&
e
->
rgbGreen
==
g
&&
e
->
rgb
Blue
==
b
)
return
a
;
WARN
(
"Alpha didn't match index, searching full palette.
\n
"
);
for
(
i
=
0
;
i
<
256
;
++
i
)
{
e
=
&
surface
->
palette
->
palent
s
[
i
];
if
(
e
->
peRed
==
r
&&
e
->
peGreen
==
g
&&
e
->
pe
Blue
==
b
)
e
=
&
surface
->
palette
->
color
s
[
i
];
if
(
e
->
rgbRed
==
r
&&
e
->
rgbGreen
==
g
&&
e
->
rgb
Blue
==
b
)
return
i
;
}
...
...
dlls/wined3d/wined3d_private.h
View file @
1558391a
...
...
@@ -2958,7 +2958,7 @@ struct wined3d_palette
struct
wined3d_device
*
device
;
unsigned
int
size
;
PALETTEENTRY
palent
s
[
256
];
RGBQUAD
color
s
[
256
];
DWORD
flags
;
};
...
...
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