4 * Copyright 2010 Rico Schüller
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
25 #include "d3dcompiler_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler
);
30 /* IUnknown methods */
32 static HRESULT STDMETHODCALLTYPE
d3dcompiler_blob_QueryInterface(ID3DBlob
*iface
, REFIID riid
, void **object
)
34 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
36 if (IsEqualGUID(riid
, &IID_ID3D10Blob
)
37 || IsEqualGUID(riid
, &IID_IUnknown
))
39 IUnknown_AddRef(iface
);
44 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
50 static ULONG STDMETHODCALLTYPE
d3dcompiler_blob_AddRef(ID3DBlob
*iface
)
52 struct d3dcompiler_blob
*blob
= (struct d3dcompiler_blob
*)iface
;
53 ULONG refcount
= InterlockedIncrement(&blob
->refcount
);
55 TRACE("%p increasing refcount to %u\n", blob
, refcount
);
60 static ULONG STDMETHODCALLTYPE
d3dcompiler_blob_Release(ID3DBlob
*iface
)
62 struct d3dcompiler_blob
*blob
= (struct d3dcompiler_blob
*)iface
;
63 ULONG refcount
= InterlockedDecrement(&blob
->refcount
);
65 TRACE("%p decreasing refcount to %u\n", blob
, refcount
);
69 HeapFree(GetProcessHeap(), 0, blob
->data
);
70 HeapFree(GetProcessHeap(), 0, blob
);
76 /* ID3DBlob methods */
78 static void * STDMETHODCALLTYPE
d3dcompiler_blob_GetBufferPointer(ID3DBlob
*iface
)
80 struct d3dcompiler_blob
*blob
= (struct d3dcompiler_blob
*)iface
;
82 TRACE("iface %p\n", iface
);
87 static SIZE_T STDMETHODCALLTYPE
d3dcompiler_blob_GetBufferSize(ID3DBlob
*iface
)
89 struct d3dcompiler_blob
*blob
= (struct d3dcompiler_blob
*)iface
;
91 TRACE("iface %p\n", iface
);
96 const struct ID3D10BlobVtbl d3dcompiler_blob_vtbl
=
98 /* IUnknown methods */
99 d3dcompiler_blob_QueryInterface
,
100 d3dcompiler_blob_AddRef
,
101 d3dcompiler_blob_Release
,
102 /* ID3DBlob methods */
103 d3dcompiler_blob_GetBufferPointer
,
104 d3dcompiler_blob_GetBufferSize
,
107 HRESULT
d3dcompiler_blob_init(struct d3dcompiler_blob
*blob
, SIZE_T data_size
)
109 blob
->vtbl
= &d3dcompiler_blob_vtbl
;
111 blob
->size
= data_size
;
113 blob
->data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, data_size
);
116 ERR("Failed to allocate D3D blob data memory\n");
117 return E_OUTOFMEMORY
;