wined3d: Get rid of wined3d_device_init_gdi().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-04-12 17:20:44 +04:30 committed by Alexandre Julliard
parent 0ffb153551
commit b599e8e3a0
4 changed files with 34 additions and 68 deletions

View File

@ -569,6 +569,9 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw,
TRACE("ddraw %p.\n", ddraw); TRACE("ddraw %p.\n", ddraw);
if (ddraw->flags & DDRAW_NO3D)
return wined3d_device_init_3d(ddraw->wined3d_device, swapchain_desc);
if (!window || window == GetDesktopWindow()) if (!window || window == GetDesktopWindow())
{ {
window = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "Hidden D3D Window", window = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "Hidden D3D Window",
@ -594,8 +597,7 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw,
/* Set this NOW, otherwise creating the depth stencil surface will cause a /* Set this NOW, otherwise creating the depth stencil surface will cause a
* recursive loop until ram or emulated video memory is full. */ * recursive loop until ram or emulated video memory is full. */
ddraw->flags |= DDRAW_D3D_INITIALIZED; ddraw->flags |= DDRAW_D3D_INITIALIZED;
hr = wined3d_device_init_3d(ddraw->wined3d_device, swapchain_desc); if (FAILED(hr = wined3d_device_init_3d(ddraw->wined3d_device, swapchain_desc)))
if (FAILED(hr))
{ {
ddraw->flags &= ~DDRAW_D3D_INITIALIZED; ddraw->flags &= ~DDRAW_D3D_INITIALIZED;
return hr; return hr;
@ -638,12 +640,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
swapchain_desc.windowed = windowed; swapchain_desc.windowed = windowed;
swapchain_desc.flags = WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH; swapchain_desc.flags = WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
if (!(ddraw->flags & DDRAW_NO3D)) if (FAILED(hr = ddraw_attach_d3d_device(ddraw, &swapchain_desc)))
hr = ddraw_attach_d3d_device(ddraw, &swapchain_desc);
else
hr = wined3d_device_init_gdi(ddraw->wined3d_device, &swapchain_desc);
if (FAILED(hr))
{ {
ERR("Failed to create swapchain, hr %#x.\n", hr); ERR("Failed to create swapchain, hr %#x.\n", hr);
return hr; return hr;

View File

@ -1079,8 +1079,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
if (device->d3d_initialized) if (device->d3d_initialized)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
if (device->wined3d->flags & WINED3D_NO3D)
return WINED3DERR_INVALIDCALL;
memset(device->fb.render_targets, 0, sizeof(device->fb.render_targets)); memset(device->fb.render_targets, 0, sizeof(device->fb.render_targets));
@ -1120,6 +1118,18 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
} }
device->swapchains[0] = swapchain; device->swapchains[0] = swapchain;
if (device->wined3d->flags & WINED3D_NO3D)
{
if (!(device->blitter = wined3d_cpu_blitter_create()))
{
ERR("Failed to create CPU blitter.\n");
heap_free(device->swapchains);
device->swapchain_count = 0;
goto err_out;
}
}
else
{
if (FAILED(hr = wined3d_device_create_primary_opengl_context(device))) if (FAILED(hr = wined3d_device_create_primary_opengl_context(device)))
goto err_out; goto err_out;
device_init_swapchain_state(device, swapchain); device_init_swapchain_state(device, swapchain);
@ -1140,6 +1150,8 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
if (wined3d_settings.logo) if (wined3d_settings.logo)
device_load_logo(device, wined3d_settings.logo); device_load_logo(device, wined3d_settings.logo);
}
return WINED3D_OK; return WINED3D_OK;
err_out: err_out:
@ -1153,47 +1165,6 @@ err_out:
return hr; return hr;
} }
HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
struct wined3d_swapchain_desc *swapchain_desc)
{
struct wined3d_swapchain *swapchain = NULL;
HRESULT hr;
TRACE("device %p, swapchain_desc %p.\n", device, swapchain_desc);
/* Setup the implicit swapchain */
TRACE("Creating implicit swapchain\n");
hr = device->device_parent->ops->create_swapchain(device->device_parent,
swapchain_desc, &swapchain);
if (FAILED(hr))
{
WARN("Failed to create implicit swapchain\n");
goto err_out;
}
device->swapchain_count = 1;
if (!(device->swapchains = heap_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Out of memory!\n");
goto err_out;
}
device->swapchains[0] = swapchain;
if (!(device->blitter = wined3d_cpu_blitter_create()))
{
ERR("Failed to create CPU blitter.\n");
heap_free(device->swapchains);
device->swapchain_count = 0;
goto err_out;
}
return WINED3D_OK;
err_out:
wined3d_swapchain_decref(swapchain);
return hr;
}
static void device_free_sampler(struct wine_rb_entry *entry, void *context) static void device_free_sampler(struct wine_rb_entry *entry, void *context)
{ {
struct wined3d_sampler *sampler = WINE_RB_ENTRY_VALUE(entry, struct wined3d_sampler, entry); struct wined3d_sampler *sampler = WINE_RB_ENTRY_VALUE(entry, struct wined3d_sampler, entry);

View File

@ -121,7 +121,6 @@
@ cdecl wined3d_device_get_wined3d(ptr) @ cdecl wined3d_device_get_wined3d(ptr)
@ cdecl wined3d_device_incref(ptr) @ cdecl wined3d_device_incref(ptr)
@ cdecl wined3d_device_init_3d(ptr ptr) @ cdecl wined3d_device_init_3d(ptr ptr)
@ cdecl wined3d_device_init_gdi(ptr ptr)
@ cdecl wined3d_device_multiply_transform(ptr long ptr) @ cdecl wined3d_device_multiply_transform(ptr long ptr)
@ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long) @ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
@ cdecl wined3d_device_release_focus_window(ptr) @ cdecl wined3d_device_release_focus_window(ptr)

View File

@ -2364,7 +2364,6 @@ struct wined3d_sampler * __cdecl wined3d_device_get_vs_sampler(const struct wine
struct wined3d * __cdecl wined3d_device_get_wined3d(const struct wined3d_device *device); struct wined3d * __cdecl wined3d_device_get_wined3d(const struct wined3d_device *device);
ULONG __cdecl wined3d_device_incref(struct wined3d_device *device); ULONG __cdecl wined3d_device_incref(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_init_3d(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc); HRESULT __cdecl wined3d_device_init_3d(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc);
HRESULT __cdecl wined3d_device_init_gdi(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc);
void __cdecl wined3d_device_multiply_transform(struct wined3d_device *device, void __cdecl wined3d_device_multiply_transform(struct wined3d_device *device,
enum wined3d_transform_state state, const struct wined3d_matrix *matrix); enum wined3d_transform_state state, const struct wined3d_matrix *matrix);
HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device, HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,