xref: /reactos/dll/directx/wine/d3drm/texture.c (revision e792c304)
1 /*
2  * Implementation of IDirect3DRMTextureX interfaces
3  *
4  * Copyright 2012 Christian Costa
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #include "config.h"
22 #include "wine/port.h"
23 
24 #include "d3drm_private.h"
25 
26 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
27 
28 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture(IDirect3DRMTexture *iface)
29 {
30     return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture_iface);
31 }
32 
33 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture2(IDirect3DRMTexture2 *iface)
34 {
35     return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture2_iface);
36 }
37 
38 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture3(IDirect3DRMTexture3 *iface)
39 {
40     return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture3_iface);
41 }
42 
43 static void d3drm_texture_destroy(struct d3drm_texture *texture)
44 {
45     TRACE("texture %p is being destroyed.\n", texture);
46 
47     d3drm_object_cleanup((IDirect3DRMObject*)&texture->IDirect3DRMTexture_iface, &texture->obj);
48     if (texture->image || texture->surface)
49         IDirect3DRM_Release(texture->d3drm);
50     if (texture->surface)
51         IDirectDrawSurface_Release(texture->surface);
52     heap_free(texture);
53 }
54 
55 static BOOL d3drm_validate_image(D3DRMIMAGE *image)
56 {
57     if (!image
58             || !image->red_mask
59             || !image->green_mask
60             || !image->blue_mask
61             || !image->buffer1
62             || !(image->rgb || (image->palette && image->palette_size)))
63     {
64         return FALSE;
65     }
66 
67     return TRUE;
68 }
69 
70 static HRESULT WINAPI d3drm_texture1_QueryInterface(IDirect3DRMTexture *iface, REFIID riid, void **out)
71 {
72     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
73 
74     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
75 
76     return IDirect3DRMTexture3_QueryInterface(&texture->IDirect3DRMTexture3_iface, riid, out);
77 }
78 
79 static ULONG WINAPI d3drm_texture1_AddRef(IDirect3DRMTexture *iface)
80 {
81     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
82 
83     TRACE("iface %p.\n", iface);
84 
85     return IDirect3DRMTexture3_AddRef(&texture->IDirect3DRMTexture3_iface);
86 }
87 
88 static ULONG WINAPI d3drm_texture1_Release(IDirect3DRMTexture *iface)
89 {
90     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
91 
92     TRACE("iface %p.\n", iface);
93 
94     return IDirect3DRMTexture3_Release(&texture->IDirect3DRMTexture3_iface);
95 }
96 
97 static HRESULT WINAPI d3drm_texture1_Clone(IDirect3DRMTexture *iface,
98         IUnknown *outer, REFIID iid, void **out)
99 {
100     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
101 
102     TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
103 
104     return IDirect3DRMTexture3_Clone(&texture->IDirect3DRMTexture3_iface, outer, iid, out);
105 }
106 
107 static HRESULT WINAPI d3drm_texture1_AddDestroyCallback(IDirect3DRMTexture *iface,
108         D3DRMOBJECTCALLBACK cb, void *ctx)
109 {
110     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
111 
112     TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
113 
114     return IDirect3DRMTexture3_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
115 }
116 
117 static HRESULT WINAPI d3drm_texture1_DeleteDestroyCallback(IDirect3DRMTexture *iface,
118         D3DRMOBJECTCALLBACK cb, void *ctx)
119 {
120     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
121 
122     TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
123 
124     return IDirect3DRMTexture3_DeleteDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
125 }
126 
127 static HRESULT WINAPI d3drm_texture1_SetAppData(IDirect3DRMTexture *iface, DWORD data)
128 {
129     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
130 
131     TRACE("iface %p, data %#x.\n", iface, data);
132 
133     return IDirect3DRMTexture3_SetAppData(&texture->IDirect3DRMTexture3_iface, data);
134 }
135 
136 static DWORD WINAPI d3drm_texture1_GetAppData(IDirect3DRMTexture *iface)
137 {
138     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
139 
140     TRACE("iface %p.\n", iface);
141 
142     return IDirect3DRMTexture3_GetAppData(&texture->IDirect3DRMTexture3_iface);
143 }
144 
145 static HRESULT WINAPI d3drm_texture1_SetName(IDirect3DRMTexture *iface, const char *name)
146 {
147     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
148 
149     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
150 
151     return IDirect3DRMTexture3_SetName(&texture->IDirect3DRMTexture3_iface, name);
152 }
153 
154 static HRESULT WINAPI d3drm_texture1_GetName(IDirect3DRMTexture *iface, DWORD *size, char *name)
155 {
156     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
157 
158     TRACE("iface %p, size %p, name %p.\n", iface, size, name);
159 
160     return IDirect3DRMTexture3_GetName(&texture->IDirect3DRMTexture3_iface, size, name);
161 }
162 
163 static HRESULT WINAPI d3drm_texture1_GetClassName(IDirect3DRMTexture *iface, DWORD *size, char *name)
164 {
165     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
166 
167     TRACE("iface %p, size %p, name %p.\n", iface, size, name);
168 
169     return IDirect3DRMTexture3_GetClassName(&texture->IDirect3DRMTexture3_iface, size, name);
170 }
171 
172 static HRESULT WINAPI d3drm_texture1_InitFromFile(IDirect3DRMTexture *iface, const char *filename)
173 {
174     FIXME("iface %p, filename %s stub!\n", iface, debugstr_a(filename));
175 
176     return E_NOTIMPL;
177 }
178 
179 static HRESULT WINAPI d3drm_texture1_InitFromSurface(IDirect3DRMTexture *iface,
180         IDirectDrawSurface *surface)
181 {
182     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
183 
184     TRACE("iface %p, surface %p.\n", iface, surface);
185 
186     return IDirect3DRMTexture3_InitFromSurface(&texture->IDirect3DRMTexture3_iface, surface);
187 }
188 
189 static HRESULT WINAPI d3drm_texture1_InitFromResource(IDirect3DRMTexture *iface, HRSRC resource)
190 {
191     FIXME("iface %p, resource %p stub!\n", iface, resource);
192 
193     return E_NOTIMPL;
194 }
195 
196 static HRESULT WINAPI d3drm_texture1_Changed(IDirect3DRMTexture *iface, BOOL pixels, BOOL palette)
197 {
198     FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface, pixels, palette);
199 
200     return E_NOTIMPL;
201 }
202 
203 static HRESULT WINAPI d3drm_texture1_SetColors(IDirect3DRMTexture *iface, DWORD max_colors)
204 {
205     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
206 
207     TRACE("iface %p, max_colors %u.\n", iface, max_colors);
208 
209     return IDirect3DRMTexture3_SetColors(&texture->IDirect3DRMTexture3_iface, max_colors);
210 }
211 
212 static HRESULT WINAPI d3drm_texture1_SetShades(IDirect3DRMTexture *iface, DWORD max_shades)
213 {
214     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
215 
216     TRACE("iface %p, max_shades %u.\n", iface, max_shades);
217 
218     return IDirect3DRMTexture3_SetShades(&texture->IDirect3DRMTexture3_iface, max_shades);
219 }
220 
221 static HRESULT WINAPI d3drm_texture1_SetDecalSize(IDirect3DRMTexture *iface, D3DVALUE width, D3DVALUE height)
222 {
223     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
224 
225     TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
226 
227     return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
228 }
229 
230 static HRESULT WINAPI d3drm_texture1_SetDecalOrigin(IDirect3DRMTexture *iface, LONG x, LONG y)
231 {
232     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
233 
234     TRACE("iface %p, x %d, y %d.\n", iface, x, y);
235 
236     return IDirect3DRMTexture3_SetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
237 }
238 
239 static HRESULT WINAPI d3drm_texture1_SetDecalScale(IDirect3DRMTexture *iface, DWORD scale)
240 {
241     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
242 
243     TRACE("iface %p, scale %u.\n", iface, scale);
244 
245     return IDirect3DRMTexture3_SetDecalScale(&texture->IDirect3DRMTexture3_iface, scale);
246 }
247 
248 static HRESULT WINAPI d3drm_texture1_SetDecalTransparency(IDirect3DRMTexture *iface, BOOL transparency)
249 {
250     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
251 
252     TRACE("iface %p, transparency %#x.\n", iface, transparency);
253 
254     return IDirect3DRMTexture3_SetDecalTransparency(&texture->IDirect3DRMTexture3_iface, transparency);
255 }
256 
257 static HRESULT WINAPI d3drm_texture1_SetDecalTransparentColor(IDirect3DRMTexture *iface, D3DCOLOR color)
258 {
259     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
260 
261     TRACE("iface %p, color 0x%08x.\n", iface, color);
262 
263     return IDirect3DRMTexture3_SetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface, color);
264 }
265 
266 static HRESULT WINAPI d3drm_texture1_GetDecalSize(IDirect3DRMTexture *iface, D3DVALUE *width, D3DVALUE *height)
267 {
268     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
269 
270     TRACE("iface %p, width %p, height %p.\n", iface, width, height);
271 
272     return IDirect3DRMTexture3_GetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
273 }
274 
275 static HRESULT WINAPI d3drm_texture1_GetDecalOrigin(IDirect3DRMTexture *iface, LONG *x, LONG *y)
276 {
277     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
278 
279     TRACE("iface %p, x %p, y %p.\n", iface, x, y);
280 
281     return IDirect3DRMTexture3_GetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
282 }
283 
284 static D3DRMIMAGE * WINAPI d3drm_texture1_GetImage(IDirect3DRMTexture *iface)
285 {
286     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
287 
288     TRACE("iface %p.\n", iface);
289 
290     return IDirect3DRMTexture3_GetImage(&texture->IDirect3DRMTexture3_iface);
291 }
292 
293 static DWORD WINAPI d3drm_texture1_GetShades(IDirect3DRMTexture *iface)
294 {
295     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
296 
297     TRACE("iface %p.\n", iface);
298 
299     return IDirect3DRMTexture3_GetShades(&texture->IDirect3DRMTexture3_iface);
300 }
301 
302 static DWORD WINAPI d3drm_texture1_GetColors(IDirect3DRMTexture *iface)
303 {
304     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
305 
306     TRACE("iface %p.\n", iface);
307 
308     return IDirect3DRMTexture3_GetColors(&texture->IDirect3DRMTexture3_iface);
309 }
310 
311 static DWORD WINAPI d3drm_texture1_GetDecalScale(IDirect3DRMTexture *iface)
312 {
313     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
314 
315     TRACE("iface %p.\n", iface);
316 
317     return IDirect3DRMTexture3_GetDecalScale(&texture->IDirect3DRMTexture3_iface);
318 }
319 
320 static BOOL WINAPI d3drm_texture1_GetDecalTransparency(IDirect3DRMTexture *iface)
321 {
322     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
323 
324     TRACE("iface %p.\n", iface);
325 
326     return IDirect3DRMTexture3_GetDecalTransparency(&texture->IDirect3DRMTexture3_iface);
327 }
328 
329 static D3DCOLOR WINAPI d3drm_texture1_GetDecalTransparentColor(IDirect3DRMTexture *iface)
330 {
331     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
332 
333     TRACE("iface %p.\n", iface);
334 
335     return IDirect3DRMTexture3_GetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface);
336 }
337 
338 static const struct IDirect3DRMTextureVtbl d3drm_texture1_vtbl =
339 {
340     d3drm_texture1_QueryInterface,
341     d3drm_texture1_AddRef,
342     d3drm_texture1_Release,
343     d3drm_texture1_Clone,
344     d3drm_texture1_AddDestroyCallback,
345     d3drm_texture1_DeleteDestroyCallback,
346     d3drm_texture1_SetAppData,
347     d3drm_texture1_GetAppData,
348     d3drm_texture1_SetName,
349     d3drm_texture1_GetName,
350     d3drm_texture1_GetClassName,
351     d3drm_texture1_InitFromFile,
352     d3drm_texture1_InitFromSurface,
353     d3drm_texture1_InitFromResource,
354     d3drm_texture1_Changed,
355     d3drm_texture1_SetColors,
356     d3drm_texture1_SetShades,
357     d3drm_texture1_SetDecalSize,
358     d3drm_texture1_SetDecalOrigin,
359     d3drm_texture1_SetDecalScale,
360     d3drm_texture1_SetDecalTransparency,
361     d3drm_texture1_SetDecalTransparentColor,
362     d3drm_texture1_GetDecalSize,
363     d3drm_texture1_GetDecalOrigin,
364     d3drm_texture1_GetImage,
365     d3drm_texture1_GetShades,
366     d3drm_texture1_GetColors,
367     d3drm_texture1_GetDecalScale,
368     d3drm_texture1_GetDecalTransparency,
369     d3drm_texture1_GetDecalTransparentColor,
370 };
371 
372 static HRESULT WINAPI d3drm_texture2_QueryInterface(IDirect3DRMTexture2 *iface, REFIID riid, void **out)
373 {
374     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
375 
376     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
377 
378     return IDirect3DRMTexture3_QueryInterface(&texture->IDirect3DRMTexture3_iface, riid, out);
379 }
380 
381 static ULONG WINAPI d3drm_texture2_AddRef(IDirect3DRMTexture2 *iface)
382 {
383     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
384 
385     TRACE("iface %p.\n", iface);
386 
387     return IDirect3DRMTexture3_AddRef(&texture->IDirect3DRMTexture3_iface);
388 }
389 
390 static ULONG WINAPI d3drm_texture2_Release(IDirect3DRMTexture2 *iface)
391 {
392     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
393 
394     TRACE("iface %p.\n", iface);
395 
396     return IDirect3DRMTexture3_Release(&texture->IDirect3DRMTexture3_iface);
397 }
398 
399 static HRESULT WINAPI d3drm_texture2_Clone(IDirect3DRMTexture2 *iface,
400         IUnknown *outer, REFIID iid, void **out)
401 {
402     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
403 
404     TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
405 
406     return IDirect3DRMTexture3_Clone(&texture->IDirect3DRMTexture3_iface, outer, iid, out);
407 }
408 
409 static HRESULT WINAPI d3drm_texture2_AddDestroyCallback(IDirect3DRMTexture2 *iface,
410         D3DRMOBJECTCALLBACK cb, void *ctx)
411 {
412     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
413 
414     TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
415 
416     return IDirect3DRMTexture3_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
417 }
418 
419 static HRESULT WINAPI d3drm_texture2_DeleteDestroyCallback(IDirect3DRMTexture2 *iface,
420         D3DRMOBJECTCALLBACK cb, void *ctx)
421 {
422     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
423 
424     TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
425 
426     return IDirect3DRMTexture3_DeleteDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
427 }
428 
429 static HRESULT WINAPI d3drm_texture2_SetAppData(IDirect3DRMTexture2 *iface, DWORD data)
430 {
431     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
432 
433     TRACE("iface %p, data %#x.\n", iface, data);
434 
435     return IDirect3DRMTexture3_SetAppData(&texture->IDirect3DRMTexture3_iface, data);
436 }
437 
438 static DWORD WINAPI d3drm_texture2_GetAppData(IDirect3DRMTexture2 *iface)
439 {
440     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
441 
442     TRACE("iface %p.\n", iface);
443 
444     return IDirect3DRMTexture3_GetAppData(&texture->IDirect3DRMTexture3_iface);
445 }
446 
447 static HRESULT WINAPI d3drm_texture2_SetName(IDirect3DRMTexture2 *iface, const char *name)
448 {
449     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
450 
451     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
452 
453     return IDirect3DRMTexture3_SetName(&texture->IDirect3DRMTexture3_iface, name);
454 }
455 
456 static HRESULT WINAPI d3drm_texture2_GetName(IDirect3DRMTexture2 *iface, DWORD *size, char *name)
457 {
458     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
459 
460     TRACE("iface %p, size %p, name %p.\n", iface, size, name);
461 
462     return IDirect3DRMTexture3_GetName(&texture->IDirect3DRMTexture3_iface, size, name);
463 }
464 
465 static HRESULT WINAPI d3drm_texture2_GetClassName(IDirect3DRMTexture2 *iface, DWORD *size, char *name)
466 {
467     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
468 
469     TRACE("iface %p, size %p, name %p.\n", iface, size, name);
470 
471     return IDirect3DRMTexture3_GetClassName(&texture->IDirect3DRMTexture3_iface, size, name);
472 }
473 
474 static HRESULT WINAPI d3drm_texture2_InitFromFile(IDirect3DRMTexture2 *iface, const char *filename)
475 {
476     FIXME("iface %p, filename %s stub!\n", iface, debugstr_a(filename));
477 
478     return E_NOTIMPL;
479 }
480 
481 static HRESULT WINAPI d3drm_texture2_InitFromSurface(IDirect3DRMTexture2 *iface,
482         IDirectDrawSurface *surface)
483 {
484     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
485 
486     TRACE("iface %p, surface %p.\n", iface, surface);
487 
488     return IDirect3DRMTexture3_InitFromSurface(&texture->IDirect3DRMTexture3_iface, surface);
489 }
490 
491 static HRESULT WINAPI d3drm_texture2_InitFromResource(IDirect3DRMTexture2 *iface, HRSRC resource)
492 {
493     FIXME("iface %p, resource %p stub!\n", iface, resource);
494 
495     return E_NOTIMPL;
496 }
497 
498 static HRESULT WINAPI d3drm_texture2_Changed(IDirect3DRMTexture2 *iface, BOOL pixels, BOOL palette)
499 {
500     FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface, pixels, palette);
501 
502     return E_NOTIMPL;
503 }
504 
505 static HRESULT WINAPI d3drm_texture2_SetColors(IDirect3DRMTexture2 *iface, DWORD max_colors)
506 {
507     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
508 
509     TRACE("iface %p, max_colors %u.\n", iface, max_colors);
510 
511     return IDirect3DRMTexture3_SetColors(&texture->IDirect3DRMTexture3_iface, max_colors);
512 }
513 
514 static HRESULT WINAPI d3drm_texture2_SetShades(IDirect3DRMTexture2 *iface, DWORD max_shades)
515 {
516     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
517 
518     TRACE("iface %p, max_shades %u.\n", iface, max_shades);
519 
520     return IDirect3DRMTexture3_SetShades(&texture->IDirect3DRMTexture3_iface, max_shades);
521 }
522 
523 static HRESULT WINAPI d3drm_texture2_SetDecalSize(IDirect3DRMTexture2 *iface, D3DVALUE width, D3DVALUE height)
524 {
525     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
526 
527     TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
528 
529     return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
530 }
531 
532 static HRESULT WINAPI d3drm_texture2_SetDecalOrigin(IDirect3DRMTexture2 *iface, LONG x, LONG y)
533 {
534     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
535 
536     TRACE("iface %p, x %d, y %d.\n", iface, x, y);
537 
538     return IDirect3DRMTexture3_SetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
539 }
540 
541 static HRESULT WINAPI d3drm_texture2_SetDecalScale(IDirect3DRMTexture2 *iface, DWORD scale)
542 {
543     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
544 
545     TRACE("iface %p, scale %u.\n", iface, scale);
546 
547     return IDirect3DRMTexture3_SetDecalScale(&texture->IDirect3DRMTexture3_iface, scale);
548 }
549 
550 static HRESULT WINAPI d3drm_texture2_SetDecalTransparency(IDirect3DRMTexture2 *iface, BOOL transparency)
551 {
552     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
553 
554     TRACE("iface %p, transparency %#x.\n", iface, transparency);
555 
556     return IDirect3DRMTexture3_SetDecalTransparency(&texture->IDirect3DRMTexture3_iface, transparency);
557 }
558 
559 static HRESULT WINAPI d3drm_texture2_SetDecalTransparentColor(IDirect3DRMTexture2 *iface, D3DCOLOR color)
560 {
561     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
562 
563     TRACE("iface %p, color 0x%08x.\n", iface, color);
564 
565     return IDirect3DRMTexture3_SetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface, color);
566 }
567 
568 static HRESULT WINAPI d3drm_texture2_GetDecalSize(IDirect3DRMTexture2 *iface, D3DVALUE *width, D3DVALUE *height)
569 {
570     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
571 
572     TRACE("iface %p, width %p, height %p.\n", iface, width, height);
573 
574     return IDirect3DRMTexture3_GetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
575 }
576 
577 static HRESULT WINAPI d3drm_texture2_GetDecalOrigin(IDirect3DRMTexture2 *iface, LONG *x, LONG *y)
578 {
579     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
580 
581     TRACE("iface %p, x %p, y %p.\n", iface, x, y);
582 
583     return IDirect3DRMTexture3_GetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
584 }
585 
586 static D3DRMIMAGE * WINAPI d3drm_texture2_GetImage(IDirect3DRMTexture2 *iface)
587 {
588     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
589 
590     TRACE("iface %p.\n", iface);
591 
592     return IDirect3DRMTexture3_GetImage(&texture->IDirect3DRMTexture3_iface);
593 }
594 
595 static DWORD WINAPI d3drm_texture2_GetShades(IDirect3DRMTexture2 *iface)
596 {
597     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
598 
599     TRACE("iface %p.\n", iface);
600 
601     return IDirect3DRMTexture3_GetShades(&texture->IDirect3DRMTexture3_iface);
602 }
603 
604 static DWORD WINAPI d3drm_texture2_GetColors(IDirect3DRMTexture2 *iface)
605 {
606     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
607 
608     TRACE("iface %p.\n", iface);
609 
610     return IDirect3DRMTexture3_GetColors(&texture->IDirect3DRMTexture3_iface);
611 }
612 
613 static DWORD WINAPI d3drm_texture2_GetDecalScale(IDirect3DRMTexture2 *iface)
614 {
615     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
616 
617     TRACE("iface %p.\n", iface);
618 
619     return IDirect3DRMTexture3_GetDecalScale(&texture->IDirect3DRMTexture3_iface);
620 }
621 
622 static BOOL WINAPI d3drm_texture2_GetDecalTransparency(IDirect3DRMTexture2 *iface)
623 {
624     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
625 
626     TRACE("iface %p.\n", iface);
627 
628     return IDirect3DRMTexture3_GetDecalTransparency(&texture->IDirect3DRMTexture3_iface);
629 }
630 
631 static D3DCOLOR WINAPI d3drm_texture2_GetDecalTransparentColor(IDirect3DRMTexture2 *iface)
632 {
633     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
634 
635     TRACE("iface %p.\n", iface);
636 
637     return IDirect3DRMTexture3_GetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface);
638 }
639 
640 static HRESULT WINAPI d3drm_texture2_InitFromImage(IDirect3DRMTexture2 *iface, D3DRMIMAGE *image)
641 {
642     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
643 
644     TRACE("iface %p, image %p.\n", iface, image);
645 
646     return IDirect3DRMTexture3_InitFromImage(&texture->IDirect3DRMTexture3_iface, image);
647 }
648 
649 static HRESULT WINAPI d3drm_texture2_InitFromResource2(IDirect3DRMTexture2 *iface,
650         HMODULE module, const char *name, const char *type)
651 {
652     FIXME("iface %p, module %p, name %s, type %s stub!\n",
653             iface, module, debugstr_a(name), debugstr_a(type));
654 
655     return E_NOTIMPL;
656 }
657 
658 static HRESULT WINAPI d3drm_texture2_GenerateMIPMap(IDirect3DRMTexture2 *iface, DWORD flags)
659 {
660     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
661 
662     TRACE("iface %p, flags %#x.\n", iface, flags);
663 
664     return IDirect3DRMTexture3_GenerateMIPMap(&texture->IDirect3DRMTexture3_iface, flags);
665 }
666 
667 static const struct IDirect3DRMTexture2Vtbl d3drm_texture2_vtbl =
668 {
669     d3drm_texture2_QueryInterface,
670     d3drm_texture2_AddRef,
671     d3drm_texture2_Release,
672     d3drm_texture2_Clone,
673     d3drm_texture2_AddDestroyCallback,
674     d3drm_texture2_DeleteDestroyCallback,
675     d3drm_texture2_SetAppData,
676     d3drm_texture2_GetAppData,
677     d3drm_texture2_SetName,
678     d3drm_texture2_GetName,
679     d3drm_texture2_GetClassName,
680     d3drm_texture2_InitFromFile,
681     d3drm_texture2_InitFromSurface,
682     d3drm_texture2_InitFromResource,
683     d3drm_texture2_Changed,
684     d3drm_texture2_SetColors,
685     d3drm_texture2_SetShades,
686     d3drm_texture2_SetDecalSize,
687     d3drm_texture2_SetDecalOrigin,
688     d3drm_texture2_SetDecalScale,
689     d3drm_texture2_SetDecalTransparency,
690     d3drm_texture2_SetDecalTransparentColor,
691     d3drm_texture2_GetDecalSize,
692     d3drm_texture2_GetDecalOrigin,
693     d3drm_texture2_GetImage,
694     d3drm_texture2_GetShades,
695     d3drm_texture2_GetColors,
696     d3drm_texture2_GetDecalScale,
697     d3drm_texture2_GetDecalTransparency,
698     d3drm_texture2_GetDecalTransparentColor,
699     d3drm_texture2_InitFromImage,
700     d3drm_texture2_InitFromResource2,
701     d3drm_texture2_GenerateMIPMap,
702 };
703 
704 static HRESULT WINAPI d3drm_texture3_QueryInterface(IDirect3DRMTexture3 *iface, REFIID riid, void **out)
705 {
706     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
707 
708     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
709 
710     if (IsEqualGUID(riid, &IID_IDirect3DRMTexture)
711             || IsEqualGUID(riid, &IID_IDirect3DRMVisual)
712             || IsEqualGUID(riid, &IID_IDirect3DRMObject)
713             || IsEqualGUID(riid, &IID_IUnknown))
714     {
715         *out = &texture->IDirect3DRMTexture_iface;
716     }
717     else if (IsEqualGUID(riid, &IID_IDirect3DRMTexture2))
718     {
719         *out = &texture->IDirect3DRMTexture2_iface;
720     }
721     else if (IsEqualGUID(riid, &IID_IDirect3DRMTexture3))
722     {
723         *out = &texture->IDirect3DRMTexture3_iface;
724     }
725     else
726     {
727         *out = NULL;
728         WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
729         return CLASS_E_CLASSNOTAVAILABLE;
730     }
731 
732     IUnknown_AddRef((IUnknown *)*out);
733     return S_OK;
734 }
735 
736 static ULONG WINAPI d3drm_texture3_AddRef(IDirect3DRMTexture3 *iface)
737 {
738     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
739     ULONG refcount = InterlockedIncrement(&texture->obj.ref);
740 
741     TRACE("%p increasing refcount to %u.\n", iface, refcount);
742 
743     return refcount;
744 }
745 
746 static ULONG WINAPI d3drm_texture3_Release(IDirect3DRMTexture3 *iface)
747 {
748     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
749     ULONG refcount = InterlockedDecrement(&texture->obj.ref);
750 
751     TRACE("%p decreasing refcount to %u.\n", iface, refcount);
752 
753     if (!refcount)
754         d3drm_texture_destroy(texture);
755 
756     return refcount;
757 }
758 
759 static HRESULT WINAPI d3drm_texture3_Clone(IDirect3DRMTexture3 *iface,
760         IUnknown *outer, REFIID iid, void **out)
761 {
762     FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
763 
764     return E_NOTIMPL;
765 }
766 
767 static HRESULT WINAPI d3drm_texture3_AddDestroyCallback(IDirect3DRMTexture3 *iface,
768         D3DRMOBJECTCALLBACK cb, void *ctx)
769 {
770     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
771 
772     TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
773 
774     return d3drm_object_add_destroy_callback(&texture->obj, cb, ctx);
775 }
776 
777 static HRESULT WINAPI d3drm_texture3_DeleteDestroyCallback(IDirect3DRMTexture3 *iface,
778         D3DRMOBJECTCALLBACK cb, void *ctx)
779 {
780     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
781 
782     TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
783 
784     return d3drm_object_delete_destroy_callback(&texture->obj, cb, ctx);
785 }
786 
787 static HRESULT WINAPI d3drm_texture3_SetAppData(IDirect3DRMTexture3 *iface, DWORD data)
788 {
789     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
790 
791     TRACE("iface %p, data %#x.\n", iface, data);
792 
793     texture->obj.appdata = data;
794 
795     return D3DRM_OK;
796 }
797 
798 static DWORD WINAPI d3drm_texture3_GetAppData(IDirect3DRMTexture3 *iface)
799 {
800     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
801 
802     TRACE("iface %p.\n", iface);
803 
804     return texture->obj.appdata;
805 }
806 
807 static HRESULT WINAPI d3drm_texture3_SetName(IDirect3DRMTexture3 *iface, const char *name)
808 {
809     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
810 
811     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
812 
813     return d3drm_object_set_name(&texture->obj, name);
814 }
815 
816 static HRESULT WINAPI d3drm_texture3_GetName(IDirect3DRMTexture3 *iface, DWORD *size, char *name)
817 {
818     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
819 
820     TRACE("iface %p, size %p, name %p.\n", iface, size, name);
821 
822     return d3drm_object_get_name(&texture->obj, size, name);
823 }
824 
825 static HRESULT WINAPI d3drm_texture3_GetClassName(IDirect3DRMTexture3 *iface, DWORD *size, char *name)
826 {
827     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
828 
829     TRACE("iface %p, size %p, name %p.\n", iface, size, name);
830 
831     return d3drm_object_get_class_name(&texture->obj, size, name);
832 }
833 
834 static HRESULT WINAPI d3drm_texture3_InitFromFile(IDirect3DRMTexture3 *iface, const char *filename)
835 {
836     FIXME("iface %p, filename %s stub!\n", iface, debugstr_a(filename));
837 
838     return E_NOTIMPL;
839 }
840 
841 static HRESULT WINAPI d3drm_texture3_InitFromSurface(IDirect3DRMTexture3 *iface,
842         IDirectDrawSurface *surface)
843 {
844     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
845 
846     TRACE("iface %p, surface %p.\n", iface, surface);
847 
848     if (!surface)
849         return D3DRMERR_BADOBJECT;
850 
851     /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
852     IDirect3DRM_AddRef(texture->d3drm);
853 
854     if (texture->image || texture->surface)
855         return D3DRMERR_BADOBJECT;
856 
857     texture->surface = surface;
858     IDirectDrawSurface_AddRef(texture->surface);
859     return D3DRM_OK;
860 }
861 
862 static HRESULT WINAPI d3drm_texture3_InitFromResource(IDirect3DRMTexture3 *iface, HRSRC resource)
863 {
864     FIXME("iface %p, resource %p stub!\n", iface, resource);
865 
866     return E_NOTIMPL;
867 }
868 
869 static HRESULT WINAPI d3drm_texture3_Changed(IDirect3DRMTexture3 *iface,
870         DWORD flags, DWORD rect_count, RECT *rects)
871 {
872     FIXME("iface %p, flags %#x, rect_count %u, rects %p stub!\n", iface, flags, rect_count, rects);
873 
874     return E_NOTIMPL;
875 }
876 
877 static HRESULT WINAPI d3drm_texture3_SetColors(IDirect3DRMTexture3 *iface, DWORD max_colors)
878 {
879     FIXME("iface %p, max_colors %u stub!\n", iface, max_colors);
880 
881     return E_NOTIMPL;
882 }
883 
884 static HRESULT WINAPI d3drm_texture3_SetShades(IDirect3DRMTexture3 *iface, DWORD max_shades)
885 {
886     FIXME("iface %p, max_shades %u stub!\n", iface, max_shades);
887 
888     return E_NOTIMPL;
889 }
890 
891 static HRESULT WINAPI d3drm_texture3_SetDecalSize(IDirect3DRMTexture3 *iface, D3DVALUE width, D3DVALUE height)
892 {
893     FIXME("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
894 
895     return E_NOTIMPL;
896 }
897 
898 static HRESULT WINAPI d3drm_texture3_SetDecalOrigin(IDirect3DRMTexture3 *iface, LONG x, LONG y)
899 {
900     FIXME("iface %p, x %d, y %d stub!\n", iface, x, y);
901 
902     return E_NOTIMPL;
903 }
904 
905 static HRESULT WINAPI d3drm_texture3_SetDecalScale(IDirect3DRMTexture3 *iface, DWORD scale)
906 {
907     FIXME("iface %p, scale %u stub!\n", iface, scale);
908 
909     return E_NOTIMPL;
910 }
911 
912 static HRESULT WINAPI d3drm_texture3_SetDecalTransparency(IDirect3DRMTexture3 *iface, BOOL transparency)
913 {
914     FIXME("iface %p, transparency %#x stub!\n", iface, transparency);
915 
916     return E_NOTIMPL;
917 }
918 
919 static HRESULT WINAPI d3drm_texture3_SetDecalTransparentColor(IDirect3DRMTexture3 *iface, D3DCOLOR color)
920 {
921     FIXME("iface %p, color 0x%08x stub!\n", iface, color);
922 
923     return E_NOTIMPL;
924 }
925 
926 static HRESULT WINAPI d3drm_texture3_GetDecalSize(IDirect3DRMTexture3 *iface, D3DVALUE *width, D3DVALUE *height)
927 {
928     FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
929 
930     return E_NOTIMPL;
931 }
932 
933 static HRESULT WINAPI d3drm_texture3_GetDecalOrigin(IDirect3DRMTexture3 *iface, LONG *x, LONG *y)
934 {
935     FIXME("iface %p, x %p, y %p stub!\n", iface, x, y);
936 
937     return E_NOTIMPL;
938 }
939 
940 static D3DRMIMAGE * WINAPI d3drm_texture3_GetImage(IDirect3DRMTexture3 *iface)
941 {
942     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
943 
944     TRACE("iface %p.\n", iface);
945 
946     return texture->image;
947 }
948 
949 static DWORD WINAPI d3drm_texture3_GetShades(IDirect3DRMTexture3 *iface)
950 {
951     FIXME("iface %p stub!\n", iface);
952 
953     return 0;
954 }
955 
956 static DWORD WINAPI d3drm_texture3_GetColors(IDirect3DRMTexture3 *iface)
957 {
958     FIXME("iface %p stub!\n", iface);
959 
960     return 0;
961 }
962 
963 static DWORD WINAPI d3drm_texture3_GetDecalScale(IDirect3DRMTexture3 *iface)
964 {
965     FIXME("iface %p stub!\n", iface);
966 
967     return 0;
968 }
969 
970 static BOOL WINAPI d3drm_texture3_GetDecalTransparency(IDirect3DRMTexture3 *iface)
971 {
972     FIXME("iface %p stub!\n", iface);
973 
974     return FALSE;
975 }
976 
977 static D3DCOLOR WINAPI d3drm_texture3_GetDecalTransparentColor(IDirect3DRMTexture3 *iface)
978 {
979     FIXME("iface %p stub!\n", iface);
980 
981     return 0;
982 }
983 
984 static HRESULT WINAPI d3drm_texture3_InitFromImage(IDirect3DRMTexture3 *iface, D3DRMIMAGE *image)
985 {
986     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
987 
988     TRACE("iface %p, image %p.\n", iface, image);
989 
990     if (!d3drm_validate_image(image))
991         return D3DRMERR_BADOBJECT;
992 
993     /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
994     IDirect3DRM_AddRef(texture->d3drm);
995 
996     if (texture->image || texture->surface)
997         return D3DRMERR_BADOBJECT;
998 
999     texture->image = image;
1000 
1001     return D3DRM_OK;
1002 }
1003 
1004 static HRESULT WINAPI d3drm_texture3_InitFromResource2(IDirect3DRMTexture3 *iface,
1005         HMODULE module, const char *name, const char *type)
1006 {
1007     FIXME("iface %p, module %p, name %s, type %s stub!\n",
1008             iface, module, debugstr_a(name), debugstr_a(type));
1009 
1010     return E_NOTIMPL;
1011 }
1012 
1013 static HRESULT WINAPI d3drm_texture3_GenerateMIPMap(IDirect3DRMTexture3 *iface, DWORD flags)
1014 {
1015     FIXME("iface %p, flags %#x stub!\n", iface, flags);
1016 
1017     return E_NOTIMPL;
1018 }
1019 
1020 static HRESULT WINAPI d3drm_texture3_GetSurface(IDirect3DRMTexture3 *iface,
1021         DWORD flags, IDirectDrawSurface **surface)
1022 {
1023     struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1024 
1025     TRACE("iface %p, flags %#x, surface %p.\n", iface, flags, surface);
1026 
1027     if (flags)
1028         FIXME("unexpected flags %#x.\n", flags);
1029 
1030     if (!surface)
1031         return D3DRMERR_BADVALUE;
1032 
1033     if (texture->image)
1034         return D3DRMERR_NOTCREATEDFROMDDS;
1035 
1036     *surface = texture->surface;
1037     IDirectDrawSurface_AddRef(*surface);
1038 
1039     return D3DRM_OK;
1040 }
1041 
1042 static HRESULT WINAPI d3drm_texture3_SetCacheOptions(IDirect3DRMTexture3 *iface, LONG importance, DWORD flags)
1043 {
1044     FIXME("iface %p, importance %d, flags %#x stub!\n", iface, importance, flags);
1045 
1046     return E_NOTIMPL;
1047 }
1048 
1049 static HRESULT WINAPI d3drm_texture3_GetCacheOptions(IDirect3DRMTexture3 *iface,
1050         LONG *importance, DWORD *flags)
1051 {
1052     FIXME("iface %p, importance %p, flags %p stub!\n", iface, importance, flags);
1053 
1054     return E_NOTIMPL;
1055 }
1056 
1057 static HRESULT WINAPI d3drm_texture3_SetDownsampleCallback(IDirect3DRMTexture3 *iface,
1058         D3DRMDOWNSAMPLECALLBACK cb, void *ctx)
1059 {
1060     FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1061 
1062     return E_NOTIMPL;
1063 }
1064 
1065 static HRESULT WINAPI d3drm_texture3_SetValidationCallback(IDirect3DRMTexture3 *iface,
1066         D3DRMVALIDATIONCALLBACK cb, void *ctx)
1067 {
1068     FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1069 
1070     return E_NOTIMPL;
1071 }
1072 
1073 static const struct IDirect3DRMTexture3Vtbl d3drm_texture3_vtbl =
1074 {
1075     d3drm_texture3_QueryInterface,
1076     d3drm_texture3_AddRef,
1077     d3drm_texture3_Release,
1078     d3drm_texture3_Clone,
1079     d3drm_texture3_AddDestroyCallback,
1080     d3drm_texture3_DeleteDestroyCallback,
1081     d3drm_texture3_SetAppData,
1082     d3drm_texture3_GetAppData,
1083     d3drm_texture3_SetName,
1084     d3drm_texture3_GetName,
1085     d3drm_texture3_GetClassName,
1086     d3drm_texture3_InitFromFile,
1087     d3drm_texture3_InitFromSurface,
1088     d3drm_texture3_InitFromResource,
1089     d3drm_texture3_Changed,
1090     d3drm_texture3_SetColors,
1091     d3drm_texture3_SetShades,
1092     d3drm_texture3_SetDecalSize,
1093     d3drm_texture3_SetDecalOrigin,
1094     d3drm_texture3_SetDecalScale,
1095     d3drm_texture3_SetDecalTransparency,
1096     d3drm_texture3_SetDecalTransparentColor,
1097     d3drm_texture3_GetDecalSize,
1098     d3drm_texture3_GetDecalOrigin,
1099     d3drm_texture3_GetImage,
1100     d3drm_texture3_GetShades,
1101     d3drm_texture3_GetColors,
1102     d3drm_texture3_GetDecalScale,
1103     d3drm_texture3_GetDecalTransparency,
1104     d3drm_texture3_GetDecalTransparentColor,
1105     d3drm_texture3_InitFromImage,
1106     d3drm_texture3_InitFromResource2,
1107     d3drm_texture3_GenerateMIPMap,
1108     d3drm_texture3_GetSurface,
1109     d3drm_texture3_SetCacheOptions,
1110     d3drm_texture3_GetCacheOptions,
1111     d3drm_texture3_SetDownsampleCallback,
1112     d3drm_texture3_SetValidationCallback,
1113 };
1114 
1115 HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm)
1116 {
1117     static const char classname[] = "Texture";
1118     struct d3drm_texture *object;
1119 
1120     TRACE("texture %p.\n", texture);
1121 
1122     if (!(object = heap_alloc_zero(sizeof(*object))))
1123         return E_OUTOFMEMORY;
1124 
1125     object->IDirect3DRMTexture_iface.lpVtbl = &d3drm_texture1_vtbl;
1126     object->IDirect3DRMTexture2_iface.lpVtbl = &d3drm_texture2_vtbl;
1127     object->IDirect3DRMTexture3_iface.lpVtbl = &d3drm_texture3_vtbl;
1128     object->d3drm = d3drm;
1129 
1130     d3drm_object_init(&object->obj, classname);
1131 
1132     *texture = object;
1133 
1134     return D3DRM_OK;
1135 }
1136