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
a1381fbe
Commit
a1381fbe
authored
Feb 29, 2024
by
Connor McAdams
Committed by
Alexandre Julliard
Mar 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Split off image decompression into a helper function.
Signed-off-by:
Connor McAdams
<
cmcadams@codeweavers.com
>
parent
7ff4e567
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
45 deletions
+64
-45
surface.c
dlls/d3dx9_36/surface.c
+64
-45
No files found.
dlls/d3dx9_36/surface.c
View file @
a1381fbe
...
...
@@ -1875,6 +1875,59 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
}
}
static
HRESULT
d3dx_image_decompress
(
const
void
*
memory
,
uint32_t
row_pitch
,
const
RECT
*
rect
,
const
struct
volume
*
size
,
const
struct
pixel_format_desc
*
desc
,
void
**
out_memory
,
uint32_t
*
out_row_pitch
,
RECT
*
out_rect
,
const
struct
pixel_format_desc
**
out_desc
)
{
void
(
*
fetch_dxt_texel
)(
int
srcRowStride
,
const
BYTE
*
pixdata
,
int
i
,
int
j
,
void
*
texel
);
const
struct
pixel_format_desc
*
uncompressed_desc
=
NULL
;
uint32_t
x
,
y
,
tmp_pitch
;
BYTE
*
uncompressed_mem
;
switch
(
desc
->
format
)
{
case
D3DFMT_DXT1
:
uncompressed_desc
=
get_format_info
(
D3DFMT_A8B8G8R8
);
fetch_dxt_texel
=
fetch_2d_texel_rgba_dxt1
;
break
;
case
D3DFMT_DXT2
:
case
D3DFMT_DXT3
:
uncompressed_desc
=
get_format_info
(
D3DFMT_A8B8G8R8
);
fetch_dxt_texel
=
fetch_2d_texel_rgba_dxt3
;
break
;
case
D3DFMT_DXT4
:
case
D3DFMT_DXT5
:
uncompressed_desc
=
get_format_info
(
D3DFMT_A8B8G8R8
);
fetch_dxt_texel
=
fetch_2d_texel_rgba_dxt5
;
break
;
default:
FIXME
(
"Unexpected compressed texture format %u.
\n
"
,
desc
->
format
);
return
E_NOTIMPL
;
}
if
(
!
(
uncompressed_mem
=
malloc
(
size
->
width
*
size
->
height
*
size
->
depth
*
uncompressed_desc
->
bytes_per_pixel
)))
return
E_OUTOFMEMORY
;
TRACE
(
"Decompressing image.
\n
"
);
tmp_pitch
=
row_pitch
*
desc
->
block_width
/
desc
->
block_byte_count
;
for
(
y
=
0
;
y
<
size
->
height
;
++
y
)
{
BYTE
*
ptr
=
&
uncompressed_mem
[
y
*
size
->
width
*
uncompressed_desc
->
bytes_per_pixel
];
for
(
x
=
0
;
x
<
size
->
width
;
++
x
)
{
fetch_dxt_texel
(
tmp_pitch
,
(
BYTE
*
)
memory
,
x
+
rect
->
left
,
y
+
rect
->
top
,
ptr
);
ptr
+=
uncompressed_desc
->
bytes_per_pixel
;
}
}
*
out_memory
=
uncompressed_mem
;
*
out_row_pitch
=
size
->
width
*
uncompressed_desc
->
bytes_per_pixel
;
SetRect
(
out_rect
,
0
,
0
,
size
->
width
,
size
->
height
);
*
out_desc
=
uncompressed_desc
;
return
S_OK
;
}
static
void
set_volume_struct
(
struct
volume
*
volume
,
uint32_t
width
,
uint32_t
height
,
uint32_t
depth
)
{
volume
->
width
=
width
;
...
...
@@ -1933,54 +1986,20 @@ static HRESULT d3dx_load_image_from_memory(void *dst_memory, uint32_t dst_row_pi
*/
if
(
src_desc
->
type
==
FORMAT_DXT
)
{
void
(
*
fetch_dxt_texel
)(
int
srcRowStride
,
const
BYTE
*
pixdata
,
int
i
,
int
j
,
void
*
texel
);
const
struct
pixel_format_desc
*
src_uncompressed_desc
;
uint32_t
x
,
y
,
src_uncompressed_row_pitch
,
tmp_pitch
;
DWORD
*
src_uncompressed
=
NULL
;
RECT
src_uncompressed_rect
;
tmp_pitch
=
src_row_pitch
*
src_desc
->
block_width
/
src_desc
->
block_byte_count
;
src_uncompressed
=
malloc
(
src_size
.
width
*
src_size
.
height
*
sizeof
(
DWORD
));
if
(
!
src_uncompressed
)
return
E_OUTOFMEMORY
;
const
struct
pixel_format_desc
*
uncompressed_desc
;
uint32_t
uncompressed_row_pitch
;
void
*
uncompressed_mem
=
NULL
;
RECT
uncompressed_rect
;
switch
(
src_desc
->
format
)
hr
=
d3dx_image_decompress
(
src_memory
,
src_row_pitch
,
src_rect
,
&
src_size
,
src_desc
,
&
uncompressed_mem
,
&
uncompressed_row_pitch
,
&
uncompressed_rect
,
&
uncompressed_desc
);
if
(
SUCCEEDED
(
hr
))
{
case
D3DFMT_DXT1
:
fetch_dxt_texel
=
fetch_2d_texel_rgba_dxt1
;
break
;
case
D3DFMT_DXT2
:
case
D3DFMT_DXT3
:
fetch_dxt_texel
=
fetch_2d_texel_rgba_dxt3
;
break
;
case
D3DFMT_DXT4
:
case
D3DFMT_DXT5
:
fetch_dxt_texel
=
fetch_2d_texel_rgba_dxt5
;
break
;
default:
FIXME
(
"Unexpected compressed texture format %u.
\n
"
,
src_desc
->
format
);
fetch_dxt_texel
=
NULL
;
hr
=
d3dx_load_image_from_memory
(
dst_memory
,
dst_row_pitch
,
dst_desc
,
dst_palette
,
dst_rect
,
dst_rect_aligned
,
uncompressed_mem
,
uncompressed_row_pitch
,
uncompressed_desc
,
src_palette
,
&
uncompressed_rect
,
filter_flags
,
color_key
);
}
TRACE
(
"Uncompressing DXTn surface.
\n
"
);
for
(
y
=
0
;
y
<
src_size
.
height
;
++
y
)
{
DWORD
*
ptr
=
&
src_uncompressed
[
y
*
src_size
.
width
];
for
(
x
=
0
;
x
<
src_size
.
width
;
++
x
)
{
fetch_dxt_texel
(
tmp_pitch
,
src_memory
,
x
+
src_rect
->
left
,
y
+
src_rect
->
top
,
ptr
);
++
ptr
;
}
}
src_uncompressed_row_pitch
=
src_size
.
width
*
sizeof
(
DWORD
);
src_uncompressed_desc
=
get_format_info
(
D3DFMT_A8B8G8R8
);
SetRect
(
&
src_uncompressed_rect
,
0
,
0
,
src_size
.
width
,
src_size
.
height
);
hr
=
d3dx_load_image_from_memory
(
dst_memory
,
dst_row_pitch
,
dst_desc
,
dst_palette
,
dst_rect
,
dst_rect_aligned
,
src_uncompressed
,
src_uncompressed_row_pitch
,
src_uncompressed_desc
,
src_palette
,
&
src_uncompressed_rect
,
filter_flags
,
color_key
);
free
(
src_uncompressed
);
free
(
uncompressed_mem
);
return
hr
;
}
...
...
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