Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
54fb2793
Commit
54fb2793
authored
Dec 24, 2022
by
Zebediah Figura
Committed by
Alexandre Julliard
Mar 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Factor out more common initialization into ddraw_surface_create_wined3d_texture().
parent
7a61760c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
67 deletions
+49
-67
surface.c
dlls/ddraw/surface.c
+49
-67
No files found.
dlls/ddraw/surface.c
View file @
54fb2793
...
...
@@ -6051,13 +6051,13 @@ static bool need_draw_texture(unsigned int draw_bind_flags, const struct wined3d
static
HRESULT
ddraw_surface_create_wined3d_texture
(
struct
ddraw
*
ddraw
,
unsigned
int
layers
,
unsigned
int
levels
,
struct
ddraw_texture
*
texture
,
bool
sysmem_fallback
,
struct
wined3d_texture
**
wined3d_texture
)
bool
sysmem_fallback
,
bool
reserve_memory
,
struct
wined3d_texture
**
wined3d_texture
)
{
struct
wined3d_device
*
wined3d_device
=
ddraw
->
wined3d_device
;
const
DDSURFACEDESC2
*
desc
=
&
texture
->
surface_desc
;
struct
wined3d_texture
*
draw_texture
=
NULL
;
struct
wined3d_resource_desc
wined3d_desc
;
struct
ddraw_surface
*
parent
;
struct
ddraw_surface
*
parent
,
*
root
;
unsigned
int
bind_flags
;
unsigned
int
pitch
=
0
;
unsigned
int
i
;
...
...
@@ -6135,16 +6135,7 @@ static HRESULT ddraw_surface_create_wined3d_texture(struct ddraw *ddraw,
if
(
FAILED
(
hr
=
wined3d_texture_create
(
wined3d_device
,
&
wined3d_desc
,
layers
,
levels
,
WINED3D_TEXTURE_CREATE_GET_DC_LENIENT
,
NULL
,
NULL
,
&
ddraw_null_wined3d_parent_ops
,
wined3d_texture
)))
{
parent
=
wined3d_texture_get_sub_resource_parent
(
draw_texture
,
0
);
if
(
texture
->
version
==
7
)
IDirectDrawSurface7_Release
(
&
parent
->
IDirectDrawSurface7_iface
);
else
if
(
texture
->
version
==
4
)
IDirectDrawSurface4_Release
(
&
parent
->
IDirectDrawSurface4_iface
);
else
IDirectDrawSurface_Release
(
&
parent
->
IDirectDrawSurface_iface
);
return
hr
;
}
goto
fail
;
wined3d_resource_set_parent
(
wined3d_texture_get_resource
(
*
wined3d_texture
),
texture
);
for
(
i
=
0
;
i
<
layers
*
levels
;
++
i
)
...
...
@@ -6170,9 +6161,27 @@ static HRESULT ddraw_surface_create_wined3d_texture(struct ddraw *ddraw,
WINED3D_MULTISAMPLE_NONE
,
0
,
desc
->
lpSurface
,
pitch
)))
{
ERR
(
"Failed to set surface memory, hr %#lx.
\n
"
,
hr
);
return
hr
;
goto
fail
;
}
root
=
wined3d_texture_get_sub_resource_parent
(
*
wined3d_texture
,
0
);
texture
->
root
=
root
;
wined3d_device_incref
(
texture
->
wined3d_device
=
ddraw
->
wined3d_device
);
if
(
desc
->
dwFlags
&
DDSD_CKDESTOVERLAY
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_DESTOVERLAY
,
(
struct
wined3d_color_key
*
)
&
desc
->
u3
.
ddckCKDestOverlay
);
if
(
desc
->
dwFlags
&
DDSD_CKDESTBLT
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_DESTBLT
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKDestBlt
);
if
(
desc
->
dwFlags
&
DDSD_CKSRCOVERLAY
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_SRCOVERLAY
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKSrcOverlay
);
if
(
desc
->
dwFlags
&
DDSD_CKSRCBLT
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_SRCBLT
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKSrcBlt
);
for
(
i
=
0
;
i
<
layers
*
levels
;
++
i
)
{
struct
ddraw_surface
*
surface
=
wined3d_texture_get_sub_resource_parent
(
*
wined3d_texture
,
i
);
...
...
@@ -6182,9 +6191,24 @@ static HRESULT ddraw_surface_create_wined3d_texture(struct ddraw *ddraw,
wined3d_texture_decref
(
*
wined3d_texture
);
TRACE
(
"Surface %p, created draw_texture %p, wined3d_texture %p.
\n
"
,
wined3d_texture_get_sub_resource_parent
(
*
wined3d_texture
,
0
),
draw_texture
,
*
wined3d_texture
);
if
(
reserve_memory
&&
FAILED
(
hr
=
ddraw_surface_reserve_memory
(
*
wined3d_texture
,
1
)))
{
hr
=
hr_ddraw_from_wined3d
(
hr
);
goto
fail
;
}
TRACE
(
"Surface %p, created draw_texture %p, wined3d_texture %p.
\n
"
,
root
,
draw_texture
,
*
wined3d_texture
);
return
D3D_OK
;
fail:
parent
=
wined3d_texture_get_sub_resource_parent
(
draw_texture
,
0
);
if
(
texture
->
version
==
7
)
IDirectDrawSurface7_Release
(
&
parent
->
IDirectDrawSurface7_iface
);
else
if
(
texture
->
version
==
4
)
IDirectDrawSurface4_Release
(
&
parent
->
IDirectDrawSurface4_iface
);
else
IDirectDrawSurface_Release
(
&
parent
->
IDirectDrawSurface_iface
);
return
hr
;
}
HRESULT
ddraw_surface_create
(
struct
ddraw
*
ddraw
,
const
DDSURFACEDESC2
*
surface_desc
,
...
...
@@ -6199,7 +6223,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
struct
ddraw_texture
*
texture
;
BOOL
sysmem_fallback
=
FALSE
;
unsigned
int
layers
=
1
;
BOOL
reserve_memory
;
bool
reserve_memory
;
UINT
levels
,
i
,
j
;
HRESULT
hr
;
...
...
@@ -6622,32 +6646,20 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
if
(
desc
->
ddsCaps
.
dwCaps2
&
DDSCAPS2_CUBEMAP
)
layers
=
6
;
reserve_memory
=
!
(
desc
->
dwFlags
&
DDSD_LPSURFACE
)
&&
desc
->
ddsCaps
.
dwCaps
&
DDSCAPS_VIDEOMEMORY
&&
wined3d_display_mode_format
.
u1
.
dwRGBBitCount
<=
16
;
if
(
FAILED
(
hr
=
ddraw_surface_create_wined3d_texture
(
ddraw
,
layers
,
levels
,
texture
,
sysmem_fallback
,
&
wined3d_texture
)))
texture
,
sysmem_fallback
,
reserve_memory
,
&
wined3d_texture
)))
{
WARN
(
"Failed to create wined3d texture, hr %#lx.
\n
"
,
hr
);
heap_free
(
texture
);
return
hr_ddraw_from_wined3d
(
hr
);
}
root
=
wined3d_texture_get_sub_resource_parent
(
wined3d_texture
,
0
);
root
=
texture
->
root
;
root
->
is_root
=
TRUE
;
texture
->
root
=
root
;
wined3d_device_incref
(
texture
->
wined3d_device
=
ddraw
->
wined3d_device
);
if
(
desc
->
dwFlags
&
DDSD_CKDESTOVERLAY
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_DESTOVERLAY
,
(
struct
wined3d_color_key
*
)
&
desc
->
u3
.
ddckCKDestOverlay
);
if
(
desc
->
dwFlags
&
DDSD_CKDESTBLT
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_DESTBLT
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKDestBlt
);
if
(
desc
->
dwFlags
&
DDSD_CKSRCOVERLAY
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_SRCOVERLAY
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKSrcOverlay
);
if
(
desc
->
dwFlags
&
DDSD_CKSRCBLT
)
ddraw_surface_set_wined3d_textures_colour_key
(
root
,
DDCKEY_SRCBLT
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKSrcBlt
);
for
(
i
=
0
;
i
<
layers
;
++
i
)
{
...
...
@@ -6709,16 +6721,6 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
}
}
reserve_memory
=
!
(
desc
->
dwFlags
&
DDSD_LPSURFACE
)
&&
desc
->
ddsCaps
.
dwCaps
&
DDSCAPS_VIDEOMEMORY
&&
wined3d_display_mode_format
.
u1
.
dwRGBBitCount
<=
16
;
if
(
reserve_memory
&&
FAILED
(
hr
=
ddraw_surface_reserve_memory
(
wined3d_texture
,
layers
*
levels
)))
{
ERR
(
"Failed to reserve surface memory, hr %#lx.
\n
"
,
hr
);
goto
fail
;
}
if
(
desc
->
dwFlags
&
DDSD_BACKBUFFERCOUNT
)
{
unsigned
int
count
=
desc
->
u5
.
dwBackBufferCount
;
...
...
@@ -6747,35 +6749,15 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
desc
->
u5
.
dwBackBufferCount
=
0
;
if
(
FAILED
(
hr
=
ddraw_surface_create_wined3d_texture
(
ddraw
,
1
,
1
,
texture
,
sysmem_fallback
,
&
wined3d_texture
)))
texture
,
sysmem_fallback
,
reserve_memory
,
&
wined3d_texture
)))
{
heap_free
(
texture
);
hr
=
hr_ddraw_from_wined3d
(
hr
);
goto
fail
;
}
last
=
wined3d_texture_get_sub_resource_parent
(
wined3d_texture
,
0
);
texture
->
root
=
last
;
wined3d_device_incref
(
texture
->
wined3d_device
=
ddraw
->
wined3d_device
);
if
(
desc
->
dwFlags
&
DDSD_CKDESTOVERLAY
)
wined3d_texture_set_color_key
(
wined3d_texture
,
DDCKEY_DESTOVERLAY
,
(
struct
wined3d_color_key
*
)
&
desc
->
u3
.
ddckCKDestOverlay
);
if
(
desc
->
dwFlags
&
DDSD_CKDESTBLT
)
wined3d_texture_set_color_key
(
wined3d_texture
,
DDCKEY_DESTBLT
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKDestBlt
);
if
(
desc
->
dwFlags
&
DDSD_CKSRCOVERLAY
)
wined3d_texture_set_color_key
(
wined3d_texture
,
DDCKEY_SRCOVERLAY
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKSrcOverlay
);
if
(
desc
->
dwFlags
&
DDSD_CKSRCBLT
)
wined3d_texture_set_color_key
(
wined3d_texture
,
DDCKEY_SRCBLT
,
(
struct
wined3d_color_key
*
)
&
desc
->
ddckCKSrcBlt
);
if
(
reserve_memory
&&
FAILED
(
hr
=
ddraw_surface_reserve_memory
(
wined3d_texture
,
1
)))
{
hr
=
hr_ddraw_from_wined3d
(
hr
);
goto
fail
;
}
last
=
texture
->
root
;
*
attach
=
last
;
attach
=
&
last
->
complex_array
[
0
];
}
...
...
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