wined3d: Refactor wined3d_find_closest_matching_adapter_mode() to wined3d_output_find_closest_matching_mode().
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
aa177f6afc
commit
c51e97bc0d
|
@ -49,8 +49,6 @@ static void dxgi_mode1_from_wined3d(DXGI_MODE_DESC1 *mode, const struct wined3d_
|
|||
static HRESULT dxgi_output_find_closest_matching_mode(struct dxgi_output *output,
|
||||
struct wined3d_display_mode *mode, IUnknown *device)
|
||||
{
|
||||
struct dxgi_adapter *adapter;
|
||||
struct wined3d *wined3d;
|
||||
HRESULT hr;
|
||||
|
||||
if (!mode->width != !mode->height)
|
||||
|
@ -66,10 +64,7 @@ static HRESULT dxgi_output_find_closest_matching_mode(struct dxgi_output *output
|
|||
}
|
||||
|
||||
wined3d_mutex_lock();
|
||||
adapter = output->adapter;
|
||||
wined3d = adapter->factory->wined3d;
|
||||
|
||||
hr = wined3d_find_closest_matching_adapter_mode(wined3d, adapter->ordinal, mode);
|
||||
hr = wined3d_output_find_closest_matching_mode(output->wined3d_output, mode);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
|
|
|
@ -156,15 +156,13 @@ static HRESULT dxgi_swapchain_set_fullscreen_state(struct wined3d_swapchain_stat
|
|||
const struct wined3d_swapchain_desc *swapchain_desc, IDXGIOutput *output)
|
||||
{
|
||||
struct dxgi_output *dxgi_output;
|
||||
struct dxgi_adapter *adapter;
|
||||
HRESULT hr;
|
||||
|
||||
dxgi_output = unsafe_impl_from_IDXGIOutput(output);
|
||||
adapter = dxgi_output->adapter;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_swapchain_state_set_fullscreen(state, swapchain_desc,
|
||||
adapter->factory->wined3d, dxgi_output->wined3d_output, NULL);
|
||||
dxgi_output->wined3d_output, NULL);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
|
@ -175,7 +173,6 @@ static HRESULT dxgi_swapchain_resize_target(IDXGISwapChain1 *swapchain,
|
|||
{
|
||||
struct wined3d_display_mode mode;
|
||||
struct dxgi_output *dxgi_output;
|
||||
struct dxgi_adapter *adapter;
|
||||
IDXGIOutput *output;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -188,7 +185,6 @@ static HRESULT dxgi_swapchain_resize_target(IDXGISwapChain1 *swapchain,
|
|||
if (FAILED(hr = IDXGISwapChain1_GetContainingOutput(swapchain, &output)))
|
||||
return hr;
|
||||
dxgi_output = unsafe_impl_from_IDXGIOutput(output);
|
||||
adapter = dxgi_output->adapter;
|
||||
|
||||
TRACE("Mode: %s.\n", debug_dxgi_mode(target_mode_desc));
|
||||
|
||||
|
@ -197,8 +193,7 @@ static HRESULT dxgi_swapchain_resize_target(IDXGISwapChain1 *swapchain,
|
|||
|
||||
wined3d_display_mode_from_dxgi(&mode, target_mode_desc);
|
||||
|
||||
hr = wined3d_swapchain_state_resize_target(state, adapter->factory->wined3d,
|
||||
dxgi_output->wined3d_output, &mode);
|
||||
hr = wined3d_swapchain_state_resize_target(state, dxgi_output->wined3d_output, &mode);
|
||||
IDXGIOutput_Release(output);
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -5156,7 +5156,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
|||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(hr = wined3d_swapchain_state_set_fullscreen(&swapchain->state,
|
||||
swapchain_desc, device->wined3d, output, mode)))
|
||||
swapchain_desc, output, mode)))
|
||||
return hr;
|
||||
|
||||
/* Switch from fullscreen to windowed. */
|
||||
|
|
|
@ -1080,18 +1080,18 @@ HRESULT CDECL wined3d_output_get_mode(const struct wined3d_output *output,
|
|||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d,
|
||||
unsigned int adapter_idx, struct wined3d_display_mode *mode)
|
||||
HRESULT CDECL wined3d_output_find_closest_matching_mode(const struct wined3d_output *output,
|
||||
struct wined3d_display_mode *mode)
|
||||
{
|
||||
unsigned int i, j, mode_count, matching_mode_count, closest;
|
||||
struct wined3d_display_mode **matching_modes;
|
||||
struct wined3d_display_mode *modes;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
|
||||
TRACE("output %p, mode %p.\n", output, mode);
|
||||
|
||||
if (!(mode_count = wined3d_output_get_mode_count(&wined3d->adapters[adapter_idx]->outputs[0],
|
||||
mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
|
||||
if (!(mode_count = wined3d_output_get_mode_count(output, mode->format_id,
|
||||
WINED3D_SCANLINE_ORDERING_UNKNOWN)))
|
||||
{
|
||||
WARN("Output has 0 matching modes.\n");
|
||||
return E_FAIL;
|
||||
|
@ -1107,8 +1107,8 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
|
|||
|
||||
for (i = 0; i < mode_count; ++i)
|
||||
{
|
||||
if (FAILED(hr = wined3d_output_get_mode(&wined3d->adapters[adapter_idx]->outputs[0],
|
||||
mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
|
||||
if (FAILED(hr = wined3d_output_get_mode(output, mode->format_id,
|
||||
WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
|
||||
{
|
||||
heap_free(matching_modes);
|
||||
heap_free(modes);
|
||||
|
@ -1144,8 +1144,7 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
|
|||
if (!mode->width || !mode->height)
|
||||
{
|
||||
struct wined3d_display_mode current_mode;
|
||||
if (FAILED(hr = wined3d_output_get_display_mode(&wined3d->adapters[adapter_idx]->outputs[0],
|
||||
¤t_mode, NULL)))
|
||||
if (FAILED(hr = wined3d_output_get_display_mode(output, ¤t_mode, NULL)))
|
||||
{
|
||||
heap_free(matching_modes);
|
||||
heap_free(modes);
|
||||
|
|
|
@ -1440,13 +1440,13 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha
|
|||
}
|
||||
|
||||
static HRESULT wined3d_swapchain_state_set_display_mode(struct wined3d_swapchain_state *state,
|
||||
struct wined3d *wined3d, struct wined3d_output *output, struct wined3d_display_mode *mode)
|
||||
struct wined3d_output *output, struct wined3d_display_mode *mode)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (state->desc.flags & WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE)
|
||||
{
|
||||
if (FAILED(hr = wined3d_find_closest_matching_adapter_mode(wined3d, 0, mode)))
|
||||
if (FAILED(hr = wined3d_output_find_closest_matching_mode(output, mode)))
|
||||
{
|
||||
WARN("Failed to find closest matching mode, hr %#x.\n", hr);
|
||||
}
|
||||
|
@ -1462,15 +1462,14 @@ static HRESULT wined3d_swapchain_state_set_display_mode(struct wined3d_swapchain
|
|||
}
|
||||
|
||||
HRESULT CDECL wined3d_swapchain_state_resize_target(struct wined3d_swapchain_state *state,
|
||||
struct wined3d *wined3d, struct wined3d_output *output,
|
||||
const struct wined3d_display_mode *mode)
|
||||
struct wined3d_output *output, const struct wined3d_display_mode *mode)
|
||||
{
|
||||
struct wined3d_display_mode actual_mode;
|
||||
RECT original_window_rect, window_rect;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("state %p, wined3d %p, output %p, mode %p.\n", state, wined3d, output, mode);
|
||||
TRACE("state %p, output %p, mode %p.\n", state, output, mode);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
|
||||
|
@ -1490,8 +1489,7 @@ HRESULT CDECL wined3d_swapchain_state_resize_target(struct wined3d_swapchain_sta
|
|||
else if (state->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
|
||||
{
|
||||
actual_mode = *mode;
|
||||
if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, wined3d, output,
|
||||
&actual_mode)))
|
||||
if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, output, &actual_mode)))
|
||||
{
|
||||
wined3d_mutex_unlock();
|
||||
return hr;
|
||||
|
@ -1628,14 +1626,14 @@ void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_st
|
|||
}
|
||||
|
||||
HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_state *state,
|
||||
const struct wined3d_swapchain_desc *swapchain_desc, struct wined3d *wined3d,
|
||||
struct wined3d_output *output, const struct wined3d_display_mode *mode)
|
||||
const struct wined3d_swapchain_desc *swapchain_desc, struct wined3d_output *output,
|
||||
const struct wined3d_display_mode *mode)
|
||||
{
|
||||
struct wined3d_display_mode actual_mode;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("state %p, swapchain_desc %p, wined3d %p, output %p, mode %p.\n",
|
||||
state, swapchain_desc, wined3d, output, mode);
|
||||
TRACE("state %p, swapchain_desc %p, output %p, mode %p.\n",
|
||||
state, swapchain_desc, output, mode);
|
||||
|
||||
if (state->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
|
||||
{
|
||||
|
@ -1660,8 +1658,7 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st
|
|||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, wined3d, output,
|
||||
&actual_mode)))
|
||||
if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, output, &actual_mode)))
|
||||
return hr;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
@ cdecl wined3d_check_device_type(ptr long long long long long)
|
||||
@ cdecl wined3d_create(long)
|
||||
@ cdecl wined3d_decref(ptr)
|
||||
@ cdecl wined3d_find_closest_matching_adapter_mode(ptr long ptr)
|
||||
@ cdecl wined3d_get_adapter(ptr long)
|
||||
@ cdecl wined3d_get_adapter_count(ptr)
|
||||
@ cdecl wined3d_get_adapter_identifier(ptr long long ptr)
|
||||
|
@ -158,6 +157,7 @@
|
|||
@ cdecl wined3d_device_update_texture(ptr ptr ptr)
|
||||
@ cdecl wined3d_device_validate_device(ptr ptr)
|
||||
|
||||
@ cdecl wined3d_output_find_closest_matching_mode(ptr ptr)
|
||||
@ cdecl wined3d_output_get_display_mode(ptr ptr ptr)
|
||||
@ cdecl wined3d_output_get_mode(ptr long long long ptr)
|
||||
@ cdecl wined3d_output_get_mode_count(ptr long long)
|
||||
|
@ -282,8 +282,8 @@
|
|||
|
||||
@ cdecl wined3d_swapchain_state_create(ptr ptr ptr ptr)
|
||||
@ cdecl wined3d_swapchain_state_destroy(ptr)
|
||||
@ cdecl wined3d_swapchain_state_resize_target(ptr ptr ptr ptr)
|
||||
@ cdecl wined3d_swapchain_state_set_fullscreen(ptr ptr ptr ptr ptr)
|
||||
@ cdecl wined3d_swapchain_state_resize_target(ptr ptr ptr)
|
||||
@ cdecl wined3d_swapchain_state_set_fullscreen(ptr ptr ptr ptr)
|
||||
|
||||
@ cdecl wined3d_texture_add_dirty_region(ptr long ptr)
|
||||
@ cdecl wined3d_texture_blt(ptr long ptr ptr long ptr long ptr long)
|
||||
|
|
|
@ -570,8 +570,8 @@ static LRESULT CALLBACK wined3d_hook_proc(int code, WPARAM wparam, LPARAM lparam
|
|||
ERR("Failed to get output from swapchain %p.\n", swapchain);
|
||||
break;
|
||||
}
|
||||
wined3d_swapchain_state_set_fullscreen(&swapchain->state, &swapchain_desc,
|
||||
swapchain->device->wined3d, output, NULL);
|
||||
wined3d_swapchain_state_set_fullscreen(&swapchain->state, &swapchain_desc, output,
|
||||
NULL);
|
||||
|
||||
wined3d_wndproc_mutex_unlock();
|
||||
|
||||
|
|
|
@ -2261,8 +2261,6 @@ HRESULT __cdecl wined3d_check_device_type(const struct wined3d *wined3d, UINT ad
|
|||
enum wined3d_format_id backbuffer_format_id, BOOL windowed);
|
||||
struct wined3d * __cdecl wined3d_create(DWORD flags);
|
||||
ULONG __cdecl wined3d_decref(struct wined3d *wined3d);
|
||||
HRESULT __cdecl wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d,
|
||||
unsigned int adapter_idx, struct wined3d_display_mode *mode);
|
||||
struct wined3d_adapter * __cdecl wined3d_get_adapter(const struct wined3d *wined3d,
|
||||
unsigned int idx);
|
||||
UINT __cdecl wined3d_get_adapter_count(const struct wined3d *wined3d);
|
||||
|
@ -2495,6 +2493,8 @@ HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
|
|||
struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
|
||||
HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
|
||||
|
||||
HRESULT __cdecl wined3d_output_find_closest_matching_mode(const struct wined3d_output *output,
|
||||
struct wined3d_display_mode *mode);
|
||||
HRESULT __cdecl wined3d_output_get_display_mode(const struct wined3d_output *output,
|
||||
struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation);
|
||||
HRESULT __cdecl wined3d_output_get_mode(const struct wined3d_output *output,
|
||||
|
@ -2762,11 +2762,10 @@ HRESULT __cdecl wined3d_swapchain_state_create(const struct wined3d_swapchain_de
|
|||
HWND window, struct wined3d *wined3d, struct wined3d_swapchain_state **state);
|
||||
void __cdecl wined3d_swapchain_state_destroy(struct wined3d_swapchain_state *state);
|
||||
HRESULT __cdecl wined3d_swapchain_state_resize_target(struct wined3d_swapchain_state *state,
|
||||
struct wined3d *wined3d, struct wined3d_output *output,
|
||||
const struct wined3d_display_mode *mode);
|
||||
HRESULT __cdecl wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_state *state,
|
||||
const struct wined3d_swapchain_desc *desc, struct wined3d *wined3d,
|
||||
struct wined3d_output *output, const struct wined3d_display_mode *mode);
|
||||
HRESULT __cdecl wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_state *state,
|
||||
const struct wined3d_swapchain_desc *desc, struct wined3d_output *output,
|
||||
const struct wined3d_display_mode *mode);
|
||||
|
||||
HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
|
||||
UINT layer, const struct wined3d_box *dirty_region);
|
||||
|
|
Loading…
Reference in New Issue