static HRESULT WINAPI d3d9_surface_GetDC(IDirect3DSurface9 *iface, HDC *dc) { struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface); HRESULT hr; TRACE("iface %p, dc %p.\n", iface, dc); if (!surface->getdc_supported) { WARN("Surface does not support GetDC, returning D3DERR_INVALIDCALL\n"); /* Don't touch the DC */ return D3DERR_INVALIDCALL; } wined3d_mutex_lock(); hr = wined3d_surface_getdc(surface->wined3d_surface, dc); wined3d_mutex_unlock(); return hr; }
static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid) { IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface); WINED3DADAPTER_IDENTIFIER adapter_id; HRESULT hr; TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid); adapter_id.driver_size = 0; adapter_id.description_size = 0; adapter_id.device_name_size = 0; wined3d_mutex_lock(); hr = wined3d_get_adapter_identifier(This->WineD3D, adapter, 0, &adapter_id); wined3d_mutex_unlock(); memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid)); return hr; }
static ULONG STDMETHODCALLTYPE d3d11_query_Release(ID3D11Query *iface) { struct d3d_query *query = impl_from_ID3D11Query(iface); ULONG refcount = InterlockedDecrement(&query->refcount); TRACE("%p decreasing refcount to %u.\n", query, refcount); if (!refcount) { ID3D11Device *device = query->device; wined3d_mutex_lock(); wined3d_query_decref(query->wined3d_query); wined3d_mutex_unlock(); ID3D11Device_Release(device); } return refcount; }
static ULONG WINAPI d3d9_texture_3d_Release(IDirect3DVolumeTexture9 *iface) { struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); ULONG ref = InterlockedDecrement(&texture->resource.refcount); TRACE("%p decreasing refcount to %u.\n", iface, ref); if (!ref) { IDirect3DDevice9Ex *parent_device = texture->parent_device; wined3d_mutex_lock(); wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); /* Release the device last, as it may cause the device to be destroyed. */ IDirect3DDevice9Ex_Release(parent_device); } return ref; }
/***************************************************************************** * IDirect3DMaterial3::GetMaterial * * Returns the material assigned to this interface * * Params: * Mat: Pointer to a D3DMATERIAL structure to store the material description * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if Mat is NULL * *****************************************************************************/ static HRESULT WINAPI d3d_material3_GetMaterial(IDirect3DMaterial3 *iface, D3DMATERIAL *mat) { struct d3d_material *material = impl_from_IDirect3DMaterial3(iface); DWORD dwSize; TRACE("iface %p, mat %p.\n", iface, mat); if (TRACE_ON(ddraw)) { TRACE(" Returning material : "); dump_material(&material->mat); } /* Copies the material structure */ wined3d_mutex_lock(); dwSize = mat->dwSize; memcpy(mat, &material->mat, dwSize); wined3d_mutex_unlock(); return DD_OK; }
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(IDirect3DVolumeTexture9 *iface, UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { IDirect3DVolumeTexture9Impl *texture = (IDirect3DVolumeTexture9Impl *)iface; struct wined3d_resource *sub_resource; HRESULT hr; TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n", iface, level, locked_box, box, flags); wined3d_mutex_lock(); if (!(sub_resource = IWineD3DBaseTexture_GetSubResource(texture->wined3d_texture, level))) hr = D3DERR_INVALIDCALL; else hr = IDirect3DVolume9_LockBox((IDirect3DVolume9 *)wined3d_resource_get_parent(sub_resource), locked_box, box, flags); wined3d_mutex_unlock(); return hr; }
static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D3DVERTEXBUFFER_DESC *desc) { IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface; WINED3DBUFFER_DESC wined3d_desc; TRACE("iface %p, desc %p.\n", iface, desc); wined3d_mutex_lock(); IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc); wined3d_mutex_unlock(); desc->Format = D3DFMT_VERTEXDATA; desc->Usage = wined3d_desc.Usage; desc->Pool = wined3d_desc.Pool; desc->Size = wined3d_desc.Size; desc->Type = D3DRTYPE_VERTEXBUFFER; desc->FVF = buffer->fvf; return D3D_OK; }
static HRESULT WINAPI d3d8_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type, D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type) { struct d3d8 *d3d8 = impl_from_IDirect3D8(iface); HRESULT hr; TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n", iface, adapter, device_type, format, windowed, multisample_type); if (multisample_type > D3DMULTISAMPLE_16_SAMPLES) return D3DERR_INVALIDCALL; wined3d_mutex_lock(); hr = wined3d_check_device_multisample_type(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(format), windowed, (enum wined3d_multisample_type)multisample_type, NULL); wined3d_mutex_unlock(); return hr; }
static HMONITOR WINAPI d3d8_GetAdapterMonitor(IDirect3D8 *iface, UINT adapter) { struct d3d8 *d3d8 = impl_from_IDirect3D8(iface); struct wined3d_output_desc desc; HRESULT hr; TRACE("iface %p, adapter %u.\n", iface, adapter); wined3d_mutex_lock(); hr = wined3d_get_output_desc(d3d8->wined3d, adapter, &desc); wined3d_mutex_unlock(); if (FAILED(hr)) { WARN("Failed to get output desc, hr %#x.\n", hr); return NULL; } return desc.monitor; }
static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface) { struct d3d_blend_state *state = impl_from_ID3D11BlendState(iface); ULONG refcount = InterlockedDecrement(&state->refcount); TRACE("%p decreasing refcount to %u.\n", state, refcount); if (!refcount) { struct d3d_device *device = impl_from_ID3D11Device(state->device); wined3d_mutex_lock(); wine_rb_remove(&device->blend_states, &state->desc); ID3D11Device_Release(state->device); wined3d_private_store_cleanup(&state->private_store); wined3d_mutex_unlock(); HeapFree(GetProcessHeap(), 0, state); } return refcount; }
static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface) { struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface); ULONG ref = InterlockedDecrement(&swapchain->refcount); TRACE("%p decreasing refcount to %u.\n", iface, ref); if (!ref) { IDirect3DDevice8 *parent_device = swapchain->parent_device; wined3d_mutex_lock(); wined3d_swapchain_decref(swapchain->wined3d_swapchain); wined3d_mutex_unlock(); if (parent_device) IDirect3DDevice8_Release(parent_device); } return ref; }
static HRESULT WINAPI d3d9_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid) { struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface); struct wined3d_adapter_identifier adapter_id; HRESULT hr; TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid); adapter_id.driver_size = 0; adapter_id.description_size = 0; adapter_id.device_name_size = 0; wined3d_mutex_lock(); hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, 0, &adapter_id); wined3d_mutex_unlock(); memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid)); return hr; }
static HRESULT WINAPI d3d9_CheckDeviceType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed) { struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface); HRESULT hr; TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n", iface, adapter, device_type, display_format, backbuffer_format, windowed); /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */ if (!windowed && display_format != D3DFMT_X8R8G8B8 && display_format != D3DFMT_R5G6B5) return WINED3DERR_NOTAVAILABLE; wined3d_mutex_lock(); hr = wined3d_check_device_type(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format), wined3dformat_from_d3dformat(backbuffer_format), windowed); wined3d_mutex_unlock(); return hr; }
static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) { IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", iface, ref); if (ref == 0) { IDirect3DDevice8 *parentDevice = This->parentDevice; TRACE("Releasing child %p\n", This->wineD3DCubeTexture); wined3d_mutex_lock(); IWineD3DCubeTexture_Release(This->wineD3DCubeTexture); wined3d_mutex_unlock(); /* Release the device last, as it may cause the device to be destroyed. */ IDirect3DDevice8_Release(parentDevice); } return ref; }
HRESULT dxgi_get_private_data(struct wined3d_private_store *store, REFGUID guid, UINT *data_size, void *data) { const struct wined3d_private_data *stored_data; DWORD size_in; HRESULT hr; if (!data_size) return E_INVALIDARG; wined3d_mutex_lock(); if (!(stored_data = wined3d_private_store_get_private_data(store, guid))) { hr = DXGI_ERROR_NOT_FOUND; *data_size = 0; goto done; } size_in = *data_size; *data_size = stored_data->size; if (!data) { hr = S_OK; goto done; } if (size_in < stored_data->size) { hr = DXGI_ERROR_MORE_DATA; goto done; } if (stored_data->flags & WINED3DSPD_IUNKNOWN) IUnknown_AddRef(stored_data->content.object); memcpy(data, stored_data->content.data, stored_data->size); hr = S_OK; done: wined3d_mutex_unlock(); return hr; }
static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface) { struct dxgi_device *This = impl_from_IWineDXGIDevice(iface); ULONG refcount = InterlockedDecrement(&This->refcount); TRACE("%p decreasing refcount to %u\n", This, refcount); if (!refcount) { if (This->child_layer) IUnknown_Release(This->child_layer); wined3d_mutex_lock(); wined3d_device_uninit_3d(This->wined3d_device); wined3d_device_decref(This->wined3d_device); wined3d_mutex_unlock(); IDXGIFactory1_Release(This->factory); wined3d_private_store_cleanup(&This->private_store); HeapFree(GetProcessHeap(), 0, This); } return refcount; }
static ULONG WINAPI d3d9_vertexshader_Release(IDirect3DVertexShader9 *iface) { IDirect3DVertexShader9Impl *shader = impl_from_IDirect3DVertexShader9(iface); ULONG refcount = InterlockedDecrement(&shader->ref); TRACE("%p decreasing refcount to %u.\n", iface, refcount); if (!refcount) { IDirect3DDevice9Ex *device = shader->parentDevice; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); wined3d_mutex_unlock(); /* Release the device last, as it may cause the device to be destroyed. */ IDirect3DDevice9Ex_Release(device); } return refcount; }
static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) { IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface; WINED3DSURFACE_DESC wined3ddesc; TRACE("iface %p, desc %p.\n", iface, pDesc); wined3d_mutex_lock(); IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc); wined3d_mutex_unlock(); pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format); pDesc->Type = wined3ddesc.resource_type; pDesc->Usage = wined3ddesc.usage; pDesc->Pool = wined3ddesc.pool; pDesc->MultiSampleType = wined3ddesc.multisample_type; pDesc->MultiSampleQuality = wined3ddesc.multisample_quality; pDesc->Width = wined3ddesc.width; pDesc->Height = wined3ddesc.height; return D3D_OK; }
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc) { IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface; HRESULT hr; WINED3DBUFFER_DESC desc; TRACE("iface %p, desc %p.\n", iface, pDesc); wined3d_mutex_lock(); hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc); wined3d_mutex_unlock(); if (SUCCEEDED(hr)) { pDesc->Format = d3dformat_from_wined3dformat(This->format); pDesc->Usage = desc.Usage; pDesc->Pool = desc.Pool; pDesc->Size = desc.Size; pDesc->Type = D3DRTYPE_INDEXBUFFER; } return hr; }
static HRESULT WINAPI d3d8_texture_2d_UnlockRect(IDirect3DTexture8 *iface, UINT level) { struct d3d8_texture *texture = impl_from_IDirect3DTexture8(iface); struct wined3d_resource *sub_resource; struct d3d8_surface *surface_impl; HRESULT hr; TRACE("iface %p, level %u.\n", iface, level); wined3d_mutex_lock(); if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level))) hr = D3DERR_INVALIDCALL; else { surface_impl = wined3d_resource_get_parent(sub_resource); hr = IDirect3DSurface8_UnlockRect(&surface_impl->IDirect3DSurface8_iface); } wined3d_mutex_unlock(); return hr; }
static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc) { struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface); struct wined3d_resource_desc wined3d_desc; struct wined3d_resource *wined3d_resource; TRACE("iface %p, desc %p.\n", iface, desc); wined3d_mutex_lock(); wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); wined3d_mutex_unlock(); desc->Format = d3dformat_from_wined3dformat(buffer->format); desc->Type = D3DRTYPE_INDEXBUFFER; desc->Usage = buffer->usage; desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; return D3D_OK; }
static ULONG STDMETHODCALLTYPE d3d11_buffer_Release(ID3D11Buffer *iface) { struct d3d_buffer *buffer = impl_from_ID3D11Buffer(iface); ULONG refcount = InterlockedDecrement(&buffer->refcount); TRACE("%p decreasing refcount to %u.\n", buffer, refcount); if (!refcount) { ID3D11Device2 *device = buffer->device; wined3d_mutex_lock(); wined3d_buffer_decref(buffer->wined3d_buffer); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); } return refcount; }
static HRESULT WINAPI d3d9_texture_3d_UnlockBox(IDirect3DVolumeTexture9 *iface, UINT level) { struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); struct wined3d_resource *sub_resource; struct d3d9_volume *volume_impl; HRESULT hr; TRACE("iface %p, level %u.\n", iface, level); wined3d_mutex_lock(); if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level))) hr = D3DERR_INVALIDCALL; else { volume_impl = wined3d_resource_get_parent(sub_resource); hr = IDirect3DVolume9_UnlockBox(&volume_impl->IDirect3DVolume9_iface); } wined3d_mutex_unlock(); return hr; }
static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); struct wined3d_map_desc map_desc; HRESULT hr; TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", iface, locked_box, box, flags); wined3d_mutex_lock(); hr = wined3d_resource_sub_resource_map(wined3d_texture_get_resource(volume->wined3d_texture), volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock(); locked_box->RowPitch = map_desc.row_pitch; locked_box->SlicePitch = map_desc.slice_pitch; locked_box->pBits = map_desc.data; return hr; }
BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) { DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER; if (!extended) flags |= WINED3D_VIDMEM_ACCOUNTING; else flags |= WINED3D_RESTORE_MODE_ON_ACTIVATE; d3d9->IDirect3D9Ex_iface.lpVtbl = &d3d9_vtbl; d3d9->refcount = 1; wined3d_mutex_lock(); d3d9->wined3d = wined3d_create(flags); wined3d_mutex_unlock(); if (!d3d9->wined3d) return FALSE; d3d9->extended = extended; return TRUE; }
HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type) { HRESULT hr; query->lpVtbl = &Direct3DQuery9_Vtbl; query->ref = 1; wined3d_mutex_lock(); hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query); wined3d_mutex_unlock(); if (FAILED(hr)) { WARN("Failed to create wined3d query, hr %#x.\n", hr); return hr; } query->parentDevice = (IDirect3DDevice9Ex *)device; IDirect3DDevice9Ex_AddRef(query->parentDevice); return D3D_OK; }
static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface) { struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); ULONG refcount = InterlockedDecrement(&factory->refcount); TRACE("%p decreasing refcount to %u.\n", iface, refcount); if (!refcount) { if (factory->device_window) DestroyWindow(factory->device_window); wined3d_mutex_lock(); wined3d_decref(factory->wined3d); wined3d_mutex_unlock(); wined3d_private_store_cleanup(&factory->private_store); HeapFree(GetProcessHeap(), 0, factory); } return refcount; }
static ULONG STDMETHODCALLTYPE d3d11_texture2d_Release(ID3D11Texture2D *iface) { struct d3d_texture2d *texture = impl_from_ID3D11Texture2D(iface); ULONG refcount = InterlockedDecrement(&texture->refcount); TRACE("%p decreasing refcount to %u.\n", texture, refcount); if (!refcount) { ID3D11Device *device = texture->device; wined3d_mutex_lock(); wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device_Release(device); } return refcount; }
HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type) { HRESULT hr; query->IDirect3DQuery9_iface.lpVtbl = &Direct3DQuery9_Vtbl; query->ref = 1; wined3d_mutex_lock(); hr = wined3d_query_create(device->wined3d_device, type, &query->wineD3DQuery); wined3d_mutex_unlock(); if (FAILED(hr)) { WARN("Failed to create wined3d query, hr %#x.\n", hr); return hr; } query->parentDevice = &device->IDirect3DDevice9Ex_iface; IDirect3DDevice9Ex_AddRef(query->parentDevice); return D3D_OK; }
static HRESULT WINAPI ddraw_clipper_SetHWnd(IDirectDrawClipper *iface, DWORD flags, HWND window) { struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface); TRACE("iface %p, flags %#x, window %p.\n", iface, flags, window); if (!ddraw_clipper_is_valid(clipper)) return DDERR_INVALIDPARAMS; if (flags) { FIXME("flags %#x, not supported.\n", flags); return DDERR_INVALIDPARAMS; } wined3d_mutex_lock(); clipper->window = window; wined3d_mutex_unlock(); return DD_OK; }