[AMSTREAM] We don't need to define WIDL_C_INLINE_WRAPPERS here anymore.
[reactos.git] / dll / directx / wine / d3d9 / d3d9_main.c
index d407e49..4bd80e1 100644 (file)
  *
  */
 
-#include <config.h>
-#include <initguid.h>
 #include "d3d9_private.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
-
 static int D3DPERF_event_level = 0;
 
 void WINAPI DebugSetMute(void) {
@@ -90,24 +86,12 @@ void* WINAPI Direct3DShaderValidatorCreate9(void)
     return NULL;
 }
 
-/*******************************************************************
- *       DllMain
- */
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
-{
-    /* At process attach */
-    TRACE("fdwReason=%d\n", fdwReason);
-    if (fdwReason == DLL_PROCESS_ATTACH)
-        DisableThreadLibraryCalls(hInstDLL);
-
-    return TRUE;
-}
-
 /***********************************************************************
  *              D3DPERF_BeginEvent (D3D9.@)
  */
-int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, LPCWSTR name) {
-    TRACE("(color %#x, name %s) : stub\n", color, debugstr_w(name));
+int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, const WCHAR *name)
+{
+    TRACE("color 0x%08x, name %s.\n", color, debugstr_w(name));
 
     return D3DPERF_event_level++;
 }
@@ -151,13 +135,93 @@ BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
 /***********************************************************************
  *              D3DPERF_SetMarker (D3D9.@)
  */
-void WINAPI D3DPERF_SetMarker(D3DCOLOR color, LPCWSTR name) {
-    FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
+void WINAPI D3DPERF_SetMarker(D3DCOLOR color, const WCHAR *name)
+{
+    FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
 }
 
 /***********************************************************************
  *              D3DPERF_SetRegion (D3D9.@)
  */
-void WINAPI D3DPERF_SetRegion(D3DCOLOR color, LPCWSTR name) {
-    FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
+void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name)
+{
+    FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
+}
+
+void d3d9_resource_cleanup(struct d3d9_resource *resource)
+{
+    wined3d_private_store_cleanup(&resource->private_store);
+}
+
+HRESULT d3d9_resource_free_private_data(struct d3d9_resource *resource, const GUID *guid)
+{
+    struct wined3d_private_data *entry;
+
+    wined3d_mutex_lock();
+    entry = wined3d_private_store_get_private_data(&resource->private_store, guid);
+    if (!entry)
+    {
+        wined3d_mutex_unlock();
+        return D3DERR_NOTFOUND;
+    }
+
+    wined3d_private_store_free_private_data(&resource->private_store, entry);
+    wined3d_mutex_unlock();
+
+    return D3D_OK;
+}
+
+HRESULT d3d9_resource_get_private_data(struct d3d9_resource *resource, const GUID *guid,
+        void *data, DWORD *data_size)
+{
+    const struct wined3d_private_data *stored_data;
+    DWORD size_in;
+    HRESULT hr;
+
+    wined3d_mutex_lock();
+    stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
+    if (!stored_data)
+    {
+        hr = D3DERR_NOTFOUND;
+        goto done;
+    }
+
+    size_in = *data_size;
+    *data_size = stored_data->size;
+    if (!data)
+    {
+        hr = D3D_OK;
+        goto done;
+    }
+    if (size_in < stored_data->size)
+    {
+        hr = D3DERR_MOREDATA;
+        goto done;
+    }
+
+    if (stored_data->flags & WINED3DSPD_IUNKNOWN)
+        IUnknown_AddRef(stored_data->content.object);
+    memcpy(data, stored_data->content.data, stored_data->size);
+    hr = D3D_OK;
+
+done:
+    wined3d_mutex_unlock();
+    return hr;
+}
+
+void d3d9_resource_init(struct d3d9_resource *resource)
+{
+    resource->refcount = 1;
+    wined3d_private_store_init(&resource->private_store);
+}
+
+HRESULT d3d9_resource_set_private_data(struct d3d9_resource *resource, const GUID *guid,
+        const void *data, DWORD data_size, DWORD flags)
+{
+    HRESULT hr;
+
+    wined3d_mutex_lock();
+    hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
+    wined3d_mutex_unlock();
+    return hr;
 }