From b599e8e3a04cc80bd09647fd784eac70dc2e411d Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 12 Apr 2019 17:20:44 +0430 Subject: [PATCH] wined3d: Get rid of wined3d_device_init_gdi(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/ddraw/ddraw.c | 13 +++--- dlls/wined3d/device.c | 87 +++++++++++++-------------------------- dlls/wined3d/wined3d.spec | 1 - include/wine/wined3d.h | 1 - 4 files changed, 34 insertions(+), 68 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 8467fbf4ccc..f4aabf4efab 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -569,6 +569,9 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *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()) { 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 * recursive loop until ram or emulated video memory is full. */ ddraw->flags |= DDRAW_D3D_INITIALIZED; - hr = wined3d_device_init_3d(ddraw->wined3d_device, swapchain_desc); - if (FAILED(hr)) + if (FAILED(hr = wined3d_device_init_3d(ddraw->wined3d_device, swapchain_desc))) { ddraw->flags &= ~DDRAW_D3D_INITIALIZED; return hr; @@ -638,12 +640,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win swapchain_desc.windowed = windowed; swapchain_desc.flags = WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH; - if (!(ddraw->flags & DDRAW_NO3D)) - hr = ddraw_attach_d3d_device(ddraw, &swapchain_desc); - else - hr = wined3d_device_init_gdi(ddraw->wined3d_device, &swapchain_desc); - - if (FAILED(hr)) + if (FAILED(hr = ddraw_attach_d3d_device(ddraw, &swapchain_desc))) { ERR("Failed to create swapchain, hr %#x.\n", hr); return hr; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1d870c0c201..1424ed4ab7e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1079,8 +1079,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device, if (device->d3d_initialized) return WINED3DERR_INVALIDCALL; - if (device->wined3d->flags & WINED3D_NO3D) - return WINED3DERR_INVALIDCALL; memset(device->fb.render_targets, 0, sizeof(device->fb.render_targets)); @@ -1120,26 +1118,40 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device, } device->swapchains[0] = swapchain; - if (FAILED(hr = wined3d_device_create_primary_opengl_context(device))) - goto err_out; - device_init_swapchain_state(device, 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))) + goto err_out; + device_init_swapchain_state(device, swapchain); - device->contexts[0]->last_was_rhw = 0; + device->contexts[0]->last_was_rhw = 0; - TRACE("All defaults now set up.\n"); + TRACE("All defaults now set up.\n"); - /* Clear the screen */ - if (device->back_buffer_view) - clear_flags |= WINED3DCLEAR_TARGET; - if (swapchain_desc->enable_auto_depth_stencil) - clear_flags |= WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL; - if (clear_flags) - wined3d_device_clear(device, 0, NULL, clear_flags, &black, 1.0f, 0); + /* Clear the screen */ + if (device->back_buffer_view) + clear_flags |= WINED3DCLEAR_TARGET; + if (swapchain_desc->enable_auto_depth_stencil) + clear_flags |= WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL; + if (clear_flags) + wined3d_device_clear(device, 0, NULL, clear_flags, &black, 1.0f, 0); - device->d3d_initialized = TRUE; + device->d3d_initialized = TRUE; + + if (wined3d_settings.logo) + device_load_logo(device, wined3d_settings.logo); + } - if (wined3d_settings.logo) - device_load_logo(device, wined3d_settings.logo); return WINED3D_OK; err_out: @@ -1153,47 +1165,6 @@ err_out: 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) { struct wined3d_sampler *sampler = WINE_RB_ENTRY_VALUE(entry, struct wined3d_sampler, entry); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 75b9fe12c60..1422c65245e 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -121,7 +121,6 @@ @ cdecl wined3d_device_get_wined3d(ptr) @ cdecl wined3d_device_incref(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_process_vertices(ptr long long long ptr ptr long long) @ cdecl wined3d_device_release_focus_window(ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 51fb7e6c8c9..e943e0d988c 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -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); 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_gdi(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc); void __cdecl wined3d_device_multiply_transform(struct wined3d_device *device, enum wined3d_transform_state state, const struct wined3d_matrix *matrix); HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,