ntoskrnl.exe: Implement NtBuildNumber.
[wine.git] / dlls / d3drm / texture.c
blob7741718ce90f41bcd4a10996938239d8ae84c3a1
1 /*
2 * Implementation of IDirect3DRMTextureX interfaces
4 * Copyright 2012 Christian Costa
5 * Copyright 2016 Aaryaman Vasishta
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include "d3drm_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
29 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture(IDirect3DRMTexture *iface)
31 return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture_iface);
34 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture2(IDirect3DRMTexture2 *iface)
36 return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture2_iface);
39 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture3(IDirect3DRMTexture3 *iface)
41 return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture3_iface);
44 static void d3drm_texture_destroy(struct d3drm_texture *texture)
46 TRACE("texture %p is being destroyed.\n", texture);
48 d3drm_object_cleanup((IDirect3DRMObject*)&texture->IDirect3DRMTexture_iface, &texture->obj);
49 if (texture->image || texture->surface)
50 IDirect3DRM_Release(texture->d3drm);
51 if (texture->surface)
52 IDirectDrawSurface_Release(texture->surface);
53 heap_free(texture);
56 static BOOL d3drm_validate_image(D3DRMIMAGE *image)
58 if (!image
59 || !image->red_mask
60 || !image->green_mask
61 || !image->blue_mask
62 || !image->buffer1
63 || !(image->rgb || (image->palette && image->palette_size)))
65 return FALSE;
68 return TRUE;
71 static BOOL d3drm_image_palettise(D3DRMIMAGE *image, unsigned char *src_data,
72 SIZE_T w, SIZE_T h, BOOL flip)
74 unsigned char *dst_data, *src_ptr, *dst_ptr;
75 SIZE_T src_pitch, dst_pitch, i, x, y;
76 D3DRMPALETTEENTRY *palette, *entry;
77 unsigned int colour_count = 0;
79 if (w > (~(SIZE_T)0 - 3) / h)
80 return FALSE;
82 src_pitch = flip ? -w * 3 : w * 3;
83 dst_pitch = (w + 3) & ~3;
85 if (!(dst_data = heap_alloc(dst_pitch * h)))
87 WARN("Failed to allocate image buffer.\n");
88 return FALSE;
90 memset(dst_data, 0xff, dst_pitch * h);
92 if (!(palette = heap_alloc(256 * sizeof(*palette))))
94 WARN("Failed to allocate palette.\n");
95 heap_free(dst_data);
96 return FALSE;
99 src_ptr = flip ? &src_data[(h - 1) * w * 3] : src_data;
100 dst_ptr = dst_data;
102 for (y = 0; y < h; ++y)
104 for (x = 0; x < w; ++x)
106 for (i = 0; i < colour_count; ++i)
108 entry = &palette[i];
109 if (entry->red == src_ptr[x * 3 + 0]
110 && entry->green == src_ptr[x * 3 + 1]
111 && entry->blue == src_ptr[x * 3 + 2])
112 break;
115 if (i == colour_count)
117 if (colour_count == 256)
119 heap_free(dst_data);
120 heap_free(palette);
121 return FALSE;
124 entry = &palette[colour_count++];
125 entry->red = src_ptr[x * 3 + 0];
126 entry->green = src_ptr[x * 3 + 1];
127 entry->blue = src_ptr[x * 3 + 2];
128 entry->flags = D3DRMPALETTE_READONLY;
131 dst_ptr[x] = i;
134 src_ptr += src_pitch;
135 dst_ptr += dst_pitch;
138 image->depth = 8;
139 image->rgb = 0;
140 image->bytes_per_line = dst_pitch;
141 image->buffer1 = dst_data;
142 image->red_mask = 0xff;
143 image->green_mask = 0xff;
144 image->blue_mask = 0xff;
145 image->palette_size = colour_count;
146 if (!(image->palette = heap_realloc(palette, colour_count * sizeof(*palette))))
147 image->palette = palette;
149 return TRUE;
152 static HRESULT d3drm_image_load_32(D3DRMIMAGE *image, unsigned char *src_data,
153 LONGLONG src_data_size, SIZE_T w, SIZE_T h, BOOL flip)
155 unsigned char *dst_data, *src_ptr, *dst_ptr;
156 SIZE_T src_pitch, dst_pitch, x, y;
158 if (d3drm_image_palettise(image, src_data, w, h, flip))
159 return D3DRM_OK;
161 if (w > (~(SIZE_T)0 / 4) / h)
162 return D3DRMERR_BADALLOC;
164 src_pitch = flip ? -w * 3 : w * 3;
165 dst_pitch = w * 4;
167 if (!(dst_data = heap_alloc(dst_pitch * h)))
169 WARN("Failed to allocate image buffer.\n");
170 return D3DRMERR_BADALLOC;
173 src_ptr = flip ? &src_data[(h - 1) * w * 3] : src_data;
174 dst_ptr = dst_data;
176 for (y = 0; y < h; ++y)
178 for (x = 0; x < w; ++x)
180 dst_ptr[x * 4 + 0] = src_ptr[x * 3 + 0];
181 dst_ptr[x * 4 + 1] = src_ptr[x * 3 + 1];
182 dst_ptr[x * 4 + 2] = src_ptr[x * 3 + 2];
183 dst_ptr[x * 4 + 3] = 0xff;
186 src_ptr += src_pitch;
187 dst_ptr += dst_pitch;
190 image->depth = 32;
191 image->rgb = 1;
192 image->bytes_per_line = dst_pitch;
193 image->buffer1 = dst_data;
194 image->red_mask = 0xff0000;
195 image->green_mask = 0x00ff00;
196 image->blue_mask = 0x0000ff;
197 image->palette_size = 0;
198 image->palette = NULL;
200 return D3DRM_OK;
203 static HRESULT d3drm_image_load_8(D3DRMIMAGE *image, const RGBQUAD *palette,
204 unsigned char *src_data, LONGLONG src_data_size, SIZE_T w, SIZE_T h, BOOL flip)
206 unsigned char *dst_data;
207 SIZE_T i;
209 if (w > ~(SIZE_T)0 / h)
210 return D3DRMERR_BADALLOC;
212 if (!(dst_data = heap_alloc(w * h)))
214 WARN("Failed to allocate image buffer.\n");
215 return D3DRMERR_BADALLOC;
218 if (!(image->palette = heap_alloc(256 * sizeof(*image->palette))))
220 WARN("Failed to allocate palette.\n");
221 heap_free(dst_data);
222 return D3DRMERR_BADALLOC;
225 memcpy(image->palette, palette, 256 * sizeof(*image->palette));
226 for (i = 0; i < 256; ++i)
228 image->palette[i].flags = D3DRMPALETTE_READONLY;
231 if (flip)
233 for (i = 0; i < h; ++i)
235 memcpy(&dst_data[i * w], &src_data[(h - 1 - i) * w], w);
238 else
240 memcpy(dst_data, src_data, w * h);
243 image->depth = 8;
244 image->rgb = 0;
245 image->bytes_per_line = w;
246 image->buffer1 = dst_data;
247 image->red_mask = 0xff;
248 image->green_mask = 0xff;
249 image->blue_mask = 0xff;
250 image->palette_size = 256;
252 return D3DRM_OK;
255 static void CDECL destroy_image_callback(IDirect3DRMObject *obj, void *arg)
257 D3DRMIMAGE *image = arg;
259 TRACE("texture object %p, image %p.\n", obj, image);
261 heap_free(image->buffer1);
262 heap_free(image);
265 static HRESULT d3drm_texture_load(struct d3drm_texture *texture,
266 const char *path, BOOL flip, D3DRMIMAGE **image_out)
268 BITMAPFILEHEADER *header;
269 unsigned int w, h, bpp;
270 HANDLE file, mapping;
271 LARGE_INTEGER size;
272 D3DRMIMAGE *image;
273 BITMAPINFO *info;
274 LONGLONG rem;
275 HRESULT hr;
277 if ((file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
278 return D3DRMERR_BADOBJECT;
280 mapping = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
281 CloseHandle(file);
282 if (!mapping || mapping == INVALID_HANDLE_VALUE)
283 return D3DRMERR_BADVALUE;
285 if (!GetFileSizeEx(mapping, &size))
287 CloseHandle(mapping);
288 return D3DRMERR_BADVALUE;
290 rem = size.QuadPart;
292 header = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
293 CloseHandle(mapping);
294 if (!header)
295 return D3DRMERR_BADVALUE;
297 hr = D3DRMERR_BADALLOC;
298 if (!(image = heap_alloc_zero(sizeof(*image))))
299 goto fail;
301 hr = D3DRMERR_BADFILE;
302 if (rem < sizeof(*header) || header->bfType != 0x4d42 /* BM */)
303 goto fail;
304 rem -= sizeof(*header);
306 info = (BITMAPINFO *)&header[1];
307 /* Only allow version 1 DIB's (BITMAPINFOHEADER) to be loaded. */
308 if (rem < sizeof(info->bmiHeader) || info->bmiHeader.biSize != sizeof(info->bmiHeader))
309 goto fail;
310 rem -= sizeof(info->bmiHeader);
312 w = info->bmiHeader.biWidth;
313 h = abs(info->bmiHeader.biHeight);
314 bpp = info->bmiHeader.biBitCount == 24 ? 32 : info->bmiHeader.biBitCount;
315 if (bpp != 8 && bpp != 32)
316 goto fail;
318 image->width = w;
319 image->height = h;
320 image->aspectx = 1;
321 image->aspecty = 1;
322 if (bpp == 8)
324 rem -= 256 * sizeof(*info->bmiColors);
325 if (w > rem / h)
326 goto fail;
327 hr = d3drm_image_load_8(image, info->bmiColors, (unsigned char *)&info->bmiColors[256], rem, w, h, flip);
329 else
331 if (w > (rem / 3) / h)
332 goto fail;
333 hr = d3drm_image_load_32(image, (unsigned char *)&info->bmiColors, rem, w, h, flip);
335 if (FAILED(hr))
336 goto fail;
338 /* Use an internal destroy callback to destroy the image struct. */
339 hr = IDirect3DRMObject_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, destroy_image_callback, image);
341 *image_out = image;
343 UnmapViewOfFile(header);
345 return hr;
347 fail:
348 heap_free(image);
349 UnmapViewOfFile(header);
351 return hr;
354 static HRESULT WINAPI d3drm_texture1_QueryInterface(IDirect3DRMTexture *iface, REFIID riid, void **out)
356 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
358 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
360 return IDirect3DRMTexture3_QueryInterface(&texture->IDirect3DRMTexture3_iface, riid, out);
363 static ULONG WINAPI d3drm_texture1_AddRef(IDirect3DRMTexture *iface)
365 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
367 TRACE("iface %p.\n", iface);
369 return IDirect3DRMTexture3_AddRef(&texture->IDirect3DRMTexture3_iface);
372 static ULONG WINAPI d3drm_texture1_Release(IDirect3DRMTexture *iface)
374 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
376 TRACE("iface %p.\n", iface);
378 return IDirect3DRMTexture3_Release(&texture->IDirect3DRMTexture3_iface);
381 static HRESULT WINAPI d3drm_texture1_Clone(IDirect3DRMTexture *iface,
382 IUnknown *outer, REFIID iid, void **out)
384 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
386 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
388 return IDirect3DRMTexture3_Clone(&texture->IDirect3DRMTexture3_iface, outer, iid, out);
391 static HRESULT WINAPI d3drm_texture1_AddDestroyCallback(IDirect3DRMTexture *iface,
392 D3DRMOBJECTCALLBACK cb, void *ctx)
394 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
396 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
398 return IDirect3DRMTexture3_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
401 static HRESULT WINAPI d3drm_texture1_DeleteDestroyCallback(IDirect3DRMTexture *iface,
402 D3DRMOBJECTCALLBACK cb, void *ctx)
404 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
406 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
408 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
411 static HRESULT WINAPI d3drm_texture1_SetAppData(IDirect3DRMTexture *iface, DWORD data)
413 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
415 TRACE("iface %p, data %#x.\n", iface, data);
417 return IDirect3DRMTexture3_SetAppData(&texture->IDirect3DRMTexture3_iface, data);
420 static DWORD WINAPI d3drm_texture1_GetAppData(IDirect3DRMTexture *iface)
422 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
424 TRACE("iface %p.\n", iface);
426 return IDirect3DRMTexture3_GetAppData(&texture->IDirect3DRMTexture3_iface);
429 static HRESULT WINAPI d3drm_texture1_SetName(IDirect3DRMTexture *iface, const char *name)
431 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
433 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
435 return IDirect3DRMTexture3_SetName(&texture->IDirect3DRMTexture3_iface, name);
438 static HRESULT WINAPI d3drm_texture1_GetName(IDirect3DRMTexture *iface, DWORD *size, char *name)
440 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
442 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
444 return IDirect3DRMTexture3_GetName(&texture->IDirect3DRMTexture3_iface, size, name);
447 static HRESULT WINAPI d3drm_texture1_GetClassName(IDirect3DRMTexture *iface, DWORD *size, char *name)
449 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
451 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
453 return IDirect3DRMTexture3_GetClassName(&texture->IDirect3DRMTexture3_iface, size, name);
456 static HRESULT WINAPI d3drm_texture1_InitFromFile(IDirect3DRMTexture *iface, const char *filename)
458 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
459 D3DRMIMAGE *image;
460 HRESULT hr;
462 TRACE("iface %p, filename %s.\n", iface, debugstr_a(filename));
464 if (FAILED(hr = d3drm_texture_load(texture, filename, FALSE, &image)))
465 return hr;
467 return IDirect3DRMTexture3_InitFromImage(&texture->IDirect3DRMTexture3_iface, image);
470 static HRESULT WINAPI d3drm_texture1_InitFromSurface(IDirect3DRMTexture *iface,
471 IDirectDrawSurface *surface)
473 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
475 TRACE("iface %p, surface %p.\n", iface, surface);
477 return IDirect3DRMTexture3_InitFromSurface(&texture->IDirect3DRMTexture3_iface, surface);
480 static HRESULT WINAPI d3drm_texture1_InitFromResource(IDirect3DRMTexture *iface, HRSRC resource)
482 FIXME("iface %p, resource %p stub!\n", iface, resource);
484 return E_NOTIMPL;
487 static HRESULT WINAPI d3drm_texture1_Changed(IDirect3DRMTexture *iface, BOOL pixels, BOOL palette)
489 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface, pixels, palette);
491 return E_NOTIMPL;
494 static HRESULT WINAPI d3drm_texture1_SetColors(IDirect3DRMTexture *iface, DWORD max_colors)
496 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
498 TRACE("iface %p, max_colors %u.\n", iface, max_colors);
500 return IDirect3DRMTexture3_SetColors(&texture->IDirect3DRMTexture3_iface, max_colors);
503 static HRESULT WINAPI d3drm_texture1_SetShades(IDirect3DRMTexture *iface, DWORD max_shades)
505 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
507 TRACE("iface %p, max_shades %u.\n", iface, max_shades);
509 return IDirect3DRMTexture3_SetShades(&texture->IDirect3DRMTexture3_iface, max_shades);
512 static HRESULT WINAPI d3drm_texture1_SetDecalSize(IDirect3DRMTexture *iface, D3DVALUE width, D3DVALUE height)
514 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
516 TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
518 return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
521 static HRESULT WINAPI d3drm_texture1_SetDecalOrigin(IDirect3DRMTexture *iface, LONG x, LONG y)
523 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
525 TRACE("iface %p, x %d, y %d.\n", iface, x, y);
527 return IDirect3DRMTexture3_SetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
530 static HRESULT WINAPI d3drm_texture1_SetDecalScale(IDirect3DRMTexture *iface, DWORD scale)
532 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
534 TRACE("iface %p, scale %u.\n", iface, scale);
536 return IDirect3DRMTexture3_SetDecalScale(&texture->IDirect3DRMTexture3_iface, scale);
539 static HRESULT WINAPI d3drm_texture1_SetDecalTransparency(IDirect3DRMTexture *iface, BOOL transparency)
541 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
543 TRACE("iface %p, transparency %#x.\n", iface, transparency);
545 return IDirect3DRMTexture3_SetDecalTransparency(&texture->IDirect3DRMTexture3_iface, transparency);
548 static HRESULT WINAPI d3drm_texture1_SetDecalTransparentColor(IDirect3DRMTexture *iface, D3DCOLOR color)
550 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
552 TRACE("iface %p, color 0x%08x.\n", iface, color);
554 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface, color);
557 static HRESULT WINAPI d3drm_texture1_GetDecalSize(IDirect3DRMTexture *iface, D3DVALUE *width, D3DVALUE *height)
559 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
561 TRACE("iface %p, width %p, height %p.\n", iface, width, height);
563 return IDirect3DRMTexture3_GetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
566 static HRESULT WINAPI d3drm_texture1_GetDecalOrigin(IDirect3DRMTexture *iface, LONG *x, LONG *y)
568 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
570 TRACE("iface %p, x %p, y %p.\n", iface, x, y);
572 return IDirect3DRMTexture3_GetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
575 static D3DRMIMAGE * WINAPI d3drm_texture1_GetImage(IDirect3DRMTexture *iface)
577 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
579 TRACE("iface %p.\n", iface);
581 return IDirect3DRMTexture3_GetImage(&texture->IDirect3DRMTexture3_iface);
584 static DWORD WINAPI d3drm_texture1_GetShades(IDirect3DRMTexture *iface)
586 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
588 TRACE("iface %p.\n", iface);
590 return IDirect3DRMTexture3_GetShades(&texture->IDirect3DRMTexture3_iface);
593 static DWORD WINAPI d3drm_texture1_GetColors(IDirect3DRMTexture *iface)
595 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
597 TRACE("iface %p.\n", iface);
599 return IDirect3DRMTexture3_GetColors(&texture->IDirect3DRMTexture3_iface);
602 static DWORD WINAPI d3drm_texture1_GetDecalScale(IDirect3DRMTexture *iface)
604 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
606 TRACE("iface %p.\n", iface);
608 return IDirect3DRMTexture3_GetDecalScale(&texture->IDirect3DRMTexture3_iface);
611 static BOOL WINAPI d3drm_texture1_GetDecalTransparency(IDirect3DRMTexture *iface)
613 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
615 TRACE("iface %p.\n", iface);
617 return IDirect3DRMTexture3_GetDecalTransparency(&texture->IDirect3DRMTexture3_iface);
620 static D3DCOLOR WINAPI d3drm_texture1_GetDecalTransparentColor(IDirect3DRMTexture *iface)
622 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
624 TRACE("iface %p.\n", iface);
626 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface);
629 static const struct IDirect3DRMTextureVtbl d3drm_texture1_vtbl =
631 d3drm_texture1_QueryInterface,
632 d3drm_texture1_AddRef,
633 d3drm_texture1_Release,
634 d3drm_texture1_Clone,
635 d3drm_texture1_AddDestroyCallback,
636 d3drm_texture1_DeleteDestroyCallback,
637 d3drm_texture1_SetAppData,
638 d3drm_texture1_GetAppData,
639 d3drm_texture1_SetName,
640 d3drm_texture1_GetName,
641 d3drm_texture1_GetClassName,
642 d3drm_texture1_InitFromFile,
643 d3drm_texture1_InitFromSurface,
644 d3drm_texture1_InitFromResource,
645 d3drm_texture1_Changed,
646 d3drm_texture1_SetColors,
647 d3drm_texture1_SetShades,
648 d3drm_texture1_SetDecalSize,
649 d3drm_texture1_SetDecalOrigin,
650 d3drm_texture1_SetDecalScale,
651 d3drm_texture1_SetDecalTransparency,
652 d3drm_texture1_SetDecalTransparentColor,
653 d3drm_texture1_GetDecalSize,
654 d3drm_texture1_GetDecalOrigin,
655 d3drm_texture1_GetImage,
656 d3drm_texture1_GetShades,
657 d3drm_texture1_GetColors,
658 d3drm_texture1_GetDecalScale,
659 d3drm_texture1_GetDecalTransparency,
660 d3drm_texture1_GetDecalTransparentColor,
663 static HRESULT WINAPI d3drm_texture2_QueryInterface(IDirect3DRMTexture2 *iface, REFIID riid, void **out)
665 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
667 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
669 return IDirect3DRMTexture3_QueryInterface(&texture->IDirect3DRMTexture3_iface, riid, out);
672 static ULONG WINAPI d3drm_texture2_AddRef(IDirect3DRMTexture2 *iface)
674 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
676 TRACE("iface %p.\n", iface);
678 return IDirect3DRMTexture3_AddRef(&texture->IDirect3DRMTexture3_iface);
681 static ULONG WINAPI d3drm_texture2_Release(IDirect3DRMTexture2 *iface)
683 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
685 TRACE("iface %p.\n", iface);
687 return IDirect3DRMTexture3_Release(&texture->IDirect3DRMTexture3_iface);
690 static HRESULT WINAPI d3drm_texture2_Clone(IDirect3DRMTexture2 *iface,
691 IUnknown *outer, REFIID iid, void **out)
693 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
695 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
697 return IDirect3DRMTexture3_Clone(&texture->IDirect3DRMTexture3_iface, outer, iid, out);
700 static HRESULT WINAPI d3drm_texture2_AddDestroyCallback(IDirect3DRMTexture2 *iface,
701 D3DRMOBJECTCALLBACK cb, void *ctx)
703 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
705 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
707 return IDirect3DRMTexture3_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
710 static HRESULT WINAPI d3drm_texture2_DeleteDestroyCallback(IDirect3DRMTexture2 *iface,
711 D3DRMOBJECTCALLBACK cb, void *ctx)
713 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
715 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
717 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
720 static HRESULT WINAPI d3drm_texture2_SetAppData(IDirect3DRMTexture2 *iface, DWORD data)
722 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
724 TRACE("iface %p, data %#x.\n", iface, data);
726 return IDirect3DRMTexture3_SetAppData(&texture->IDirect3DRMTexture3_iface, data);
729 static DWORD WINAPI d3drm_texture2_GetAppData(IDirect3DRMTexture2 *iface)
731 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
733 TRACE("iface %p.\n", iface);
735 return IDirect3DRMTexture3_GetAppData(&texture->IDirect3DRMTexture3_iface);
738 static HRESULT WINAPI d3drm_texture2_SetName(IDirect3DRMTexture2 *iface, const char *name)
740 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
742 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
744 return IDirect3DRMTexture3_SetName(&texture->IDirect3DRMTexture3_iface, name);
747 static HRESULT WINAPI d3drm_texture2_GetName(IDirect3DRMTexture2 *iface, DWORD *size, char *name)
749 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
751 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
753 return IDirect3DRMTexture3_GetName(&texture->IDirect3DRMTexture3_iface, size, name);
756 static HRESULT WINAPI d3drm_texture2_GetClassName(IDirect3DRMTexture2 *iface, DWORD *size, char *name)
758 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
760 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
762 return IDirect3DRMTexture3_GetClassName(&texture->IDirect3DRMTexture3_iface, size, name);
765 static HRESULT WINAPI d3drm_texture2_InitFromFile(IDirect3DRMTexture2 *iface, const char *filename)
767 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
769 TRACE("iface %p, filename %s.\n", iface, debugstr_a(filename));
771 return IDirect3DRMTexture3_InitFromFile(&texture->IDirect3DRMTexture3_iface, filename);
774 static HRESULT WINAPI d3drm_texture2_InitFromSurface(IDirect3DRMTexture2 *iface,
775 IDirectDrawSurface *surface)
777 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
779 TRACE("iface %p, surface %p.\n", iface, surface);
781 return IDirect3DRMTexture3_InitFromSurface(&texture->IDirect3DRMTexture3_iface, surface);
784 static HRESULT WINAPI d3drm_texture2_InitFromResource(IDirect3DRMTexture2 *iface, HRSRC resource)
786 FIXME("iface %p, resource %p stub!\n", iface, resource);
788 return E_NOTIMPL;
791 static HRESULT WINAPI d3drm_texture2_Changed(IDirect3DRMTexture2 *iface, BOOL pixels, BOOL palette)
793 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface, pixels, palette);
795 return E_NOTIMPL;
798 static HRESULT WINAPI d3drm_texture2_SetColors(IDirect3DRMTexture2 *iface, DWORD max_colors)
800 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
802 TRACE("iface %p, max_colors %u.\n", iface, max_colors);
804 return IDirect3DRMTexture3_SetColors(&texture->IDirect3DRMTexture3_iface, max_colors);
807 static HRESULT WINAPI d3drm_texture2_SetShades(IDirect3DRMTexture2 *iface, DWORD max_shades)
809 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
811 TRACE("iface %p, max_shades %u.\n", iface, max_shades);
813 return IDirect3DRMTexture3_SetShades(&texture->IDirect3DRMTexture3_iface, max_shades);
816 static HRESULT WINAPI d3drm_texture2_SetDecalSize(IDirect3DRMTexture2 *iface, D3DVALUE width, D3DVALUE height)
818 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
820 TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
822 return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
825 static HRESULT WINAPI d3drm_texture2_SetDecalOrigin(IDirect3DRMTexture2 *iface, LONG x, LONG y)
827 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
829 TRACE("iface %p, x %d, y %d.\n", iface, x, y);
831 return IDirect3DRMTexture3_SetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
834 static HRESULT WINAPI d3drm_texture2_SetDecalScale(IDirect3DRMTexture2 *iface, DWORD scale)
836 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
838 TRACE("iface %p, scale %u.\n", iface, scale);
840 return IDirect3DRMTexture3_SetDecalScale(&texture->IDirect3DRMTexture3_iface, scale);
843 static HRESULT WINAPI d3drm_texture2_SetDecalTransparency(IDirect3DRMTexture2 *iface, BOOL transparency)
845 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
847 TRACE("iface %p, transparency %#x.\n", iface, transparency);
849 return IDirect3DRMTexture3_SetDecalTransparency(&texture->IDirect3DRMTexture3_iface, transparency);
852 static HRESULT WINAPI d3drm_texture2_SetDecalTransparentColor(IDirect3DRMTexture2 *iface, D3DCOLOR color)
854 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
856 TRACE("iface %p, color 0x%08x.\n", iface, color);
858 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface, color);
861 static HRESULT WINAPI d3drm_texture2_GetDecalSize(IDirect3DRMTexture2 *iface, D3DVALUE *width, D3DVALUE *height)
863 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
865 TRACE("iface %p, width %p, height %p.\n", iface, width, height);
867 return IDirect3DRMTexture3_GetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
870 static HRESULT WINAPI d3drm_texture2_GetDecalOrigin(IDirect3DRMTexture2 *iface, LONG *x, LONG *y)
872 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
874 TRACE("iface %p, x %p, y %p.\n", iface, x, y);
876 return IDirect3DRMTexture3_GetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
879 static D3DRMIMAGE * WINAPI d3drm_texture2_GetImage(IDirect3DRMTexture2 *iface)
881 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
883 TRACE("iface %p.\n", iface);
885 return IDirect3DRMTexture3_GetImage(&texture->IDirect3DRMTexture3_iface);
888 static DWORD WINAPI d3drm_texture2_GetShades(IDirect3DRMTexture2 *iface)
890 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
892 TRACE("iface %p.\n", iface);
894 return IDirect3DRMTexture3_GetShades(&texture->IDirect3DRMTexture3_iface);
897 static DWORD WINAPI d3drm_texture2_GetColors(IDirect3DRMTexture2 *iface)
899 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
901 TRACE("iface %p.\n", iface);
903 return IDirect3DRMTexture3_GetColors(&texture->IDirect3DRMTexture3_iface);
906 static DWORD WINAPI d3drm_texture2_GetDecalScale(IDirect3DRMTexture2 *iface)
908 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
910 TRACE("iface %p.\n", iface);
912 return IDirect3DRMTexture3_GetDecalScale(&texture->IDirect3DRMTexture3_iface);
915 static BOOL WINAPI d3drm_texture2_GetDecalTransparency(IDirect3DRMTexture2 *iface)
917 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
919 TRACE("iface %p.\n", iface);
921 return IDirect3DRMTexture3_GetDecalTransparency(&texture->IDirect3DRMTexture3_iface);
924 static D3DCOLOR WINAPI d3drm_texture2_GetDecalTransparentColor(IDirect3DRMTexture2 *iface)
926 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
928 TRACE("iface %p.\n", iface);
930 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface);
933 static HRESULT WINAPI d3drm_texture2_InitFromImage(IDirect3DRMTexture2 *iface, D3DRMIMAGE *image)
935 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
937 TRACE("iface %p, image %p.\n", iface, image);
939 return IDirect3DRMTexture3_InitFromImage(&texture->IDirect3DRMTexture3_iface, image);
942 static HRESULT WINAPI d3drm_texture2_InitFromResource2(IDirect3DRMTexture2 *iface,
943 HMODULE module, const char *name, const char *type)
945 FIXME("iface %p, module %p, name %s, type %s stub!\n",
946 iface, module, debugstr_a(name), debugstr_a(type));
948 return E_NOTIMPL;
951 static HRESULT WINAPI d3drm_texture2_GenerateMIPMap(IDirect3DRMTexture2 *iface, DWORD flags)
953 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
955 TRACE("iface %p, flags %#x.\n", iface, flags);
957 return IDirect3DRMTexture3_GenerateMIPMap(&texture->IDirect3DRMTexture3_iface, flags);
960 static const struct IDirect3DRMTexture2Vtbl d3drm_texture2_vtbl =
962 d3drm_texture2_QueryInterface,
963 d3drm_texture2_AddRef,
964 d3drm_texture2_Release,
965 d3drm_texture2_Clone,
966 d3drm_texture2_AddDestroyCallback,
967 d3drm_texture2_DeleteDestroyCallback,
968 d3drm_texture2_SetAppData,
969 d3drm_texture2_GetAppData,
970 d3drm_texture2_SetName,
971 d3drm_texture2_GetName,
972 d3drm_texture2_GetClassName,
973 d3drm_texture2_InitFromFile,
974 d3drm_texture2_InitFromSurface,
975 d3drm_texture2_InitFromResource,
976 d3drm_texture2_Changed,
977 d3drm_texture2_SetColors,
978 d3drm_texture2_SetShades,
979 d3drm_texture2_SetDecalSize,
980 d3drm_texture2_SetDecalOrigin,
981 d3drm_texture2_SetDecalScale,
982 d3drm_texture2_SetDecalTransparency,
983 d3drm_texture2_SetDecalTransparentColor,
984 d3drm_texture2_GetDecalSize,
985 d3drm_texture2_GetDecalOrigin,
986 d3drm_texture2_GetImage,
987 d3drm_texture2_GetShades,
988 d3drm_texture2_GetColors,
989 d3drm_texture2_GetDecalScale,
990 d3drm_texture2_GetDecalTransparency,
991 d3drm_texture2_GetDecalTransparentColor,
992 d3drm_texture2_InitFromImage,
993 d3drm_texture2_InitFromResource2,
994 d3drm_texture2_GenerateMIPMap,
997 static HRESULT WINAPI d3drm_texture3_QueryInterface(IDirect3DRMTexture3 *iface, REFIID riid, void **out)
999 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1001 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
1003 if (IsEqualGUID(riid, &IID_IDirect3DRMTexture)
1004 || IsEqualGUID(riid, &IID_IDirect3DRMVisual)
1005 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
1006 || IsEqualGUID(riid, &IID_IUnknown))
1008 *out = &texture->IDirect3DRMTexture_iface;
1010 else if (IsEqualGUID(riid, &IID_IDirect3DRMTexture2))
1012 *out = &texture->IDirect3DRMTexture2_iface;
1014 else if (IsEqualGUID(riid, &IID_IDirect3DRMTexture3))
1016 *out = &texture->IDirect3DRMTexture3_iface;
1018 else
1020 *out = NULL;
1021 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
1022 return CLASS_E_CLASSNOTAVAILABLE;
1025 IUnknown_AddRef((IUnknown *)*out);
1026 return S_OK;
1029 static ULONG WINAPI d3drm_texture3_AddRef(IDirect3DRMTexture3 *iface)
1031 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1032 ULONG refcount = InterlockedIncrement(&texture->obj.ref);
1034 TRACE("%p increasing refcount to %u.\n", iface, refcount);
1036 return refcount;
1039 static ULONG WINAPI d3drm_texture3_Release(IDirect3DRMTexture3 *iface)
1041 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1042 ULONG refcount = InterlockedDecrement(&texture->obj.ref);
1044 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
1046 if (!refcount)
1047 d3drm_texture_destroy(texture);
1049 return refcount;
1052 static HRESULT WINAPI d3drm_texture3_Clone(IDirect3DRMTexture3 *iface,
1053 IUnknown *outer, REFIID iid, void **out)
1055 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
1057 return E_NOTIMPL;
1060 static HRESULT WINAPI d3drm_texture3_AddDestroyCallback(IDirect3DRMTexture3 *iface,
1061 D3DRMOBJECTCALLBACK cb, void *ctx)
1063 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1065 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
1067 return d3drm_object_add_destroy_callback(&texture->obj, cb, ctx);
1070 static HRESULT WINAPI d3drm_texture3_DeleteDestroyCallback(IDirect3DRMTexture3 *iface,
1071 D3DRMOBJECTCALLBACK cb, void *ctx)
1073 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1075 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
1077 return d3drm_object_delete_destroy_callback(&texture->obj, cb, ctx);
1080 static HRESULT WINAPI d3drm_texture3_SetAppData(IDirect3DRMTexture3 *iface, DWORD data)
1082 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1084 TRACE("iface %p, data %#x.\n", iface, data);
1086 texture->obj.appdata = data;
1088 return D3DRM_OK;
1091 static DWORD WINAPI d3drm_texture3_GetAppData(IDirect3DRMTexture3 *iface)
1093 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1095 TRACE("iface %p.\n", iface);
1097 return texture->obj.appdata;
1100 static HRESULT WINAPI d3drm_texture3_SetName(IDirect3DRMTexture3 *iface, const char *name)
1102 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1104 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1106 return d3drm_object_set_name(&texture->obj, name);
1109 static HRESULT WINAPI d3drm_texture3_GetName(IDirect3DRMTexture3 *iface, DWORD *size, char *name)
1111 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1113 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1115 return d3drm_object_get_name(&texture->obj, size, name);
1118 static HRESULT WINAPI d3drm_texture3_GetClassName(IDirect3DRMTexture3 *iface, DWORD *size, char *name)
1120 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1122 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1124 return d3drm_object_get_class_name(&texture->obj, size, name);
1127 static HRESULT WINAPI d3drm_texture3_InitFromFile(IDirect3DRMTexture3 *iface, const char *filename)
1129 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1130 D3DRMIMAGE *image;
1131 HRESULT hr;
1133 TRACE("iface %p, filename %s.\n", iface, debugstr_a(filename));
1135 if (FAILED(hr = d3drm_texture_load(texture, filename, TRUE, &image)))
1136 return hr;
1138 return IDirect3DRMTexture3_InitFromImage(iface, image);
1141 static HRESULT WINAPI d3drm_texture3_InitFromSurface(IDirect3DRMTexture3 *iface,
1142 IDirectDrawSurface *surface)
1144 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1146 TRACE("iface %p, surface %p.\n", iface, surface);
1148 if (!surface)
1149 return D3DRMERR_BADOBJECT;
1151 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1152 IDirect3DRM_AddRef(texture->d3drm);
1154 if (texture->image || texture->surface)
1155 return D3DRMERR_BADOBJECT;
1157 texture->surface = surface;
1158 IDirectDrawSurface_AddRef(texture->surface);
1159 return D3DRM_OK;
1162 static HRESULT WINAPI d3drm_texture3_InitFromResource(IDirect3DRMTexture3 *iface, HRSRC resource)
1164 FIXME("iface %p, resource %p stub!\n", iface, resource);
1166 return E_NOTIMPL;
1169 static HRESULT WINAPI d3drm_texture3_Changed(IDirect3DRMTexture3 *iface,
1170 DWORD flags, DWORD rect_count, RECT *rects)
1172 FIXME("iface %p, flags %#x, rect_count %u, rects %p stub!\n", iface, flags, rect_count, rects);
1174 return E_NOTIMPL;
1177 static HRESULT WINAPI d3drm_texture3_SetColors(IDirect3DRMTexture3 *iface, DWORD max_colors)
1179 FIXME("iface %p, max_colors %u stub!\n", iface, max_colors);
1181 return E_NOTIMPL;
1184 static HRESULT WINAPI d3drm_texture3_SetShades(IDirect3DRMTexture3 *iface, DWORD max_shades)
1186 FIXME("iface %p, max_shades %u stub!\n", iface, max_shades);
1188 return E_NOTIMPL;
1191 static HRESULT WINAPI d3drm_texture3_SetDecalSize(IDirect3DRMTexture3 *iface, D3DVALUE width, D3DVALUE height)
1193 FIXME("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
1195 return E_NOTIMPL;
1198 static HRESULT WINAPI d3drm_texture3_SetDecalOrigin(IDirect3DRMTexture3 *iface, LONG x, LONG y)
1200 FIXME("iface %p, x %d, y %d stub!\n", iface, x, y);
1202 return E_NOTIMPL;
1205 static HRESULT WINAPI d3drm_texture3_SetDecalScale(IDirect3DRMTexture3 *iface, DWORD scale)
1207 FIXME("iface %p, scale %u stub!\n", iface, scale);
1209 return E_NOTIMPL;
1212 static HRESULT WINAPI d3drm_texture3_SetDecalTransparency(IDirect3DRMTexture3 *iface, BOOL transparency)
1214 FIXME("iface %p, transparency %#x stub!\n", iface, transparency);
1216 return E_NOTIMPL;
1219 static HRESULT WINAPI d3drm_texture3_SetDecalTransparentColor(IDirect3DRMTexture3 *iface, D3DCOLOR color)
1221 FIXME("iface %p, color 0x%08x stub!\n", iface, color);
1223 return E_NOTIMPL;
1226 static HRESULT WINAPI d3drm_texture3_GetDecalSize(IDirect3DRMTexture3 *iface, D3DVALUE *width, D3DVALUE *height)
1228 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1230 return E_NOTIMPL;
1233 static HRESULT WINAPI d3drm_texture3_GetDecalOrigin(IDirect3DRMTexture3 *iface, LONG *x, LONG *y)
1235 FIXME("iface %p, x %p, y %p stub!\n", iface, x, y);
1237 return E_NOTIMPL;
1240 static D3DRMIMAGE * WINAPI d3drm_texture3_GetImage(IDirect3DRMTexture3 *iface)
1242 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1244 TRACE("iface %p.\n", iface);
1246 return texture->image;
1249 static DWORD WINAPI d3drm_texture3_GetShades(IDirect3DRMTexture3 *iface)
1251 FIXME("iface %p stub!\n", iface);
1253 return 0;
1256 static DWORD WINAPI d3drm_texture3_GetColors(IDirect3DRMTexture3 *iface)
1258 FIXME("iface %p stub!\n", iface);
1260 return 0;
1263 static DWORD WINAPI d3drm_texture3_GetDecalScale(IDirect3DRMTexture3 *iface)
1265 FIXME("iface %p stub!\n", iface);
1267 return 0;
1270 static BOOL WINAPI d3drm_texture3_GetDecalTransparency(IDirect3DRMTexture3 *iface)
1272 FIXME("iface %p stub!\n", iface);
1274 return FALSE;
1277 static D3DCOLOR WINAPI d3drm_texture3_GetDecalTransparentColor(IDirect3DRMTexture3 *iface)
1279 FIXME("iface %p stub!\n", iface);
1281 return 0;
1284 static HRESULT WINAPI d3drm_texture3_InitFromImage(IDirect3DRMTexture3 *iface, D3DRMIMAGE *image)
1286 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1288 TRACE("iface %p, image %p.\n", iface, image);
1290 if (!d3drm_validate_image(image))
1291 return D3DRMERR_BADOBJECT;
1293 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1294 IDirect3DRM_AddRef(texture->d3drm);
1296 if (texture->image || texture->surface)
1297 return D3DRMERR_BADOBJECT;
1299 texture->image = image;
1301 return D3DRM_OK;
1304 static HRESULT WINAPI d3drm_texture3_InitFromResource2(IDirect3DRMTexture3 *iface,
1305 HMODULE module, const char *name, const char *type)
1307 FIXME("iface %p, module %p, name %s, type %s stub!\n",
1308 iface, module, debugstr_a(name), debugstr_a(type));
1310 return E_NOTIMPL;
1313 static HRESULT WINAPI d3drm_texture3_GenerateMIPMap(IDirect3DRMTexture3 *iface, DWORD flags)
1315 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1317 return E_NOTIMPL;
1320 static HRESULT WINAPI d3drm_texture3_GetSurface(IDirect3DRMTexture3 *iface,
1321 DWORD flags, IDirectDrawSurface **surface)
1323 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1325 TRACE("iface %p, flags %#x, surface %p.\n", iface, flags, surface);
1327 if (flags)
1328 FIXME("unexpected flags %#x.\n", flags);
1330 if (!surface)
1331 return D3DRMERR_BADVALUE;
1333 if (texture->image)
1334 return D3DRMERR_NOTCREATEDFROMDDS;
1336 *surface = texture->surface;
1337 IDirectDrawSurface_AddRef(*surface);
1339 return D3DRM_OK;
1342 static HRESULT WINAPI d3drm_texture3_SetCacheOptions(IDirect3DRMTexture3 *iface, LONG importance, DWORD flags)
1344 FIXME("iface %p, importance %d, flags %#x stub!\n", iface, importance, flags);
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI d3drm_texture3_GetCacheOptions(IDirect3DRMTexture3 *iface,
1350 LONG *importance, DWORD *flags)
1352 FIXME("iface %p, importance %p, flags %p stub!\n", iface, importance, flags);
1354 return E_NOTIMPL;
1357 static HRESULT WINAPI d3drm_texture3_SetDownsampleCallback(IDirect3DRMTexture3 *iface,
1358 D3DRMDOWNSAMPLECALLBACK cb, void *ctx)
1360 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1362 return E_NOTIMPL;
1365 static HRESULT WINAPI d3drm_texture3_SetValidationCallback(IDirect3DRMTexture3 *iface,
1366 D3DRMVALIDATIONCALLBACK cb, void *ctx)
1368 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1370 return E_NOTIMPL;
1373 static const struct IDirect3DRMTexture3Vtbl d3drm_texture3_vtbl =
1375 d3drm_texture3_QueryInterface,
1376 d3drm_texture3_AddRef,
1377 d3drm_texture3_Release,
1378 d3drm_texture3_Clone,
1379 d3drm_texture3_AddDestroyCallback,
1380 d3drm_texture3_DeleteDestroyCallback,
1381 d3drm_texture3_SetAppData,
1382 d3drm_texture3_GetAppData,
1383 d3drm_texture3_SetName,
1384 d3drm_texture3_GetName,
1385 d3drm_texture3_GetClassName,
1386 d3drm_texture3_InitFromFile,
1387 d3drm_texture3_InitFromSurface,
1388 d3drm_texture3_InitFromResource,
1389 d3drm_texture3_Changed,
1390 d3drm_texture3_SetColors,
1391 d3drm_texture3_SetShades,
1392 d3drm_texture3_SetDecalSize,
1393 d3drm_texture3_SetDecalOrigin,
1394 d3drm_texture3_SetDecalScale,
1395 d3drm_texture3_SetDecalTransparency,
1396 d3drm_texture3_SetDecalTransparentColor,
1397 d3drm_texture3_GetDecalSize,
1398 d3drm_texture3_GetDecalOrigin,
1399 d3drm_texture3_GetImage,
1400 d3drm_texture3_GetShades,
1401 d3drm_texture3_GetColors,
1402 d3drm_texture3_GetDecalScale,
1403 d3drm_texture3_GetDecalTransparency,
1404 d3drm_texture3_GetDecalTransparentColor,
1405 d3drm_texture3_InitFromImage,
1406 d3drm_texture3_InitFromResource2,
1407 d3drm_texture3_GenerateMIPMap,
1408 d3drm_texture3_GetSurface,
1409 d3drm_texture3_SetCacheOptions,
1410 d3drm_texture3_GetCacheOptions,
1411 d3drm_texture3_SetDownsampleCallback,
1412 d3drm_texture3_SetValidationCallback,
1415 HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm)
1417 static const char classname[] = "Texture";
1418 struct d3drm_texture *object;
1420 TRACE("texture %p.\n", texture);
1422 if (!(object = heap_alloc_zero(sizeof(*object))))
1423 return E_OUTOFMEMORY;
1425 object->IDirect3DRMTexture_iface.lpVtbl = &d3drm_texture1_vtbl;
1426 object->IDirect3DRMTexture2_iface.lpVtbl = &d3drm_texture2_vtbl;
1427 object->IDirect3DRMTexture3_iface.lpVtbl = &d3drm_texture3_vtbl;
1428 object->d3drm = d3drm;
1430 d3drm_object_init(&object->obj, classname);
1432 *texture = object;
1434 return D3DRM_OK;