2006-06-09 19:36:12 +02:00
|
|
|
/* DirectDraw Surface Implementation
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997-2000 Marcus Meissner
|
|
|
|
* Copyright (c) 1998-2000 Lionel Ulmer
|
|
|
|
* Copyright (c) 2000-2001 TransGaming Technologies Inc.
|
2008-10-18 19:19:45 +02:00
|
|
|
* Copyright (c) 2006 Stefan Dösinger
|
2011-06-06 13:39:04 +02:00
|
|
|
* Copyright (c) 2011 Ričardas Barkauskas for CodeWeavers
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ddraw_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
static struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface);
|
|
|
|
static struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface);
|
2011-06-11 20:20:25 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
static inline struct ddraw_surface *impl_from_IDirectDrawGammaControl(IDirectDrawGammaControl *iface)
|
2010-08-18 19:26:18 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawGammaControl_iface);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
static BOOL ddraw_surface_is_lost(const struct ddraw_surface *surface)
|
|
|
|
{
|
2020-04-16 17:27:41 +02:00
|
|
|
return ddraw_surface_can_be_lost(surface)
|
|
|
|
&& (surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->is_lost);
|
2020-03-26 14:09:39 +01:00
|
|
|
}
|
|
|
|
|
2021-01-19 14:34:55 +01:00
|
|
|
static BOOL ddraw_gdi_is_front(struct ddraw *ddraw)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface;
|
|
|
|
|
|
|
|
if (!ddraw->gdi_surface || !(surface = wined3d_texture_get_sub_resource_parent(ddraw->gdi_surface, 0)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER;
|
|
|
|
}
|
|
|
|
|
2011-10-24 21:24:38 +02:00
|
|
|
/* This is slow, of course. Also, in case of locks, we can't prevent other
|
|
|
|
* applications from drawing to the screen while we've locked the frontbuffer.
|
|
|
|
* We'd like to do this in wined3d instead, but for that to work wined3d needs
|
|
|
|
* to support windowless rendering first. */
|
2018-03-27 13:06:52 +02:00
|
|
|
HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
|
|
|
|
const RECT *rect, BOOL read, unsigned int swap_interval)
|
2011-10-24 21:24:38 +02:00
|
|
|
{
|
2021-03-11 14:34:01 +01:00
|
|
|
struct wined3d_texture *dst_texture, *wined3d_texture;
|
2021-01-19 14:34:55 +01:00
|
|
|
struct ddraw *ddraw = surface->ddraw;
|
2011-10-24 21:24:38 +02:00
|
|
|
HDC surface_dc, screen_dc;
|
|
|
|
int x, y, w, h;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL ret;
|
2016-01-27 20:44:34 +01:00
|
|
|
RECT r;
|
2011-10-24 21:24:38 +02:00
|
|
|
|
2021-12-10 20:03:41 +01:00
|
|
|
TRACE("surface %p, rect %s, read %#x, swap_interval %u.\n",
|
|
|
|
surface, wine_dbgstr_rect(rect), read, swap_interval);
|
|
|
|
|
2021-01-19 14:34:55 +01:00
|
|
|
if (ddraw->flags & DDRAW_SWAPPED && !read)
|
2018-03-30 14:51:11 +02:00
|
|
|
{
|
2021-01-19 14:34:55 +01:00
|
|
|
ddraw->flags &= ~DDRAW_SWAPPED;
|
2018-03-30 14:51:11 +02:00
|
|
|
rect = NULL;
|
|
|
|
}
|
|
|
|
|
2011-10-24 21:24:38 +02:00
|
|
|
if (!rect)
|
|
|
|
{
|
2016-01-27 20:44:34 +01:00
|
|
|
SetRect(&r, 0, 0, surface->surface_desc.dwWidth, surface->surface_desc.dwHeight);
|
|
|
|
rect = &r;
|
2011-10-24 21:24:38 +02:00
|
|
|
}
|
|
|
|
|
2016-01-27 20:44:34 +01:00
|
|
|
x = rect->left;
|
|
|
|
y = rect->top;
|
|
|
|
w = rect->right - rect->left;
|
|
|
|
h = rect->bottom - rect->top;
|
|
|
|
|
2011-10-24 21:24:38 +02:00
|
|
|
if (w <= 0 || h <= 0)
|
2011-10-24 21:24:37 +02:00
|
|
|
return DD_OK;
|
|
|
|
|
2021-01-19 14:34:55 +01:00
|
|
|
/* The interaction between ddraw and GDI drawing is not all that well
|
|
|
|
* documented, and somewhat arcane. In ddraw exclusive mode, GDI draws
|
|
|
|
* seemingly go to the *original* frontbuffer/primary surface, while ddraw
|
|
|
|
* draws/flips go to the *current* frontbuffer surface. The bottom line is
|
|
|
|
* that if the current frontbuffer is not the GDI frontbuffer, and there's
|
|
|
|
* e.g. a popup window in front of the ddraw swapchain window, we can't
|
|
|
|
* use wined3d_swapchain_present() to get the ddraw contents to the screen
|
|
|
|
* while in exclusive mode, since it would get obscured by the popup
|
|
|
|
* window. On the other hand, if the current frontbuffer *is* the GDI
|
|
|
|
* frontbuffer, that's what's supposed to happen; the popup should obscure
|
2021-12-10 20:03:42 +01:00
|
|
|
* (part of) the ddraw swapchain window.
|
2021-01-19 14:34:55 +01:00
|
|
|
*
|
|
|
|
* This affects the "Deer Hunter" demo, which uses a popup window and GDI
|
|
|
|
* draws to draw part of the user interface. See also the "fswindow"
|
|
|
|
* sample is the DirectX 7 SDK. */
|
|
|
|
if (ddraw->swapchain_window && (!(ddraw->cooperative_level & DDSCL_EXCLUSIVE)
|
|
|
|
|| ddraw->swapchain_window == GetForegroundWindow() || ddraw_gdi_is_front(ddraw)))
|
2011-10-24 21:24:38 +02:00
|
|
|
{
|
|
|
|
/* Nothing to do, we control the frontbuffer, or at least the parts we
|
|
|
|
* care about. */
|
|
|
|
if (read)
|
|
|
|
return DD_OK;
|
|
|
|
|
2018-03-27 13:06:52 +02:00
|
|
|
if (swap_interval)
|
2021-01-19 14:34:55 +01:00
|
|
|
dst_texture = wined3d_swapchain_get_back_buffer(ddraw->wined3d_swapchain, 0);
|
2018-03-27 13:06:52 +02:00
|
|
|
else
|
2021-01-19 14:34:55 +01:00
|
|
|
dst_texture = ddraw->wined3d_frontbuffer;
|
2018-03-27 13:06:52 +02:00
|
|
|
|
2021-04-07 03:56:44 +02:00
|
|
|
if (SUCCEEDED(hr = wined3d_device_context_blt(ddraw->immediate_context, dst_texture, 0, rect,
|
2021-03-11 14:34:02 +01:00
|
|
|
ddraw_surface_get_any_texture(surface, DDRAW_SURFACE_READ), surface->sub_resource_idx, rect, 0,
|
2021-03-11 14:34:01 +01:00
|
|
|
NULL, WINED3D_TEXF_POINT)) && swap_interval)
|
2018-03-30 14:51:11 +02:00
|
|
|
{
|
2021-01-19 14:34:55 +01:00
|
|
|
hr = wined3d_swapchain_present(ddraw->wined3d_swapchain, rect, rect, NULL, swap_interval, 0);
|
|
|
|
ddraw->flags |= DDRAW_SWAPPED;
|
2018-03-30 14:51:11 +02:00
|
|
|
}
|
2018-03-27 13:06:52 +02:00
|
|
|
return hr;
|
2011-10-24 21:24:38 +02:00
|
|
|
}
|
|
|
|
|
2021-03-11 14:34:01 +01:00
|
|
|
wined3d_texture = ddraw_surface_get_default_texture(surface, read ? (rect ? DDRAW_SURFACE_RW : DDRAW_SURFACE_WRITE)
|
|
|
|
: DDRAW_SURFACE_READ);
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_texture_get_dc(wined3d_texture, surface->sub_resource_idx, &surface_dc)))
|
2011-10-24 21:24:38 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to get surface DC, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2015-03-20 12:47:10 +01:00
|
|
|
if (surface->palette)
|
2016-08-26 13:51:21 +02:00
|
|
|
wined3d_palette_apply_to_dc(surface->palette->wined3d_palette, surface_dc);
|
2011-10-24 21:24:38 +02:00
|
|
|
|
|
|
|
if (!(screen_dc = GetDC(NULL)))
|
|
|
|
{
|
2021-03-11 14:34:01 +01:00
|
|
|
wined3d_texture_release_dc(wined3d_texture, surface->sub_resource_idx, surface_dc);
|
2011-10-24 21:24:38 +02:00
|
|
|
ERR("Failed to get screen DC.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read)
|
|
|
|
ret = BitBlt(surface_dc, x, y, w, h,
|
|
|
|
screen_dc, x, y, SRCCOPY);
|
|
|
|
else
|
|
|
|
ret = BitBlt(screen_dc, x, y, w, h,
|
|
|
|
surface_dc, x, y, SRCCOPY);
|
|
|
|
|
|
|
|
ReleaseDC(NULL, screen_dc);
|
2021-03-11 14:34:01 +01:00
|
|
|
wined3d_texture_release_dc(wined3d_texture, surface->sub_resource_idx, surface_dc);
|
2011-10-24 21:24:38 +02:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ERR("Failed to blit to/from screen.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
2011-09-15 20:01:51 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
2006-06-23 18:18:02 +02:00
|
|
|
* IUnknown parts follow
|
2006-06-09 19:36:12 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::QueryInterface
|
|
|
|
*
|
|
|
|
* A normal QueryInterface implementation. For QueryInterface rules
|
|
|
|
* see ddraw.c, IDirectDraw7::QueryInterface. This method
|
|
|
|
* can Query IDirectDrawSurface interfaces in all version, IDirect3DTexture
|
|
|
|
* in all versions, the IDirectDrawGammaControl interface and it can
|
|
|
|
* create an IDirect3DDevice. (Uses IDirect3D7::CreateDevice)
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* riid: The interface id queried for
|
|
|
|
* obj: Address to write the pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* S_OK on success
|
|
|
|
* E_NOINTERFACE if the requested interface wasn't found
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_QueryInterface(IDirectDrawSurface7 *iface, REFIID riid, void **obj)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if(!riid)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2012-03-30 01:08:36 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawSurface7))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface7_AddRef(iface);
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) returning IDirectDrawSurface7 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-30 01:08:34 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawSurface4))
|
2011-06-06 13:39:04 +02:00
|
|
|
{
|
2011-06-28 01:34:23 +02:00
|
|
|
IDirectDrawSurface4_AddRef(&This->IDirectDrawSurface4_iface);
|
2011-06-06 13:39:04 +02:00
|
|
|
*obj = &This->IDirectDrawSurface4_iface;
|
|
|
|
TRACE("(%p) returning IDirectDrawSurface4 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-30 01:08:34 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawSurface3))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-20 22:51:01 +02:00
|
|
|
IDirectDrawSurface3_AddRef(&This->IDirectDrawSurface3_iface);
|
2011-05-31 13:57:04 +02:00
|
|
|
*obj = &This->IDirectDrawSurface3_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) returning IDirectDrawSurface3 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-30 01:08:34 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawSurface2))
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
2011-06-19 16:24:32 +02:00
|
|
|
IDirectDrawSurface2_AddRef(&This->IDirectDrawSurface2_iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
*obj = &This->IDirectDrawSurface2_iface;
|
|
|
|
TRACE("(%p) returning IDirectDrawSurface2 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-30 01:08:34 +02:00
|
|
|
|
2012-03-30 01:08:36 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawSurface)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
2011-06-09 17:29:36 +02:00
|
|
|
{
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(&This->IDirectDrawSurface_iface);
|
2011-06-09 17:29:36 +02:00
|
|
|
*obj = &This->IDirectDrawSurface_iface;
|
|
|
|
TRACE("(%p) returning IDirectDrawSurface interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-30 01:08:34 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawGammaControl))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-28 01:53:17 +02:00
|
|
|
IDirectDrawGammaControl_AddRef(&This->IDirectDrawGammaControl_iface);
|
2011-06-08 17:23:17 +02:00
|
|
|
*obj = &This->IDirectDrawGammaControl_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) returning IDirectDrawGammaControl interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-03-30 01:08:34 +02:00
|
|
|
|
2012-04-01 13:12:01 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IDirectDrawColorControl))
|
|
|
|
{
|
|
|
|
WARN("Color control not implemented.\n");
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-04-02 22:42:19 +02:00
|
|
|
if (This->version != 7)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-04-02 22:42:19 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_D3DDEVICE_WineD3D)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3DHALDevice)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3DRGBDevice))
|
2010-07-18 23:26:33 +02:00
|
|
|
{
|
2012-04-03 21:15:12 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-04-05 19:55:35 +02:00
|
|
|
if (!This->device1)
|
2012-04-02 22:42:19 +02:00
|
|
|
{
|
2013-09-17 09:22:36 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-03-11 14:33:53 +01:00
|
|
|
if (FAILED(hr = d3d_device_create(This->ddraw, riid, This, (IUnknown *)&This->IDirectDrawSurface_iface,
|
2013-09-17 09:22:36 +02:00
|
|
|
1, &This->device1, (IUnknown *)&This->IDirectDrawSurface_iface)))
|
2012-04-05 19:55:35 +02:00
|
|
|
{
|
|
|
|
This->device1 = NULL;
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
WARN("Failed to create device, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2012-04-02 22:42:19 +02:00
|
|
|
}
|
2012-04-05 19:55:35 +02:00
|
|
|
wined3d_mutex_unlock();
|
2012-04-02 22:42:19 +02:00
|
|
|
|
2012-04-05 19:55:35 +02:00
|
|
|
IDirect3DDevice_AddRef(&This->device1->IDirect3DDevice_iface);
|
|
|
|
*obj = &This->device1->IDirect3DDevice_iface;
|
2010-07-18 23:26:33 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-04-01 13:12:02 +02:00
|
|
|
if (IsEqualGUID(&IID_IDirect3DTexture2, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-04-01 13:12:02 +02:00
|
|
|
IDirect3DTexture2_AddRef(&This->IDirect3DTexture2_iface);
|
|
|
|
*obj = &This->IDirect3DTexture2_iface;
|
|
|
|
return S_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2012-04-01 13:12:02 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID( &IID_IDirect3DTexture, riid ))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-04-01 13:12:02 +02:00
|
|
|
IDirect3DTexture2_AddRef(&This->IDirect3DTexture_iface);
|
|
|
|
*obj = &This->IDirect3DTexture_iface;
|
|
|
|
return S_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:08:35 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
2012-04-02 22:42:20 +02:00
|
|
|
if (This->version != 7)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_QueryInterface(IDirectDrawSurface4 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_QueryInterface(IDirectDrawSurface3 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_QueryInterface(IDirectDrawSurface2 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_QueryInterface(IDirectDrawSurface *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2011-06-08 17:23:17 +02:00
|
|
|
static HRESULT WINAPI ddraw_gamma_control_QueryInterface(IDirectDrawGammaControl *iface,
|
|
|
|
REFIID riid, void **object)
|
2010-08-18 19:26:18 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawGammaControl(iface);
|
2011-06-08 17:23:17 +02:00
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
static HRESULT WINAPI d3d_texture2_QueryInterface(IDirect3DTexture2 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture2(iface);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_QueryInterface(IDirect3DTexture *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture(iface);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_QueryInterface(&surface->IDirectDrawSurface7_iface, riid, object);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2012-10-01 11:05:23 +02:00
|
|
|
static void ddraw_surface_add_iface(struct ddraw_surface *surface)
|
2011-06-19 12:18:22 +02:00
|
|
|
{
|
2012-10-01 11:05:23 +02:00
|
|
|
ULONG iface_count = InterlockedIncrement(&surface->iface_count);
|
|
|
|
TRACE("%p increasing iface count to %u.\n", surface, iface_count);
|
2011-06-19 12:18:22 +02:00
|
|
|
|
|
|
|
if (iface_count == 1)
|
|
|
|
{
|
2012-10-01 11:05:23 +02:00
|
|
|
if (surface->ifaceToRelease)
|
|
|
|
IUnknown_AddRef(surface->ifaceToRelease);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2014-08-21 09:55:55 +02:00
|
|
|
if (surface->wined3d_rtv)
|
|
|
|
wined3d_rendertarget_view_incref(surface->wined3d_rtv);
|
2021-03-11 14:33:55 +01:00
|
|
|
wined3d_texture_incref(surface->draw_texture ? surface->draw_texture : surface->wined3d_texture);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2011-06-19 12:18:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::AddRef
|
|
|
|
*
|
|
|
|
* A normal addref implementation
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface7_AddRef(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref7);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
if (refcount == 1)
|
2009-09-16 08:37:15 +02:00
|
|
|
{
|
2011-06-19 12:18:22 +02:00
|
|
|
ddraw_surface_add_iface(This);
|
2009-09-16 08:37:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
return refcount;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static ULONG WINAPI ddraw_surface4_AddRef(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface4(iface);
|
2011-06-28 01:34:23 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref4);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
2011-06-28 01:34:23 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface3_AddRef(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface3(iface);
|
2011-06-20 22:51:01 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref3);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2011-06-20 22:51:01 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static ULONG WINAPI ddraw_surface2_AddRef(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface2(iface);
|
2011-06-19 16:24:32 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref2);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
2011-06-19 16:24:32 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static ULONG WINAPI ddraw_surface1_AddRef(IDirectDrawSurface *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref1);
|
2011-06-09 17:29:36 +02:00
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
static ULONG WINAPI ddraw_gamma_control_AddRef(IDirectDrawGammaControl *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawGammaControl(iface);
|
2011-06-28 01:53:17 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->gamma_count);
|
2011-06-08 17:23:17 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
2010-08-18 19:26:18 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
return refcount;
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
static ULONG WINAPI d3d_texture2_AddRef(IDirect3DTexture2 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture2(iface);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-04-01 13:12:03 +02:00
|
|
|
return IUnknown_AddRef(surface->texture_outer);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d_texture1_AddRef(IDirect3DTexture *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture(iface);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-04-01 13:12:03 +02:00
|
|
|
return IUnknown_AddRef(surface->texture_outer);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 16:44:23 +02:00
|
|
|
static HRESULT ddraw_surface_set_palette(struct ddraw_surface *surface, IDirectDrawPalette *palette)
|
2014-04-24 14:36:09 +02:00
|
|
|
{
|
|
|
|
struct ddraw_palette *palette_impl = unsafe_impl_from_IDirectDrawPalette(palette);
|
|
|
|
struct ddraw_palette *prev;
|
|
|
|
|
|
|
|
TRACE("iface %p, palette %p.\n", surface, palette);
|
|
|
|
|
2014-05-07 15:16:37 +02:00
|
|
|
if (palette_impl && palette_impl->flags & DDPCAPS_ALPHA
|
|
|
|
&& !(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
|
|
|
{
|
|
|
|
WARN("Alpha palette set on non-texture surface, returning DDERR_INVALIDSURFACETYPE.\n");
|
|
|
|
return DDERR_INVALIDSURFACETYPE;
|
|
|
|
}
|
|
|
|
|
2014-05-15 16:13:31 +02:00
|
|
|
if (!format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat))
|
2014-04-24 14:36:09 +02:00
|
|
|
return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
|
|
|
prev = surface->palette;
|
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
if (prev)
|
|
|
|
prev->flags &= ~DDPCAPS_PRIMARYSURFACE;
|
|
|
|
if (palette_impl)
|
|
|
|
palette_impl->flags |= DDPCAPS_PRIMARYSURFACE;
|
2014-06-28 10:49:32 +02:00
|
|
|
wined3d_swapchain_set_palette(surface->ddraw->wined3d_swapchain,
|
2016-08-26 13:51:21 +02:00
|
|
|
palette_impl ? palette_impl->wined3d_palette : NULL);
|
2018-03-27 13:06:52 +02:00
|
|
|
ddraw_surface_update_frontbuffer(surface, NULL, FALSE, 0);
|
2014-04-24 14:36:09 +02:00
|
|
|
}
|
|
|
|
if (palette_impl)
|
|
|
|
IDirectDrawPalette_AddRef(&palette_impl->IDirectDrawPalette_iface);
|
|
|
|
if (prev)
|
|
|
|
IDirectDrawPalette_Release(&prev->IDirectDrawPalette_iface);
|
|
|
|
surface->palette = palette_impl;
|
|
|
|
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
static void ddraw_surface_cleanup(struct ddraw_surface *surface)
|
2011-04-20 22:09:24 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surf;
|
2011-04-20 22:09:24 +02:00
|
|
|
UINT i;
|
|
|
|
|
|
|
|
TRACE("surface %p.\n", surface);
|
|
|
|
|
2011-09-19 21:50:24 +02:00
|
|
|
/* The refcount test shows that the palette is detached when the surface
|
|
|
|
* is destroyed. */
|
2014-04-24 14:36:09 +02:00
|
|
|
ddraw_surface_set_palette(surface, NULL);
|
2011-09-19 21:50:24 +02:00
|
|
|
|
|
|
|
/* Loop through all complex attached surfaces and destroy them.
|
|
|
|
*
|
|
|
|
* Yet again, only the root can have more than one complexly attached
|
|
|
|
* surface, all the others have a total of one. */
|
|
|
|
for (i = 0; i < MAX_COMPLEX_ATTACHED; ++i)
|
2011-04-20 22:09:24 +02:00
|
|
|
{
|
2011-09-19 21:50:24 +02:00
|
|
|
if (!surface->complex_array[i])
|
|
|
|
break;
|
2011-04-20 22:09:24 +02:00
|
|
|
|
2011-09-19 21:50:24 +02:00
|
|
|
surf = surface->complex_array[i];
|
|
|
|
surface->complex_array[i] = NULL;
|
2013-12-04 09:49:34 +01:00
|
|
|
if (!surf->is_complex_root)
|
2018-08-21 22:01:40 +02:00
|
|
|
{
|
|
|
|
struct ddraw_texture *texture = wined3d_texture_get_parent(surf->wined3d_texture);
|
|
|
|
struct wined3d_device *wined3d_device = texture->wined3d_device;
|
|
|
|
struct ddraw_surface *root = texture->root;
|
|
|
|
|
2013-12-04 09:49:34 +01:00
|
|
|
ddraw_surface_cleanup(surf);
|
2018-08-21 22:01:40 +02:00
|
|
|
|
|
|
|
if (surf == root)
|
|
|
|
wined3d_device_decref(wined3d_device);
|
|
|
|
}
|
2011-09-19 21:50:24 +02:00
|
|
|
}
|
|
|
|
|
2012-04-05 19:55:35 +02:00
|
|
|
if (surface->device1)
|
|
|
|
IUnknown_Release(&surface->device1->IUnknown_inner);
|
2011-04-20 22:09:24 +02:00
|
|
|
|
2012-06-13 18:23:35 +02:00
|
|
|
if (surface->iface_count > 1)
|
|
|
|
{
|
|
|
|
/* This can happen when a complex surface is destroyed, because the
|
|
|
|
* 2nd surface was addref()ed when the app called
|
|
|
|
* GetAttachedSurface(). */
|
|
|
|
WARN("Destroying surface %p with refcounts 7: %u 4: %u 3: %u 2: %u 1: %u.\n",
|
|
|
|
surface, surface->ref7, surface->ref4, surface->ref3, surface->ref2, surface->ref1);
|
|
|
|
}
|
|
|
|
|
2014-08-21 09:55:55 +02:00
|
|
|
if (surface->wined3d_rtv)
|
|
|
|
wined3d_rendertarget_view_decref(surface->wined3d_rtv);
|
2021-03-11 14:33:55 +01:00
|
|
|
wined3d_texture_decref(surface->draw_texture ? surface->draw_texture : surface->wined3d_texture);
|
2011-04-20 22:09:24 +02:00
|
|
|
}
|
|
|
|
|
2017-03-24 03:43:45 +01:00
|
|
|
static ULONG ddraw_surface_release_iface(struct ddraw_surface *This)
|
2011-06-19 12:18:22 +02:00
|
|
|
{
|
2016-03-15 16:55:09 +01:00
|
|
|
ULONG iface_count;
|
|
|
|
|
|
|
|
/* Prevent the surface from being destroyed if it's still attached to
|
|
|
|
* another surface. It will be destroyed when the root is destroyed. */
|
|
|
|
if (This->iface_count == 1 && This->attached_iface)
|
|
|
|
IUnknown_AddRef(This->attached_iface);
|
|
|
|
iface_count = InterlockedDecrement(&This->iface_count);
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
TRACE("%p decreasing iface count to %u.\n", This, iface_count);
|
|
|
|
|
|
|
|
if (iface_count == 0)
|
|
|
|
{
|
2017-01-04 00:04:47 +01:00
|
|
|
struct ddraw_texture *texture = wined3d_texture_get_parent(This->wined3d_texture);
|
|
|
|
struct wined3d_device *wined3d_device = texture->wined3d_device;
|
2012-10-01 11:05:23 +02:00
|
|
|
IUnknown *release_iface = This->ifaceToRelease;
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
/* Complex attached surfaces are destroyed implicitly when the root is released */
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2011-06-19 12:18:22 +02:00
|
|
|
if(!This->is_complex_root)
|
|
|
|
{
|
|
|
|
WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2011-06-28 00:06:16 +02:00
|
|
|
return iface_count;
|
2011-06-19 12:18:22 +02:00
|
|
|
}
|
2013-11-15 08:24:33 +01:00
|
|
|
ddraw_surface_cleanup(This);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2012-10-01 11:05:23 +02:00
|
|
|
|
|
|
|
if (release_iface)
|
|
|
|
IUnknown_Release(release_iface);
|
2017-01-04 00:04:47 +01:00
|
|
|
/* Release the device only after anything that may reference it (the
|
|
|
|
* wined3d texture and rendertarget view in particular) is released. */
|
|
|
|
wined3d_device_decref(wined3d_device);
|
2011-06-19 12:18:22 +02:00
|
|
|
}
|
|
|
|
|
2011-06-28 00:06:16 +02:00
|
|
|
return iface_count;
|
2011-06-19 12:18:22 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Release
|
|
|
|
*
|
|
|
|
* Reduces the surface's refcount by 1. If the refcount falls to 0, the
|
|
|
|
* surface is destroyed.
|
|
|
|
*
|
|
|
|
* Destroying the surface is a bit tricky. For the connection between
|
|
|
|
* WineD3DSurfaces and DirectDrawSurfaces see IDirectDraw7::CreateSurface
|
|
|
|
* It has a nice graph explaining the connection.
|
|
|
|
*
|
|
|
|
* What happens here is basically this:
|
2006-06-23 18:18:02 +02:00
|
|
|
* When a surface is destroyed, its WineD3DSurface is released,
|
2006-06-09 19:36:12 +02:00
|
|
|
* and the refcount of the DirectDraw interface is reduced by 1. If it has
|
|
|
|
* complex surfaces attached to it, then these surfaces are destroyed too,
|
2006-06-23 18:18:02 +02:00
|
|
|
* regardless of their refcount. If any surface being destroyed has another
|
|
|
|
* surface attached to it (with a "soft" attachment, not complex), then
|
2006-06-09 19:36:12 +02:00
|
|
|
* this surface is detached with DeleteAttachedSurface.
|
|
|
|
*
|
|
|
|
* When the surface is a texture, the WineD3DTexture is released.
|
|
|
|
* If the surface is the Direct3D render target, then the D3D
|
2006-06-23 18:18:02 +02:00
|
|
|
* capabilities of the WineD3DDevice are uninitialized, which causes the
|
2006-06-09 19:36:12 +02:00
|
|
|
* swapchain to be released.
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* When a complex sublevel falls to ref zero, then this is ignored.
|
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref7);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
if (refcount == 0)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-19 12:18:22 +02:00
|
|
|
ddraw_surface_release_iface(This);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
return refcount;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static ULONG WINAPI ddraw_surface4_Release(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface4(iface);
|
2011-06-28 01:34:23 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref4);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
2011-06-28 01:34:23 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface3_Release(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface3(iface);
|
2011-06-20 22:51:01 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref3);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2011-06-20 22:51:01 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static ULONG WINAPI ddraw_surface2_Release(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface2(iface);
|
2011-06-19 16:24:32 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref2);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
2011-06-19 16:24:32 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static ULONG WINAPI ddraw_surface1_Release(IDirectDrawSurface *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref1);
|
2011-06-09 17:29:36 +02:00
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
static ULONG WINAPI ddraw_gamma_control_Release(IDirectDrawGammaControl *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawGammaControl(iface);
|
2011-06-28 01:53:17 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->gamma_count);
|
2011-06-08 17:23:17 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
2010-08-18 19:26:18 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
return refcount;
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
static ULONG WINAPI d3d_texture2_Release(IDirect3DTexture2 *iface)
|
|
|
|
{
|
2012-04-01 13:12:03 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture2(iface);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-04-01 13:12:03 +02:00
|
|
|
return IUnknown_Release(surface->texture_outer);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d_texture1_Release(IDirect3DTexture *iface)
|
|
|
|
{
|
2012-04-01 13:12:03 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture(iface);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-04-01 13:12:03 +02:00
|
|
|
return IUnknown_Release(surface->texture_outer);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetAttachedSurface
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Returns an attached surface with the requested caps. Surface attachment
|
2006-06-09 19:36:12 +02:00
|
|
|
* and complex surfaces are not clearly described by the MSDN or sdk,
|
|
|
|
* so this method is tricky and likely to contain problems.
|
2007-04-27 15:31:12 +02:00
|
|
|
* This implementation searches the complex list first, then the
|
|
|
|
* attachment chain.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* The chains are searched from This down to the last surface in the chain,
|
|
|
|
* not from the first element in the chain. The first surface found is
|
|
|
|
* returned. The MSDN says that this method fails if more than one surface
|
2007-04-27 15:31:12 +02:00
|
|
|
* matches the caps, but it is not sure if that is right. The attachment
|
|
|
|
* structure may not even allow two matching surfaces.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* The found surface is AddRef-ed before it is returned.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Caps: Pointer to a DDCAPS2 structure describing the caps asked for
|
|
|
|
* Surface: Address to store the found surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Caps or Surface is NULL
|
|
|
|
* DDERR_NOTFOUND if no surface was found
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *iface,
|
2019-08-05 20:58:31 +02:00
|
|
|
DDSCAPS2 *caps, IDirectDrawSurface7 **surface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2019-08-05 20:58:31 +02:00
|
|
|
struct ddraw_surface *head_surface = impl_from_IDirectDrawSurface7(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surf;
|
2006-06-09 19:36:12 +02:00
|
|
|
DDSCAPS2 our_caps;
|
2007-04-27 15:31:12 +02:00
|
|
|
int i;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, surface);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(head_surface))
|
2019-08-05 20:58:31 +02:00
|
|
|
{
|
|
|
|
WARN("Surface %p is lost.\n", head_surface);
|
|
|
|
|
|
|
|
*surface = NULL;
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
if(head_surface->version < 7)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/* Earlier dx apps put garbage into these members, clear them */
|
2019-08-05 20:58:31 +02:00
|
|
|
our_caps.dwCaps = caps->dwCaps;
|
2006-06-09 19:36:12 +02:00
|
|
|
our_caps.dwCaps2 = 0;
|
|
|
|
our_caps.dwCaps3 = 0;
|
2015-02-28 09:22:59 +01:00
|
|
|
our_caps.u1.dwCaps4 = 0;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2008-12-25 02:01:02 +01:00
|
|
|
else
|
|
|
|
{
|
2019-08-05 20:58:31 +02:00
|
|
|
our_caps = *caps;
|
2008-12-25 02:01:02 +01:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("head_surface %p, looking for caps %#x, %#x, %#x, %#x.\n", head_surface, our_caps.dwCaps,
|
|
|
|
our_caps.dwCaps2, our_caps.dwCaps3, our_caps.u1.dwCaps4); /* FIXME: Better debugging */
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-04-27 15:31:12 +02:00
|
|
|
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2019-08-05 20:58:31 +02:00
|
|
|
surf = head_surface->complex_array[i];
|
2007-04-27 15:31:12 +02:00
|
|
|
if(!surf) break;
|
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("Surface %p, caps %#x, %#x, %#x, %#x.\n", surf,
|
2012-07-13 12:53:08 +02:00
|
|
|
surf->surface_desc.ddsCaps.dwCaps,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps2,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps3,
|
2015-02-28 09:22:59 +01:00
|
|
|
surf->surface_desc.ddsCaps.u1.dwCaps4);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
|
|
|
|
((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
|
|
|
|
|
|
|
|
/* MSDN: "This method fails if more than one surface is attached
|
|
|
|
* that matches the capabilities requested."
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* Not sure how to test this.
|
2006-06-09 19:36:12 +02:00
|
|
|
*/
|
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("head_surface %p, returning surface %p.\n", head_surface, surf);
|
|
|
|
*surface = &surf->IDirectDrawSurface7_iface;
|
|
|
|
ddraw_surface7_AddRef(*surface);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Next, look at the attachment chain */
|
2019-08-05 20:58:31 +02:00
|
|
|
surf = head_surface;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
while( (surf = surf->next_attached) )
|
|
|
|
{
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("Surface %p, caps %#x, %#x, %#x, %#x.\n", surf,
|
2012-07-13 12:53:08 +02:00
|
|
|
surf->surface_desc.ddsCaps.dwCaps,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps2,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps3,
|
2015-02-28 09:22:59 +01:00
|
|
|
surf->surface_desc.ddsCaps.u1.dwCaps4);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
|
|
|
|
((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
|
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("head_surface %p, returning surface %p.\n", head_surface, surf);
|
|
|
|
*surface = &surf->IDirectDrawSurface7_iface;
|
|
|
|
ddraw_surface7_AddRef(*surface);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
TRACE("head_surface %p, didn't find a valid surface.\n", head_surface);
|
2011-11-13 19:52:24 +01:00
|
|
|
|
|
|
|
wined3d_mutex_unlock();
|
2008-04-02 23:11:43 +02:00
|
|
|
|
2019-08-05 20:58:31 +02:00
|
|
|
*surface = NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetAttachedSurface(IDirectDrawSurface4 *iface,
|
|
|
|
DDSCAPS2 *caps, IDirectDrawSurface4 **attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct ddraw_surface *attachment_impl;
|
2011-06-06 13:39:04 +02:00
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surface->IDirectDrawSurface7_iface,
|
2011-06-06 13:39:04 +02:00
|
|
|
caps, &attachment7);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface4_iface;
|
2011-06-28 01:34:23 +02:00
|
|
|
ddraw_surface4_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetAttachedSurface(IDirectDrawSurface3 *iface,
|
|
|
|
DDSCAPS *caps, IDirectDrawSurface3 **attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
struct ddraw_surface *attachment_impl;
|
2010-07-19 18:36:20 +02:00
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
caps2.dwCaps = caps->dwCaps;
|
|
|
|
caps2.dwCaps2 = 0;
|
|
|
|
caps2.dwCaps3 = 0;
|
2015-02-28 09:22:59 +01:00
|
|
|
caps2.u1.dwCaps4 = 0;
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surface->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
&caps2, &attachment7);
|
2011-06-06 12:08:56 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
2011-06-06 12:57:55 +02:00
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
2011-06-06 12:08:56 +02:00
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface3_iface;
|
2011-06-20 22:51:01 +02:00
|
|
|
ddraw_surface3_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetAttachedSurface(IDirectDrawSurface2 *iface,
|
|
|
|
DDSCAPS *caps, IDirectDrawSurface2 **attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct ddraw_surface *attachment_impl;
|
2011-06-09 16:35:15 +02:00
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
caps2.dwCaps = caps->dwCaps;
|
|
|
|
caps2.dwCaps2 = 0;
|
|
|
|
caps2.dwCaps3 = 0;
|
2015-02-28 09:22:59 +01:00
|
|
|
caps2.u1.dwCaps4 = 0;
|
2011-06-09 16:35:15 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surface->IDirectDrawSurface7_iface,
|
2011-06-09 16:35:15 +02:00
|
|
|
&caps2, &attachment7);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface2_iface;
|
2011-06-19 16:24:32 +02:00
|
|
|
ddraw_surface2_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *iface,
|
|
|
|
DDSCAPS *caps, IDirectDrawSurface **attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *attachment_impl;
|
2011-06-09 17:29:36 +02:00
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
caps2.dwCaps = caps->dwCaps;
|
|
|
|
caps2.dwCaps2 = 0;
|
|
|
|
caps2.dwCaps3 = 0;
|
2015-02-28 09:22:59 +01:00
|
|
|
caps2.u1.dwCaps4 = 0;
|
2011-06-09 17:29:36 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surface->IDirectDrawSurface7_iface,
|
2011-06-09 17:29:36 +02:00
|
|
|
&caps2, &attachment7);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
ddraw_surface1_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2011-06-09 17:29:36 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Lock
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Locks the surface and returns a pointer to the surface's memory
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Rect: Rectangle to lock. If NULL, the whole surface is locked
|
|
|
|
* DDSD: Pointer to a DDSURFACEDESC2 which shall receive the surface's desc.
|
|
|
|
* Flags: Locking flags, e.g Read only or write only
|
|
|
|
* h: An event handle that's not used and must be NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DDSD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2016-02-02 19:23:29 +01:00
|
|
|
static HRESULT surface_lock(struct ddraw_surface *surface,
|
2017-01-17 12:26:37 +01:00
|
|
|
RECT *rect, DDSURFACEDESC2 *surface_desc, unsigned int surface_desc_size,
|
|
|
|
DWORD flags, HANDLE h)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-04-12 22:49:04 +02:00
|
|
|
struct wined3d_map_desc map_desc;
|
2021-03-26 11:56:22 +01:00
|
|
|
unsigned int wined3d_flags;
|
2017-01-17 12:26:37 +01:00
|
|
|
struct wined3d_box box;
|
2011-10-24 21:24:38 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
TRACE("surface %p, rect %s, surface_desc %p, surface_desc_size %u, flags %#x, h %p.\n",
|
|
|
|
surface, wine_dbgstr_rect(rect), surface_desc, surface_desc_size, flags, h);
|
2007-05-30 15:25:34 +02:00
|
|
|
|
2016-02-02 19:23:29 +01:00
|
|
|
/* surface->surface_desc.dwWidth and dwHeight are changeable, thus lock */
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2007-05-03 20:58:48 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Should I check for the handle to be NULL?
|
|
|
|
*
|
|
|
|
* The DDLOCK flags and the D3DLOCK flags are equal
|
|
|
|
* for the supported values. The others are ignored by WineD3D
|
|
|
|
*/
|
|
|
|
|
2008-02-25 16:22:41 +01:00
|
|
|
/* Windows zeroes this if the rect is invalid */
|
2016-02-02 19:23:29 +01:00
|
|
|
surface_desc->lpSurface = NULL;
|
2008-02-25 16:22:41 +01:00
|
|
|
|
2016-02-02 19:23:29 +01:00
|
|
|
if (rect)
|
2008-02-25 16:22:41 +01:00
|
|
|
{
|
2016-02-02 19:23:29 +01:00
|
|
|
if ((rect->left < 0) || (rect->top < 0)
|
|
|
|
|| (rect->left > rect->right) || (rect->right > surface->surface_desc.dwWidth)
|
|
|
|
|| (rect->top > rect->bottom) || (rect->bottom > surface->surface_desc.dwHeight))
|
2008-02-25 16:22:41 +01:00
|
|
|
{
|
|
|
|
WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2008-02-25 16:22:41 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2017-04-06 23:44:30 +02:00
|
|
|
wined3d_box_set(&box, rect->left, rect->top, rect->right, rect->bottom, 0, 1);
|
2008-02-25 16:22:41 +01:00
|
|
|
}
|
|
|
|
|
2016-02-02 19:23:29 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE, 0);
|
2011-10-24 21:24:38 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2021-03-26 11:56:22 +01:00
|
|
|
{
|
|
|
|
wined3d_flags = wined3dmapflags_from_ddrawmapflags(flags);
|
2021-03-11 14:34:01 +01:00
|
|
|
hr = wined3d_resource_map(wined3d_texture_get_resource
|
2021-03-26 11:56:22 +01:00
|
|
|
(ddraw_surface_get_default_texture(surface, wined3d_flags & WINED3D_MAP_WRITE ? DDRAW_SURFACE_RW
|
|
|
|
: DDRAW_SURFACE_READ)), surface->sub_resource_idx, &map_desc, rect ? &box : NULL, wined3d_flags);
|
|
|
|
}
|
2010-10-14 13:04:02 +02:00
|
|
|
if (FAILED(hr))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-08-24 23:51:14 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
/* D3D8 and D3D9 return the general D3DERR_INVALIDCALL error, but ddraw has a more
|
2017-03-05 18:59:47 +01:00
|
|
|
* specific error. But since wined3d returns that error in this only occasion,
|
|
|
|
* keep d3d8 and d3d9 free from the return value override. There are many different
|
|
|
|
* places where d3d8/9 would have to catch the DDERR_SURFACEBUSY, it is much easier
|
|
|
|
* to do it in one place in ddraw.
|
2007-08-24 23:51:14 +02:00
|
|
|
*/
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_SURFACEBUSY;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2016-02-02 19:23:29 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2011-10-27 17:06:24 +02:00
|
|
|
{
|
2016-02-02 19:23:29 +01:00
|
|
|
if (flags & DDLOCK_READONLY)
|
2016-07-30 22:07:45 +02:00
|
|
|
SetRectEmpty(&surface->ddraw->primary_lock);
|
2016-02-02 19:23:29 +01:00
|
|
|
else if (rect)
|
|
|
|
surface->ddraw->primary_lock = *rect;
|
2011-10-27 17:06:24 +02:00
|
|
|
else
|
2016-02-02 19:23:29 +01:00
|
|
|
SetRect(&surface->ddraw->primary_lock, 0, 0, surface->surface_desc.dwWidth, surface->surface_desc.dwHeight);
|
2011-10-27 17:06:24 +02:00
|
|
|
}
|
2011-10-24 21:24:37 +02:00
|
|
|
|
2014-08-19 14:20:29 +02:00
|
|
|
/* Windows does not set DDSD_LPSURFACE on locked surfaces. */
|
2017-01-17 12:26:37 +01:00
|
|
|
DD_STRUCT_COPY_BYSIZE_(surface_desc, &surface->surface_desc, surface_desc_size, surface->surface_desc.dwSize);
|
2016-02-02 19:23:29 +01:00
|
|
|
surface_desc->lpSurface = map_desc.data;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
TRACE("locked surface returning description :\n");
|
2016-02-02 19:23:29 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
DDRAW_dump_surface_desc(surface_desc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
static BOOL surface_validate_lock_desc(struct ddraw_surface *surface,
|
|
|
|
const DDSURFACEDESC *desc, unsigned int *size)
|
|
|
|
{
|
|
|
|
if (!desc)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (desc->dwSize == sizeof(DDSURFACEDESC) || desc->dwSize == sizeof(DDSURFACEDESC2))
|
|
|
|
{
|
|
|
|
*size = desc->dwSize;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->version == 7
|
|
|
|
&& surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE
|
|
|
|
&& !(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
|
|
|
|
{
|
|
|
|
if (desc->dwSize >= sizeof(DDSURFACEDESC2))
|
|
|
|
*size = sizeof(DDSURFACEDESC2);
|
|
|
|
else
|
|
|
|
*size = sizeof(DDSURFACEDESC);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Invalid structure size %u.\n", desc->dwSize);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-09-04 23:33:52 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Lock(IDirectDrawSurface7 *iface,
|
|
|
|
RECT *rect, DDSURFACEDESC2 *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2017-01-17 12:26:37 +01:00
|
|
|
unsigned int surface_desc_size;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-09-04 23:33:52 +02:00
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
if (!surface_validate_lock_desc(surface, (DDSURFACEDESC *)surface_desc, &surface_desc_size))
|
2011-09-04 23:33:52 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2017-01-17 12:26:37 +01:00
|
|
|
|
2020-03-26 14:09:41 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
|
|
|
{
|
|
|
|
WARN("Surface is lost.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h);
|
2011-09-04 23:33:52 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Lock(IDirectDrawSurface4 *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC2 *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
2017-01-17 12:26:37 +01:00
|
|
|
unsigned int surface_desc_size;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
if (!surface_validate_lock_desc(surface, (DDSURFACEDESC *)surface_desc, &surface_desc_size))
|
2011-09-04 23:33:52 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2017-01-17 12:26:37 +01:00
|
|
|
|
2020-03-26 14:09:41 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
|
|
|
{
|
|
|
|
WARN("Surface is lost.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2020-03-26 14:09:40 +01:00
|
|
|
static HRESULT ddraw_surface_lock_ddsd(struct ddraw_surface *surface, RECT *rect,
|
2010-07-19 18:36:20 +02:00
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
2017-01-17 12:26:37 +01:00
|
|
|
unsigned int surface_desc_size;
|
2011-09-04 23:33:52 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
|
|
|
HRESULT hr;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2017-01-17 12:26:37 +01:00
|
|
|
if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size))
|
2011-09-04 23:33:52 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2020-03-26 14:09:41 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
|
|
|
{
|
|
|
|
WARN("Surface is lost.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2011-09-04 23:33:52 +02:00
|
|
|
surface_desc2.dwSize = surface_desc->dwSize;
|
2011-10-18 20:46:11 +02:00
|
|
|
surface_desc2.dwFlags = 0;
|
2017-01-17 12:26:37 +01:00
|
|
|
hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h);
|
2011-09-04 23:33:52 +02:00
|
|
|
DDSD2_to_DDSD(&surface_desc2, surface_desc);
|
|
|
|
surface_desc->dwSize = surface_desc2.dwSize;
|
|
|
|
return hr;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2020-03-26 14:09:40 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
|
|
|
return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Lock(IDirectDrawSurface2 *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
2020-03-26 14:09:40 +01:00
|
|
|
return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2017-01-17 12:26:37 +01:00
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
2020-03-26 14:09:40 +01:00
|
|
|
return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
/* FRAPS hooks IDirectDrawSurface::Unlock and expects the version 1 method to be called when the
|
|
|
|
* game uses later interfaces. */
|
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Unlock(IDirectDrawSurface *iface, void *data)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2020-08-11 13:50:43 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2007-05-10 21:55:14 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2021-03-11 14:34:01 +01:00
|
|
|
hr = wined3d_resource_unmap(wined3d_texture_get_resource
|
|
|
|
(ddraw_surface_get_default_texture(surface, 0)), surface->sub_resource_idx);
|
2014-08-19 14:20:29 +02:00
|
|
|
if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE, 0);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-10 21:55:14 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *rect)
|
2011-06-06 13:39:04 +02:00
|
|
|
{
|
2020-08-11 13:50:43 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
2011-06-06 13:39:04 +02:00
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, NULL);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Unlock(IDirectDrawSurface4 *iface, RECT *rect)
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
2020-08-11 13:50:43 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, NULL);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *data)
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
2020-08-11 13:50:43 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, data);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Unlock(IDirectDrawSurface2 *iface, void *data)
|
2011-06-09 17:29:36 +02:00
|
|
|
{
|
2020-08-11 13:50:43 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
|
|
|
|
2020-08-11 13:50:43 +02:00
|
|
|
return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, data);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-03-27 13:06:52 +02:00
|
|
|
static unsigned int ddraw_swap_interval_from_flags(DWORD flags)
|
|
|
|
{
|
|
|
|
if (flags & DDFLIP_NOVSYNC)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (flags & (DDFLIP_INTERVAL2 | DDFLIP_INTERVAL3 | DDFLIP_INTERVAL4))
|
|
|
|
{
|
|
|
|
case DDFLIP_INTERVAL2:
|
|
|
|
return 2;
|
|
|
|
case DDFLIP_INTERVAL3:
|
|
|
|
return 3;
|
|
|
|
case DDFLIP_INTERVAL4:
|
|
|
|
return 4;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:44 +02:00
|
|
|
/* FRAPS hooks IDirectDrawSurface::Flip and expects the version 1 method to be called when the
|
|
|
|
* game uses later interfaces. */
|
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Flip(IDirectDrawSurface *iface,
|
|
|
|
IDirectDrawSurface *src, DWORD flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2020-08-11 13:50:44 +02:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src);
|
2020-06-16 18:20:29 +02:00
|
|
|
struct ddraw_texture *dst_ddraw_texture, *src_ddraw_texture;
|
2014-08-21 09:55:55 +02:00
|
|
|
struct wined3d_rendertarget_view *tmp_rtv, *src_rtv, *rtv;
|
2020-08-11 13:50:44 +02:00
|
|
|
DDSCAPS caps = {DDSCAPS_FLIP};
|
2021-03-11 14:33:55 +01:00
|
|
|
struct wined3d_texture *texture, *draw_texture;
|
2020-08-11 13:50:44 +02:00
|
|
|
IDirectDrawSurface *current;
|
2020-06-16 18:20:29 +02:00
|
|
|
void *texture_memory;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2013-12-04 09:49:35 +01:00
|
|
|
TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-12-04 09:49:35 +01:00
|
|
|
if (src == iface || !(dst_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_OVERLAY)))
|
2013-12-03 09:59:19 +01:00
|
|
|
return DDERR_NOTFLIPPABLE;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(dst_impl))
|
2014-07-01 07:52:29 +02:00
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2007-05-30 15:25:34 +02:00
|
|
|
|
2016-04-21 17:05:09 +02:00
|
|
|
if ((dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
&& !(dst_impl->ddraw->cooperative_level & DDSCL_EXCLUSIVE))
|
2015-12-04 11:30:13 +01:00
|
|
|
{
|
|
|
|
WARN("Not in exclusive mode.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOEXCLUSIVEMODE;
|
|
|
|
}
|
|
|
|
|
2014-08-21 09:55:55 +02:00
|
|
|
tmp_rtv = ddraw_surface_get_rendertarget_view(dst_impl);
|
2016-01-29 18:48:56 +01:00
|
|
|
if (dst_impl->sub_resource_idx)
|
|
|
|
ERR("Invalid sub-resource index %u on surface %p.\n", dst_impl->sub_resource_idx, dst_impl);
|
2013-12-05 10:34:17 +01:00
|
|
|
texture = dst_impl->wined3d_texture;
|
2021-04-20 06:38:07 +02:00
|
|
|
rtv = wined3d_device_context_get_rendertarget_view(dst_impl->ddraw->immediate_context, 0);
|
2020-06-16 18:20:29 +02:00
|
|
|
dst_ddraw_texture = wined3d_texture_get_parent(dst_impl->wined3d_texture);
|
|
|
|
texture_memory = dst_ddraw_texture->texture_memory;
|
2021-03-11 14:33:55 +01:00
|
|
|
draw_texture = dst_impl->draw_texture;
|
2013-12-05 10:34:17 +01:00
|
|
|
|
2013-12-04 09:49:35 +01:00
|
|
|
if (src_impl)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-12-04 09:49:35 +01:00
|
|
|
for (current = iface; current != src;)
|
|
|
|
{
|
2020-08-11 13:50:44 +02:00
|
|
|
if (FAILED(hr = ddraw_surface1_GetAttachedSurface(current, &caps, ¤t)))
|
2013-12-04 09:49:35 +01:00
|
|
|
{
|
|
|
|
WARN("Surface %p is not on the same flip chain as surface %p.\n", src, iface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOTFLIPPABLE;
|
|
|
|
}
|
2020-08-11 13:50:44 +02:00
|
|
|
ddraw_surface1_Release(current);
|
2013-12-04 09:49:35 +01:00
|
|
|
if (current == iface)
|
|
|
|
{
|
|
|
|
WARN("Surface %p is not on the same flip chain as surface %p.\n", src, iface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOTFLIPPABLE;
|
|
|
|
}
|
|
|
|
}
|
2013-12-05 10:34:18 +01:00
|
|
|
|
2014-08-21 09:55:55 +02:00
|
|
|
src_rtv = ddraw_surface_get_rendertarget_view(src_impl);
|
|
|
|
if (rtv == dst_impl->wined3d_rtv)
|
2021-07-15 07:18:33 +02:00
|
|
|
wined3d_device_context_set_rendertarget_views(dst_impl->ddraw->immediate_context, 0, 1, &src_rtv, FALSE);
|
2014-08-21 09:55:55 +02:00
|
|
|
wined3d_rendertarget_view_set_parent(src_rtv, dst_impl);
|
|
|
|
dst_impl->wined3d_rtv = src_rtv;
|
2016-02-29 11:38:21 +01:00
|
|
|
wined3d_texture_set_sub_resource_parent(src_impl->wined3d_texture, 0, dst_impl);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (src_impl->draw_texture)
|
|
|
|
wined3d_texture_set_sub_resource_parent(src_impl->draw_texture, 0, dst_impl);
|
2020-06-16 18:20:29 +02:00
|
|
|
src_ddraw_texture = wined3d_texture_get_parent(src_impl->wined3d_texture);
|
|
|
|
dst_ddraw_texture->texture_memory = src_ddraw_texture->texture_memory;
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture), dst_ddraw_texture);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (src_impl->draw_texture)
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->draw_texture), dst_ddraw_texture);
|
2020-06-16 18:20:29 +02:00
|
|
|
dst_ddraw_texture = src_ddraw_texture;
|
2016-01-29 18:48:56 +01:00
|
|
|
if (src_impl->sub_resource_idx)
|
|
|
|
ERR("Invalid sub-resource index %u on surface %p.\n", src_impl->sub_resource_idx, src_impl);
|
2013-12-05 10:34:18 +01:00
|
|
|
dst_impl->wined3d_texture = src_impl->wined3d_texture;
|
2021-03-11 14:33:55 +01:00
|
|
|
dst_impl->draw_texture = src_impl->draw_texture;
|
2013-12-04 09:49:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-05 10:34:18 +01:00
|
|
|
for (current = iface;;)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2020-08-11 13:50:44 +02:00
|
|
|
if (FAILED(hr = ddraw_surface1_GetAttachedSurface(current, &caps, ¤t)))
|
2013-12-05 10:34:18 +01:00
|
|
|
{
|
|
|
|
ERR("Can't find a flip target\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOTFLIPPABLE; /* Unchecked */
|
|
|
|
}
|
2020-08-11 13:50:44 +02:00
|
|
|
ddraw_surface1_Release(current);
|
2013-12-05 10:34:18 +01:00
|
|
|
if (current == iface)
|
|
|
|
{
|
2020-08-11 13:50:44 +02:00
|
|
|
dst_impl = impl_from_IDirectDrawSurface(iface);
|
2013-12-05 10:34:18 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:44 +02:00
|
|
|
src_impl = impl_from_IDirectDrawSurface(current);
|
2014-08-21 09:55:55 +02:00
|
|
|
src_rtv = ddraw_surface_get_rendertarget_view(src_impl);
|
|
|
|
if (rtv == dst_impl->wined3d_rtv)
|
2021-07-15 07:18:33 +02:00
|
|
|
wined3d_device_context_set_rendertarget_views(dst_impl->ddraw->immediate_context,
|
|
|
|
0, 1, &src_rtv, FALSE);
|
2014-08-21 09:55:55 +02:00
|
|
|
wined3d_rendertarget_view_set_parent(src_rtv, dst_impl);
|
|
|
|
dst_impl->wined3d_rtv = src_rtv;
|
2016-02-29 11:38:21 +01:00
|
|
|
wined3d_texture_set_sub_resource_parent(src_impl->wined3d_texture, 0, dst_impl);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (src_impl->draw_texture)
|
|
|
|
wined3d_texture_set_sub_resource_parent(src_impl->draw_texture, 0, dst_impl);
|
2020-06-16 18:20:29 +02:00
|
|
|
src_ddraw_texture = wined3d_texture_get_parent(src_impl->wined3d_texture);
|
|
|
|
dst_ddraw_texture->texture_memory = src_ddraw_texture->texture_memory;
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture), dst_ddraw_texture);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (src_impl->draw_texture)
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->draw_texture), dst_ddraw_texture);
|
2020-06-16 18:20:29 +02:00
|
|
|
dst_ddraw_texture = src_ddraw_texture;
|
2016-01-29 18:48:56 +01:00
|
|
|
if (src_impl->sub_resource_idx)
|
|
|
|
ERR("Invalid sub-resource index %u on surface %p.\n", src_impl->sub_resource_idx, src_impl);
|
2013-12-05 10:34:18 +01:00
|
|
|
dst_impl->wined3d_texture = src_impl->wined3d_texture;
|
2021-03-11 14:33:55 +01:00
|
|
|
dst_impl->draw_texture = src_impl->draw_texture;
|
2013-12-05 10:34:18 +01:00
|
|
|
dst_impl = src_impl;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-05 10:34:17 +01:00
|
|
|
/* We don't have to worry about potential texture bindings, since
|
|
|
|
* flippable surfaces can never be textures. */
|
2014-08-21 09:55:55 +02:00
|
|
|
if (rtv == src_impl->wined3d_rtv)
|
2021-07-15 07:18:33 +02:00
|
|
|
wined3d_device_context_set_rendertarget_views(dst_impl->ddraw->immediate_context, 0, 1, &tmp_rtv, FALSE);
|
2014-08-21 09:55:55 +02:00
|
|
|
wined3d_rendertarget_view_set_parent(tmp_rtv, src_impl);
|
|
|
|
src_impl->wined3d_rtv = tmp_rtv;
|
2016-02-29 11:38:21 +01:00
|
|
|
wined3d_texture_set_sub_resource_parent(texture, 0, src_impl);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (draw_texture)
|
|
|
|
wined3d_texture_set_sub_resource_parent(draw_texture, 0, src_impl);
|
2020-06-16 18:20:29 +02:00
|
|
|
dst_ddraw_texture->texture_memory = texture_memory;
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(texture), dst_ddraw_texture);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (draw_texture)
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(draw_texture), dst_ddraw_texture);
|
2013-12-05 10:34:17 +01:00
|
|
|
src_impl->wined3d_texture = texture;
|
2021-03-11 14:33:55 +01:00
|
|
|
src_impl->draw_texture = draw_texture;
|
2013-12-05 10:34:17 +01:00
|
|
|
|
2018-03-27 13:06:52 +02:00
|
|
|
if (flags & ~(DDFLIP_NOVSYNC | DDFLIP_INTERVAL2 | DDFLIP_INTERVAL3 | DDFLIP_INTERVAL4))
|
2013-12-05 10:34:17 +01:00
|
|
|
{
|
|
|
|
static UINT once;
|
|
|
|
if (!once++)
|
|
|
|
FIXME("Ignoring flags %#x.\n", flags);
|
|
|
|
else
|
|
|
|
WARN("Ignoring flags %#x.\n", flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(dst_impl, NULL, FALSE, ddraw_swap_interval_from_flags(flags));
|
2013-12-05 10:34:17 +01:00
|
|
|
else
|
|
|
|
hr = DD_OK;
|
2011-09-15 20:01:51 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:44 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 *iface,
|
|
|
|
IDirectDrawSurface7 *src, DWORD flags)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src);
|
|
|
|
|
|
|
|
TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags);
|
|
|
|
|
|
|
|
return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags);
|
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Flip(IDirectDrawSurface4 *iface,
|
2016-04-21 17:05:07 +02:00
|
|
|
IDirectDrawSurface4 *src, DWORD flags)
|
2011-06-06 13:39:04 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
2016-04-21 17:05:07 +02:00
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface4(src);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2016-04-21 17:05:07 +02:00
|
|
|
TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
2020-08-11 13:50:44 +02:00
|
|
|
return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Flip(IDirectDrawSurface3 *iface,
|
2016-04-21 17:05:07 +02:00
|
|
|
IDirectDrawSurface3 *src, DWORD flags)
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2016-04-21 17:05:07 +02:00
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface3(src);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2016-04-21 17:05:07 +02:00
|
|
|
TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2020-08-11 13:50:44 +02:00
|
|
|
return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Flip(IDirectDrawSurface2 *iface,
|
2016-04-21 17:05:07 +02:00
|
|
|
IDirectDrawSurface2 *src, DWORD flags)
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2016-04-21 17:05:07 +02:00
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface2(src);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2016-04-21 17:05:07 +02:00
|
|
|
TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
2020-08-11 13:50:44 +02:00
|
|
|
return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2017-03-29 23:17:28 +02:00
|
|
|
static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *dst_rect,
|
|
|
|
struct ddraw_surface *src_surface, const RECT *src_rect, DWORD flags, DWORD fill_colour,
|
|
|
|
const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
|
|
|
|
{
|
2021-04-08 04:20:03 +02:00
|
|
|
struct ddraw *ddraw = dst_surface->ddraw;
|
|
|
|
struct wined3d_device *wined3d_device = ddraw->wined3d_device;
|
2017-03-29 23:17:28 +02:00
|
|
|
struct wined3d_color colour;
|
2017-04-24 23:31:31 +02:00
|
|
|
DWORD wined3d_flags;
|
2017-03-29 23:17:28 +02:00
|
|
|
|
|
|
|
if (flags & DDBLT_COLORFILL)
|
|
|
|
{
|
2018-09-27 17:30:34 +02:00
|
|
|
wined3d_flags = WINED3DCLEAR_TARGET;
|
|
|
|
if (!(flags & DDBLT_ASYNC))
|
|
|
|
wined3d_flags |= WINED3DCLEAR_SYNCHRONOUS;
|
|
|
|
|
2017-03-29 23:17:28 +02:00
|
|
|
if (!wined3d_colour_from_ddraw_colour(&dst_surface->surface_desc.u4.ddpfPixelFormat,
|
|
|
|
dst_surface->palette, fill_colour, &colour))
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2021-04-08 04:20:03 +02:00
|
|
|
wined3d_device_apply_stateblock(wined3d_device, ddraw->state);
|
2021-03-11 14:34:01 +01:00
|
|
|
ddraw_surface_get_draw_texture(dst_surface, dst_rect ? DDRAW_SURFACE_RW : DDRAW_SURFACE_WRITE);
|
2021-04-08 04:20:03 +02:00
|
|
|
return wined3d_device_context_clear_rendertarget_view(ddraw->immediate_context,
|
2017-03-29 23:17:28 +02:00
|
|
|
ddraw_surface_get_rendertarget_view(dst_surface),
|
2018-09-27 17:30:34 +02:00
|
|
|
dst_rect, wined3d_flags, &colour, 0.0f, 0);
|
2017-03-29 23:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & DDBLT_DEPTHFILL)
|
|
|
|
{
|
2018-09-27 17:30:34 +02:00
|
|
|
wined3d_flags = WINED3DCLEAR_ZBUFFER;
|
|
|
|
if (!(flags & DDBLT_ASYNC))
|
|
|
|
wined3d_flags |= WINED3DCLEAR_SYNCHRONOUS;
|
|
|
|
|
2017-03-29 23:17:28 +02:00
|
|
|
if (!wined3d_colour_from_ddraw_colour(&dst_surface->surface_desc.u4.ddpfPixelFormat,
|
|
|
|
dst_surface->palette, fill_colour, &colour))
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2021-04-08 04:20:03 +02:00
|
|
|
wined3d_device_apply_stateblock(wined3d_device, ddraw->state);
|
2021-03-11 14:34:01 +01:00
|
|
|
ddraw_surface_get_draw_texture(dst_surface, dst_rect ? DDRAW_SURFACE_RW : DDRAW_SURFACE_WRITE);
|
2021-04-08 04:20:03 +02:00
|
|
|
return wined3d_device_context_clear_rendertarget_view(ddraw->immediate_context,
|
2017-03-29 23:17:28 +02:00
|
|
|
ddraw_surface_get_rendertarget_view(dst_surface),
|
2018-09-27 17:30:34 +02:00
|
|
|
dst_rect, wined3d_flags, NULL, colour.r, 0);
|
2017-03-29 23:17:28 +02:00
|
|
|
}
|
|
|
|
|
2017-04-24 23:31:31 +02:00
|
|
|
wined3d_flags = flags & ~DDBLT_ASYNC;
|
|
|
|
if (wined3d_flags & ~WINED3D_BLT_MASK)
|
2017-03-29 23:17:28 +02:00
|
|
|
{
|
|
|
|
FIXME("Unhandled flags %#x.\n", flags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-04-24 23:31:31 +02:00
|
|
|
if (!(flags & DDBLT_ASYNC))
|
|
|
|
wined3d_flags |= WINED3D_BLT_SYNCHRONOUS;
|
|
|
|
|
2021-04-08 04:20:03 +02:00
|
|
|
return wined3d_device_context_blt(ddraw->immediate_context,
|
2021-04-07 03:56:44 +02:00
|
|
|
ddraw_surface_get_any_texture(dst_surface, DDRAW_SURFACE_RW), dst_surface->sub_resource_idx, dst_rect,
|
|
|
|
ddraw_surface_get_any_texture(src_surface, DDRAW_SURFACE_READ), src_surface->sub_resource_idx, src_rect,
|
|
|
|
wined3d_flags, fx, filter);
|
2017-03-29 23:17:28 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, const RECT *dst_rect_in,
|
2017-03-29 23:17:28 +02:00
|
|
|
struct ddraw_surface *src_surface, const RECT *src_rect_in, DWORD flags, DWORD fill_colour,
|
2016-02-15 18:18:03 +01:00
|
|
|
const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
|
2011-12-12 20:53:56 +01:00
|
|
|
{
|
|
|
|
RECT src_rect, dst_rect;
|
|
|
|
float scale_x, scale_y;
|
|
|
|
const RECT *clip_rect;
|
|
|
|
UINT clip_list_size;
|
|
|
|
RGNDATA *clip_list;
|
|
|
|
HRESULT hr = DD_OK;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
if (!dst_rect_in)
|
2016-03-22 10:31:25 +01:00
|
|
|
SetRect(&dst_rect, 0, 0, dst_surface->surface_desc.dwWidth,
|
|
|
|
dst_surface->surface_desc.dwHeight);
|
2011-12-12 20:53:56 +01:00
|
|
|
else
|
|
|
|
dst_rect = *dst_rect_in;
|
|
|
|
|
|
|
|
if (IsRectEmpty(&dst_rect))
|
|
|
|
return DDERR_INVALIDRECT;
|
|
|
|
|
|
|
|
if (src_surface)
|
|
|
|
{
|
|
|
|
if (!src_rect_in)
|
2016-03-22 10:31:25 +01:00
|
|
|
SetRect(&src_rect, 0, 0, src_surface->surface_desc.dwWidth,
|
|
|
|
src_surface->surface_desc.dwHeight);
|
2011-12-12 20:53:56 +01:00
|
|
|
else
|
|
|
|
src_rect = *src_rect_in;
|
|
|
|
|
|
|
|
if (IsRectEmpty(&src_rect))
|
|
|
|
return DDERR_INVALIDRECT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-03 09:26:06 +01:00
|
|
|
SetRectEmpty(&src_rect);
|
2011-12-12 20:53:56 +01:00
|
|
|
}
|
|
|
|
|
2016-01-27 20:44:35 +01:00
|
|
|
if (!dst_surface->clipper)
|
|
|
|
{
|
|
|
|
if (src_surface && src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(src_surface, &src_rect, TRUE, 0);
|
2016-01-27 20:44:35 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2017-03-29 23:17:28 +02:00
|
|
|
hr = ddraw_surface_blt(dst_surface, &dst_rect, src_surface, &src_rect, flags, fill_colour, fx, filter);
|
2016-01-27 20:44:35 +01:00
|
|
|
if (SUCCEEDED(hr) && (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(dst_surface, &dst_rect, FALSE, 0);
|
2016-01-27 20:44:35 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-03-22 10:50:04 +01:00
|
|
|
if (!ddraw_clipper_is_valid(dst_surface->clipper))
|
|
|
|
{
|
|
|
|
FIXME("Attempting to blit with an invalid clipper.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-12-12 20:53:56 +01:00
|
|
|
scale_x = (float)(src_rect.right - src_rect.left) / (float)(dst_rect.right - dst_rect.left);
|
|
|
|
scale_y = (float)(src_rect.bottom - src_rect.top) / (float)(dst_rect.bottom - dst_rect.top);
|
|
|
|
|
|
|
|
if (FAILED(hr = IDirectDrawClipper_GetClipList(&dst_surface->clipper->IDirectDrawClipper_iface,
|
|
|
|
&dst_rect, NULL, &clip_list_size)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get clip list size, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:32:47 +01:00
|
|
|
if (!(clip_list = heap_alloc(clip_list_size)))
|
2011-12-12 20:53:56 +01:00
|
|
|
{
|
|
|
|
WARN("Failed to allocate clip list.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = IDirectDrawClipper_GetClipList(&dst_surface->clipper->IDirectDrawClipper_iface,
|
|
|
|
&dst_rect, clip_list, &clip_list_size)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get clip list, hr %#x.\n", hr);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(clip_list);
|
2011-12-12 20:53:56 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
clip_rect = (RECT *)clip_list->Buffer;
|
|
|
|
for (i = 0; i < clip_list->rdh.nCount; ++i)
|
|
|
|
{
|
|
|
|
RECT src_rect_clipped = src_rect;
|
|
|
|
|
|
|
|
if (src_surface)
|
|
|
|
{
|
2012-01-06 11:20:05 +01:00
|
|
|
src_rect_clipped.left += (LONG)((clip_rect[i].left - dst_rect.left) * scale_x);
|
|
|
|
src_rect_clipped.top += (LONG)((clip_rect[i].top - dst_rect.top) * scale_y);
|
|
|
|
src_rect_clipped.right -= (LONG)((dst_rect.right - clip_rect[i].right) * scale_x);
|
|
|
|
src_rect_clipped.bottom -= (LONG)((dst_rect.bottom - clip_rect[i].bottom) * scale_y);
|
2011-12-12 20:53:56 +01:00
|
|
|
|
2013-12-03 09:59:18 +01:00
|
|
|
if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2011-12-12 20:53:56 +01:00
|
|
|
{
|
2018-03-27 13:06:52 +02:00
|
|
|
if (FAILED(hr = ddraw_surface_update_frontbuffer(src_surface, &src_rect_clipped, TRUE, 0)))
|
2011-12-12 20:53:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-29 23:17:28 +02:00
|
|
|
if (FAILED(hr = ddraw_surface_blt(dst_surface, &clip_rect[i],
|
|
|
|
src_surface, &src_rect_clipped, flags, fill_colour, fx, filter)))
|
2011-12-12 20:53:56 +01:00
|
|
|
break;
|
|
|
|
|
2013-12-03 09:59:18 +01:00
|
|
|
if (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2011-12-12 20:53:56 +01:00
|
|
|
{
|
2018-03-27 13:06:52 +02:00
|
|
|
if (FAILED(hr = ddraw_surface_update_frontbuffer(dst_surface, &clip_rect[i], FALSE, 0)))
|
2011-12-12 20:53:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(clip_list);
|
2011-12-12 20:53:56 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:42 +02:00
|
|
|
/* FRAPS hooks IDirectDrawSurface::Blt and expects the version 1 method to be called when the
|
|
|
|
* game uses later interfaces. */
|
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Blt(IDirectDrawSurface *iface, RECT *dst_rect,
|
|
|
|
IDirectDrawSurface *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2020-08-11 13:50:42 +02:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src_surface);
|
2021-03-31 12:27:36 +02:00
|
|
|
struct wined3d_blt_fx wined3d_fx = {0};
|
2017-04-24 23:31:30 +02:00
|
|
|
DWORD unsupported_flags;
|
2017-03-29 23:17:28 +02:00
|
|
|
DWORD fill_colour = 0;
|
2011-10-24 21:24:38 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2015-03-17 23:54:14 +01:00
|
|
|
DDBLTFX rop_fx;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2010-11-02 12:02:46 +01:00
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
2016-02-15 18:18:03 +01:00
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2017-04-24 23:31:30 +02:00
|
|
|
unsupported_flags = DDBLT_ALPHADEST
|
|
|
|
| DDBLT_ALPHADESTCONSTOVERRIDE
|
|
|
|
| DDBLT_ALPHADESTNEG
|
|
|
|
| DDBLT_ALPHADESTSURFACEOVERRIDE
|
|
|
|
| DDBLT_ALPHAEDGEBLEND
|
|
|
|
| DDBLT_ALPHASRC
|
|
|
|
| DDBLT_ALPHASRCCONSTOVERRIDE
|
|
|
|
| DDBLT_ALPHASRCNEG
|
|
|
|
| DDBLT_ALPHASRCSURFACEOVERRIDE
|
|
|
|
| DDBLT_ZBUFFER
|
|
|
|
| DDBLT_ZBUFFERDESTCONSTOVERRIDE
|
|
|
|
| DDBLT_ZBUFFERDESTOVERRIDE
|
|
|
|
| DDBLT_ZBUFFERSRCCONSTOVERRIDE
|
|
|
|
| DDBLT_ZBUFFERSRCOVERRIDE;
|
|
|
|
if (flags & unsupported_flags)
|
|
|
|
{
|
|
|
|
WARN("Ignoring unsupported flags %#x.\n", flags & unsupported_flags);
|
|
|
|
flags &= ~unsupported_flags;
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if ((flags & DDBLT_KEYSRCOVERRIDE) && (!fx || flags & DDBLT_KEYSRC))
|
|
|
|
{
|
2007-02-15 03:03:05 +01:00
|
|
|
WARN("Invalid source color key parameters, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if ((flags & DDBLT_KEYDESTOVERRIDE) && (!fx || flags & DDBLT_KEYDEST))
|
|
|
|
{
|
2007-02-15 03:03:05 +01:00
|
|
|
WARN("Invalid destination color key parameters, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (flags & DDBLT_DDROPS)
|
2016-02-15 18:18:01 +01:00
|
|
|
{
|
|
|
|
FIXME("DDBLT_DDROPS not implemented.\n");
|
2016-02-15 18:18:03 +01:00
|
|
|
if (fx)
|
|
|
|
FIXME(" rop %#x, pattern %p.\n", fx->dwDDROP, fx->u5.lpDDSPattern);
|
2016-02-15 18:18:01 +01:00
|
|
|
return DDERR_NORASTEROPHW;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2007-06-08 19:04:13 +02:00
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (flags & (DDBLT_COLORFILL | DDBLT_DEPTHFILL))
|
2015-03-16 14:48:52 +01:00
|
|
|
{
|
2016-02-15 18:18:03 +01:00
|
|
|
if (flags & DDBLT_ROP)
|
2015-03-16 23:06:57 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
WARN("DDBLT_ROP used with DDBLT_COLORFILL or DDBLT_DEPTHFILL, returning DDERR_INVALIDPARAMS.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2016-02-15 18:18:03 +01:00
|
|
|
if (src_impl)
|
2015-03-16 14:48:52 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
2015-03-16 14:48:54 +01:00
|
|
|
WARN("Depth or colorfill is not compatible with source surfaces, returning DDERR_INVALIDPARAMS\n");
|
2015-03-16 14:48:52 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2016-02-15 18:18:03 +01:00
|
|
|
if (!fx)
|
2015-03-16 14:48:52 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
2016-02-15 18:18:03 +01:00
|
|
|
WARN("Depth or colorfill used with NULL fx, returning DDERR_INVALIDPARAMS.\n");
|
2015-03-16 14:48:52 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2015-03-16 14:48:54 +01:00
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if ((flags & (DDBLT_COLORFILL | DDBLT_DEPTHFILL)) == (DDBLT_COLORFILL | DDBLT_DEPTHFILL))
|
|
|
|
flags &= ~DDBLT_DEPTHFILL;
|
2015-03-16 14:48:54 +01:00
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if ((dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) && (flags & DDBLT_COLORFILL))
|
2015-03-16 14:48:52 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
WARN("DDBLT_COLORFILL used on a depth buffer, returning DDERR_INVALIDPARAMS.\n");
|
2015-03-16 14:48:54 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2016-02-15 18:18:03 +01:00
|
|
|
if (!(dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) && (flags & DDBLT_DEPTHFILL))
|
2015-03-16 14:48:54 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
WARN("DDBLT_DEPTHFILL used on a color buffer, returning DDERR_INVALIDPARAMS.\n");
|
2015-03-16 23:06:57 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (flags & DDBLT_ROP)
|
2015-03-16 23:06:57 +01:00
|
|
|
{
|
2016-02-15 18:18:03 +01:00
|
|
|
if (!fx)
|
2015-03-16 23:06:57 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
2016-02-15 18:18:03 +01:00
|
|
|
WARN("DDBLT_ROP used with NULL fx, returning DDERR_INVALIDPARAMS.\n");
|
2015-03-16 14:48:52 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2015-03-17 23:54:14 +01:00
|
|
|
|
2017-03-29 23:17:28 +02:00
|
|
|
if (src_impl && src_rect
|
|
|
|
&& ((ULONG)src_rect->left >= src_rect->right || src_rect->right > src_impl->surface_desc.dwWidth
|
|
|
|
|| (ULONG)src_rect->top >= src_rect->bottom || src_rect->bottom > src_impl->surface_desc.dwHeight))
|
|
|
|
{
|
2019-08-14 14:04:37 +02:00
|
|
|
wined3d_mutex_unlock();
|
2017-03-29 23:17:28 +02:00
|
|
|
WARN("Invalid source rectangle.\n");
|
|
|
|
return DDERR_INVALIDRECT;
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
flags &= ~DDBLT_ROP;
|
|
|
|
switch (fx->dwROP)
|
2015-03-17 23:54:14 +01:00
|
|
|
{
|
|
|
|
case SRCCOPY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WHITENESS:
|
|
|
|
case BLACKNESS:
|
2016-02-15 18:18:03 +01:00
|
|
|
rop_fx = *fx;
|
2015-03-17 23:54:14 +01:00
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (fx->dwROP == WHITENESS)
|
2015-03-17 23:54:14 +01:00
|
|
|
rop_fx.u5.dwFillColor = 0xffffffff;
|
|
|
|
else
|
|
|
|
rop_fx.u5.dwFillColor = 0;
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
|
|
|
|
flags |= DDBLT_DEPTHFILL;
|
2015-03-17 23:54:14 +01:00
|
|
|
else
|
2016-02-15 18:18:03 +01:00
|
|
|
flags |= DDBLT_COLORFILL;
|
2015-03-17 23:54:14 +01:00
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
fx = &rop_fx;
|
2015-03-17 23:54:14 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wined3d_mutex_unlock();
|
2016-02-15 18:18:03 +01:00
|
|
|
WARN("Unsupported ROP %#x used, returning DDERR_NORASTEROPHW.\n", fx->dwROP);
|
2015-03-17 23:54:14 +01:00
|
|
|
return DDERR_NORASTEROPHW;
|
|
|
|
}
|
2015-03-16 14:48:52 +01:00
|
|
|
}
|
|
|
|
|
2017-05-02 15:31:04 +02:00
|
|
|
if (!(flags & (DDBLT_COLORFILL | DDBLT_DEPTHFILL)) && !src_impl)
|
|
|
|
{
|
|
|
|
WARN("No source surface.\n");
|
2019-08-14 14:04:37 +02:00
|
|
|
wined3d_mutex_unlock();
|
2017-05-02 15:31:04 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (flags & DDBLT_KEYSRC && (!src_impl || !(src_impl->surface_desc.dwFlags & DDSD_CKSRCBLT)))
|
2017-03-08 20:29:00 +01:00
|
|
|
{
|
|
|
|
WARN("DDBLT_KEYSRC blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
if (flags & DDBLT_KEYDEST && !(dst_impl->surface_desc.dwFlags & DDSD_CKDESTBLT))
|
2012-03-11 22:03:12 +01:00
|
|
|
{
|
2007-02-15 03:03:05 +01:00
|
|
|
WARN("DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-02-15 03:03:05 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2016-02-15 18:18:03 +01:00
|
|
|
if (fx)
|
|
|
|
{
|
|
|
|
wined3d_fx.fx = fx->dwDDFX;
|
2017-03-29 23:17:28 +02:00
|
|
|
fill_colour = fx->u5.dwFillColor;
|
2016-02-15 18:18:03 +01:00
|
|
|
wined3d_fx.dst_color_key.color_space_low_value = fx->ddckDestColorkey.dwColorSpaceLowValue;
|
|
|
|
wined3d_fx.dst_color_key.color_space_high_value = fx->ddckDestColorkey.dwColorSpaceHighValue;
|
|
|
|
wined3d_fx.src_color_key.color_space_low_value = fx->ddckSrcColorkey.dwColorSpaceLowValue;
|
|
|
|
wined3d_fx.src_color_key.color_space_high_value = fx->ddckSrcColorkey.dwColorSpaceHighValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ddraw_surface_blt_clipped(dst_impl, dst_rect, src_impl,
|
2017-03-29 23:17:28 +02:00
|
|
|
src_rect, flags, fill_colour, fx ? &wined3d_fx : NULL, WINED3D_TEXF_LINEAR);
|
2007-05-30 15:25:34 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 13:50:42 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *dst_rect,
|
|
|
|
IDirectDrawSurface7 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *dst = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface7(src_surface);
|
|
|
|
|
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect,
|
|
|
|
src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Blt(IDirectDrawSurface4 *iface, RECT *dst_rect,
|
2011-06-06 13:39:04 +02:00
|
|
|
IDirectDrawSurface4 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface4(src_surface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
2020-08-11 13:50:42 +02:00
|
|
|
return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect,
|
|
|
|
src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Blt(IDirectDrawSurface3 *iface, RECT *dst_rect,
|
2010-07-19 18:36:20 +02:00
|
|
|
IDirectDrawSurface3 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst = impl_from_IDirectDrawSurface3(iface);
|
2020-08-11 13:50:42 +02:00
|
|
|
struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface3(src_surface);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2010-11-02 12:02:46 +01:00
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
2010-07-19 18:36:20 +02:00
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
2020-08-11 13:50:42 +02:00
|
|
|
return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect,
|
|
|
|
src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Blt(IDirectDrawSurface2 *iface, RECT *dst_rect,
|
2011-06-09 16:35:15 +02:00
|
|
|
IDirectDrawSurface2 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst = impl_from_IDirectDrawSurface2(iface);
|
2020-08-11 13:50:42 +02:00
|
|
|
struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface2(src_surface);
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
2020-08-11 13:50:42 +02:00
|
|
|
return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect,
|
|
|
|
src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::AddAttachedSurface
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* Attaches a surface to another surface. How the surface attachments work
|
|
|
|
* is not totally understood yet, and this method is prone to problems.
|
2011-10-11 21:59:21 +02:00
|
|
|
* The surface that is attached is AddRef-ed.
|
2007-04-27 15:31:12 +02:00
|
|
|
*
|
|
|
|
* Tests with complex surfaces suggest that the surface attachments form a
|
|
|
|
* tree, but no method to test this has been found yet.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* The attachment list consists of a first surface (first_attached) and
|
2006-06-09 19:36:12 +02:00
|
|
|
* for each surface a pointer to the next attached surface (next_attached).
|
|
|
|
* For the first surface, and a surface that has no attachments
|
|
|
|
* first_attached points to the surface itself. A surface that has
|
|
|
|
* no successors in the chain has next_attached set to NULL.
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* Newly attached surfaces are attached right after the root surface.
|
|
|
|
* If a surface is attached to a complex surface compound, it's attached to
|
|
|
|
* the surface that the app requested, not the complex root. See
|
|
|
|
* GetAttachedSurface for a description how surfaces are found.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This is how the current implementation works, and it was coded by looking
|
|
|
|
* at the needs of the applications.
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* So far only Z-Buffer attachments are tested, and they are activated in
|
|
|
|
* WineD3D. Mipmaps could be tricky to activate in WineD3D.
|
2007-05-04 18:31:14 +02:00
|
|
|
* Back buffers should work in 2D mode, but they are not tested(They can be
|
|
|
|
* attached in older iface versions). Rendering to the front buffer and
|
2007-04-27 15:31:12 +02:00
|
|
|
* switching between that and double buffering is not yet implemented in
|
|
|
|
* WineD3D, so for 3D it might have unexpected results.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2010-07-19 18:36:20 +02:00
|
|
|
* ddraw_surface_attach_surface is the real thing,
|
|
|
|
* ddraw_surface7_AddAttachedSurface is a wrapper around it that
|
2007-05-04 18:31:14 +02:00
|
|
|
* performs additional checks. Version 7 of this interface is much more restrictive
|
|
|
|
* than its predecessors.
|
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
* Params:
|
|
|
|
* Attach: Surface to attach to iface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_CANNOTATTACHSURFACE if the surface can't be attached for some reason
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-03-11 22:03:12 +01:00
|
|
|
static HRESULT ddraw_surface_attach_surface(struct ddraw_surface *This, struct ddraw_surface *Surf)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("surface %p, attachment %p.\n", This, Surf);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(Surf == This)
|
|
|
|
return DDERR_CANNOTATTACHSURFACE; /* unchecked */
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2007-05-30 15:25:34 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Check if the surface is already attached somewhere */
|
2010-08-22 23:35:39 +02:00
|
|
|
if (Surf->next_attached || Surf->first_attached != Surf)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-22 23:35:39 +02:00
|
|
|
/* TODO: Test for the structure of the manual attachment. Is it a
|
|
|
|
* chain or a list? What happens if one surface is attached to 2
|
|
|
|
* different surfaces? */
|
|
|
|
WARN("Surface %p is already attached somewhere. next_attached %p, first_attached %p.\n",
|
|
|
|
Surf, Surf->next_attached, Surf->first_attached);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-05-04 18:31:14 +02:00
|
|
|
return DDERR_SURFACEALREADYATTACHED;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This inserts the new surface at the 2nd position in the chain, right after the root surface */
|
|
|
|
Surf->next_attached = This->next_attached;
|
|
|
|
Surf->first_attached = This->first_attached;
|
|
|
|
This->next_attached = Surf;
|
|
|
|
|
2007-04-24 22:30:03 +02:00
|
|
|
/* Check if the WineD3D depth stencil needs updating */
|
2012-04-09 20:43:40 +02:00
|
|
|
if (This->ddraw->d3ddevice)
|
|
|
|
d3d_device_update_depth_stencil(This->ddraw->d3ddevice);
|
2006-10-25 12:54:15 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-10 12:15:22 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_AddAttachedSurface(IDirectDrawSurface7 *iface, IDirectDrawSurface7 *attachment)
|
2007-05-04 18:31:14 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface7(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2007-05-04 18:31:14 +02:00
|
|
|
|
2011-10-10 12:15:22 +02:00
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2007-05-04 18:31:14 +02:00
|
|
|
/* Version 7 of this interface seems to refuse everything except z buffers, as per msdn */
|
2011-10-10 12:15:22 +02:00
|
|
|
if(!(attachment_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
|
2007-05-04 18:31:14 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
WARN("Application tries to attach a non Z buffer surface. caps %08x\n",
|
2011-10-10 12:15:22 +02:00
|
|
|
attachment_impl->surface_desc.ddsCaps.dwCaps);
|
2007-05-04 18:31:14 +02:00
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
|
|
|
}
|
|
|
|
|
2011-10-10 12:15:22 +02:00
|
|
|
hr = ddraw_surface_attach_surface(This, attachment_impl);
|
2011-06-20 23:30:12 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
2011-10-11 21:59:21 +02:00
|
|
|
attachment_impl->attached_iface = (IUnknown *)attachment;
|
2012-01-30 21:19:48 +01:00
|
|
|
IUnknown_AddRef(attachment_impl->attached_iface);
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2007-05-04 18:31:14 +02:00
|
|
|
}
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_AddAttachedSurface(IDirectDrawSurface4 *iface, IDirectDrawSurface4 *attachment)
|
|
|
|
{
|
2014-01-27 10:07:52 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface4(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2011-06-06 13:39:04 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
/* Tests suggest that
|
|
|
|
* -> offscreen plain surfaces can be attached to other offscreen plain surfaces
|
|
|
|
* -> offscreen plain surfaces can be attached to primaries
|
|
|
|
* -> primaries can be attached to offscreen plain surfaces
|
|
|
|
* -> z buffers can be attached to primaries */
|
2014-01-27 10:07:52 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN)
|
2011-10-10 12:15:22 +02:00
|
|
|
&& attachment_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN))
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
|
|
|
/* Sizes have to match */
|
2014-01-27 10:07:52 +01:00
|
|
|
if (attachment_impl->surface_desc.dwWidth != surface->surface_desc.dwWidth
|
|
|
|
|| attachment_impl->surface_desc.dwHeight != surface->surface_desc.dwHeight)
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
|
|
|
WARN("Surface sizes do not match.\n");
|
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
|
|
|
}
|
|
|
|
}
|
2014-01-27 10:07:52 +01:00
|
|
|
else if (!(surface->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE))
|
|
|
|
|| !(attachment_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER)))
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
|
|
|
WARN("Invalid attachment combination.\n");
|
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
|
|
|
}
|
|
|
|
|
2014-01-27 10:07:52 +01:00
|
|
|
if (FAILED(hr = ddraw_surface_attach_surface(surface, attachment_impl)))
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2014-01-27 10:07:52 +01:00
|
|
|
|
2011-10-11 21:59:21 +02:00
|
|
|
attachment_impl->attached_iface = (IUnknown *)attachment;
|
2012-01-30 21:19:48 +01:00
|
|
|
IUnknown_AddRef(attachment_impl->attached_iface);
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2014-01-27 10:07:52 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface3_AddAttachedSurface(IDirectDrawSurface3 *iface, IDirectDrawSurface3 *attachment)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface3(attachment);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
|
|
|
if (FAILED(hr = ddraw_surface4_AddAttachedSurface(&surface->IDirectDrawSurface4_iface,
|
|
|
|
attachment_impl ? &attachment_impl->IDirectDrawSurface4_iface : NULL)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
attachment_impl->attached_iface = (IUnknown *)attachment;
|
|
|
|
IUnknown_AddRef(attachment_impl->attached_iface);
|
|
|
|
ddraw_surface4_Release(&attachment_impl->IDirectDrawSurface4_iface);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_AddAttachedSurface(IDirectDrawSurface2 *iface, IDirectDrawSurface2 *attachment)
|
|
|
|
{
|
2014-01-27 10:07:52 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface2(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2011-06-09 16:35:15 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
2014-01-27 10:07:52 +01:00
|
|
|
if (FAILED(hr = ddraw_surface4_AddAttachedSurface(&surface->IDirectDrawSurface4_iface,
|
|
|
|
attachment_impl ? &attachment_impl->IDirectDrawSurface4_iface : NULL)))
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2014-01-27 10:07:52 +01:00
|
|
|
|
2011-10-11 21:59:21 +02:00
|
|
|
attachment_impl->attached_iface = (IUnknown *)attachment;
|
2012-01-30 21:19:48 +01:00
|
|
|
IUnknown_AddRef(attachment_impl->attached_iface);
|
2014-01-27 10:07:52 +01:00
|
|
|
ddraw_surface4_Release(&attachment_impl->IDirectDrawSurface4_iface);
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_AddAttachedSurface(IDirectDrawSurface *iface, IDirectDrawSurface *attachment)
|
|
|
|
{
|
2014-01-27 10:07:52 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2011-06-09 17:29:36 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
2014-01-27 10:07:52 +01:00
|
|
|
if (FAILED(hr = ddraw_surface4_AddAttachedSurface(&surface->IDirectDrawSurface4_iface,
|
|
|
|
attachment_impl ? &attachment_impl->IDirectDrawSurface4_iface : NULL)))
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2014-01-27 10:07:52 +01:00
|
|
|
|
2011-10-11 21:59:21 +02:00
|
|
|
attachment_impl->attached_iface = (IUnknown *)attachment;
|
2012-01-30 21:19:48 +01:00
|
|
|
IUnknown_AddRef(attachment_impl->attached_iface);
|
2014-01-27 10:07:52 +01:00
|
|
|
ddraw_surface4_Release(&attachment_impl->IDirectDrawSurface4_iface);
|
2011-06-20 23:30:12 +02:00
|
|
|
return hr;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::DeleteAttachedSurface
|
|
|
|
*
|
|
|
|
* Removes a surface from the attachment chain. The surface's refcount
|
|
|
|
* is decreased by one after it has been removed
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Some flags, not used by this implementation
|
|
|
|
* Attach: Surface to detach
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_SURFACENOTATTACHED if the surface isn't attached to
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-03-11 22:03:12 +01:00
|
|
|
static HRESULT ddraw_surface_delete_attached_surface(struct ddraw_surface *surface,
|
|
|
|
struct ddraw_surface *attachment, IUnknown *detach_iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2021-04-20 06:38:08 +02:00
|
|
|
struct wined3d_rendertarget_view *dsv;
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *prev = surface;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
TRACE("surface %p, attachment %p, detach_iface %p.\n", surface, attachment, detach_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
if (!attachment || (attachment->first_attached != surface) || (attachment == surface) )
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-05-04 18:31:14 +02:00
|
|
|
return DDERR_CANNOTDETACHSURFACE;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
if (attachment->attached_iface != detach_iface)
|
2011-10-11 21:59:21 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
WARN("attachment->attach_iface %p != detach_iface %p.\n", attachment->attached_iface, detach_iface);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2011-10-11 21:59:21 +02:00
|
|
|
return DDERR_SURFACENOTATTACHED;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Remove MIPMAPSUBLEVEL if this seemed to be one */
|
2012-03-11 22:03:12 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & attachment->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
attachment->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
|
2006-06-09 19:36:12 +02:00
|
|
|
/* FIXME: we should probably also subtract from dwMipMapCount of this
|
|
|
|
* and all parent surfaces */
|
|
|
|
}
|
|
|
|
|
2006-06-23 18:18:02 +02:00
|
|
|
/* Find the predecessor of the detached surface */
|
2016-03-15 16:55:11 +01:00
|
|
|
while (prev->next_attached != attachment)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2016-03-15 16:55:11 +01:00
|
|
|
if (!(prev = prev->next_attached))
|
|
|
|
{
|
|
|
|
ERR("Failed to find predecessor of %p.\n", attachment);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_SURFACENOTATTACHED;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unchain the surface */
|
2012-03-11 22:03:12 +01:00
|
|
|
prev->next_attached = attachment->next_attached;
|
|
|
|
attachment->next_attached = NULL;
|
|
|
|
attachment->first_attached = attachment;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2016-03-15 16:55:10 +01:00
|
|
|
/* Check if the wined3d depth stencil needs updating. Note that we don't
|
|
|
|
* just call d3d_device_update_depth_stencil() here since it uses
|
|
|
|
* QueryInterface(). Some applications, SCP - Containment Breach in
|
|
|
|
* particular, modify the QueryInterface() pointer in the surface vtbl
|
|
|
|
* but don't cleanup properly after the relevant dll is unloaded. */
|
2021-04-20 06:38:08 +02:00
|
|
|
dsv = wined3d_device_context_get_depth_stencil_view(surface->ddraw->immediate_context);
|
|
|
|
if (attachment->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER && dsv == attachment->wined3d_rtv)
|
2021-04-06 06:40:20 +02:00
|
|
|
wined3d_device_context_set_depth_stencil_view(surface->ddraw->immediate_context, NULL);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2011-10-18 20:46:12 +02:00
|
|
|
|
|
|
|
/* Set attached_iface to NULL before releasing it, the surface may go
|
|
|
|
* away. */
|
2012-03-11 22:03:12 +01:00
|
|
|
attachment->attached_iface = NULL;
|
2011-10-18 20:46:12 +02:00
|
|
|
IUnknown_Release(detach_iface);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface7 *attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface7(attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface_delete_attached_surface(surface, attachment_impl, (IUnknown *)attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_DeleteAttachedSurface(IDirectDrawSurface4 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface4 *attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface4(attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface_delete_attached_surface(surface, attachment_impl, (IUnknown *)attachment);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_DeleteAttachedSurface(IDirectDrawSurface3 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface3 *attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface3(attachment);
|
2011-10-11 21:59:21 +02:00
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface_delete_attached_surface(surface, attachment_impl, (IUnknown *)attachment);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_DeleteAttachedSurface(IDirectDrawSurface2 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface2 *attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface2(attachment);
|
2011-10-11 21:59:21 +02:00
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface_delete_attached_surface(surface, attachment_impl, (IUnknown *)attachment);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_DeleteAttachedSurface(IDirectDrawSurface *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface *attachment)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *attachment_impl = unsafe_impl_from_IDirectDrawSurface(attachment);
|
2011-10-11 21:59:21 +02:00
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface_delete_attached_surface(surface, attachment_impl, (IUnknown *)attachment);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::AddOverlayDirtyRect
|
|
|
|
*
|
|
|
|
* "This method is not currently implemented"
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Rect: ?
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_AddOverlayDirtyRect(IDirectDrawSurface7 *iface, RECT *Rect)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(Rect));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DDERR_UNSUPPORTED; /* unchecked */
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_AddOverlayDirtyRect(IDirectDrawSurface4 *iface, RECT *rect)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&surface->IDirectDrawSurface7_iface, rect);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_AddOverlayDirtyRect(IDirectDrawSurface3 *iface, RECT *rect)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&surface->IDirectDrawSurface7_iface, rect);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_AddOverlayDirtyRect(IDirectDrawSurface2 *iface, RECT *rect)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&surface->IDirectDrawSurface7_iface, rect);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_AddOverlayDirtyRect(IDirectDrawSurface *iface, RECT *rect)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&surface->IDirectDrawSurface7_iface, rect);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetDC
|
|
|
|
*
|
|
|
|
* Returns a GDI device context for the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* hdc: Address of a HDC variable to store the dc to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if hdc is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2016-02-08 18:32:06 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *dc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2011-10-24 21:24:38 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
if (!dc)
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-04-13 12:18:47 +02:00
|
|
|
if (surface->dc)
|
|
|
|
hr = DDERR_DCALREADYCREATED;
|
|
|
|
else if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(surface, NULL, TRUE, 0);
|
2011-10-24 21:24:38 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2021-03-11 14:34:01 +01:00
|
|
|
hr = wined3d_texture_get_dc(ddraw_surface_get_default_texture(surface, DDRAW_SURFACE_RW), surface->sub_resource_idx, dc);
|
2014-05-15 16:13:31 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2014-05-15 16:13:31 +02:00
|
|
|
{
|
2016-02-08 18:32:06 +01:00
|
|
|
surface->dc = *dc;
|
2014-05-15 16:13:31 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
if (format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat))
|
|
|
|
{
|
|
|
|
const struct ddraw_palette *palette;
|
|
|
|
|
|
|
|
if (surface->palette)
|
|
|
|
palette = surface->palette;
|
|
|
|
else if (surface->ddraw->primary)
|
|
|
|
palette = surface->ddraw->primary->palette;
|
|
|
|
else
|
|
|
|
palette = NULL;
|
2014-05-15 16:13:31 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
if (palette)
|
2016-08-26 13:51:21 +02:00
|
|
|
wined3d_palette_apply_to_dc(palette->wined3d_palette, *dc);
|
2016-02-08 18:32:06 +01:00
|
|
|
}
|
2014-05-15 16:13:31 +02:00
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2016-02-08 18:32:06 +01:00
|
|
|
switch (hr)
|
2009-09-05 16:37:19 +02:00
|
|
|
{
|
2016-02-08 18:32:06 +01:00
|
|
|
/* Some, but not all errors set *dc to NULL. E.g. DCALREADYCREATED
|
|
|
|
* does not touch *dc. */
|
2009-09-05 16:37:19 +02:00
|
|
|
case WINED3DERR_INVALIDCALL:
|
2016-02-08 18:32:06 +01:00
|
|
|
*dc = NULL;
|
2016-04-14 19:32:46 +02:00
|
|
|
return DDERR_CANTCREATEDC;
|
2009-09-05 16:37:19 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
default:
|
|
|
|
return hr;
|
2009-09-05 16:37:19 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetDC(IDirectDrawSurface4 *iface, HDC *dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDC(&surface->IDirectDrawSurface7_iface, dc);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetDC(IDirectDrawSurface3 *iface, HDC *dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDC(&surface->IDirectDrawSurface7_iface, dc);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetDC(IDirectDrawSurface2 *iface, HDC *dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDC(&surface->IDirectDrawSurface7_iface, dc);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetDC(IDirectDrawSurface *iface, HDC *dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDC(&surface->IDirectDrawSurface7_iface, dc);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::ReleaseDC
|
|
|
|
*
|
|
|
|
* Releases the DC that was constructed with GetDC
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* hdc: HDC to release
|
|
|
|
*
|
|
|
|
* Returns:
|
2017-03-05 18:59:47 +01:00
|
|
|
* DD_OK on success, error code otherwise.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC hdc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, hdc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-04-13 12:18:47 +02:00
|
|
|
if (!surface->dc)
|
|
|
|
{
|
|
|
|
hr = DDERR_NODC;
|
|
|
|
}
|
2021-03-11 14:34:01 +01:00
|
|
|
else if (SUCCEEDED(hr = wined3d_texture_release_dc(ddraw_surface_get_default_texture(surface, 0),
|
|
|
|
surface->sub_resource_idx, hdc)))
|
2016-02-08 18:32:06 +01:00
|
|
|
{
|
|
|
|
surface->dc = NULL;
|
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(surface, NULL, FALSE, 0);
|
2016-02-08 18:32:06 +01:00
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_ReleaseDC(IDirectDrawSurface4 *iface, HDC dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_ReleaseDC(&surface->IDirectDrawSurface7_iface, dc);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_ReleaseDC(IDirectDrawSurface3 *iface, HDC dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_ReleaseDC(&surface->IDirectDrawSurface7_iface, dc);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_ReleaseDC(IDirectDrawSurface2 *iface, HDC dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_ReleaseDC(&surface->IDirectDrawSurface7_iface, dc);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_ReleaseDC(IDirectDrawSurface *iface, HDC dc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_ReleaseDC(&surface->IDirectDrawSurface7_iface, dc);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetCaps
|
|
|
|
*
|
|
|
|
* Returns the surface's caps
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Caps: Address to write the caps to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Caps is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetCaps(IDirectDrawSurface7 *iface, DDSCAPS2 *Caps)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, Caps);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Caps)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
*Caps = surface->surface_desc.ddsCaps;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetCaps(IDirectDrawSurface4 *iface, DDSCAPS2 *caps)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetCaps(&surface->IDirectDrawSurface7_iface, caps);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetCaps(IDirectDrawSurface3 *iface, DDSCAPS *caps)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetCaps(&surface->IDirectDrawSurface7_iface, &caps2);
|
2010-07-19 18:36:20 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
caps->dwCaps = caps2.dwCaps;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetCaps(IDirectDrawSurface2 *iface, DDSCAPS *caps)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetCaps(&surface->IDirectDrawSurface7_iface, &caps2);
|
2011-06-09 16:35:15 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
caps->dwCaps = caps2.dwCaps;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetCaps(IDirectDrawSurface *iface, DDSCAPS *caps)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2011-06-09 17:29:36 +02:00
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = ddraw_surface7_GetCaps(&surface->IDirectDrawSurface7_iface, &caps2);
|
2011-06-09 17:29:36 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
caps->dwCaps = caps2.dwCaps;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetPriority(IDirectDrawSurface7 *iface, DWORD priority)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2014-07-16 14:39:10 +02:00
|
|
|
DWORD managed = DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE;
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2014-07-16 14:39:15 +02:00
|
|
|
struct wined3d_resource *resource;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
TRACE("iface %p, priority %u.\n", iface, priority);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2014-07-16 14:39:10 +02:00
|
|
|
/* No need to check for offscreen plain surfaces or mipmap sublevels. SetPriority
|
|
|
|
* calls on such surfaces segfault on Windows. */
|
|
|
|
if (!(surface->surface_desc.ddsCaps.dwCaps2 & managed))
|
|
|
|
{
|
|
|
|
WARN("Called on non-managed texture returning DDERR_INVALIDPARAMS.\n");
|
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-16 14:39:15 +02:00
|
|
|
resource = wined3d_texture_get_resource(surface->wined3d_texture);
|
|
|
|
wined3d_resource_set_priority(resource, priority);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (surface->draw_texture)
|
|
|
|
wined3d_resource_set_priority(wined3d_texture_get_resource(surface->draw_texture), priority);
|
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
hr = DD_OK;
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWORD *priority)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2014-07-16 14:39:15 +02:00
|
|
|
const struct wined3d_resource *resource;
|
2014-07-16 14:39:10 +02:00
|
|
|
DWORD managed = DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
TRACE("iface %p, priority %p.\n", iface, priority);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2014-07-16 14:39:10 +02:00
|
|
|
WARN("Called on offscreenplain surface, returning DDERR_INVALIDOBJECT.\n");
|
|
|
|
hr = DDERR_INVALIDOBJECT;
|
|
|
|
}
|
2016-01-05 15:04:53 +01:00
|
|
|
else if (!(surface->surface_desc.ddsCaps.dwCaps2 & managed) || !surface->is_complex_root)
|
2014-07-16 14:39:10 +02:00
|
|
|
{
|
2016-01-05 15:04:53 +01:00
|
|
|
WARN("Called on non-managed texture or non-root surface, returning DDERR_INVALIDPARAMS.\n");
|
2014-07-16 14:39:10 +02:00
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-16 14:39:15 +02:00
|
|
|
resource = wined3d_texture_get_resource(surface->wined3d_texture);
|
|
|
|
*priority = wined3d_resource_get_priority(resource);
|
2014-07-16 14:39:10 +02:00
|
|
|
hr = DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2014-07-16 14:39:10 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetPrivateData
|
|
|
|
*
|
|
|
|
* Stores some data in the surface that is intended for the application's
|
|
|
|
* use.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* tag: GUID that identifies the data
|
|
|
|
* Data: Pointer to the private data
|
|
|
|
* Size: Size of the private data
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
2017-03-05 18:59:47 +01:00
|
|
|
* D3D_OK on success, error code otherwise.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface,
|
2014-03-16 20:38:58 +01:00
|
|
|
REFGUID tag, void *data, DWORD size, DWORD flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2007-05-11 00:09:35 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n",
|
2014-03-16 20:38:58 +01:00
|
|
|
iface, debugstr_guid(tag), data, size, flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2014-04-07 22:27:32 +02:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
WARN("data is NULL, returning DDERR_INVALIDPARAMS.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2014-03-16 20:38:58 +01:00
|
|
|
hr = wined3d_private_store_set_private_data(&surface->private_store, tag, data, size, flags);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2014-03-16 20:38:58 +01:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetPrivateData(IDirectDrawSurface4 *iface,
|
|
|
|
REFGUID tag, void *data, DWORD size, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n",
|
|
|
|
iface, debugstr_guid(tag), data, size, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetPrivateData(&surface->IDirectDrawSurface7_iface, tag, data, size, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetPrivateData
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Returns the private data set with IDirectDrawSurface7::SetPrivateData
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* tag: GUID of the data to return
|
|
|
|
* Data: Address where to write the data to
|
|
|
|
* Size: Size of the buffer at Data
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Data is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2014-03-16 20:38:58 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPrivateData(IDirectDrawSurface7 *iface, REFGUID tag, void *data, DWORD *size)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2014-03-16 20:38:58 +01:00
|
|
|
const struct wined3d_private_data *stored_data;
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %p.\n",
|
2014-03-16 20:38:58 +01:00
|
|
|
iface, debugstr_guid(tag), data, size);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2014-03-16 20:38:58 +01:00
|
|
|
stored_data = wined3d_private_store_get_private_data(&surface->private_store, tag);
|
|
|
|
if (!stored_data)
|
|
|
|
{
|
|
|
|
hr = DDERR_NOTFOUND;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (!size)
|
|
|
|
{
|
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (*size < stored_data->size)
|
|
|
|
{
|
|
|
|
*size = stored_data->size;
|
|
|
|
hr = DDERR_MOREDATA;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
goto done;
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
|
2014-03-16 20:38:58 +01:00
|
|
|
*size = stored_data->size;
|
|
|
|
memcpy(data, stored_data->content.data, stored_data->size);
|
|
|
|
hr = DD_OK;
|
|
|
|
|
|
|
|
done:
|
|
|
|
wined3d_mutex_unlock();
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetPrivateData(IDirectDrawSurface4 *iface, REFGUID tag, void *data, DWORD *size)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %p.\n",
|
|
|
|
iface, debugstr_guid(tag), data, size);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPrivateData(&surface->IDirectDrawSurface7_iface, tag, data, size);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::FreePrivateData
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Frees private data stored in the surface
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* tag: Tag of the data to free
|
|
|
|
*
|
|
|
|
* Returns:
|
2017-03-05 18:59:47 +01:00
|
|
|
* D3D_OK on success, error code otherwise.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_FreePrivateData(IDirectDrawSurface7 *iface, REFGUID tag)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2014-03-16 20:38:58 +01:00
|
|
|
struct wined3d_private_data *entry;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2014-03-16 20:38:58 +01:00
|
|
|
entry = wined3d_private_store_get_private_data(&surface->private_store, tag);
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_private_store_free_private_data(&surface->private_store, entry);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2014-03-16 20:38:58 +01:00
|
|
|
return DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_FreePrivateData(IDirectDrawSurface4 *iface, REFGUID tag)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag));
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_FreePrivateData(&surface->IDirectDrawSurface7_iface, tag);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::PageLock
|
|
|
|
*
|
|
|
|
* Prevents a sysmem surface from being paged out
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Not used, must be 0(unchecked)
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_PageLock(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* This is Windows memory management related - we don't need this */
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_PageLock(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_PageLock(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_PageLock(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_PageLock(&surface->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_PageLock(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_PageLock(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::PageUnlock
|
|
|
|
*
|
|
|
|
* Allows a sysmem surface to be paged out
|
|
|
|
*
|
|
|
|
* Params:
|
2008-04-02 21:26:42 +02:00
|
|
|
* Flags: Not used, must be 0(unchecked)
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_PageUnlock(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_PageUnlock(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_PageUnlock(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_PageUnlock(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_PageUnlock(&surface->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_PageUnlock(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_PageUnlock(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::BltBatch
|
|
|
|
*
|
|
|
|
* An unimplemented function
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, Batch, Count, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* MSDN: "not currently implemented" */
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_BltBatch(IDirectDrawSurface4 *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
2011-06-06 13:39:04 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltBatch(&surface->IDirectDrawSurface7_iface, batch, count, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_BltBatch(IDirectDrawSurface3 *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltBatch(&surface->IDirectDrawSurface7_iface, batch, count, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_BltBatch(IDirectDrawSurface2 *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltBatch(&surface->IDirectDrawSurface7_iface, batch, count, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_BltBatch(IDirectDrawSurface *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
2011-06-09 17:29:36 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltBatch(&surface->IDirectDrawSurface7_iface, batch, count, flags);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::EnumAttachedSurfaces
|
|
|
|
*
|
|
|
|
* Enumerates all surfaces attached to this surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* context: Pointer to pass unmodified to the callback
|
|
|
|
* cb: Callback function to call for each surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if cb is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK7 cb)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
struct ddraw_surface *surf;
|
2006-06-09 19:36:12 +02:00
|
|
|
DDSURFACEDESC2 desc;
|
2007-04-27 15:31:12 +02:00
|
|
|
int i;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Attached surfaces aren't handled in WineD3D */
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, cb);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!cb)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
2007-04-27 15:31:12 +02:00
|
|
|
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
surf = surface->complex_array[i];
|
2007-04-27 15:31:12 +02:00
|
|
|
if(!surf) break;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
ddraw_surface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
desc = surf->surface_desc;
|
|
|
|
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
|
2011-06-05 18:55:04 +02:00
|
|
|
if (cb(&surf->IDirectDrawSurface7_iface, &desc, context) == DDENUMRET_CANCEL)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
for (surf = surface->next_attached; surf != NULL; surf = surf->next_attached)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-05 18:55:04 +02:00
|
|
|
ddraw_surface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
desc = surf->surface_desc;
|
|
|
|
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
|
2011-06-05 18:55:04 +02:00
|
|
|
if (cb(&surf->IDirectDrawSurface7_iface, &desc, context) == DDENUMRET_CANCEL)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE(" end of enumeration.\n");
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
struct callback_info2
|
|
|
|
{
|
|
|
|
LPDDENUMSURFACESCALLBACK2 callback;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
struct callback_info
|
|
|
|
{
|
|
|
|
LPDDENUMSURFACESCALLBACK callback;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT CALLBACK EnumCallback2(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface);
|
2011-06-06 13:39:04 +02:00
|
|
|
const struct callback_info2 *info = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
ddraw_surface4_AddRef(&surface_impl->IDirectDrawSurface4_iface);
|
2011-06-28 01:34:23 +02:00
|
|
|
ddraw_surface7_Release(surface);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return info->callback(&surface_impl->IDirectDrawSurface4_iface, surface_desc, info->context);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT CALLBACK EnumCallback(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface);
|
2010-07-19 18:36:20 +02:00
|
|
|
const struct callback_info *info = context;
|
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
ddraw_surface1_AddRef(&surface_impl->IDirectDrawSurface_iface);
|
|
|
|
ddraw_surface7_Release(surface);
|
|
|
|
|
2011-08-28 15:00:59 +02:00
|
|
|
/* FIXME: Check surface_test.dwSize */
|
2011-06-09 17:29:36 +02:00
|
|
|
return info->callback(&surface_impl->IDirectDrawSurface_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
(DDSURFACEDESC *)surface_desc, info->context);
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_EnumAttachedSurfaces(IDirectDrawSurface4 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK2 callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
2011-06-06 13:39:04 +02:00
|
|
|
struct callback_info2 info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&surface->IDirectDrawSurface7_iface,
|
2011-06-06 13:39:04 +02:00
|
|
|
&info, EnumCallback2);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_EnumAttachedSurfaces(IDirectDrawSurface3 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&surface->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
&info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_EnumAttachedSurfaces(IDirectDrawSurface2 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&surface->IDirectDrawSurface7_iface,
|
2011-06-09 16:35:15 +02:00
|
|
|
&info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_EnumAttachedSurfaces(IDirectDrawSurface *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2011-06-09 17:29:36 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&surface->IDirectDrawSurface7_iface,
|
2011-06-09 17:29:36 +02:00
|
|
|
&info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::EnumOverlayZOrders
|
|
|
|
*
|
|
|
|
* "Enumerates the overlay surfaces on the specified destination"
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
|
|
|
|
* context: context to pass back to the callback
|
|
|
|
* cb: callback function to call for each enumerated surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
|
|
|
|
DWORD Flags, void *context, LPDDENUMSURFACESCALLBACK7 cb)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, flags %#x, context %p, callback %p stub!\n", iface, Flags, context, cb);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_EnumOverlayZOrders(IDirectDrawSurface4 *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK2 callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
2011-06-06 13:39:04 +02:00
|
|
|
struct callback_info2 info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&surface->IDirectDrawSurface7_iface,
|
2011-06-06 13:39:04 +02:00
|
|
|
flags, &info, EnumCallback2);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_EnumOverlayZOrders(IDirectDrawSurface3 *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&surface->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
flags, &info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_EnumOverlayZOrders(IDirectDrawSurface2 *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&surface->IDirectDrawSurface7_iface,
|
2011-06-09 16:35:15 +02:00
|
|
|
flags, &info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_EnumOverlayZOrders(IDirectDrawSurface *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2011-06-09 17:29:36 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&surface->IDirectDrawSurface7_iface,
|
2011-06-09 17:29:36 +02:00
|
|
|
flags, &info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetBltStatus
|
|
|
|
*
|
|
|
|
* Returns the blitting status
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetBltStatus(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2015-09-09 19:02:25 +02:00
|
|
|
switch (Flags)
|
2007-04-14 22:44:55 +02:00
|
|
|
{
|
2015-09-09 19:02:25 +02:00
|
|
|
case WINEDDGBS_CANBLT:
|
|
|
|
case WINEDDGBS_ISBLTDONE:
|
|
|
|
return DD_OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2007-04-14 22:44:55 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetBltStatus(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetBltStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetBltStatus(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetBltStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetBltStatus(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetBltStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetBltStatus(IDirectDrawSurface *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetBltStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetColorKey
|
|
|
|
*
|
|
|
|
* Returns the color key assigned to the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Some flags
|
|
|
|
* CKey: Address to store the key to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if CKey is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetColorKey(IDirectDrawSurface7 *iface, DWORD Flags, DDCOLORKEY *CKey)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, Flags, CKey);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!CKey)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2008-05-05 23:49:32 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
switch (Flags)
|
|
|
|
{
|
|
|
|
case DDCKEY_DESTBLT:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKDESTBLT))
|
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2008-05-05 23:49:32 +02:00
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.ddckCKDestBlt;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_DESTOVERLAY:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKDESTOVERLAY))
|
2011-11-13 19:52:24 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
2008-05-05 23:49:32 +02:00
|
|
|
return DDERR_NOCOLORKEY;
|
2011-11-13 19:52:24 +01:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.u3.ddckCKDestOverlay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCBLT:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKSRCBLT))
|
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2008-05-05 23:49:32 +02:00
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.ddckCKSrcBlt;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCOVERLAY:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKSRCOVERLAY))
|
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2008-05-05 23:49:32 +02:00
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.ddckCKSrcOverlay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetColorKey(IDirectDrawSurface4 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetColorKey(&surface->IDirectDrawSurface7_iface, flags, color_key);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetColorKey(IDirectDrawSurface3 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetColorKey(&surface->IDirectDrawSurface7_iface, flags, color_key);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetColorKey(IDirectDrawSurface2 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetColorKey(&surface->IDirectDrawSurface7_iface, flags, color_key);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetColorKey(IDirectDrawSurface *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetColorKey(&surface->IDirectDrawSurface7_iface, flags, color_key);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetFlipStatus
|
|
|
|
*
|
|
|
|
* Returns the flipping status of the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetFlipStatus(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2015-09-09 19:02:26 +02:00
|
|
|
/* XXX: DDERR_INVALIDSURFACETYPE */
|
2011-11-13 19:52:24 +01:00
|
|
|
|
2015-09-09 19:02:26 +02:00
|
|
|
switch (Flags)
|
2007-04-14 22:44:55 +02:00
|
|
|
{
|
2015-09-09 19:02:26 +02:00
|
|
|
case WINEDDGFS_CANFLIP:
|
|
|
|
case WINEDDGFS_ISFLIPDONE:
|
|
|
|
return DD_OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2007-04-14 22:44:55 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetFlipStatus(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetFlipStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetFlipStatus(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetFlipStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetFlipStatus(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetFlipStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetFlipStatus(IDirectDrawSurface *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetFlipStatus(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetOverlayPosition
|
|
|
|
*
|
|
|
|
* Returns the display coordinates of a visible and active overlay surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* X
|
|
|
|
* Y
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_NOTAOVERLAYSURFACE, because it's a stub
|
|
|
|
*****************************************************************************/
|
2016-02-05 21:31:02 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetOverlayPosition(IDirectDrawSurface7 *iface, LONG *x, LONG *y)
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2016-02-05 21:31:02 +01:00
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-02-05 21:31:02 +01:00
|
|
|
hr = wined3d_texture_get_overlay_position(surface->wined3d_texture,
|
|
|
|
surface->sub_resource_idx, x, y);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetOverlayPosition(IDirectDrawSurface4 *iface, LONG *x, LONG *y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetOverlayPosition(IDirectDrawSurface3 *iface, LONG *x, LONG *y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetOverlayPosition(IDirectDrawSurface2 *iface, LONG *x, LONG *y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetOverlayPosition(IDirectDrawSurface *iface, LONG *x, LONG *y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetPixelFormat
|
|
|
|
*
|
|
|
|
* Returns the pixel format of the Surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
|
|
|
|
* format should be written
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if PixelFormat is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPixelFormat(IDirectDrawSurface7 *iface, DDPIXELFORMAT *PixelFormat)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/* What is DDERR_INVALIDSURFACETYPE for here? */
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, PixelFormat);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!PixelFormat)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
DD_STRUCT_COPY_BYSIZE(PixelFormat, &surface->surface_desc.u4.ddpfPixelFormat);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetPixelFormat(IDirectDrawSurface4 *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPixelFormat(&surface->IDirectDrawSurface7_iface, pixel_format);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetPixelFormat(IDirectDrawSurface3 *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPixelFormat(&surface->IDirectDrawSurface7_iface, pixel_format);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetPixelFormat(IDirectDrawSurface2 *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPixelFormat(&surface->IDirectDrawSurface7_iface, pixel_format);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetPixelFormat(IDirectDrawSurface *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPixelFormat(&surface->IDirectDrawSurface7_iface, pixel_format);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetSurfaceDesc
|
|
|
|
*
|
|
|
|
* Returns the description of this surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
|
|
|
|
* surface desc
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DDSD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetSurfaceDesc(IDirectDrawSurface7 *iface, DDSURFACEDESC2 *DDSD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!DDSD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-08 17:22:16 +02:00
|
|
|
if (DDSD->dwSize != sizeof(DDSURFACEDESC2))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2007-06-08 17:22:16 +02:00
|
|
|
WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",DDSD->dwSize);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
DD_STRUCT_COPY_BYSIZE(DDSD, &surface->surface_desc);
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("Returning surface desc:\n");
|
|
|
|
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetSurfaceDesc(IDirectDrawSurface4 *iface, DDSURFACEDESC2 *DDSD)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetSurfaceDesc(&surface->IDirectDrawSurface7_iface, DDSD);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetSurfaceDesc(IDirectDrawSurface3 *iface, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
|
|
|
|
|
|
|
|
if (!surface_desc) return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if (surface_desc->dwSize != sizeof(DDSURFACEDESC))
|
|
|
|
{
|
|
|
|
WARN("Incorrect structure size %u, returning DDERR_INVALIDPARAMS.\n", surface_desc->dwSize);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
DDSD2_to_DDSD(&surface->surface_desc, surface_desc);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("Returning surface desc:\n");
|
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
/* DDRAW_dump_surface_desc handles the smaller size */
|
|
|
|
DDRAW_dump_surface_desc((DDSURFACEDESC2 *)surface_desc);
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-07-19 18:36:20 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetSurfaceDesc(IDirectDrawSurface2 *iface, DDSURFACEDESC *DDSD)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface3_GetSurfaceDesc(&surface->IDirectDrawSurface3_iface, DDSD);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetSurfaceDesc(IDirectDrawSurface *iface, DDSURFACEDESC *DDSD)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface3_GetSurfaceDesc(&surface->IDirectDrawSurface3_iface, DDSD);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Initialize
|
|
|
|
*
|
|
|
|
* Initializes the surface. This is a no-op in Wine
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DD: Pointer to an DirectDraw interface
|
|
|
|
* DDSD: Surface description for initialization
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_ALREADYINITIALIZED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Initialize(IDirectDrawSurface7 *iface,
|
2010-07-19 12:47:57 +02:00
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC2 *surface_desc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-07-19 12:47:57 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DDERR_ALREADYINITIALIZED;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Initialize(IDirectDrawSurface4 *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC2 *surface_desc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Initialize(&surface->IDirectDrawSurface7_iface,
|
2011-06-06 13:39:04 +02:00
|
|
|
ddraw, surface_desc);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Initialize(IDirectDrawSurface3 *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Initialize(&surface->IDirectDrawSurface7_iface,
|
2011-09-03 21:06:11 +02:00
|
|
|
ddraw, surface_desc ? &surface_desc2 : NULL);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Initialize(IDirectDrawSurface2 *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Initialize(&surface->IDirectDrawSurface7_iface,
|
2011-09-03 21:06:11 +02:00
|
|
|
ddraw, surface_desc ? &surface_desc2 : NULL);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Initialize(IDirectDrawSurface *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Initialize(&surface->IDirectDrawSurface7_iface,
|
2011-09-03 21:06:11 +02:00
|
|
|
ddraw, surface_desc ? &surface_desc2 : NULL);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture1::Initialize
|
|
|
|
*
|
|
|
|
* The sdk says it's not implemented
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture1_Initialize(IDirect3DTexture *iface,
|
|
|
|
IDirect3DDevice *device, IDirectDrawSurface *surface)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, device %p, surface %p.\n", iface, device, surface);
|
|
|
|
|
|
|
|
return DDERR_UNSUPPORTED; /* Unchecked */
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::IsLost
|
|
|
|
*
|
|
|
|
* Checks if the surface is lost
|
|
|
|
*
|
|
|
|
* Returns:
|
2008-05-06 15:54:52 +02:00
|
|
|
* DD_OK, if the surface is usable
|
2006-06-09 19:36:12 +02:00
|
|
|
* DDERR_ISLOST if the surface is lost
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_IsLost(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_IsLost(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_IsLost(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_IsLost(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_IsLost(IDirectDrawSurface *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Restore
|
|
|
|
*
|
|
|
|
* Restores a lost surface. This makes the surface usable again, but
|
|
|
|
* doesn't reload its old contents
|
|
|
|
*
|
|
|
|
* Returns:
|
2017-03-05 18:59:47 +01:00
|
|
|
* DD_OK on success, error code otherwise.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2019-08-05 20:58:32 +02:00
|
|
|
unsigned int i;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2017-02-01 12:02:56 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
struct wined3d_swapchain *swapchain = surface->ddraw->wined3d_swapchain;
|
2017-02-01 12:02:57 +01:00
|
|
|
struct wined3d_sub_resource_desc wined3d_desc;
|
2017-02-01 12:02:56 +01:00
|
|
|
struct wined3d_display_mode mode;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_swapchain_get_display_mode(swapchain, &mode, NULL)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get display mode, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-02-01 12:02:57 +01:00
|
|
|
if (FAILED(hr = wined3d_texture_get_sub_resource_desc(surface->wined3d_texture, 0, &wined3d_desc)))
|
2017-02-01 12:02:56 +01:00
|
|
|
{
|
2017-02-01 12:02:57 +01:00
|
|
|
WARN("Failed to get resource desc, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode.width != wined3d_desc.width || mode.height != wined3d_desc.height)
|
|
|
|
{
|
|
|
|
WARN("Display mode dimensions %ux%u don't match surface dimensions %ux%u.\n",
|
|
|
|
mode.width, mode.height, wined3d_desc.width, wined3d_desc.height);
|
|
|
|
return DDERR_WRONGMODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode.format_id != wined3d_desc.format)
|
|
|
|
{
|
|
|
|
WARN("Display mode format %#x doesn't match surface format %#x.\n",
|
|
|
|
mode.format_id, wined3d_desc.format);
|
2017-02-01 12:02:56 +01:00
|
|
|
return DDERR_WRONGMODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-30 14:12:28 +02:00
|
|
|
if (!ddraw_surface_can_be_lost(surface))
|
|
|
|
return DD_OK;
|
2015-12-04 11:30:14 +01:00
|
|
|
ddraw_update_lost_surfaces(surface->ddraw);
|
2020-07-30 14:12:28 +02:00
|
|
|
if (surface->ddraw->device_state == DDRAW_DEVICE_STATE_LOST)
|
|
|
|
return DDERR_WRONGMODE;
|
2019-08-05 20:58:32 +02:00
|
|
|
|
2020-07-30 14:12:28 +02:00
|
|
|
surface->is_lost = FALSE;
|
2019-08-05 20:58:32 +02:00
|
|
|
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
|
|
|
|
{
|
|
|
|
if (surface->complex_array[i])
|
|
|
|
surface->complex_array[i]->is_lost = FALSE;
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
|
2015-12-04 11:30:14 +01:00
|
|
|
return DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Restore(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Restore(&surface->IDirectDrawSurface7_iface);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Restore(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Restore(&surface->IDirectDrawSurface7_iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Restore(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Restore(&surface->IDirectDrawSurface7_iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Restore(IDirectDrawSurface *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_Restore(&surface->IDirectDrawSurface7_iface);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetOverlayPosition
|
|
|
|
*
|
|
|
|
* Changes the display coordinates of an overlay surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* X:
|
|
|
|
* Y:
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
|
|
|
|
*****************************************************************************/
|
2016-02-05 21:31:03 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetOverlayPosition(IDirectDrawSurface7 *iface, LONG x, LONG y)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2016-02-05 21:31:03 +01:00
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
2006-10-05 16:37:42 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-02-05 21:31:03 +01:00
|
|
|
hr = wined3d_texture_set_overlay_position(surface->wined3d_texture,
|
|
|
|
surface->sub_resource_idx, x, y);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetOverlayPosition(IDirectDrawSurface4 *iface, LONG x, LONG y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetOverlayPosition(IDirectDrawSurface3 *iface, LONG x, LONG y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetOverlayPosition(IDirectDrawSurface2 *iface, LONG x, LONG y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetOverlayPosition(IDirectDrawSurface *iface, LONG x, LONG y)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetOverlayPosition(&surface->IDirectDrawSurface7_iface, x, y);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::UpdateOverlay
|
|
|
|
*
|
|
|
|
* Modifies the attributes of an overlay surface.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* SrcRect: The section of the source being used for the overlay
|
|
|
|
* DstSurface: Address of the surface that is overlaid
|
|
|
|
* DstRect: Place of the overlay
|
|
|
|
* Flags: some DDOVER_* flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED, because we don't support overlays
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2016-02-08 18:32:01 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface7 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = impl_from_IDirectDrawSurface7(iface);
|
2016-02-08 18:32:01 +01:00
|
|
|
struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface7(dst_surface);
|
|
|
|
struct wined3d_texture *dst_wined3d_texture = NULL;
|
|
|
|
unsigned int dst_sub_resource_idx = 0;
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
2016-02-08 18:32:01 +01:00
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
2006-10-05 16:43:26 +02:00
|
|
|
|
2016-02-15 18:18:00 +01:00
|
|
|
if (fx)
|
|
|
|
FIXME("Ignoring fx %p.\n", fx);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-02-08 18:32:01 +01:00
|
|
|
if (dst_impl)
|
|
|
|
{
|
|
|
|
dst_wined3d_texture = dst_impl->wined3d_texture;
|
|
|
|
dst_sub_resource_idx = dst_impl->sub_resource_idx;
|
|
|
|
}
|
2016-02-15 18:18:00 +01:00
|
|
|
hr = wined3d_texture_update_overlay(src_impl->wined3d_texture, src_impl->sub_resource_idx,
|
|
|
|
src_rect, dst_wined3d_texture, dst_sub_resource_idx, dst_rect, flags);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2020-04-21 15:37:17 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_UpdateOverlay(IDirectDrawSurface4 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface4 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface4(dst_surface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlay(&src_impl->IDirectDrawSurface7_iface, src_rect,
|
2011-06-06 13:39:04 +02:00
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_UpdateOverlay(IDirectDrawSurface3 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface3 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface3(dst_surface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlay(&src_impl->IDirectDrawSurface7_iface, src_rect,
|
2011-06-05 18:55:04 +02:00
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_UpdateOverlay(IDirectDrawSurface2 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface2 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface2(dst_surface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlay(&src_impl->IDirectDrawSurface7_iface, src_rect,
|
2011-06-09 16:35:15 +02:00
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_UpdateOverlay(IDirectDrawSurface *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface(dst_surface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlay(&src_impl->IDirectDrawSurface7_iface, src_rect,
|
2011-06-09 17:29:36 +02:00
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::UpdateOverlayDisplay
|
|
|
|
*
|
|
|
|
* The DX7 sdk says that it's not implemented
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: ?
|
|
|
|
*
|
|
|
|
* Returns: DDERR_UNSUPPORTED, because we don't support overlays
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_UpdateOverlayDisplay(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_UpdateOverlayDisplay(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_UpdateOverlayDisplay(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&surface->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_UpdateOverlayDisplay(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_UpdateOverlayDisplay(IDirectDrawSurface *iface, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&surface->IDirectDrawSurface7_iface, flags);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::UpdateOverlayZOrder
|
|
|
|
*
|
|
|
|
* Sets an overlay's Z order
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDOVERZ_* flags
|
|
|
|
* DDSRef: Defines the relative position in the overlay chain
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_NOTOVERLAYSURFACE, because we don't support overlays
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
|
2016-02-08 18:32:02 +01:00
|
|
|
DWORD flags, IDirectDrawSurface7 *reference)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2006-10-05 16:41:19 +02:00
|
|
|
|
2016-02-08 18:32:02 +01:00
|
|
|
FIXME("iface %p, flags %#x, reference %p stub!\n", iface, flags, reference);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-02-08 18:32:02 +01:00
|
|
|
if (!(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_OVERLAY))
|
|
|
|
{
|
|
|
|
WARN("Not an overlay surface.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOTAOVERLAYSURFACE;
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2016-02-08 18:32:02 +01:00
|
|
|
return DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_UpdateOverlayZOrder(IDirectDrawSurface4 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface4 *reference)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct ddraw_surface *reference_impl = unsafe_impl_from_IDirectDrawSurface4(reference);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&surface->IDirectDrawSurface7_iface, flags,
|
2011-06-06 13:39:04 +02:00
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_UpdateOverlayZOrder(IDirectDrawSurface3 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface3 *reference)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
struct ddraw_surface *reference_impl = unsafe_impl_from_IDirectDrawSurface3(reference);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&surface->IDirectDrawSurface7_iface, flags,
|
2011-06-05 18:55:04 +02:00
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_UpdateOverlayZOrder(IDirectDrawSurface2 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface2 *reference)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct ddraw_surface *reference_impl = unsafe_impl_from_IDirectDrawSurface2(reference);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&surface->IDirectDrawSurface7_iface, flags,
|
2011-06-09 16:35:15 +02:00
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_UpdateOverlayZOrder(IDirectDrawSurface *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface *reference)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *reference_impl = unsafe_impl_from_IDirectDrawSurface(reference);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&surface->IDirectDrawSurface7_iface, flags,
|
2011-06-09 17:29:36 +02:00
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetDDInterface
|
|
|
|
*
|
|
|
|
* Returns the IDirectDraw7 interface pointer of the DirectDraw object this
|
|
|
|
* surface belongs to
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DD: Address to write the interface pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetDDInterface(IDirectDrawSurface7 *iface, void **DD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, DD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!DD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-07-10 16:06:33 +02:00
|
|
|
switch(This->version)
|
|
|
|
{
|
|
|
|
case 7:
|
2011-01-19 01:42:43 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw7_iface;
|
2006-07-10 16:06:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2011-01-19 01:40:53 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw4_iface;
|
2007-02-16 19:09:19 +01:00
|
|
|
break;
|
2006-07-10 16:06:33 +02:00
|
|
|
|
|
|
|
case 2:
|
2011-01-19 01:36:36 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw2_iface;
|
2007-02-16 19:09:19 +01:00
|
|
|
break;
|
|
|
|
|
2006-07-10 16:06:33 +02:00
|
|
|
case 1:
|
2011-01-19 01:33:42 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw_iface;
|
2006-07-10 16:06:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2009-01-21 09:56:13 +01:00
|
|
|
IUnknown_AddRef((IUnknown *)*DD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetDDInterface(IDirectDrawSurface4 *iface, void **ddraw)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, ddraw);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDDInterface(&surface->IDirectDrawSurface7_iface, ddraw);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetDDInterface(IDirectDrawSurface3 *iface, void **ddraw)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, ddraw);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDDInterface(&surface->IDirectDrawSurface7_iface, ddraw);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetDDInterface(IDirectDrawSurface2 *iface, void **ddraw)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, ddraw);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetDDInterface(&surface->IDirectDrawSurface7_iface, ddraw);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_ChangeUniquenessValue(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_ChangeUniquenessValue(&surface->IDirectDrawSurface7_iface);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetUniquenessValue(IDirectDrawSurface7 *iface, DWORD *pValue)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, value %p.\n", iface, pValue);
|
|
|
|
|
2015-03-03 05:09:56 +01:00
|
|
|
*pValue = 0;
|
2011-11-13 19:52:24 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetUniquenessValue(IDirectDrawSurface4 *iface, DWORD *pValue)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, value %p.\n", iface, pValue);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetUniquenessValue(&surface->IDirectDrawSurface7_iface, pValue);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetLOD
|
|
|
|
*
|
|
|
|
* Sets the level of detail of a texture
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* MaxLOD: LOD to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDOBJECT if the surface is invalid for this method
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetLOD(IDirectDrawSurface7 *iface, DWORD MaxLOD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, lod %u.\n", iface, MaxLOD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
if (!(surface->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDOBJECT;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
hr = wined3d_texture_set_lod(surface->wined3d_texture, MaxLOD);
|
2021-03-11 14:33:55 +01:00
|
|
|
if (SUCCEEDED(hr) && surface->draw_texture)
|
|
|
|
hr = wined3d_texture_set_lod(surface->draw_texture, MaxLOD);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetLOD
|
|
|
|
*
|
|
|
|
* Returns the level of detail of a Direct3D texture
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* MaxLOD: Address to write the LOD to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if MaxLOD is NULL
|
|
|
|
* DDERR_INVALIDOBJECT if the surface is invalid for this method
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetLOD(IDirectDrawSurface7 *iface, DWORD *MaxLOD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, lod %p.\n", iface, MaxLOD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!MaxLOD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
if (!(surface->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDOBJECT;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
*MaxLOD = wined3d_texture_get_lod(surface->wined3d_texture);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::BltFast
|
|
|
|
*
|
|
|
|
* Performs a fast Blit.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* dstx: The x coordinate to blit to on the destination
|
|
|
|
* dsty: The y coordinate to blit to on the destination
|
|
|
|
* Source: The source surface
|
|
|
|
* rsrc: The source rectangle
|
|
|
|
* trans: Type of transfer. Some DDBLTFAST_* flags
|
|
|
|
*
|
|
|
|
* Returns:
|
2017-03-05 18:59:47 +01:00
|
|
|
* DD_OK on success, error code otherwise.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2016-01-27 20:44:36 +01:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_BltFast(IDirectDrawSurface7 *iface,
|
|
|
|
DWORD dst_x, DWORD dst_y, IDirectDrawSurface7 *src_surface, RECT *src_rect, DWORD trans)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2016-01-27 20:44:36 +01:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src_surface);
|
2017-04-24 23:31:31 +02:00
|
|
|
DWORD flags = WINED3D_BLT_SYNCHRONOUS;
|
2010-06-24 12:10:03 +02:00
|
|
|
DWORD src_w, src_h, dst_w, dst_h;
|
2011-10-24 21:24:38 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2016-01-27 20:44:36 +01:00
|
|
|
RECT dst_rect, s;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
2016-01-27 20:44:36 +01:00
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), trans);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2016-01-27 20:44:36 +01:00
|
|
|
dst_w = dst_impl->surface_desc.dwWidth;
|
|
|
|
dst_h = dst_impl->surface_desc.dwHeight;
|
2010-06-24 12:10:03 +02:00
|
|
|
|
2016-01-27 20:44:36 +01:00
|
|
|
if (!src_rect)
|
2007-05-24 22:24:00 +02:00
|
|
|
{
|
2016-01-27 20:44:36 +01:00
|
|
|
SetRect(&s, 0, 0, src_impl->surface_desc.dwWidth, src_impl->surface_desc.dwHeight);
|
|
|
|
src_rect = &s;
|
2010-06-24 12:10:03 +02:00
|
|
|
}
|
|
|
|
|
2016-01-27 20:44:36 +01:00
|
|
|
src_w = src_rect->right - src_rect->left;
|
|
|
|
src_h = src_rect->bottom - src_rect->top;
|
|
|
|
if (src_w > dst_w || dst_x > dst_w - src_w
|
|
|
|
|| src_h > dst_h || dst_y > dst_h - src_h)
|
2010-06-24 12:10:03 +02:00
|
|
|
{
|
|
|
|
WARN("Destination area out of bounds, returning DDERR_INVALIDRECT.\n");
|
|
|
|
return DDERR_INVALIDRECT;
|
2007-05-24 22:24:00 +02:00
|
|
|
}
|
|
|
|
|
2016-01-27 20:44:36 +01:00
|
|
|
SetRect(&dst_rect, dst_x, dst_y, dst_x + src_w, dst_y + src_h);
|
2011-10-30 18:06:34 +01:00
|
|
|
if (trans & DDBLTFAST_SRCCOLORKEY)
|
2016-02-15 18:18:02 +01:00
|
|
|
flags |= WINED3D_BLT_SRC_CKEY;
|
2011-10-30 18:06:34 +01:00
|
|
|
if (trans & DDBLTFAST_DESTCOLORKEY)
|
2016-02-15 18:18:02 +01:00
|
|
|
flags |= WINED3D_BLT_DST_CKEY;
|
2011-10-30 18:06:34 +01:00
|
|
|
if (trans & DDBLTFAST_WAIT)
|
2016-02-15 18:18:02 +01:00
|
|
|
flags |= WINED3D_BLT_WAIT;
|
2011-10-30 18:06:34 +01:00
|
|
|
if (trans & DDBLTFAST_DONOTWAIT)
|
2016-02-15 18:18:02 +01:00
|
|
|
flags |= WINED3D_BLT_DO_NOT_WAIT;
|
2011-10-30 18:06:34 +01:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2016-01-27 20:44:36 +01:00
|
|
|
if (dst_impl->clipper)
|
2012-01-04 23:34:54 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
WARN("Destination surface has a clipper set, returning DDERR_BLTFASTCANTCLIP.\n");
|
|
|
|
return DDERR_BLTFASTCANTCLIP;
|
|
|
|
}
|
|
|
|
|
2016-01-27 20:44:36 +01:00
|
|
|
if (src_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(src_impl, src_rect, TRUE, 0);
|
2012-01-04 23:34:54 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2021-04-07 03:56:44 +02:00
|
|
|
hr = wined3d_device_context_blt(dst_impl->ddraw->immediate_context,
|
|
|
|
ddraw_surface_get_any_texture(dst_impl, DDRAW_SURFACE_RW), dst_impl->sub_resource_idx, &dst_rect,
|
|
|
|
ddraw_surface_get_any_texture(src_impl,DDRAW_SURFACE_READ), src_impl->sub_resource_idx, src_rect,
|
|
|
|
flags, NULL, WINED3D_TEXF_POINT);
|
2016-01-27 20:44:36 +01:00
|
|
|
if (SUCCEEDED(hr) && (dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
2018-03-27 13:06:52 +02:00
|
|
|
hr = ddraw_surface_update_frontbuffer(dst_impl, &dst_rect, FALSE, 0);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_BltFast(IDirectDrawSurface4 *iface, DWORD dst_x, DWORD dst_y,
|
2011-06-06 13:39:04 +02:00
|
|
|
IDirectDrawSurface4 *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface4(src_surface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltFast(&dst_impl->IDirectDrawSurface7_iface, dst_x, dst_y,
|
2011-06-06 13:39:04 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_BltFast(IDirectDrawSurface3 *iface, DWORD dst_x, DWORD dst_y,
|
2010-07-19 18:36:20 +02:00
|
|
|
IDirectDrawSurface3 *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface3(src_surface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltFast(&dst_impl->IDirectDrawSurface7_iface, dst_x, dst_y,
|
2011-06-05 18:55:04 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_BltFast(IDirectDrawSurface2 *iface, DWORD dst_x, DWORD dst_y,
|
2011-06-09 16:35:15 +02:00
|
|
|
IDirectDrawSurface2 *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface2(src_surface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltFast(&dst_impl->IDirectDrawSurface7_iface, dst_x, dst_y,
|
2011-06-09 16:35:15 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
|
|
|
}
|
|
|
|
|
2015-06-11 17:38:47 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_BltFast(IDirectDrawSurface *iface, DWORD dst_x, DWORD dst_y,
|
2011-06-09 17:29:36 +02:00
|
|
|
IDirectDrawSurface *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src_surface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_BltFast(&dst_impl->IDirectDrawSurface7_iface, dst_x, dst_y,
|
2011-06-09 17:29:36 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
|
|
|
}
|
|
|
|
|
2019-03-13 19:16:23 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetClipper(IDirectDrawSurface7 *iface, IDirectDrawClipper **clipper)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2019-03-13 19:16:23 +01:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2019-03-13 19:16:23 +01:00
|
|
|
if (!clipper)
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-03-11 22:03:12 +01:00
|
|
|
if (!surface->clipper)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2019-03-13 19:16:23 +01:00
|
|
|
*clipper = NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_NOCLIPPERATTACHED;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2019-03-13 19:16:23 +01:00
|
|
|
*clipper = &surface->clipper->IDirectDrawClipper_iface;
|
2019-03-22 10:50:04 +01:00
|
|
|
if (ddraw_clipper_is_valid(surface->clipper))
|
|
|
|
IDirectDrawClipper_AddRef(*clipper);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetClipper(IDirectDrawSurface3 *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetClipper(IDirectDrawSurface2 *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetClipper(IDirectDrawSurface *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetClipper
|
|
|
|
*
|
|
|
|
* Sets a clipper for the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Clipper: IDirectDrawClipper interface of the clipper to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:22:55 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
|
|
|
|
IDirectDrawClipper *iclipper)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
2011-12-12 20:53:55 +01:00
|
|
|
struct ddraw_clipper *clipper = unsafe_impl_from_IDirectDrawClipper(iclipper);
|
|
|
|
struct ddraw_clipper *old_clipper = This->clipper;
|
2008-08-07 21:09:19 +02:00
|
|
|
HWND clipWindow;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-20 11:22:55 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, iclipper);
|
2007-05-30 15:25:34 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2011-06-20 11:22:55 +02:00
|
|
|
if (clipper == This->clipper)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-20 11:22:55 +02:00
|
|
|
This->clipper = clipper;
|
2007-02-16 19:08:21 +01:00
|
|
|
|
2011-06-20 11:22:55 +02:00
|
|
|
if (clipper != NULL)
|
|
|
|
IDirectDrawClipper_AddRef(iclipper);
|
2019-03-22 10:50:04 +01:00
|
|
|
if (old_clipper && ddraw_clipper_is_valid(old_clipper))
|
2011-12-12 20:53:55 +01:00
|
|
|
IDirectDrawClipper_Release(&old_clipper->IDirectDrawClipper_iface);
|
2008-08-07 21:09:19 +02:00
|
|
|
|
2011-09-19 21:50:24 +02:00
|
|
|
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_swapchain)
|
2011-04-13 19:14:31 +02:00
|
|
|
{
|
2008-08-07 21:09:19 +02:00
|
|
|
clipWindow = NULL;
|
2011-06-20 11:22:55 +02:00
|
|
|
if(clipper) {
|
|
|
|
IDirectDrawClipper_GetHWnd(iclipper, &clipWindow);
|
2008-08-07 21:09:19 +02:00
|
|
|
}
|
|
|
|
|
2011-04-13 19:14:31 +02:00
|
|
|
if (clipWindow)
|
2011-10-24 21:24:38 +02:00
|
|
|
{
|
2011-09-19 21:50:24 +02:00
|
|
|
wined3d_swapchain_set_window(This->ddraw->wined3d_swapchain, clipWindow);
|
2011-11-17 20:11:40 +01:00
|
|
|
ddraw_set_swapchain_window(This->ddraw, clipWindow);
|
2011-10-24 21:24:38 +02:00
|
|
|
}
|
2011-04-13 19:14:31 +02:00
|
|
|
else
|
2011-10-24 21:24:38 +02:00
|
|
|
{
|
2011-09-19 21:50:24 +02:00
|
|
|
wined3d_swapchain_set_window(This->ddraw->wined3d_swapchain, This->ddraw->d3d_window);
|
2011-11-17 20:11:40 +01:00
|
|
|
ddraw_set_swapchain_window(This->ddraw, This->ddraw->dest_window);
|
2011-10-24 21:24:38 +02:00
|
|
|
}
|
2008-08-07 21:09:19 +02:00
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2011-12-12 20:53:55 +01:00
|
|
|
return DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetClipper(IDirectDrawSurface3 *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetClipper(IDirectDrawSurface2 *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetClipper(IDirectDrawSurface *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetClipper(&surface->IDirectDrawSurface7_iface, clipper);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetSurfaceDesc
|
|
|
|
*
|
|
|
|
* Sets the surface description. It can override the pixel format, the surface
|
|
|
|
* memory, ...
|
|
|
|
* It's not really tested.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DDSD: Pointer to the new surface description to set
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DDSD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, DDSURFACEDESC2 *DDSD, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2020-06-17 00:54:26 +02:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2011-12-08 15:59:06 +01:00
|
|
|
const DWORD allowed_flags = DDSD_LPSURFACE | DDSD_PIXELFORMAT | DDSD_WIDTH
|
|
|
|
| DDSD_HEIGHT | DDSD_PITCH | DDSD_CAPS;
|
2012-01-12 21:43:08 +01:00
|
|
|
enum wined3d_format_id format_id;
|
2013-06-14 09:07:10 +02:00
|
|
|
UINT pitch, width, height;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, DDSD, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (!DDSD)
|
|
|
|
{
|
|
|
|
WARN("DDSD is NULL, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
if (Flags)
|
|
|
|
{
|
|
|
|
WARN("Flags is %x, returning DDERR_INVALIDPARAMS\n", Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2011-09-03 21:06:11 +02:00
|
|
|
}
|
2020-06-17 00:54:26 +02:00
|
|
|
if (!(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
|
|
|
|
|| surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE
|
|
|
|
|| surface->surface_desc.ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE))
|
2011-12-08 15:59:06 +01:00
|
|
|
{
|
|
|
|
WARN("Surface is not in system memory, returning DDERR_INVALIDSURFACETYPE.\n");
|
|
|
|
return DDERR_INVALIDSURFACETYPE;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-10-15 15:41:17 +02:00
|
|
|
/* Tests show that only LPSURFACE and PIXELFORMAT can be set, and LPSURFACE is required
|
|
|
|
* for PIXELFORMAT to work */
|
2011-12-08 15:59:06 +01:00
|
|
|
if (DDSD->dwFlags & ~allowed_flags)
|
2011-10-15 15:41:17 +02:00
|
|
|
{
|
|
|
|
WARN("Invalid flags (0x%08x) set, returning DDERR_INVALIDPARAMS\n", DDSD->dwFlags);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2013-12-03 13:44:36 +01:00
|
|
|
if (!(DDSD->dwFlags & DDSD_LPSURFACE) || !DDSD->lpSurface)
|
2011-10-15 15:41:17 +02:00
|
|
|
{
|
2013-12-03 13:44:36 +01:00
|
|
|
WARN("DDSD_LPSURFACE is not set or lpSurface is NULL, returning DDERR_INVALIDPARAMS\n");
|
2011-10-15 15:41:17 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2013-12-03 13:44:35 +01:00
|
|
|
if ((DDSD->dwFlags & DDSD_CAPS) && DDSD->ddsCaps.dwCaps)
|
2011-12-08 15:59:06 +01:00
|
|
|
{
|
|
|
|
WARN("DDSD_CAPS is set, returning DDERR_INVALIDCAPS.\n");
|
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
if (DDSD->dwFlags & DDSD_WIDTH)
|
|
|
|
{
|
|
|
|
if (!(DDSD->dwFlags & DDSD_PITCH))
|
|
|
|
{
|
|
|
|
WARN("DDSD_WIDTH is set, but DDSD_PITCH is not, returning DDERR_INVALIDPARAMS.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
if (!DDSD->dwWidth || DDSD->u1.lPitch <= 0 || DDSD->u1.lPitch & 0x3)
|
|
|
|
{
|
|
|
|
WARN("Pitch is %d, width is %u, returning DDERR_INVALIDPARAMS.\n",
|
|
|
|
DDSD->u1.lPitch, DDSD->dwWidth);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2020-06-17 00:54:26 +02:00
|
|
|
if (DDSD->dwWidth != surface->surface_desc.dwWidth)
|
|
|
|
TRACE("Surface width changed from %u to %u.\n", surface->surface_desc.dwWidth, DDSD->dwWidth);
|
|
|
|
if (DDSD->u1.lPitch != surface->surface_desc.u1.lPitch)
|
|
|
|
TRACE("Surface pitch changed from %u to %u.\n", surface->surface_desc.u1.lPitch, DDSD->u1.lPitch);
|
2013-06-14 09:07:10 +02:00
|
|
|
pitch = DDSD->u1.lPitch;
|
2012-01-12 21:43:08 +01:00
|
|
|
width = DDSD->dwWidth;
|
2011-12-08 15:59:06 +01:00
|
|
|
}
|
|
|
|
else if (DDSD->dwFlags & DDSD_PITCH)
|
|
|
|
{
|
|
|
|
WARN("DDSD_PITCH is set, but DDSD_WIDTH is not, returning DDERR_INVALIDPARAMS.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2012-01-12 21:43:08 +01:00
|
|
|
else
|
|
|
|
{
|
2020-06-17 00:54:26 +02:00
|
|
|
pitch = surface->surface_desc.u1.lPitch;
|
|
|
|
width = surface->surface_desc.dwWidth;
|
2012-01-12 21:43:08 +01:00
|
|
|
}
|
|
|
|
|
2011-12-08 15:59:06 +01:00
|
|
|
if (DDSD->dwFlags & DDSD_HEIGHT)
|
|
|
|
{
|
|
|
|
if (!DDSD->dwHeight)
|
|
|
|
{
|
|
|
|
WARN("Height is 0, returning DDERR_INVALIDPARAMS.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2020-06-17 00:54:26 +02:00
|
|
|
if (DDSD->dwHeight != surface->surface_desc.dwHeight)
|
|
|
|
TRACE("Surface height changed from %u to %u.\n", surface->surface_desc.dwHeight, DDSD->dwHeight);
|
2012-01-12 21:43:08 +01:00
|
|
|
height = DDSD->dwHeight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-17 00:54:26 +02:00
|
|
|
height = surface->surface_desc.dwHeight;
|
2011-12-08 15:59:06 +01:00
|
|
|
}
|
2011-10-15 15:41:17 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2006-06-09 19:36:12 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_PIXELFORMAT)
|
|
|
|
{
|
2012-01-12 21:43:08 +01:00
|
|
|
enum wined3d_format_id current_format_id;
|
2013-06-07 10:17:54 +02:00
|
|
|
format_id = wined3dformat_from_ddrawformat(&DDSD->u4.ddpfPixelFormat);
|
2006-06-23 17:13:10 +02:00
|
|
|
|
2012-01-12 21:43:08 +01:00
|
|
|
if (format_id == WINED3DFMT_UNKNOWN)
|
2006-06-23 17:13:10 +02:00
|
|
|
{
|
|
|
|
ERR("Requested to set an unknown pixelformat\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-23 17:13:10 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2020-06-17 00:54:26 +02:00
|
|
|
current_format_id = wined3dformat_from_ddrawformat(&surface->surface_desc.u4.ddpfPixelFormat);
|
2012-01-12 21:43:08 +01:00
|
|
|
if (format_id != current_format_id)
|
|
|
|
TRACE("Surface format changed from %#x to %#x.\n", current_format_id, format_id);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2012-01-12 21:43:08 +01:00
|
|
|
else
|
|
|
|
{
|
2020-06-17 00:54:26 +02:00
|
|
|
format_id = wined3dformat_from_ddrawformat(&surface->surface_desc.u4.ddpfPixelFormat);
|
2012-01-12 21:43:08 +01:00
|
|
|
}
|
|
|
|
|
2020-06-17 00:54:26 +02:00
|
|
|
if (FAILED(hr = wined3d_texture_update_desc(surface->wined3d_texture, surface->sub_resource_idx,
|
|
|
|
width, height, format_id, WINED3D_MULTISAMPLE_NONE, 0, DDSD->lpSurface, pitch)))
|
2012-01-12 21:43:08 +01:00
|
|
|
{
|
2014-01-07 22:12:13 +01:00
|
|
|
WARN("Failed to update surface desc, hr %#x.\n", hr);
|
|
|
|
wined3d_mutex_unlock();
|
2014-01-07 22:12:15 +01:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
2012-01-12 21:43:08 +01:00
|
|
|
}
|
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
if (surface->draw_texture && FAILED(hr = wined3d_texture_update_desc(surface->draw_texture,
|
|
|
|
surface->sub_resource_idx, width, height, format_id, WINED3D_MULTISAMPLE_NONE, 0, NULL, 0)))
|
|
|
|
{
|
|
|
|
ERR("Failed to update surface desc for draw_texture, hr %#x.\n", hr);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2014-01-07 22:12:13 +01:00
|
|
|
if (DDSD->dwFlags & DDSD_WIDTH)
|
2020-06-17 00:54:26 +02:00
|
|
|
surface->surface_desc.dwWidth = width;
|
2014-01-07 22:12:13 +01:00
|
|
|
if (DDSD->dwFlags & DDSD_PITCH)
|
2020-06-17 00:54:26 +02:00
|
|
|
surface->surface_desc.u1.lPitch = DDSD->u1.lPitch;
|
2014-01-07 22:12:13 +01:00
|
|
|
if (DDSD->dwFlags & DDSD_HEIGHT)
|
2020-06-17 00:54:26 +02:00
|
|
|
surface->surface_desc.dwHeight = height;
|
2014-01-07 22:12:13 +01:00
|
|
|
if (DDSD->dwFlags & DDSD_PIXELFORMAT)
|
2020-06-17 00:54:26 +02:00
|
|
|
surface->surface_desc.u4.ddpfPixelFormat = DDSD->u4.ddpfPixelFormat;
|
2014-01-07 22:12:13 +01:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetSurfaceDesc(IDirectDrawSurface4 *iface,
|
|
|
|
DDSURFACEDESC2 *surface_desc, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, surface_desc, flags);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetSurfaceDesc(&surface->IDirectDrawSurface7_iface,
|
2011-06-06 13:39:04 +02:00
|
|
|
surface_desc, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetSurfaceDesc(IDirectDrawSurface3 *iface,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2012-03-11 22:03:12 +01:00
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, surface_desc, flags);
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_SetSurfaceDesc(&surface->IDirectDrawSurface7_iface,
|
2011-09-03 21:06:11 +02:00
|
|
|
surface_desc ? &surface_desc2 : NULL, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2013-12-12 10:23:30 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette **palette)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2012-04-08 19:13:24 +02:00
|
|
|
struct ddraw_palette *palette_impl;
|
2011-04-29 13:03:41 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2013-12-12 10:23:30 +01:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-12-12 10:23:30 +01:00
|
|
|
if (!palette)
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
2014-07-06 18:06:43 +02:00
|
|
|
{
|
|
|
|
WARN("Surface lost, returning DDERR_SURFACELOST.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2013-12-12 10:23:30 +01:00
|
|
|
if ((palette_impl = surface->palette))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-12-12 10:23:30 +01:00
|
|
|
*palette = &palette_impl->IDirectDrawPalette_iface;
|
|
|
|
IDirectDrawPalette_AddRef(*palette);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-12 10:23:30 +01:00
|
|
|
*palette = NULL;
|
2006-09-09 13:45:19 +02:00
|
|
|
hr = DDERR_NOPALETTEATTACHED;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetPalette(IDirectDrawSurface4 *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPalette(&surface->IDirectDrawSurface7_iface, palette);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetPalette(IDirectDrawSurface3 *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPalette(&surface->IDirectDrawSurface7_iface, palette);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetPalette(IDirectDrawSurface2 *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPalette(&surface->IDirectDrawSurface7_iface, palette);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetPalette(IDirectDrawSurface *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return ddraw_surface7_GetPalette(&surface->IDirectDrawSurface7_iface, palette);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
static HRESULT ddraw_surface_set_wined3d_textures_colour_key(struct ddraw_surface *surface, DWORD flags,
|
|
|
|
struct wined3d_color_key *color_key)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = wined3d_texture_set_color_key(surface->wined3d_texture, flags, color_key);
|
|
|
|
if (surface->draw_texture && SUCCEEDED(hr))
|
|
|
|
hr = wined3d_texture_set_color_key(surface->draw_texture, flags, color_key);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
static HRESULT ddraw_surface_set_color_key(struct ddraw_surface *surface, DWORD flags, DDCOLORKEY *color_key)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2014-01-09 12:17:02 +01:00
|
|
|
DDCOLORKEY fixed_color_key;
|
2014-01-09 12:17:01 +01:00
|
|
|
HRESULT hr = WINED3D_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2015-08-23 21:59:35 +02:00
|
|
|
if (flags & DDCKEY_COLORSPACE)
|
|
|
|
{
|
|
|
|
if (color_key && color_key->dwColorSpaceLowValue != color_key->dwColorSpaceHighValue)
|
|
|
|
{
|
|
|
|
WARN("Range color keys are not supported, returning DDERR_NOCOLORKEYHW.\n");
|
|
|
|
return DDERR_NOCOLORKEYHW;
|
|
|
|
}
|
|
|
|
flags &= ~DDCKEY_COLORSPACE;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2014-01-09 12:17:02 +01:00
|
|
|
|
|
|
|
if (color_key)
|
2006-12-09 23:13:14 +01:00
|
|
|
{
|
2015-08-23 21:59:35 +02:00
|
|
|
fixed_color_key.dwColorSpaceLowValue = fixed_color_key.dwColorSpaceHighValue = color_key->dwColorSpaceLowValue;
|
2014-01-09 12:17:02 +01:00
|
|
|
switch (flags & ~DDCKEY_COLORSPACE)
|
2006-12-09 23:13:14 +01:00
|
|
|
{
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_DESTBLT:
|
|
|
|
surface->surface_desc.ddckCKDestBlt = fixed_color_key;
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_CKDESTBLT;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_DESTOVERLAY:
|
|
|
|
surface->surface_desc.u3.ddckCKDestOverlay = fixed_color_key;
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_SRCOVERLAY:
|
|
|
|
surface->surface_desc.ddckCKSrcOverlay = fixed_color_key;
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_SRCBLT:
|
|
|
|
surface->surface_desc.ddckCKSrcBlt = fixed_color_key;
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_CKSRCBLT;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
default:
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-12-09 23:13:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-09 12:17:02 +01:00
|
|
|
switch (flags & ~DDCKEY_COLORSPACE)
|
2006-12-09 23:13:14 +01:00
|
|
|
{
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_DESTBLT:
|
|
|
|
surface->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_DESTOVERLAY:
|
|
|
|
surface->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_SRCOVERLAY:
|
|
|
|
surface->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
case DDCKEY_SRCBLT:
|
|
|
|
surface->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
|
|
|
|
break;
|
2006-12-09 23:13:14 +01:00
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
default:
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-12-09 23:13:14 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-09 12:17:02 +01:00
|
|
|
|
2016-01-28 18:40:24 +01:00
|
|
|
if (surface->is_complex_root)
|
2021-03-11 14:33:55 +01:00
|
|
|
hr = ddraw_surface_set_wined3d_textures_colour_key(surface, flags,
|
2014-01-09 12:17:02 +01:00
|
|
|
color_key ? (struct wined3d_color_key *)&fixed_color_key : NULL);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2014-01-09 12:17:01 +01:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2015-12-22 22:43:41 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)
|
2014-01-09 12:17:02 +01:00
|
|
|
return DDERR_NOTONMIPMAPSUBLEVEL;
|
|
|
|
|
|
|
|
return ddraw_surface_set_color_key(surface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetColorKey(IDirectDrawSurface4 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
return ddraw_surface_set_color_key(surface, flags, color_key);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetColorKey(IDirectDrawSurface3 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
return ddraw_surface_set_color_key(surface, flags, color_key);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetColorKey(IDirectDrawSurface2 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
return ddraw_surface_set_color_key(surface, flags, color_key);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetColorKey(IDirectDrawSurface *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2014-01-09 12:17:02 +01:00
|
|
|
return ddraw_surface_set_color_key(surface, flags, color_key);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2013-12-12 10:23:30 +01:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette *palette)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-12-12 10:23:30 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2013-12-12 10:23:30 +01:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-12-12 10:23:30 +01:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)
|
2011-08-08 00:26:00 +02:00
|
|
|
return DDERR_NOTONMIPMAPSUBLEVEL;
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
2014-07-06 18:06:43 +02:00
|
|
|
{
|
|
|
|
WARN("Surface lost, returning DDERR_SURFACELOST.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
2011-08-08 00:26:00 +02:00
|
|
|
|
2014-04-24 14:36:09 +02:00
|
|
|
return ddraw_surface_set_palette(surface, palette);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetPalette(IDirectDrawSurface4 *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
2014-07-06 18:06:43 +02:00
|
|
|
{
|
|
|
|
WARN("Surface lost, returning DDERR_SURFACELOST.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2014-04-24 14:36:09 +02:00
|
|
|
return ddraw_surface_set_palette(surface, palette);
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetPalette(IDirectDrawSurface3 *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
2014-07-06 18:06:43 +02:00
|
|
|
{
|
|
|
|
WARN("Surface lost, returning DDERR_SURFACELOST.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2014-04-24 14:36:09 +02:00
|
|
|
return ddraw_surface_set_palette(surface, palette);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetPalette(IDirectDrawSurface2 *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
2014-07-06 18:06:43 +02:00
|
|
|
{
|
|
|
|
WARN("Surface lost, returning DDERR_SURFACELOST.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2014-04-24 14:36:09 +02:00
|
|
|
return ddraw_surface_set_palette(surface, palette);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetPalette(IDirectDrawSurface *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2020-03-26 14:09:39 +01:00
|
|
|
if (ddraw_surface_is_lost(surface))
|
2014-07-06 18:06:43 +02:00
|
|
|
{
|
|
|
|
WARN("Surface lost, returning DDERR_SURFACELOST.\n");
|
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2014-04-24 14:36:09 +02:00
|
|
|
return ddraw_surface_set_palette(surface, palette);
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
/**********************************************************
|
|
|
|
* IDirectDrawGammaControl::GetGammaRamp
|
|
|
|
*
|
|
|
|
* Returns the current gamma ramp for a surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* flags: Ignored
|
|
|
|
* gamma_ramp: Address to write the ramp to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if gamma_ramp is NULL
|
|
|
|
*
|
|
|
|
**********************************************************/
|
|
|
|
static HRESULT WINAPI ddraw_gamma_control_GetGammaRamp(IDirectDrawGammaControl *iface,
|
|
|
|
DWORD flags, DDGAMMARAMP *gamma_ramp)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawGammaControl(iface);
|
2010-08-18 19:26:18 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, gamma_ramp %p.\n", iface, flags, gamma_ramp);
|
|
|
|
|
|
|
|
if (!gamma_ramp)
|
|
|
|
{
|
|
|
|
WARN("Invalid gamma_ramp passed.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-18 19:26:18 +02:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
2011-11-21 18:48:41 +01:00
|
|
|
/* Note: DDGAMMARAMP is compatible with struct wined3d_gamma_ramp. */
|
|
|
|
wined3d_device_get_gamma_ramp(surface->ddraw->wined3d_device, 0, (struct wined3d_gamma_ramp *)gamma_ramp);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Not implemented for non-primary surfaces.\n");
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:18 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
* IDirectDrawGammaControl::SetGammaRamp
|
|
|
|
*
|
|
|
|
* Sets the red, green and blue gamma ramps for
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* flags: Can be DDSGR_CALIBRATE to request calibration
|
|
|
|
* gamma_ramp: Structure containing the new gamma ramp
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if gamma_ramp is NULL
|
|
|
|
*
|
|
|
|
**********************************************************/
|
|
|
|
static HRESULT WINAPI ddraw_gamma_control_SetGammaRamp(IDirectDrawGammaControl *iface,
|
|
|
|
DWORD flags, DDGAMMARAMP *gamma_ramp)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirectDrawGammaControl(iface);
|
2010-08-18 19:26:18 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, gamma_ramp %p.\n", iface, flags, gamma_ramp);
|
|
|
|
|
|
|
|
if (!gamma_ramp)
|
|
|
|
{
|
|
|
|
WARN("Invalid gamma_ramp passed.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-18 19:26:18 +02:00
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
2011-11-21 18:48:41 +01:00
|
|
|
/* Note: DDGAMMARAMP is compatible with struct wined3d_gamma_ramp. */
|
|
|
|
wined3d_device_set_gamma_ramp(surface->ddraw->wined3d_device,
|
|
|
|
0, flags, (struct wined3d_gamma_ramp *)gamma_ramp);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Not implemented for non-primary surfaces.\n");
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:18 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture2::PaletteChanged
|
|
|
|
*
|
|
|
|
* Informs the texture about a palette change
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* start: Start index of the change
|
|
|
|
* count: The number of changed entries
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture2_PaletteChanged(IDirect3DTexture2 *iface, DWORD start, DWORD count)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, start %u, count %u stub!\n", iface, start, count);
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_PaletteChanged(IDirect3DTexture *iface, DWORD start, DWORD count)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, start %u, count %u.\n", iface, start, count);
|
|
|
|
|
2011-07-29 17:55:50 +02:00
|
|
|
return d3d_texture2_PaletteChanged(&surface->IDirect3DTexture2_iface, start, count);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture::Unload
|
|
|
|
*
|
|
|
|
* DX5 SDK: "The IDirect3DTexture2::Unload method is not implemented
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture1_Unload(IDirect3DTexture *iface)
|
|
|
|
{
|
|
|
|
WARN("iface %p. Not implemented.\n", iface);
|
|
|
|
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture2::GetHandle
|
|
|
|
*
|
2017-03-05 18:59:47 +01:00
|
|
|
* Returns handle for the texture.
|
2010-08-18 19:26:19 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* device: Device this handle is assigned to
|
|
|
|
* handle: Address to store the handle at.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture2_GetHandle(IDirect3DTexture2 *iface,
|
|
|
|
IDirect3DDevice2 *device, D3DTEXTUREHANDLE *handle)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture2(iface);
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice2(device);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
if (!surface->Handle)
|
|
|
|
{
|
2011-10-17 15:57:19 +02:00
|
|
|
DWORD h = ddraw_allocate_handle(&device_impl->handle_table, surface, DDRAW_HANDLE_SURFACE);
|
2010-08-18 19:26:19 +02:00
|
|
|
if (h == DDRAW_INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate a texture handle.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->Handle = h + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Returning handle %08x.\n", surface->Handle);
|
|
|
|
*handle = surface->Handle;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_GetHandle(IDirect3DTexture *iface,
|
|
|
|
IDirect3DDevice *device, D3DTEXTUREHANDLE *handle)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = impl_from_IDirect3DTexture(iface);
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice(device);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return d3d_texture2_GetHandle(&surface->IDirect3DTexture2_iface,
|
2011-10-17 15:57:46 +02:00
|
|
|
device_impl ? &device_impl->IDirect3DDevice2_iface : NULL, handle);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* get_sub_mimaplevel
|
|
|
|
*
|
|
|
|
* Helper function that returns the next mipmap level
|
|
|
|
*
|
|
|
|
* tex_ptr: Surface of which to return the next level
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-03-11 22:03:12 +01:00
|
|
|
static struct ddraw_surface *get_sub_mimaplevel(struct ddraw_surface *surface)
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
/* Now go down the mipmap chain to the next surface */
|
2015-02-28 09:22:59 +01:00
|
|
|
static DDSCAPS2 mipmap_caps = { DDSCAPS_MIPMAP | DDSCAPS_TEXTURE, 0, 0, {0} };
|
2010-08-18 19:26:19 +02:00
|
|
|
IDirectDrawSurface7 *next_level;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surface->IDirectDrawSurface7_iface, &mipmap_caps, &next_level);
|
2010-08-18 19:26:19 +02:00
|
|
|
if (FAILED(hr)) return NULL;
|
|
|
|
|
|
|
|
ddraw_surface7_Release(next_level);
|
|
|
|
|
2011-06-06 12:57:55 +02:00
|
|
|
return impl_from_IDirectDrawSurface7(next_level);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture2::Load
|
|
|
|
*
|
|
|
|
* Loads a texture created with the DDSCAPS_ALLOCONLOAD
|
|
|
|
*
|
|
|
|
* This function isn't relayed to WineD3D because the whole interface is
|
2013-12-03 14:25:04 +01:00
|
|
|
* implemented in DDraw only. For speed improvements an implementation which
|
2010-08-18 19:26:19 +02:00
|
|
|
* takes OpenGL more into account could be placed into WineD3D.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* src_texture: Address of the texture to load
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_TEXTURE_LOAD_FAILED.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTexture2 *src_texture)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_surface = impl_from_IDirect3DTexture2(iface);
|
|
|
|
struct ddraw_surface *src_surface = unsafe_impl_from_IDirect3DTexture2(src_texture);
|
2016-02-01 18:42:12 +01:00
|
|
|
struct wined3d_resource *dst_resource, *src_resource;
|
2010-08-18 19:26:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, src_texture %p.\n", iface, src_texture);
|
|
|
|
|
|
|
|
if (src_surface == dst_surface)
|
|
|
|
{
|
|
|
|
TRACE("copying surface %p to surface %p, why?\n", src_surface, dst_surface);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2021-03-11 14:34:01 +01:00
|
|
|
dst_resource = wined3d_texture_get_resource(ddraw_surface_get_default_texture(dst_surface, DDRAW_SURFACE_WRITE));
|
|
|
|
src_resource = wined3d_texture_get_resource(ddraw_surface_get_default_texture(src_surface, DDRAW_SURFACE_READ));
|
2016-02-01 18:42:12 +01:00
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
if (((src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
!= (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP))
|
|
|
|
|| (src_surface->surface_desc.u2.dwMipMapCount != dst_surface->surface_desc.u2.dwMipMapCount))
|
|
|
|
{
|
|
|
|
ERR("Trying to load surfaces with different mip-map counts.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2014-05-12 15:12:42 +02:00
|
|
|
struct ddraw_palette *dst_pal, *src_pal;
|
2010-08-18 19:26:19 +02:00
|
|
|
DDSURFACEDESC *src_desc, *dst_desc;
|
|
|
|
|
2015-11-03 11:45:26 +01:00
|
|
|
TRACE("Copying surface %p to surface %p.\n", src_surface, dst_surface);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
/* Suppress the ALLOCONLOAD flag */
|
|
|
|
dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
|
|
|
|
|
|
|
|
/* Get the palettes */
|
2014-05-12 15:12:42 +02:00
|
|
|
dst_pal = dst_surface->palette;
|
|
|
|
src_pal = src_surface->palette;
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2014-05-12 15:12:42 +02:00
|
|
|
if (src_pal)
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
PALETTEENTRY palent[256];
|
|
|
|
|
2014-05-12 15:12:42 +02:00
|
|
|
if (!dst_pal)
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
return DDERR_NOPALETTEATTACHED;
|
|
|
|
}
|
2014-05-12 15:12:42 +02:00
|
|
|
IDirectDrawPalette_GetEntries(&src_pal->IDirectDrawPalette_iface, 0, 0, 256, palent);
|
|
|
|
IDirectDrawPalette_SetEntries(&dst_pal->IDirectDrawPalette_iface, 0, 0, 256, palent);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy one surface on the other */
|
|
|
|
dst_desc = (DDSURFACEDESC *)&(dst_surface->surface_desc);
|
|
|
|
src_desc = (DDSURFACEDESC *)&(src_surface->surface_desc);
|
|
|
|
|
|
|
|
if ((src_desc->dwWidth != dst_desc->dwWidth) || (src_desc->dwHeight != dst_desc->dwHeight))
|
|
|
|
{
|
|
|
|
/* Should also check for same pixel format, u1.lPitch, ... */
|
|
|
|
ERR("Error in surface sizes.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
return D3DERR_TEXTURE_LOAD_FAILED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-12 22:49:04 +02:00
|
|
|
struct wined3d_map_desc src_map_desc, dst_map_desc;
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2012-01-31 14:49:16 +01:00
|
|
|
/* Copy the src blit color key if the source has one, don't erase
|
|
|
|
* the destination's ckey if the source has none */
|
2010-08-18 19:26:19 +02:00
|
|
|
if (src_desc->dwFlags & DDSD_CKSRCBLT)
|
|
|
|
{
|
2012-01-31 14:49:16 +01:00
|
|
|
IDirectDrawSurface7_SetColorKey(&dst_surface->IDirectDrawSurface7_iface,
|
|
|
|
DDCKEY_SRCBLT, &src_desc->ddckCKSrcBlt);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2016-02-01 18:42:12 +01:00
|
|
|
if (FAILED(hr = wined3d_resource_map(src_resource,
|
2018-02-18 19:08:34 +01:00
|
|
|
src_surface->sub_resource_idx, &src_map_desc, NULL, WINED3D_MAP_READ)))
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to lock source surface, hr %#x.\n", hr);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
return D3DERR_TEXTURE_LOAD_FAILED;
|
|
|
|
}
|
|
|
|
|
2016-02-01 18:42:12 +01:00
|
|
|
if (FAILED(hr = wined3d_resource_map(dst_resource,
|
2018-02-18 19:08:34 +01:00
|
|
|
dst_surface->sub_resource_idx, &dst_map_desc, NULL, WINED3D_MAP_WRITE)))
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to lock destination surface, hr %#x.\n", hr);
|
2016-02-01 18:42:12 +01:00
|
|
|
wined3d_resource_unmap(src_resource, src_surface->sub_resource_idx);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
return D3DERR_TEXTURE_LOAD_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dst_surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
|
2012-04-12 22:49:04 +02:00
|
|
|
memcpy(dst_map_desc.data, src_map_desc.data, src_surface->surface_desc.u1.dwLinearSize);
|
2010-08-18 19:26:19 +02:00
|
|
|
else
|
2012-04-12 22:49:04 +02:00
|
|
|
memcpy(dst_map_desc.data, src_map_desc.data, src_map_desc.row_pitch * src_desc->dwHeight);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2016-02-01 18:42:12 +01:00
|
|
|
wined3d_resource_unmap(dst_resource, dst_surface->sub_resource_idx);
|
|
|
|
wined3d_resource_unmap(src_resource, src_surface->sub_resource_idx);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
src_surface = get_sub_mimaplevel(src_surface);
|
|
|
|
else
|
|
|
|
src_surface = NULL;
|
|
|
|
|
|
|
|
if (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
dst_surface = get_sub_mimaplevel(dst_surface);
|
|
|
|
else
|
|
|
|
dst_surface = NULL;
|
|
|
|
|
|
|
|
if (!src_surface || !dst_surface)
|
|
|
|
{
|
|
|
|
if (src_surface != dst_surface)
|
|
|
|
ERR("Loading surface with different mipmap structure.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_Load(IDirect3DTexture *iface, IDirect3DTexture *src_texture)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_surface = impl_from_IDirect3DTexture(iface);
|
|
|
|
struct ddraw_surface *src_surface = unsafe_impl_from_IDirect3DTexture(src_texture);
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p, src_texture %p.\n", iface, src_texture);
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
return d3d_texture2_Load(&dst_surface->IDirect3DTexture2_iface,
|
2011-07-29 17:55:50 +02:00
|
|
|
src_surface ? &src_surface->IDirect3DTexture2_iface : NULL);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* The VTable
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2020-04-27 05:58:28 +02:00
|
|
|
/* Some windowed mode wrappers expect this vtbl to be writable. */
|
|
|
|
static struct IDirectDrawSurface7Vtbl ddraw_surface7_vtbl =
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-07-19 18:36:20 +02:00
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface7_QueryInterface,
|
|
|
|
ddraw_surface7_AddRef,
|
|
|
|
ddraw_surface7_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface7_AddAttachedSurface,
|
|
|
|
ddraw_surface7_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface7_Blt,
|
|
|
|
ddraw_surface7_BltBatch,
|
|
|
|
ddraw_surface7_BltFast,
|
|
|
|
ddraw_surface7_DeleteAttachedSurface,
|
|
|
|
ddraw_surface7_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface7_EnumOverlayZOrders,
|
|
|
|
ddraw_surface7_Flip,
|
|
|
|
ddraw_surface7_GetAttachedSurface,
|
|
|
|
ddraw_surface7_GetBltStatus,
|
|
|
|
ddraw_surface7_GetCaps,
|
|
|
|
ddraw_surface7_GetClipper,
|
|
|
|
ddraw_surface7_GetColorKey,
|
|
|
|
ddraw_surface7_GetDC,
|
|
|
|
ddraw_surface7_GetFlipStatus,
|
|
|
|
ddraw_surface7_GetOverlayPosition,
|
|
|
|
ddraw_surface7_GetPalette,
|
|
|
|
ddraw_surface7_GetPixelFormat,
|
|
|
|
ddraw_surface7_GetSurfaceDesc,
|
|
|
|
ddraw_surface7_Initialize,
|
|
|
|
ddraw_surface7_IsLost,
|
|
|
|
ddraw_surface7_Lock,
|
|
|
|
ddraw_surface7_ReleaseDC,
|
|
|
|
ddraw_surface7_Restore,
|
|
|
|
ddraw_surface7_SetClipper,
|
|
|
|
ddraw_surface7_SetColorKey,
|
|
|
|
ddraw_surface7_SetOverlayPosition,
|
|
|
|
ddraw_surface7_SetPalette,
|
|
|
|
ddraw_surface7_Unlock,
|
|
|
|
ddraw_surface7_UpdateOverlay,
|
|
|
|
ddraw_surface7_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface7_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface7_GetDDInterface,
|
|
|
|
ddraw_surface7_PageLock,
|
|
|
|
ddraw_surface7_PageUnlock,
|
|
|
|
/* IDirectDrawSurface3 */
|
|
|
|
ddraw_surface7_SetSurfaceDesc,
|
|
|
|
/* IDirectDrawSurface4 */
|
|
|
|
ddraw_surface7_SetPrivateData,
|
|
|
|
ddraw_surface7_GetPrivateData,
|
|
|
|
ddraw_surface7_FreePrivateData,
|
|
|
|
ddraw_surface7_GetUniquenessValue,
|
|
|
|
ddraw_surface7_ChangeUniquenessValue,
|
|
|
|
/* IDirectDrawSurface7 */
|
|
|
|
ddraw_surface7_SetPriority,
|
|
|
|
ddraw_surface7_GetPriority,
|
|
|
|
ddraw_surface7_SetLOD,
|
|
|
|
ddraw_surface7_GetLOD,
|
|
|
|
};
|
|
|
|
|
2020-04-27 05:58:28 +02:00
|
|
|
/* Some windowed mode wrappers expect this vtbl to be writable. */
|
|
|
|
static struct IDirectDrawSurface4Vtbl ddraw_surface4_vtbl =
|
2011-06-06 13:39:04 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface4_QueryInterface,
|
|
|
|
ddraw_surface4_AddRef,
|
|
|
|
ddraw_surface4_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface4_AddAttachedSurface,
|
|
|
|
ddraw_surface4_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface4_Blt,
|
|
|
|
ddraw_surface4_BltBatch,
|
|
|
|
ddraw_surface4_BltFast,
|
|
|
|
ddraw_surface4_DeleteAttachedSurface,
|
|
|
|
ddraw_surface4_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface4_EnumOverlayZOrders,
|
|
|
|
ddraw_surface4_Flip,
|
|
|
|
ddraw_surface4_GetAttachedSurface,
|
|
|
|
ddraw_surface4_GetBltStatus,
|
|
|
|
ddraw_surface4_GetCaps,
|
|
|
|
ddraw_surface4_GetClipper,
|
|
|
|
ddraw_surface4_GetColorKey,
|
|
|
|
ddraw_surface4_GetDC,
|
|
|
|
ddraw_surface4_GetFlipStatus,
|
|
|
|
ddraw_surface4_GetOverlayPosition,
|
|
|
|
ddraw_surface4_GetPalette,
|
|
|
|
ddraw_surface4_GetPixelFormat,
|
|
|
|
ddraw_surface4_GetSurfaceDesc,
|
|
|
|
ddraw_surface4_Initialize,
|
|
|
|
ddraw_surface4_IsLost,
|
|
|
|
ddraw_surface4_Lock,
|
|
|
|
ddraw_surface4_ReleaseDC,
|
|
|
|
ddraw_surface4_Restore,
|
|
|
|
ddraw_surface4_SetClipper,
|
|
|
|
ddraw_surface4_SetColorKey,
|
|
|
|
ddraw_surface4_SetOverlayPosition,
|
|
|
|
ddraw_surface4_SetPalette,
|
|
|
|
ddraw_surface4_Unlock,
|
|
|
|
ddraw_surface4_UpdateOverlay,
|
|
|
|
ddraw_surface4_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface4_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface4_GetDDInterface,
|
|
|
|
ddraw_surface4_PageLock,
|
|
|
|
ddraw_surface4_PageUnlock,
|
|
|
|
/* IDirectDrawSurface3 */
|
|
|
|
ddraw_surface4_SetSurfaceDesc,
|
|
|
|
/* IDirectDrawSurface4 */
|
|
|
|
ddraw_surface4_SetPrivateData,
|
|
|
|
ddraw_surface4_GetPrivateData,
|
|
|
|
ddraw_surface4_FreePrivateData,
|
|
|
|
ddraw_surface4_GetUniquenessValue,
|
|
|
|
ddraw_surface4_ChangeUniquenessValue,
|
|
|
|
};
|
|
|
|
|
2020-04-27 05:58:28 +02:00
|
|
|
/* Some windowed mode wrappers expect this vtbl to be writable. */
|
|
|
|
static struct IDirectDrawSurface3Vtbl ddraw_surface3_vtbl =
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface3_QueryInterface,
|
|
|
|
ddraw_surface3_AddRef,
|
|
|
|
ddraw_surface3_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface3_AddAttachedSurface,
|
|
|
|
ddraw_surface3_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface3_Blt,
|
|
|
|
ddraw_surface3_BltBatch,
|
|
|
|
ddraw_surface3_BltFast,
|
|
|
|
ddraw_surface3_DeleteAttachedSurface,
|
|
|
|
ddraw_surface3_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface3_EnumOverlayZOrders,
|
|
|
|
ddraw_surface3_Flip,
|
|
|
|
ddraw_surface3_GetAttachedSurface,
|
|
|
|
ddraw_surface3_GetBltStatus,
|
|
|
|
ddraw_surface3_GetCaps,
|
|
|
|
ddraw_surface3_GetClipper,
|
|
|
|
ddraw_surface3_GetColorKey,
|
|
|
|
ddraw_surface3_GetDC,
|
|
|
|
ddraw_surface3_GetFlipStatus,
|
|
|
|
ddraw_surface3_GetOverlayPosition,
|
|
|
|
ddraw_surface3_GetPalette,
|
|
|
|
ddraw_surface3_GetPixelFormat,
|
|
|
|
ddraw_surface3_GetSurfaceDesc,
|
|
|
|
ddraw_surface3_Initialize,
|
|
|
|
ddraw_surface3_IsLost,
|
|
|
|
ddraw_surface3_Lock,
|
|
|
|
ddraw_surface3_ReleaseDC,
|
|
|
|
ddraw_surface3_Restore,
|
|
|
|
ddraw_surface3_SetClipper,
|
|
|
|
ddraw_surface3_SetColorKey,
|
|
|
|
ddraw_surface3_SetOverlayPosition,
|
|
|
|
ddraw_surface3_SetPalette,
|
|
|
|
ddraw_surface3_Unlock,
|
|
|
|
ddraw_surface3_UpdateOverlay,
|
|
|
|
ddraw_surface3_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface3_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface3_GetDDInterface,
|
|
|
|
ddraw_surface3_PageLock,
|
|
|
|
ddraw_surface3_PageUnlock,
|
|
|
|
/* IDirectDrawSurface3 */
|
|
|
|
ddraw_surface3_SetSurfaceDesc,
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
2010-08-18 19:26:18 +02:00
|
|
|
|
2020-04-27 05:58:28 +02:00
|
|
|
/* Some windowed mode wrappers expect this vtbl to be writable. */
|
|
|
|
static struct IDirectDrawSurface2Vtbl ddraw_surface2_vtbl =
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface2_QueryInterface,
|
|
|
|
ddraw_surface2_AddRef,
|
|
|
|
ddraw_surface2_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface2_AddAttachedSurface,
|
|
|
|
ddraw_surface2_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface2_Blt,
|
|
|
|
ddraw_surface2_BltBatch,
|
|
|
|
ddraw_surface2_BltFast,
|
|
|
|
ddraw_surface2_DeleteAttachedSurface,
|
|
|
|
ddraw_surface2_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface2_EnumOverlayZOrders,
|
|
|
|
ddraw_surface2_Flip,
|
|
|
|
ddraw_surface2_GetAttachedSurface,
|
|
|
|
ddraw_surface2_GetBltStatus,
|
|
|
|
ddraw_surface2_GetCaps,
|
|
|
|
ddraw_surface2_GetClipper,
|
|
|
|
ddraw_surface2_GetColorKey,
|
|
|
|
ddraw_surface2_GetDC,
|
|
|
|
ddraw_surface2_GetFlipStatus,
|
|
|
|
ddraw_surface2_GetOverlayPosition,
|
|
|
|
ddraw_surface2_GetPalette,
|
|
|
|
ddraw_surface2_GetPixelFormat,
|
|
|
|
ddraw_surface2_GetSurfaceDesc,
|
|
|
|
ddraw_surface2_Initialize,
|
|
|
|
ddraw_surface2_IsLost,
|
|
|
|
ddraw_surface2_Lock,
|
|
|
|
ddraw_surface2_ReleaseDC,
|
|
|
|
ddraw_surface2_Restore,
|
|
|
|
ddraw_surface2_SetClipper,
|
|
|
|
ddraw_surface2_SetColorKey,
|
|
|
|
ddraw_surface2_SetOverlayPosition,
|
|
|
|
ddraw_surface2_SetPalette,
|
|
|
|
ddraw_surface2_Unlock,
|
|
|
|
ddraw_surface2_UpdateOverlay,
|
|
|
|
ddraw_surface2_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface2_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface2_GetDDInterface,
|
|
|
|
ddraw_surface2_PageLock,
|
|
|
|
ddraw_surface2_PageUnlock,
|
|
|
|
};
|
|
|
|
|
2020-04-27 05:58:27 +02:00
|
|
|
/* Bad Mojo Redux expects this vtbl to be writable. */
|
|
|
|
static struct IDirectDrawSurfaceVtbl ddraw_surface1_vtbl =
|
2011-06-09 17:29:36 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface1_QueryInterface,
|
|
|
|
ddraw_surface1_AddRef,
|
|
|
|
ddraw_surface1_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface1_AddAttachedSurface,
|
|
|
|
ddraw_surface1_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface1_Blt,
|
|
|
|
ddraw_surface1_BltBatch,
|
|
|
|
ddraw_surface1_BltFast,
|
|
|
|
ddraw_surface1_DeleteAttachedSurface,
|
|
|
|
ddraw_surface1_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface1_EnumOverlayZOrders,
|
|
|
|
ddraw_surface1_Flip,
|
|
|
|
ddraw_surface1_GetAttachedSurface,
|
|
|
|
ddraw_surface1_GetBltStatus,
|
|
|
|
ddraw_surface1_GetCaps,
|
|
|
|
ddraw_surface1_GetClipper,
|
|
|
|
ddraw_surface1_GetColorKey,
|
|
|
|
ddraw_surface1_GetDC,
|
|
|
|
ddraw_surface1_GetFlipStatus,
|
|
|
|
ddraw_surface1_GetOverlayPosition,
|
|
|
|
ddraw_surface1_GetPalette,
|
|
|
|
ddraw_surface1_GetPixelFormat,
|
|
|
|
ddraw_surface1_GetSurfaceDesc,
|
|
|
|
ddraw_surface1_Initialize,
|
|
|
|
ddraw_surface1_IsLost,
|
|
|
|
ddraw_surface1_Lock,
|
|
|
|
ddraw_surface1_ReleaseDC,
|
|
|
|
ddraw_surface1_Restore,
|
|
|
|
ddraw_surface1_SetClipper,
|
|
|
|
ddraw_surface1_SetColorKey,
|
|
|
|
ddraw_surface1_SetOverlayPosition,
|
|
|
|
ddraw_surface1_SetPalette,
|
|
|
|
ddraw_surface1_Unlock,
|
|
|
|
ddraw_surface1_UpdateOverlay,
|
|
|
|
ddraw_surface1_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface1_UpdateOverlayZOrder,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirectDrawGammaControlVtbl ddraw_gamma_control_vtbl =
|
2010-08-18 19:26:18 +02:00
|
|
|
{
|
|
|
|
ddraw_gamma_control_QueryInterface,
|
|
|
|
ddraw_gamma_control_AddRef,
|
|
|
|
ddraw_gamma_control_Release,
|
|
|
|
ddraw_gamma_control_GetGammaRamp,
|
|
|
|
ddraw_gamma_control_SetGammaRamp,
|
|
|
|
};
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirect3DTexture2Vtbl d3d_texture2_vtbl =
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
d3d_texture2_QueryInterface,
|
|
|
|
d3d_texture2_AddRef,
|
|
|
|
d3d_texture2_Release,
|
|
|
|
d3d_texture2_GetHandle,
|
|
|
|
d3d_texture2_PaletteChanged,
|
|
|
|
d3d_texture2_Load,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirect3DTextureVtbl d3d_texture1_vtbl =
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
d3d_texture1_QueryInterface,
|
|
|
|
d3d_texture1_AddRef,
|
|
|
|
d3d_texture1_Release,
|
|
|
|
d3d_texture1_Initialize,
|
|
|
|
d3d_texture1_GetHandle,
|
|
|
|
d3d_texture1_PaletteChanged,
|
|
|
|
d3d_texture1_Load,
|
|
|
|
d3d_texture1_Unload,
|
|
|
|
};
|
2010-08-19 18:57:49 +02:00
|
|
|
|
2012-01-23 22:34:48 +01:00
|
|
|
/* Some games (e.g. Tomb Raider 3) pass the wrong version of the
|
|
|
|
* IDirectDrawSurface interface to ddraw methods. */
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
|
2011-06-06 11:30:23 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2012-01-23 22:34:48 +01:00
|
|
|
if (iface->lpVtbl != &ddraw_surface7_vtbl)
|
|
|
|
{
|
2012-08-27 12:27:48 +02:00
|
|
|
HRESULT hr = IDirectDrawSurface7_QueryInterface(iface, &IID_IDirectDrawSurface7, (void **)&iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Object %p doesn't expose interface IDirectDrawSurface7.\n", iface);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-27 12:27:48 +02:00
|
|
|
IDirectDrawSurface7_Release(iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
}
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface7_iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface)
|
2011-06-06 13:08:23 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2012-01-23 22:34:48 +01:00
|
|
|
if (iface->lpVtbl != &ddraw_surface4_vtbl)
|
|
|
|
{
|
2012-08-27 12:27:48 +02:00
|
|
|
HRESULT hr = IDirectDrawSurface4_QueryInterface(iface, &IID_IDirectDrawSurface4, (void **)&iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Object %p doesn't expose interface IDirectDrawSurface4.\n", iface);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-27 12:27:48 +02:00
|
|
|
IDirectDrawSurface4_Release(iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
}
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface4_iface);
|
2011-06-06 13:08:23 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
static struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface)
|
2011-05-31 14:49:37 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2012-01-23 22:34:48 +01:00
|
|
|
if (iface->lpVtbl != &ddraw_surface3_vtbl)
|
|
|
|
{
|
2012-08-27 12:27:48 +02:00
|
|
|
HRESULT hr = IDirectDrawSurface3_QueryInterface(iface, &IID_IDirectDrawSurface3, (void **)&iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Object %p doesn't expose interface IDirectDrawSurface3.\n", iface);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-27 12:27:48 +02:00
|
|
|
IDirectDrawSurface3_Release(iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
}
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface3_iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
static struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface)
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2012-01-23 22:34:48 +01:00
|
|
|
if (iface->lpVtbl != &ddraw_surface2_vtbl)
|
|
|
|
{
|
2012-08-27 12:27:48 +02:00
|
|
|
HRESULT hr = IDirectDrawSurface2_QueryInterface(iface, &IID_IDirectDrawSurface2, (void **)&iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Object %p doesn't expose interface IDirectDrawSurface2.\n", iface);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-27 12:27:48 +02:00
|
|
|
IDirectDrawSurface2_Release(iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
}
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface2_iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface)
|
2011-06-09 16:40:19 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2012-01-23 22:34:48 +01:00
|
|
|
if (iface->lpVtbl != &ddraw_surface1_vtbl)
|
|
|
|
{
|
2012-08-27 12:27:48 +02:00
|
|
|
HRESULT hr = IDirectDrawSurface_QueryInterface(iface, &IID_IDirectDrawSurface, (void **)&iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Object %p doesn't expose interface IDirectDrawSurface.\n", iface);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-27 12:27:48 +02:00
|
|
|
IDirectDrawSurface_Release(iface);
|
2012-01-23 22:34:48 +01:00
|
|
|
}
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface_iface);
|
2011-06-09 16:40:19 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface)
|
2011-07-29 15:30:32 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d_texture2_vtbl);
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirect3DTexture2_iface);
|
2011-07-29 15:30:32 +02:00
|
|
|
}
|
|
|
|
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface)
|
2011-07-27 16:43:24 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d_texture1_vtbl);
|
2012-03-11 22:03:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw_surface, IDirect3DTexture_iface);
|
2011-07-27 16:43:24 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:09:26 +02:00
|
|
|
static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *parent)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface = parent;
|
2011-04-20 22:09:26 +02:00
|
|
|
|
|
|
|
TRACE("surface %p.\n", surface);
|
|
|
|
|
2016-03-15 16:55:09 +01:00
|
|
|
/* This shouldn't happen, ddraw_surface_release_iface() should prevent the
|
|
|
|
* surface from being destroyed in this case. */
|
2011-04-20 22:09:26 +02:00
|
|
|
if (surface->first_attached != surface)
|
2016-03-15 16:55:09 +01:00
|
|
|
ERR("Surface is still attached to surface %p.\n", surface->first_attached);
|
2011-04-20 22:09:26 +02:00
|
|
|
|
|
|
|
while (surface->next_attached)
|
2011-10-11 21:59:21 +02:00
|
|
|
if (FAILED(ddraw_surface_delete_attached_surface(surface,
|
|
|
|
surface->next_attached, surface->next_attached->attached_iface)))
|
2011-04-20 22:09:26 +02:00
|
|
|
ERR("DeleteAttachedSurface failed.\n");
|
|
|
|
|
|
|
|
/* Having a texture handle set implies that the device still exists. */
|
|
|
|
if (surface->Handle)
|
|
|
|
ddraw_free_handle(&surface->ddraw->d3ddevice->handle_table, surface->Handle - 1, DDRAW_HANDLE_SURFACE);
|
|
|
|
|
|
|
|
/* Reduce the ddraw surface count. */
|
|
|
|
list_remove(&surface->surface_list_entry);
|
|
|
|
|
2019-03-22 10:50:04 +01:00
|
|
|
if (surface->clipper && ddraw_clipper_is_valid(surface->clipper))
|
2015-04-29 17:27:34 +02:00
|
|
|
IDirectDrawClipper_Release(&surface->clipper->IDirectDrawClipper_iface);
|
|
|
|
|
2011-09-15 20:01:49 +02:00
|
|
|
if (surface == surface->ddraw->primary)
|
2019-01-23 15:47:23 +01:00
|
|
|
{
|
2011-09-15 20:01:49 +02:00
|
|
|
surface->ddraw->primary = NULL;
|
2019-01-23 15:47:23 +01:00
|
|
|
surface->ddraw->gdi_surface = NULL;
|
|
|
|
}
|
2011-09-15 20:01:49 +02:00
|
|
|
|
2014-03-16 20:38:58 +01:00
|
|
|
wined3d_private_store_cleanup(&surface->private_store);
|
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
if (surface->draw_texture)
|
|
|
|
wined3d_texture_decref(surface->wined3d_texture);
|
|
|
|
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(surface);
|
2011-04-20 22:09:26 +02:00
|
|
|
}
|
|
|
|
|
2012-03-25 20:56:31 +02:00
|
|
|
static const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops =
|
2011-04-20 22:09:26 +02:00
|
|
|
{
|
|
|
|
ddraw_surface_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
2011-04-20 22:09:27 +02:00
|
|
|
static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *parent)
|
|
|
|
{
|
2020-03-27 21:31:41 +01:00
|
|
|
struct ddraw_texture *texture = parent;
|
2011-04-20 22:09:27 +02:00
|
|
|
|
2020-03-27 21:31:41 +01:00
|
|
|
TRACE("texture %p, texture_memory %p.\n", texture, texture->texture_memory);
|
|
|
|
|
|
|
|
heap_free(texture->texture_memory);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(parent);
|
2011-04-20 22:09:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops =
|
|
|
|
{
|
|
|
|
ddraw_texture_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
2013-11-15 08:24:30 +01:00
|
|
|
static HRESULT CDECL ddraw_reset_enum_callback(struct wined3d_resource *resource)
|
|
|
|
{
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2021-12-10 20:03:39 +01:00
|
|
|
static HRESULT ddraw_surface_reserve_memory(struct wined3d_texture *wined3d_texture,
|
|
|
|
unsigned int sub_resource_count)
|
2020-03-27 21:31:41 +01:00
|
|
|
{
|
|
|
|
static const unsigned int extra_size = 0x10000;
|
|
|
|
|
|
|
|
struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture);
|
2020-06-17 00:54:26 +02:00
|
|
|
struct wined3d_resource_desc resource_desc;
|
|
|
|
struct wined3d_sub_resource_desc desc;
|
2020-03-27 21:31:41 +01:00
|
|
|
unsigned int pitch, slice_pitch;
|
2020-06-17 00:54:26 +02:00
|
|
|
HRESULT hr = WINED3D_OK;
|
2021-12-10 20:03:39 +01:00
|
|
|
unsigned int offset, i;
|
2020-03-27 21:31:41 +01:00
|
|
|
|
2020-06-17 00:54:26 +02:00
|
|
|
wined3d_resource_get_desc(wined3d_texture_get_resource(wined3d_texture), &resource_desc);
|
|
|
|
if (!(texture->texture_memory = heap_alloc_zero(resource_desc.size + extra_size)))
|
2020-03-27 21:31:41 +01:00
|
|
|
{
|
|
|
|
ERR("Out of memory.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
TRACE("texture->texture_memory %p.\n", texture->texture_memory);
|
|
|
|
|
2020-06-17 00:54:26 +02:00
|
|
|
offset = 0;
|
2021-12-10 20:03:39 +01:00
|
|
|
for (i = 0; i < sub_resource_count; ++i)
|
2020-03-27 21:31:41 +01:00
|
|
|
{
|
2021-12-10 20:03:39 +01:00
|
|
|
if (FAILED(hr = wined3d_texture_get_sub_resource_desc(wined3d_texture, i, &desc)))
|
|
|
|
{
|
|
|
|
ERR("Subresource %u not found.\n", i);
|
|
|
|
heap_free(texture->texture_memory);
|
|
|
|
texture->texture_memory = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
wined3d_texture_get_pitch(wined3d_texture, i, &pitch, &slice_pitch);
|
2020-03-27 21:31:41 +01:00
|
|
|
|
2021-12-10 20:03:39 +01:00
|
|
|
if (FAILED(hr = wined3d_texture_update_desc(wined3d_texture, i,
|
2020-06-17 00:54:26 +02:00
|
|
|
desc.width, desc.height, resource_desc.format,
|
|
|
|
desc.multisample_type, desc.multisample_quality,
|
|
|
|
(BYTE *)texture->texture_memory + offset, pitch)))
|
|
|
|
{
|
|
|
|
heap_free(texture->texture_memory);
|
|
|
|
texture->texture_memory = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
offset += desc.size;
|
|
|
|
}
|
2020-03-27 21:31:41 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
static HRESULT ddraw_surface_create_wined3d_texture(DDSURFACEDESC2 *desc, struct wined3d_device *wined3d_device,
|
|
|
|
const struct wined3d_resource_desc *wined3d_desc, unsigned int layers, unsigned int levels,
|
|
|
|
struct ddraw_texture *texture, struct wined3d_texture **wined3d_texture)
|
|
|
|
{
|
|
|
|
struct wined3d_resource_desc draw_texture_desc;
|
|
|
|
struct wined3d_texture *draw_texture;
|
|
|
|
struct ddraw_surface *parent;
|
|
|
|
unsigned int bind_flags;
|
|
|
|
unsigned int i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
bind_flags = 0;
|
|
|
|
if ((desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
|| (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
|
|
|
bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
|
|
|
|
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
|
|
|
|
bind_flags |= WINED3D_BIND_DEPTH_STENCIL;
|
|
|
|
else if (desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
|
|
|
|
bind_flags |= WINED3D_BIND_RENDER_TARGET;
|
|
|
|
|
|
|
|
if (!bind_flags || (wined3d_desc->access & WINED3D_RESOURCE_ACCESS_GPU && !(bind_flags & ~wined3d_desc->bind_flags)))
|
|
|
|
goto no_draw_texture;
|
|
|
|
|
|
|
|
draw_texture_desc = *wined3d_desc;
|
|
|
|
draw_texture_desc.bind_flags = bind_flags;
|
|
|
|
draw_texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_texture_create(wined3d_device, &draw_texture_desc, layers,
|
|
|
|
levels, 0, NULL, texture, &ddraw_texture_wined3d_parent_ops, &draw_texture)))
|
|
|
|
{
|
|
|
|
WARN("Failed to create draw texture, hr %#x.\n", hr);
|
|
|
|
goto no_draw_texture;
|
|
|
|
}
|
|
|
|
wined3d_texture_decref(draw_texture);
|
|
|
|
|
|
|
|
/* Some applications assume surfaces will always be mapped at the same
|
|
|
|
* address. Some of those also assume that this address is valid even when
|
|
|
|
* the surface isn't mapped, and that updates done this way will be
|
|
|
|
* visible on the screen. The game Nox is such an application,
|
|
|
|
* Commandos: Behind Enemy Lines is another. Setting
|
|
|
|
* WINED3D_TEXTURE_CREATE_GET_DC_LENIENT will ensure this. */
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
wined3d_resource_set_parent(wined3d_texture_get_resource(*wined3d_texture), texture);
|
|
|
|
for (i = 0; i < layers * levels; ++i)
|
|
|
|
{
|
|
|
|
parent = wined3d_texture_get_sub_resource_parent(draw_texture, i);
|
|
|
|
assert(parent->wined3d_texture == draw_texture);
|
|
|
|
parent->draw_texture = draw_texture;
|
|
|
|
parent->wined3d_texture = *wined3d_texture;
|
|
|
|
wined3d_texture_set_sub_resource_parent(*wined3d_texture, i, parent);
|
|
|
|
wined3d_texture_incref(*wined3d_texture);
|
|
|
|
}
|
|
|
|
wined3d_texture_decref(*wined3d_texture);
|
|
|
|
TRACE("Surface %p, created draw_texture %p, wined3d_texture %p.\n",
|
|
|
|
wined3d_texture_get_sub_resource_parent(draw_texture, 0), draw_texture, wined3d_texture);
|
|
|
|
return D3D_OK;
|
|
|
|
|
|
|
|
no_draw_texture:
|
|
|
|
if (SUCCEEDED(hr = wined3d_texture_create(wined3d_device, wined3d_desc, layers, levels,
|
|
|
|
WINED3D_TEXTURE_CREATE_GET_DC_LENIENT, NULL, texture, &ddraw_texture_wined3d_parent_ops,
|
|
|
|
wined3d_texture)))
|
|
|
|
wined3d_texture_decref(*wined3d_texture);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
|
|
|
|
struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version)
|
2011-04-19 20:05:50 +02:00
|
|
|
{
|
2016-02-29 11:38:26 +01:00
|
|
|
struct wined3d_sub_resource_desc wined3d_mip_desc;
|
2013-11-12 11:00:27 +01:00
|
|
|
struct ddraw_surface *root, *mip, **attach;
|
2016-02-29 11:38:26 +01:00
|
|
|
struct wined3d_resource_desc wined3d_desc;
|
2020-03-27 21:31:41 +01:00
|
|
|
DDPIXELFORMAT wined3d_display_mode_format;
|
2013-11-12 11:00:27 +01:00
|
|
|
struct wined3d_texture *wined3d_texture;
|
2013-11-15 08:24:30 +01:00
|
|
|
struct wined3d_display_mode mode;
|
2013-11-28 09:55:41 +01:00
|
|
|
DDSURFACEDESC2 *desc, *mip_desc;
|
2013-11-12 11:00:26 +01:00
|
|
|
struct ddraw_texture *texture;
|
2020-04-16 17:27:41 +02:00
|
|
|
BOOL sysmem_fallback = FALSE;
|
2016-01-27 00:06:23 +01:00
|
|
|
unsigned int layers = 1;
|
2014-09-29 09:11:53 +02:00
|
|
|
unsigned int pitch = 0;
|
2020-03-27 21:31:41 +01:00
|
|
|
BOOL reserve_memory;
|
2016-01-27 00:06:23 +01:00
|
|
|
UINT levels, i, j;
|
2012-07-13 12:53:09 +02:00
|
|
|
HRESULT hr;
|
2011-04-19 20:05:50 +02:00
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p, version %u.\n",
|
|
|
|
ddraw, surface_desc, surface, outer_unknown, version);
|
2013-11-14 10:47:16 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE("Requesting surface desc:\n");
|
2013-11-28 09:55:41 +01:00
|
|
|
DDRAW_dump_surface_desc(surface_desc);
|
2013-11-14 10:47:16 +01:00
|
|
|
}
|
2013-11-12 11:00:26 +01:00
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
if (outer_unknown)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2018-02-13 10:32:47 +01:00
|
|
|
if (!(texture = heap_alloc(sizeof(*texture))))
|
2013-11-28 09:55:41 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2020-03-27 21:31:41 +01:00
|
|
|
texture->texture_memory = NULL;
|
2013-11-28 09:55:41 +01:00
|
|
|
texture->version = version;
|
2013-11-28 09:55:43 +01:00
|
|
|
texture->surface_desc = *surface_desc;
|
2013-11-28 09:55:41 +01:00
|
|
|
desc = &texture->surface_desc;
|
|
|
|
|
2013-11-28 09:55:40 +01:00
|
|
|
/* Ensure DDSD_CAPS is always set. */
|
|
|
|
desc->dwFlags |= DDSD_CAPS;
|
|
|
|
|
2016-04-21 17:05:08 +02:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_FLIP)
|
2013-11-27 11:04:52 +01:00
|
|
|
{
|
2016-04-21 17:05:08 +02:00
|
|
|
if (!(desc->dwFlags & DDSD_BACKBUFFERCOUNT) || !desc->u5.dwBackBufferCount)
|
|
|
|
{
|
|
|
|
WARN("Tried to create a flippable surface without any back buffers.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-04-21 17:05:08 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(desc->ddsCaps.dwCaps & DDSCAPS_COMPLEX))
|
|
|
|
{
|
|
|
|
WARN("Tried to create a flippable surface without DDSCAPS_COMPLEX.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-04-21 17:05:08 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
2013-12-05 10:34:14 +01:00
|
|
|
|
2016-05-13 13:55:28 +02:00
|
|
|
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
{
|
|
|
|
WARN("Tried to create a flippable cubemap.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-05-13 13:55:28 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2013-12-04 09:49:37 +01:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
|
|
|
|
{
|
2016-04-21 17:05:08 +02:00
|
|
|
FIXME("Flippable textures not implemented.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-04-21 17:05:08 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (desc->dwFlags & DDSD_BACKBUFFERCOUNT)
|
|
|
|
{
|
|
|
|
WARN("Tried to specify a back buffer count for a non-flippable surface.\n");
|
2016-06-07 21:18:37 +02:00
|
|
|
hr = desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP ? DDERR_INVALIDPARAMS : DDERR_INVALIDCAPS;
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-06-07 21:18:37 +02:00
|
|
|
return hr;
|
2013-12-04 09:49:37 +01:00
|
|
|
}
|
2016-04-21 17:05:08 +02:00
|
|
|
}
|
2013-12-04 09:49:37 +01:00
|
|
|
|
2016-04-21 17:05:08 +02:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
|
2013-12-04 09:49:37 +01:00
|
|
|
{
|
2016-04-21 17:05:08 +02:00
|
|
|
WARN("Tried to create a primary surface with DDSCAPS_TEXTURE.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-04-21 17:05:08 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
2013-12-05 10:34:15 +01:00
|
|
|
|
2016-04-21 17:05:08 +02:00
|
|
|
if ((desc->ddsCaps.dwCaps & DDSCAPS_COMPLEX) && !(desc->ddsCaps.dwCaps & DDSCAPS_FLIP))
|
|
|
|
{
|
|
|
|
WARN("Tried to create a flippable primary surface without both DDSCAPS_FLIP and DDSCAPS_COMPLEX.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-04-21 17:05:08 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
2013-12-05 10:34:14 +01:00
|
|
|
|
2016-04-21 17:05:08 +02:00
|
|
|
if ((desc->ddsCaps.dwCaps & DDSCAPS_FLIP) && !(ddraw->cooperative_level & DDSCL_EXCLUSIVE))
|
|
|
|
{
|
|
|
|
WARN("Tried to create a flippable primary surface without DDSCL_EXCLUSIVE.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-04-21 17:05:08 +02:00
|
|
|
return DDERR_NOEXCLUSIVEMODE;
|
2013-12-04 09:49:37 +01:00
|
|
|
}
|
2013-11-27 11:04:52 +01:00
|
|
|
}
|
|
|
|
|
2013-11-27 11:04:49 +01:00
|
|
|
/* This is a special case in ddrawex, but not allowed in ddraw. */
|
|
|
|
if ((desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
|
|
|
== (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
|
|
|
{
|
|
|
|
WARN("Tried to create a surface in both system and video memory.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-27 11:04:49 +01:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2016-01-25 23:18:33 +01:00
|
|
|
if ((desc->ddsCaps.dwCaps & (DDSCAPS_ALLOCONLOAD | DDSCAPS_MIPMAP))
|
|
|
|
&& !(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
2016-01-06 15:52:07 +01:00
|
|
|
{
|
2016-01-25 23:18:33 +01:00
|
|
|
WARN("Caps %#x require DDSCAPS_TEXTURE.\n", desc->ddsCaps.dwCaps);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-01-06 15:52:07 +01:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2013-11-26 10:41:51 +01:00
|
|
|
if ((desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES)
|
|
|
|
&& !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP))
|
|
|
|
{
|
|
|
|
WARN("Cube map faces requested without cube map flag.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-26 10:41:51 +01:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
&& !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES))
|
|
|
|
{
|
|
|
|
WARN("Cube map without faces requested.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-26 10:41:51 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
&& (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES) != DDSCAPS2_CUBEMAP_ALLFACES)
|
|
|
|
FIXME("Partial cube maps not implemented.\n");
|
|
|
|
|
2013-11-26 10:41:50 +01:00
|
|
|
if (desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE))
|
|
|
|
{
|
|
|
|
if (!(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
|
|
|
{
|
|
|
|
WARN("DDSCAPS2_TEXTUREMANAGE used without DDSCAPS_TEXTURE, returning DDERR_INVALIDCAPS.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-26 10:41:50 +01:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
if (desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
|
|
|
{
|
2019-02-01 12:59:30 +01:00
|
|
|
WARN("DDSCAPS2_TEXTUREMANAGE used with DDSCAPS_VIDEOMEMORY "
|
2013-11-26 10:41:50 +01:00
|
|
|
"or DDSCAPS_SYSTEMMEMORY, returning DDERR_INVALIDCAPS.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-26 10:41:50 +01:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 12:59:30 +01:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_WRITEONLY
|
|
|
|
&& !(desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)))
|
|
|
|
{
|
|
|
|
WARN("DDSCAPS_WRITEONLY used without DDSCAPS2_TEXTUREMANAGE, returning DDERR_INVALIDCAPS.\n");
|
|
|
|
heap_free(texture);
|
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2020-03-06 14:16:29 +01:00
|
|
|
if (FAILED(hr = wined3d_output_get_display_mode(ddraw->wined3d_output, &mode, NULL)))
|
2013-11-15 08:24:30 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to get display mode, hr %#x.\n", hr);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-12-02 12:07:35 +01:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
2013-11-15 08:24:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-27 21:31:41 +01:00
|
|
|
wined3d_display_mode_format.dwSize = sizeof(wined3d_display_mode_format);
|
|
|
|
ddrawformat_from_wined3dformat(&wined3d_display_mode_format, mode.format_id);
|
|
|
|
|
2013-11-15 08:24:30 +01:00
|
|
|
/* No pixelformat given? Use the current screen format. */
|
|
|
|
if (!(desc->dwFlags & DDSD_PIXELFORMAT))
|
|
|
|
{
|
|
|
|
desc->dwFlags |= DDSD_PIXELFORMAT;
|
2020-03-27 21:31:41 +01:00
|
|
|
desc->u4.ddpfPixelFormat = wined3d_display_mode_format;
|
2013-11-15 08:24:30 +01:00
|
|
|
}
|
|
|
|
|
2016-01-27 00:06:23 +01:00
|
|
|
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
2013-11-15 08:24:30 +01:00
|
|
|
wined3d_desc.format = wined3dformat_from_ddrawformat(&desc->u4.ddpfPixelFormat);
|
|
|
|
if (wined3d_desc.format == WINED3DFMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
WARN("Unsupported / unknown pixelformat.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-15 08:24:30 +01:00
|
|
|
return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No width or no height? Use the screen size. */
|
|
|
|
if (!(desc->dwFlags & DDSD_WIDTH) || !(desc->dwFlags & DDSD_HEIGHT))
|
|
|
|
{
|
|
|
|
if (!(desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
|
|
|
{
|
|
|
|
WARN("No width / height specified.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-15 08:24:30 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
desc->dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
|
|
|
|
desc->dwWidth = mode.width;
|
|
|
|
desc->dwHeight = mode.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!desc->dwWidth || !desc->dwHeight)
|
2013-11-28 09:55:41 +01:00
|
|
|
{
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-15 08:24:30 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2013-11-28 09:55:41 +01:00
|
|
|
}
|
2013-11-15 08:24:30 +01:00
|
|
|
|
2016-04-21 17:05:08 +02:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_FLIP)
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER;
|
|
|
|
|
2013-11-27 11:04:50 +01:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2013-11-15 08:24:30 +01:00
|
|
|
{
|
2013-11-27 11:04:50 +01:00
|
|
|
/* The first surface is a front buffer, the back buffers are created
|
|
|
|
* afterwards. */
|
2013-12-03 09:59:18 +01:00
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;
|
2013-11-27 11:04:50 +01:00
|
|
|
if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
|
|
|
|
{
|
|
|
|
struct wined3d_swapchain_desc swapchain_desc;
|
2013-11-15 08:24:30 +01:00
|
|
|
|
2013-11-27 11:04:50 +01:00
|
|
|
wined3d_swapchain_get_desc(ddraw->wined3d_swapchain, &swapchain_desc);
|
|
|
|
swapchain_desc.backbuffer_width = mode.width;
|
|
|
|
swapchain_desc.backbuffer_height = mode.height;
|
|
|
|
swapchain_desc.backbuffer_format = mode.format_id;
|
2013-11-15 08:24:30 +01:00
|
|
|
|
2019-09-26 06:05:39 +02:00
|
|
|
if (ddraw->d3ddevice)
|
|
|
|
{
|
|
|
|
if (ddraw->d3ddevice->recording)
|
|
|
|
wined3d_stateblock_decref(ddraw->d3ddevice->recording);
|
|
|
|
ddraw->d3ddevice->recording = NULL;
|
2019-10-22 04:35:55 +02:00
|
|
|
ddraw->d3ddevice->update_state = ddraw->d3ddevice->state;
|
2019-09-26 06:05:39 +02:00
|
|
|
}
|
2019-10-24 20:43:06 +02:00
|
|
|
wined3d_stateblock_reset(ddraw->state);
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_device_reset(ddraw->wined3d_device,
|
|
|
|
&swapchain_desc, NULL, ddraw_reset_enum_callback, TRUE)))
|
|
|
|
{
|
|
|
|
ERR("Failed to reset device.\n");
|
|
|
|
heap_free(texture);
|
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
2019-09-26 06:05:39 +02:00
|
|
|
|
2019-11-17 00:26:32 +01:00
|
|
|
wined3d_stateblock_set_render_state(ddraw->state, WINED3D_RS_ZENABLE,
|
|
|
|
!!swapchain_desc.enable_auto_depth_stencil);
|
2013-11-15 08:24:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-14 10:47:16 +01:00
|
|
|
wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
|
|
|
wined3d_desc.multisample_quality = 0;
|
|
|
|
wined3d_desc.usage = 0;
|
2018-10-31 10:31:47 +01:00
|
|
|
wined3d_desc.bind_flags = 0;
|
2018-02-18 19:08:35 +01:00
|
|
|
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
|
2013-11-14 10:47:16 +01:00
|
|
|
wined3d_desc.width = desc->dwWidth;
|
|
|
|
wined3d_desc.height = desc->dwHeight;
|
|
|
|
wined3d_desc.depth = 1;
|
|
|
|
wined3d_desc.size = 0;
|
2013-11-12 11:00:26 +01:00
|
|
|
|
2013-11-14 10:47:16 +01:00
|
|
|
if ((desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && (ddraw->flags & DDRAW_NO3D))
|
|
|
|
{
|
|
|
|
WARN("The application requests a 3D capable surface, but the ddraw object was created without 3D support.\n");
|
|
|
|
/* Do not fail surface creation, only fail 3D device creation. */
|
|
|
|
}
|
2012-07-13 12:53:09 +02:00
|
|
|
|
2013-11-15 08:24:29 +01:00
|
|
|
/* Mipmap count fixes */
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
{
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_COMPLEX)
|
|
|
|
{
|
|
|
|
if (desc->dwFlags & DDSD_MIPMAPCOUNT)
|
|
|
|
{
|
|
|
|
/* Mipmap count is given, should not be 0. */
|
|
|
|
if (!desc->u2.dwMipMapCount)
|
2013-11-28 09:55:41 +01:00
|
|
|
{
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-11-15 08:24:29 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2013-11-28 09:55:41 +01:00
|
|
|
}
|
2013-11-15 08:24:29 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Undocumented feature: Create sublevels until either the
|
|
|
|
* width or the height is 1. */
|
2016-01-06 15:52:05 +01:00
|
|
|
if (version == 7)
|
|
|
|
desc->u2.dwMipMapCount = wined3d_log2i(max(desc->dwWidth, desc->dwHeight)) + 1;
|
|
|
|
else
|
|
|
|
desc->u2.dwMipMapCount = wined3d_log2i(min(desc->dwWidth, desc->dwHeight)) + 1;
|
2013-11-15 08:24:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
desc->u2.dwMipMapCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
desc->dwFlags |= DDSD_MIPMAPCOUNT;
|
|
|
|
levels = desc->u2.dwMipMapCount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
levels = 1;
|
|
|
|
}
|
|
|
|
|
2013-11-15 08:24:30 +01:00
|
|
|
if (!(desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY)))
|
2013-09-06 00:11:11 +02:00
|
|
|
{
|
2013-11-15 08:24:30 +01:00
|
|
|
if (!(desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)))
|
|
|
|
{
|
2018-10-31 10:31:49 +01:00
|
|
|
unsigned int bind_flags = 0;
|
2013-11-15 08:24:30 +01:00
|
|
|
DWORD usage = 0;
|
|
|
|
|
|
|
|
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
2018-10-31 10:31:49 +01:00
|
|
|
{
|
|
|
|
usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
|
|
|
bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
|
|
|
|
}
|
2013-11-15 08:24:30 +01:00
|
|
|
else if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
|
2018-10-31 10:31:49 +01:00
|
|
|
{
|
|
|
|
bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
|
|
|
|
}
|
2013-11-15 08:24:30 +01:00
|
|
|
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
|
2018-10-31 10:31:49 +01:00
|
|
|
bind_flags |= WINED3D_BIND_DEPTH_STENCIL;
|
2013-11-15 08:24:30 +01:00
|
|
|
else if (desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
|
2018-10-31 10:31:49 +01:00
|
|
|
bind_flags |= WINED3D_BIND_RENDER_TARGET;
|
2013-11-15 08:24:30 +01:00
|
|
|
|
2018-09-25 00:25:20 +02:00
|
|
|
if (!(ddraw->flags & DDRAW_NO3D) && SUCCEEDED(hr = wined3d_check_device_format(ddraw->wined3d,
|
2020-03-10 10:35:35 +01:00
|
|
|
ddraw->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL, mode.format_id,
|
2018-10-31 10:31:49 +01:00
|
|
|
usage, bind_flags, WINED3D_RTYPE_TEXTURE_2D, wined3d_desc.format)))
|
2020-04-16 17:27:41 +02:00
|
|
|
{
|
2013-11-15 08:24:30 +01:00
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
|
2020-04-16 17:27:41 +02:00
|
|
|
}
|
2013-11-15 08:24:30 +01:00
|
|
|
else
|
2020-04-16 17:27:41 +02:00
|
|
|
{
|
2013-11-15 08:24:30 +01:00
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
2020-04-16 17:27:41 +02:00
|
|
|
sysmem_fallback = TRUE;
|
|
|
|
}
|
2013-11-15 08:24:30 +01:00
|
|
|
}
|
|
|
|
else if (!(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
|
|
|
{
|
|
|
|
/* Tests show surfaces without memory flags get these flags added
|
|
|
|
* right after creation. */
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
|
|
|
|
}
|
2013-09-06 00:11:11 +02:00
|
|
|
}
|
2013-11-14 10:47:16 +01:00
|
|
|
|
2013-12-11 22:30:45 +01:00
|
|
|
if ((desc->ddsCaps.dwCaps & (DDSCAPS_OVERLAY | DDSCAPS_SYSTEMMEMORY))
|
|
|
|
== (DDSCAPS_OVERLAY | DDSCAPS_SYSTEMMEMORY))
|
|
|
|
{
|
|
|
|
WARN("System memory overlays are not allowed.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-12-11 22:30:45 +01:00
|
|
|
return DDERR_NOOVERLAYHW;
|
|
|
|
}
|
|
|
|
|
2013-11-14 10:47:16 +01:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
|
2013-09-06 00:11:11 +02:00
|
|
|
{
|
2018-02-18 19:08:35 +01:00
|
|
|
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_CPU
|
|
|
|
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
|
2013-09-06 00:11:11 +02:00
|
|
|
}
|
2011-04-19 20:05:50 +02:00
|
|
|
else
|
2013-09-06 00:11:11 +02:00
|
|
|
{
|
2018-09-25 23:14:38 +02:00
|
|
|
if (!(ddraw->flags & DDRAW_NO3D))
|
|
|
|
{
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
|
2018-10-31 10:31:47 +01:00
|
|
|
wined3d_desc.bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
|
2018-09-25 23:14:38 +02:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
|
2018-10-31 10:31:47 +01:00
|
|
|
wined3d_desc.bind_flags |= WINED3D_BIND_DEPTH_STENCIL;
|
2018-09-25 23:14:38 +02:00
|
|
|
else if (desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
|
2018-10-31 10:31:47 +01:00
|
|
|
wined3d_desc.bind_flags |= WINED3D_BIND_RENDER_TARGET;
|
2018-09-25 23:14:38 +02:00
|
|
|
}
|
2011-04-19 20:05:50 +02:00
|
|
|
|
2013-11-14 10:47:16 +01:00
|
|
|
if (desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE))
|
|
|
|
{
|
2020-04-01 17:13:45 +02:00
|
|
|
wined3d_desc.bind_flags &= ~WINED3D_BIND_RENDER_TARGET;
|
2018-02-02 17:58:54 +01:00
|
|
|
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU
|
2018-02-18 19:08:35 +01:00
|
|
|
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
|
2013-11-14 10:47:16 +01:00
|
|
|
/* Managed textures have the system memory flag set. */
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
|
|
|
}
|
|
|
|
else if (desc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
|
|
|
|
{
|
|
|
|
/* Videomemory adds localvidmem. This is mutually exclusive with
|
|
|
|
* systemmemory and texturemanage. */
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM;
|
2018-11-18 19:39:18 +01:00
|
|
|
/* Dynamic resources can't be written by the GPU. */
|
|
|
|
if (!(wined3d_desc.bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL)))
|
|
|
|
wined3d_desc.usage |= WINED3DUSAGE_DYNAMIC;
|
2013-11-14 10:47:16 +01:00
|
|
|
}
|
2013-11-13 10:12:07 +01:00
|
|
|
}
|
|
|
|
|
2014-03-04 10:21:35 +01:00
|
|
|
if (desc->dwFlags & DDSD_LPSURFACE)
|
2014-03-04 10:21:34 +01:00
|
|
|
{
|
2018-02-02 17:58:54 +01:00
|
|
|
if (wined3d_desc.access & WINED3D_RESOURCE_ACCESS_GPU)
|
2014-03-04 10:21:35 +01:00
|
|
|
{
|
2018-02-02 17:58:54 +01:00
|
|
|
WARN("User memory surfaces should not be GPU accessible.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-03-04 10:21:35 +01:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2014-03-05 10:46:36 +01:00
|
|
|
if (version < 4)
|
|
|
|
{
|
|
|
|
WARN("User memory surfaces not supported before version 4.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-03-05 10:46:36 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2016-01-25 23:18:31 +01:00
|
|
|
if (!desc->lpSurface)
|
|
|
|
{
|
|
|
|
WARN("NULL surface memory pointer specified.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2016-01-25 23:18:31 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2014-06-12 11:52:31 +02:00
|
|
|
if (format_is_compressed(&desc->u4.ddpfPixelFormat))
|
2014-03-04 10:21:35 +01:00
|
|
|
{
|
2014-06-12 11:52:31 +02:00
|
|
|
if (version != 4 && (desc->dwFlags & DDSD_PITCH))
|
|
|
|
{
|
|
|
|
WARN("Pitch specified on a compressed user memory surface.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-06-12 11:52:31 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(desc->dwFlags & (DDSD_LINEARSIZE | DDSD_PITCH)))
|
|
|
|
{
|
|
|
|
WARN("Compressed user memory surfaces should explicitly specify the linear size.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-06-12 11:52:31 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2014-09-29 09:11:52 +02:00
|
|
|
|
|
|
|
if ((desc->dwFlags & DDSD_LINEARSIZE)
|
2020-03-10 10:35:46 +01:00
|
|
|
&& desc->u1.dwLinearSize < wined3d_calculate_format_pitch(ddraw->wined3d_adapter,
|
2014-09-29 09:11:52 +02:00
|
|
|
wined3d_desc.format, wined3d_desc.width) * ((desc->dwHeight + 3) / 4))
|
|
|
|
{
|
|
|
|
WARN("Invalid linear size %u specified.\n", desc->u1.dwLinearSize);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-09-29 09:11:52 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2014-06-12 11:52:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(desc->dwFlags & DDSD_PITCH))
|
|
|
|
{
|
|
|
|
WARN("User memory surfaces should explicitly specify the pitch.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-06-12 11:52:31 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2014-09-29 09:11:52 +02:00
|
|
|
|
2020-03-10 10:35:46 +01:00
|
|
|
if (desc->u1.lPitch < wined3d_calculate_format_pitch(ddraw->wined3d_adapter,
|
2014-09-29 09:11:52 +02:00
|
|
|
wined3d_desc.format, wined3d_desc.width) || desc->u1.lPitch & 3)
|
|
|
|
{
|
|
|
|
WARN("Invalid pitch %u specified.\n", desc->u1.lPitch);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2014-09-29 09:11:52 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2014-09-29 09:11:53 +02:00
|
|
|
|
|
|
|
pitch = desc->u1.lPitch;
|
2014-03-04 10:21:35 +01:00
|
|
|
}
|
2014-03-04 10:21:34 +01:00
|
|
|
}
|
|
|
|
|
2015-08-23 21:59:35 +02:00
|
|
|
if (((desc->dwFlags & DDSD_CKDESTOVERLAY)
|
|
|
|
&& desc->u3.ddckCKDestOverlay.dwColorSpaceLowValue != desc->u3.ddckCKDestOverlay.dwColorSpaceHighValue)
|
|
|
|
|| ((desc->dwFlags & DDSD_CKDESTBLT)
|
|
|
|
&& desc->ddckCKDestBlt.dwColorSpaceLowValue != desc->ddckCKDestBlt.dwColorSpaceHighValue)
|
|
|
|
|| ((desc->dwFlags & DDSD_CKSRCOVERLAY)
|
|
|
|
&& desc->ddckCKSrcOverlay.dwColorSpaceLowValue != desc->ddckCKSrcOverlay.dwColorSpaceHighValue)
|
|
|
|
|| ((desc->dwFlags & DDSD_CKSRCBLT)
|
|
|
|
&& desc->ddckCKSrcBlt.dwColorSpaceLowValue != desc->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
{
|
|
|
|
WARN("Range color keys not supported, returning DDERR_NOCOLORKEYHW.\n");
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2015-08-23 21:59:35 +02:00
|
|
|
return DDERR_NOCOLORKEYHW;
|
|
|
|
}
|
|
|
|
|
2018-09-25 00:25:20 +02:00
|
|
|
if ((ddraw->flags & DDRAW_NO3D) && (desc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
|
|
|
|
{
|
|
|
|
WARN("Video memory surfaces not supported without 3D support.\n");
|
|
|
|
heap_free(texture);
|
|
|
|
return DDERR_NODIRECTDRAWHW;
|
|
|
|
}
|
|
|
|
|
2013-11-14 10:47:16 +01:00
|
|
|
if (desc->ddsCaps.dwCaps & (DDSCAPS_OVERLAY))
|
|
|
|
wined3d_desc.usage |= WINED3DUSAGE_OVERLAY;
|
|
|
|
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_OWNDC)
|
|
|
|
wined3d_desc.usage |= WINED3DUSAGE_OWNDC;
|
|
|
|
|
2011-04-19 20:05:50 +02:00
|
|
|
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
2013-06-05 11:06:11 +02:00
|
|
|
{
|
2016-01-27 00:06:23 +01:00
|
|
|
wined3d_desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
2013-11-15 08:24:29 +01:00
|
|
|
layers = 6;
|
2013-06-05 11:06:11 +02:00
|
|
|
}
|
2012-07-13 12:53:09 +02:00
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
if (FAILED(hr = ddraw_surface_create_wined3d_texture(desc, ddraw->wined3d_device, &wined3d_desc, layers, levels,
|
|
|
|
texture, &wined3d_texture)))
|
2012-07-13 12:53:09 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to create wined3d texture, hr %#x.\n", hr);
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-12-02 12:07:35 +01:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
2012-07-13 12:53:09 +02:00
|
|
|
}
|
|
|
|
|
2016-02-16 17:17:28 +01:00
|
|
|
root = wined3d_texture_get_sub_resource_parent(wined3d_texture, 0);
|
2021-03-11 14:33:55 +01:00
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
root->is_complex_root = TRUE;
|
2020-04-16 17:27:41 +02:00
|
|
|
root->sysmem_fallback = sysmem_fallback;
|
2013-11-12 11:00:27 +01:00
|
|
|
texture->root = root;
|
2017-01-04 00:04:47 +01:00
|
|
|
wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device);
|
2013-11-12 11:00:27 +01:00
|
|
|
|
2014-01-09 12:17:00 +01:00
|
|
|
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
|
2021-03-11 14:33:55 +01:00
|
|
|
ddraw_surface_set_wined3d_textures_colour_key(root, DDCKEY_DESTOVERLAY,
|
2014-01-09 12:17:00 +01:00
|
|
|
(struct wined3d_color_key *)&desc->u3.ddckCKDestOverlay);
|
|
|
|
if (desc->dwFlags & DDSD_CKDESTBLT)
|
2021-03-11 14:33:55 +01:00
|
|
|
ddraw_surface_set_wined3d_textures_colour_key(root, DDCKEY_DESTBLT,
|
2014-01-09 12:17:00 +01:00
|
|
|
(struct wined3d_color_key *)&desc->ddckCKDestBlt);
|
|
|
|
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
|
2021-03-11 14:33:55 +01:00
|
|
|
ddraw_surface_set_wined3d_textures_colour_key(root, DDCKEY_SRCOVERLAY,
|
2014-01-09 12:17:00 +01:00
|
|
|
(struct wined3d_color_key *)&desc->ddckCKSrcOverlay);
|
|
|
|
if (desc->dwFlags & DDSD_CKSRCBLT)
|
2021-03-11 14:33:55 +01:00
|
|
|
ddraw_surface_set_wined3d_textures_colour_key(root, DDCKEY_SRCBLT,
|
2014-01-09 12:17:00 +01:00
|
|
|
(struct wined3d_color_key *)&desc->ddckCKSrcBlt);
|
|
|
|
|
2012-07-13 12:53:09 +02:00
|
|
|
for (i = 0; i < layers; ++i)
|
|
|
|
{
|
2013-11-12 11:00:27 +01:00
|
|
|
attach = &root->complex_array[layers - 1 - i];
|
2012-07-13 12:53:09 +02:00
|
|
|
|
|
|
|
for (j = 0; j < levels; ++j)
|
|
|
|
{
|
2016-02-16 17:17:28 +01:00
|
|
|
mip = wined3d_texture_get_sub_resource_parent(wined3d_texture, i * levels + j);
|
2020-04-16 17:27:41 +02:00
|
|
|
mip->sysmem_fallback = sysmem_fallback;
|
2012-10-24 21:23:35 +02:00
|
|
|
mip_desc = &mip->surface_desc;
|
2019-01-23 18:48:42 +01:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
mip_desc->u2.dwMipMapCount = levels - j;
|
2012-10-24 21:23:35 +02:00
|
|
|
|
|
|
|
if (j)
|
2016-02-04 21:56:32 +01:00
|
|
|
{
|
2016-02-29 11:38:26 +01:00
|
|
|
wined3d_texture_get_sub_resource_desc(wined3d_texture, i * levels + j, &wined3d_mip_desc);
|
2016-02-04 21:56:32 +01:00
|
|
|
mip_desc->dwWidth = wined3d_mip_desc.width;
|
|
|
|
mip_desc->dwHeight = wined3d_mip_desc.height;
|
|
|
|
|
2012-10-24 21:23:35 +02:00
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
|
2016-02-04 21:56:32 +01:00
|
|
|
}
|
2012-10-24 21:23:35 +02:00
|
|
|
else
|
2016-02-04 21:56:32 +01:00
|
|
|
{
|
2012-10-24 21:23:35 +02:00
|
|
|
mip_desc->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
|
2016-02-04 21:56:32 +01:00
|
|
|
}
|
2012-10-24 21:23:35 +02:00
|
|
|
|
|
|
|
if (mip_desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
{
|
|
|
|
mip_desc->ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_ALLFACES;
|
|
|
|
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case WINED3D_CUBEMAP_FACE_POSITIVE_X:
|
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEX;
|
|
|
|
break;
|
|
|
|
case WINED3D_CUBEMAP_FACE_NEGATIVE_X:
|
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEX;
|
|
|
|
break;
|
|
|
|
case WINED3D_CUBEMAP_FACE_POSITIVE_Y:
|
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEY;
|
|
|
|
break;
|
|
|
|
case WINED3D_CUBEMAP_FACE_NEGATIVE_Y:
|
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEY;
|
|
|
|
break;
|
|
|
|
case WINED3D_CUBEMAP_FACE_POSITIVE_Z:
|
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEZ;
|
|
|
|
break;
|
|
|
|
case WINED3D_CUBEMAP_FACE_NEGATIVE_Z:
|
|
|
|
mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEZ;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-14 10:47:18 +01:00
|
|
|
if (mip == root)
|
|
|
|
continue;
|
|
|
|
|
2012-07-13 12:53:09 +02:00
|
|
|
*attach = mip;
|
|
|
|
attach = &mip->complex_array[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 00:54:26 +02:00
|
|
|
if ((desc->dwFlags & DDSD_LPSURFACE) && FAILED(hr = wined3d_texture_update_desc(wined3d_texture, 0,
|
2014-09-29 09:11:53 +02:00
|
|
|
wined3d_desc.width, wined3d_desc.height, wined3d_desc.format,
|
|
|
|
WINED3D_MULTISAMPLE_NONE, 0, desc->lpSurface, pitch)))
|
|
|
|
{
|
|
|
|
ERR("Failed to set surface memory, hr %#x.\n", hr);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2020-03-27 21:31:41 +01:00
|
|
|
reserve_memory = !(desc->dwFlags & DDSD_LPSURFACE)
|
|
|
|
&& desc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY
|
|
|
|
&& wined3d_display_mode_format.u1.dwRGBBitCount <= 16;
|
|
|
|
|
2021-12-10 20:03:39 +01:00
|
|
|
if (reserve_memory && FAILED(hr = ddraw_surface_reserve_memory(wined3d_texture, layers * levels)))
|
2020-03-27 21:31:41 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to reserve surface memory, hr %#x.\n", hr);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2013-11-27 11:04:50 +01:00
|
|
|
if (desc->dwFlags & DDSD_BACKBUFFERCOUNT)
|
|
|
|
{
|
2015-02-28 09:22:59 +01:00
|
|
|
unsigned int count = desc->u5.dwBackBufferCount;
|
2013-11-27 11:04:50 +01:00
|
|
|
struct ddraw_surface *last = root;
|
|
|
|
|
|
|
|
attach = &last->complex_array[0];
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
2018-02-13 10:32:47 +01:00
|
|
|
if (!(texture = heap_alloc(sizeof(*texture))))
|
2013-11-27 11:04:50 +01:00
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2020-03-27 21:31:41 +01:00
|
|
|
texture->texture_memory = NULL;
|
2013-11-27 11:04:50 +01:00
|
|
|
texture->version = version;
|
|
|
|
texture->surface_desc = root->surface_desc;
|
|
|
|
desc = &texture->surface_desc;
|
|
|
|
|
|
|
|
/* Only one surface in the flipping chain is a back buffer, one is
|
2013-12-03 09:59:16 +01:00
|
|
|
* a front buffer, the others are just flippable surfaces. */
|
2013-12-03 09:59:17 +01:00
|
|
|
desc->ddsCaps.dwCaps &= ~(DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER
|
|
|
|
| DDSCAPS_BACKBUFFER);
|
2013-11-27 11:04:50 +01:00
|
|
|
if (!i)
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
|
2015-02-28 09:22:59 +01:00
|
|
|
desc->u5.dwBackBufferCount = 0;
|
2013-11-27 11:04:50 +01:00
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
if (FAILED(hr = ddraw_surface_create_wined3d_texture(desc, ddraw->wined3d_device, &wined3d_desc, 1, 1,
|
|
|
|
texture, &wined3d_texture)))
|
2013-11-27 11:04:50 +01:00
|
|
|
{
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(texture);
|
2013-12-02 12:07:35 +01:00
|
|
|
hr = hr_ddraw_from_wined3d(hr);
|
2013-11-27 11:04:50 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2016-02-16 17:17:28 +01:00
|
|
|
last = wined3d_texture_get_sub_resource_parent(wined3d_texture, 0);
|
2020-04-16 17:27:41 +02:00
|
|
|
last->sysmem_fallback = sysmem_fallback;
|
2013-11-27 11:04:50 +01:00
|
|
|
texture->root = last;
|
2017-01-04 00:04:47 +01:00
|
|
|
wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device);
|
2013-11-27 11:04:50 +01:00
|
|
|
|
2014-01-09 12:17:00 +01:00
|
|
|
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);
|
|
|
|
|
2021-12-10 20:03:39 +01:00
|
|
|
if (reserve_memory && FAILED(hr = ddraw_surface_reserve_memory(wined3d_texture, 1)))
|
2020-03-27 21:31:41 +01:00
|
|
|
{
|
|
|
|
hr = hr_ddraw_from_wined3d(hr);
|
|
|
|
goto fail;
|
|
|
|
}
|
2013-11-27 11:04:50 +01:00
|
|
|
*attach = last;
|
|
|
|
attach = &last->complex_array[0];
|
|
|
|
}
|
2013-12-04 09:49:34 +01:00
|
|
|
*attach = root;
|
2013-11-27 11:04:50 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
if (surface_desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2019-01-23 15:47:23 +01:00
|
|
|
{
|
2013-11-28 09:55:42 +01:00
|
|
|
ddraw->primary = root;
|
2019-01-23 15:47:23 +01:00
|
|
|
ddraw->gdi_surface = root->wined3d_texture;
|
|
|
|
}
|
2013-11-12 11:00:27 +01:00
|
|
|
*surface = root;
|
|
|
|
|
2012-07-13 12:53:09 +02:00
|
|
|
return DD_OK;
|
2013-11-27 11:04:50 +01:00
|
|
|
|
|
|
|
fail:
|
|
|
|
if (version == 7)
|
|
|
|
IDirectDrawSurface7_Release(&root->IDirectDrawSurface7_iface);
|
|
|
|
else if (version == 4)
|
|
|
|
IDirectDrawSurface4_Release(&root->IDirectDrawSurface4_iface);
|
|
|
|
else
|
|
|
|
IDirectDrawSurface_Release(&root->IDirectDrawSurface_iface);
|
|
|
|
|
|
|
|
return hr;
|
2011-04-19 20:05:50 +02:00
|
|
|
}
|
|
|
|
|
2016-01-28 18:40:25 +01:00
|
|
|
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
|
|
|
|
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
|
2016-02-12 11:06:07 +01:00
|
|
|
const struct wined3d_parent_ops **parent_ops)
|
2010-08-19 18:57:49 +02:00
|
|
|
{
|
2016-01-28 18:40:24 +01:00
|
|
|
struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture);
|
2016-02-12 11:06:07 +01:00
|
|
|
unsigned int texture_level, row_pitch, slice_pitch;
|
2013-11-14 10:47:17 +01:00
|
|
|
DDSURFACEDESC2 *desc = &surface->surface_desc;
|
|
|
|
unsigned int version = texture->version;
|
2010-08-19 18:57:49 +02:00
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
|
2011-06-06 13:39:04 +02:00
|
|
|
surface->IDirectDrawSurface4_iface.lpVtbl = &ddraw_surface4_vtbl;
|
2011-05-31 13:57:04 +02:00
|
|
|
surface->IDirectDrawSurface3_iface.lpVtbl = &ddraw_surface3_vtbl;
|
2011-06-09 16:35:15 +02:00
|
|
|
surface->IDirectDrawSurface2_iface.lpVtbl = &ddraw_surface2_vtbl;
|
2011-06-09 17:29:36 +02:00
|
|
|
surface->IDirectDrawSurface_iface.lpVtbl = &ddraw_surface1_vtbl;
|
2011-06-08 17:23:17 +02:00
|
|
|
surface->IDirectDrawGammaControl_iface.lpVtbl = &ddraw_gamma_control_vtbl;
|
2011-07-29 17:55:50 +02:00
|
|
|
surface->IDirect3DTexture2_iface.lpVtbl = &d3d_texture2_vtbl;
|
2011-07-27 16:45:13 +02:00
|
|
|
surface->IDirect3DTexture_iface.lpVtbl = &d3d_texture1_vtbl;
|
2011-06-19 12:18:22 +02:00
|
|
|
surface->iface_count = 1;
|
2011-06-20 08:30:39 +02:00
|
|
|
surface->version = version;
|
2010-08-19 18:57:49 +02:00
|
|
|
surface->ddraw = ddraw;
|
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
if (version == 7)
|
|
|
|
{
|
|
|
|
surface->ref7 = 1;
|
2012-04-01 13:12:03 +02:00
|
|
|
surface->texture_outer = (IUnknown *)&surface->IDirectDrawSurface7_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
}
|
|
|
|
else if (version == 4)
|
2011-06-28 01:34:23 +02:00
|
|
|
{
|
|
|
|
surface->ref4 = 1;
|
2012-04-01 13:12:03 +02:00
|
|
|
surface->texture_outer = (IUnknown *)&surface->IDirectDrawSurface4_iface;
|
2011-06-28 01:34:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-20 23:15:55 +02:00
|
|
|
surface->ref1 = 1;
|
2012-04-01 13:12:03 +02:00
|
|
|
surface->texture_outer = (IUnknown *)&surface->IDirectDrawSurface_iface;
|
2011-06-28 01:34:23 +02:00
|
|
|
}
|
|
|
|
|
2013-11-14 10:47:17 +01:00
|
|
|
*desc = texture->surface_desc;
|
2010-08-19 18:57:49 +02:00
|
|
|
surface->first_attached = surface;
|
|
|
|
|
2016-02-12 11:06:07 +01:00
|
|
|
texture_level = desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP ? sub_resource_idx % desc->u2.dwMipMapCount : 0;
|
|
|
|
wined3d_texture_get_pitch(wined3d_texture, texture_level, &row_pitch, &slice_pitch);
|
2014-06-12 11:52:31 +02:00
|
|
|
if (format_is_compressed(&desc->u4.ddpfPixelFormat))
|
2010-08-19 18:57:49 +02:00
|
|
|
{
|
2014-06-12 11:52:31 +02:00
|
|
|
if (desc->dwFlags & DDSD_LPSURFACE)
|
|
|
|
desc->u1.dwLinearSize = ~0u;
|
|
|
|
else
|
2016-02-12 11:06:07 +01:00
|
|
|
desc->u1.dwLinearSize = slice_pitch;
|
2014-09-29 09:11:53 +02:00
|
|
|
desc->dwFlags |= DDSD_LINEARSIZE;
|
|
|
|
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH);
|
2014-06-12 11:52:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-29 09:11:53 +02:00
|
|
|
if (!(desc->dwFlags & DDSD_LPSURFACE))
|
2016-02-12 11:06:07 +01:00
|
|
|
desc->u1.lPitch = row_pitch;
|
2014-09-29 09:11:53 +02:00
|
|
|
desc->dwFlags |= DDSD_PITCH;
|
|
|
|
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
2014-08-19 14:20:28 +02:00
|
|
|
desc->lpSurface = NULL;
|
2010-08-19 18:57:49 +02:00
|
|
|
|
2016-01-28 18:40:24 +01:00
|
|
|
wined3d_texture_incref(surface->wined3d_texture = wined3d_texture);
|
2016-01-28 18:40:25 +01:00
|
|
|
surface->sub_resource_idx = sub_resource_idx;
|
2013-11-15 08:24:31 +01:00
|
|
|
*parent_ops = &ddraw_surface_wined3d_parent_ops;
|
2021-03-11 14:34:01 +01:00
|
|
|
surface->texture_location = DDRAW_SURFACE_LOCATION_DEFAULT;
|
2013-11-15 08:24:31 +01:00
|
|
|
|
2014-03-16 20:38:58 +01:00
|
|
|
wined3d_private_store_init(&surface->private_store);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
2014-08-21 09:55:55 +02:00
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface = parent;
|
|
|
|
|
|
|
|
/* If the surface reference count drops to zero, we release our reference
|
|
|
|
* to the view, but don't clear the pointer yet, in case e.g. a
|
|
|
|
* GetRenderTarget() call brings the surface back before the view is
|
|
|
|
* actually destroyed. When the view is destroyed, we need to clear the
|
|
|
|
* pointer, or a subsequent surface AddRef() would reference it again.
|
|
|
|
*
|
|
|
|
* This is safe because as long as the view still has a reference to the
|
|
|
|
* texture, the surface is also still alive, and we're called before the
|
|
|
|
* view releases that reference. */
|
|
|
|
surface->wined3d_rtv = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wined3d_parent_ops ddraw_view_wined3d_parent_ops =
|
|
|
|
{
|
|
|
|
view_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface)
|
|
|
|
{
|
2021-03-11 14:33:55 +01:00
|
|
|
struct wined3d_texture *wined3d_texture;
|
2014-08-21 09:55:55 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (surface->wined3d_rtv)
|
|
|
|
return surface->wined3d_rtv;
|
|
|
|
|
2021-03-11 14:33:55 +01:00
|
|
|
wined3d_texture = surface->draw_texture ? surface->draw_texture : surface->wined3d_texture;
|
|
|
|
if (FAILED(hr = wined3d_rendertarget_view_create_from_sub_resource(wined3d_texture,
|
2016-02-03 22:22:58 +01:00
|
|
|
surface->sub_resource_idx, surface, &ddraw_view_wined3d_parent_ops, &surface->wined3d_rtv)))
|
2014-08-21 09:55:55 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to create rendertarget view, hr %#x.\n", hr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return surface->wined3d_rtv;
|
|
|
|
}
|