wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / d3drm / texture.c
blob07f0896a30b10c549f324b599d768c6ef64c2f13
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 "d3drm_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
26 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture(IDirect3DRMTexture *iface)
28 return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture_iface);
31 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture2(IDirect3DRMTexture2 *iface)
33 return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture2_iface);
36 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture3(IDirect3DRMTexture3 *iface)
38 return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture3_iface);
41 static void d3drm_texture_destroy(struct d3drm_texture *texture)
43 TRACE("texture %p is being destroyed.\n", texture);
45 d3drm_object_cleanup((IDirect3DRMObject*)&texture->IDirect3DRMTexture_iface, &texture->obj);
46 if (texture->image || texture->surface)
47 IDirect3DRM_Release(texture->d3drm);
48 if (texture->surface)
49 IDirectDrawSurface_Release(texture->surface);
50 heap_free(texture);
53 static BOOL d3drm_validate_image(D3DRMIMAGE *image)
55 if (!image
56 || !image->red_mask
57 || !image->green_mask
58 || !image->blue_mask
59 || !image->buffer1
60 || !(image->rgb || (image->palette && image->palette_size)))
62 return FALSE;
65 return TRUE;
68 static BOOL d3drm_image_palettise(D3DRMIMAGE *image, unsigned char *src_data,
69 SIZE_T w, SIZE_T h, BOOL flip)
71 unsigned char *dst_data, *src_ptr, *dst_ptr;
72 SIZE_T src_pitch, dst_pitch, i, x, y;
73 D3DRMPALETTEENTRY *palette, *entry;
74 unsigned int colour_count = 0;
76 if (w > (~(SIZE_T)0 - 3) / h)
77 return FALSE;
79 src_pitch = flip ? -w * 3 : w * 3;
80 dst_pitch = (w + 3) & ~3;
82 if (!(dst_data = heap_alloc(dst_pitch * h)))
84 WARN("Failed to allocate image buffer.\n");
85 return FALSE;
87 memset(dst_data, 0xff, dst_pitch * h);
89 if (!(palette = heap_alloc(256 * sizeof(*palette))))
91 WARN("Failed to allocate palette.\n");
92 heap_free(dst_data);
93 return FALSE;
96 src_ptr = flip ? &src_data[(h - 1) * w * 3] : src_data;
97 dst_ptr = dst_data;
99 for (y = 0; y < h; ++y)
101 for (x = 0; x < w; ++x)
103 for (i = 0; i < colour_count; ++i)
105 entry = &palette[i];
106 if (entry->red == src_ptr[x * 3 + 0]
107 && entry->green == src_ptr[x * 3 + 1]
108 && entry->blue == src_ptr[x * 3 + 2])
109 break;
112 if (i == colour_count)
114 if (colour_count == 256)
116 heap_free(dst_data);
117 heap_free(palette);
118 return FALSE;
121 entry = &palette[colour_count++];
122 entry->red = src_ptr[x * 3 + 0];
123 entry->green = src_ptr[x * 3 + 1];
124 entry->blue = src_ptr[x * 3 + 2];
125 entry->flags = D3DRMPALETTE_READONLY;
128 dst_ptr[x] = i;
131 src_ptr += src_pitch;
132 dst_ptr += dst_pitch;
135 image->depth = 8;
136 image->rgb = 0;
137 image->bytes_per_line = dst_pitch;
138 image->buffer1 = dst_data;
139 image->red_mask = 0xff;
140 image->green_mask = 0xff;
141 image->blue_mask = 0xff;
142 image->palette_size = colour_count;
143 if (!(image->palette = heap_realloc(palette, colour_count * sizeof(*palette))))
144 image->palette = palette;
146 return TRUE;
149 static HRESULT d3drm_image_load_32(D3DRMIMAGE *image, unsigned char *src_data,
150 LONGLONG src_data_size, SIZE_T w, SIZE_T h, BOOL flip)
152 unsigned char *dst_data, *src_ptr, *dst_ptr;
153 SIZE_T src_pitch, dst_pitch, x, y;
155 if (d3drm_image_palettise(image, src_data, w, h, flip))
156 return D3DRM_OK;
158 if (w > (~(SIZE_T)0 / 4) / h)
159 return D3DRMERR_BADALLOC;
161 src_pitch = flip ? -w * 3 : w * 3;
162 dst_pitch = w * 4;
164 if (!(dst_data = heap_alloc(dst_pitch * h)))
166 WARN("Failed to allocate image buffer.\n");
167 return D3DRMERR_BADALLOC;
170 src_ptr = flip ? &src_data[(h - 1) * w * 3] : src_data;
171 dst_ptr = dst_data;
173 for (y = 0; y < h; ++y)
175 for (x = 0; x < w; ++x)
177 dst_ptr[x * 4 + 0] = src_ptr[x * 3 + 0];
178 dst_ptr[x * 4 + 1] = src_ptr[x * 3 + 1];
179 dst_ptr[x * 4 + 2] = src_ptr[x * 3 + 2];
180 dst_ptr[x * 4 + 3] = 0xff;
183 src_ptr += src_pitch;
184 dst_ptr += dst_pitch;
187 image->depth = 32;
188 image->rgb = 1;
189 image->bytes_per_line = dst_pitch;
190 image->buffer1 = dst_data;
191 image->red_mask = 0xff0000;
192 image->green_mask = 0x00ff00;
193 image->blue_mask = 0x0000ff;
194 image->palette_size = 0;
195 image->palette = NULL;
197 return D3DRM_OK;
200 static HRESULT d3drm_image_load_8(D3DRMIMAGE *image, const RGBQUAD *palette,
201 unsigned char *src_data, LONGLONG src_data_size, SIZE_T w, SIZE_T h, BOOL flip)
203 unsigned char *dst_data;
204 SIZE_T i;
206 if (w > ~(SIZE_T)0 / h)
207 return D3DRMERR_BADALLOC;
209 if (!(dst_data = heap_alloc(w * h)))
211 WARN("Failed to allocate image buffer.\n");
212 return D3DRMERR_BADALLOC;
215 if (!(image->palette = heap_alloc(256 * sizeof(*image->palette))))
217 WARN("Failed to allocate palette.\n");
218 heap_free(dst_data);
219 return D3DRMERR_BADALLOC;
222 memcpy(image->palette, palette, 256 * sizeof(*image->palette));
223 for (i = 0; i < 256; ++i)
225 image->palette[i].flags = D3DRMPALETTE_READONLY;
228 if (flip)
230 for (i = 0; i < h; ++i)
232 memcpy(&dst_data[i * w], &src_data[(h - 1 - i) * w], w);
235 else
237 memcpy(dst_data, src_data, w * h);
240 image->depth = 8;
241 image->rgb = 0;
242 image->bytes_per_line = w;
243 image->buffer1 = dst_data;
244 image->red_mask = 0xff;
245 image->green_mask = 0xff;
246 image->blue_mask = 0xff;
247 image->palette_size = 256;
249 return D3DRM_OK;
252 static void CDECL destroy_image_callback(IDirect3DRMObject *obj, void *arg)
254 D3DRMIMAGE *image = arg;
256 TRACE("texture object %p, image %p.\n", obj, image);
258 heap_free(image->buffer1);
259 heap_free(image);
262 static HRESULT d3drm_texture_load(struct d3drm_texture *texture,
263 const char *path, BOOL flip, D3DRMIMAGE **image_out)
265 BITMAPFILEHEADER *header;
266 unsigned int w, h, bpp;
267 HANDLE file, mapping;
268 LARGE_INTEGER size;
269 D3DRMIMAGE *image;
270 BITMAPINFO *info;
271 LONGLONG rem;
272 HRESULT hr;
274 if ((file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
275 return D3DRMERR_BADOBJECT;
277 mapping = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
278 CloseHandle(file);
279 if (!mapping || mapping == INVALID_HANDLE_VALUE)
280 return D3DRMERR_BADVALUE;
282 if (!GetFileSizeEx(mapping, &size))
284 CloseHandle(mapping);
285 return D3DRMERR_BADVALUE;
287 rem = size.QuadPart;
289 header = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
290 CloseHandle(mapping);
291 if (!header)
292 return D3DRMERR_BADVALUE;
294 hr = D3DRMERR_BADALLOC;
295 if (!(image = heap_alloc_zero(sizeof(*image))))
296 goto fail;
298 hr = D3DRMERR_BADFILE;
299 if (rem < sizeof(*header) || header->bfType != 0x4d42 /* BM */)
300 goto fail;
301 rem -= sizeof(*header);
303 info = (BITMAPINFO *)&header[1];
304 /* Only allow version 1 DIB's (BITMAPINFOHEADER) to be loaded. */
305 if (rem < sizeof(info->bmiHeader) || info->bmiHeader.biSize != sizeof(info->bmiHeader))
306 goto fail;
307 rem -= sizeof(info->bmiHeader);
309 w = info->bmiHeader.biWidth;
310 h = abs(info->bmiHeader.biHeight);
311 bpp = info->bmiHeader.biBitCount == 24 ? 32 : info->bmiHeader.biBitCount;
312 if (bpp != 8 && bpp != 32)
313 goto fail;
315 image->width = w;
316 image->height = h;
317 image->aspectx = 1;
318 image->aspecty = 1;
319 if (bpp == 8)
321 rem -= 256 * sizeof(*info->bmiColors);
322 if (w > rem / h)
323 goto fail;
324 hr = d3drm_image_load_8(image, info->bmiColors, (unsigned char *)&info->bmiColors[256], rem, w, h, flip);
326 else
328 if (w > (rem / 3) / h)
329 goto fail;
330 hr = d3drm_image_load_32(image, (unsigned char *)&info->bmiColors, rem, w, h, flip);
332 if (FAILED(hr))
333 goto fail;
335 /* Use an internal destroy callback to destroy the image struct. */
336 hr = IDirect3DRMObject_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, destroy_image_callback, image);
338 *image_out = image;
340 UnmapViewOfFile(header);
342 return hr;
344 fail:
345 heap_free(image);
346 UnmapViewOfFile(header);
348 return hr;
351 static HRESULT WINAPI d3drm_texture1_QueryInterface(IDirect3DRMTexture *iface, REFIID riid, void **out)
353 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
355 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
357 return IDirect3DRMTexture3_QueryInterface(&texture->IDirect3DRMTexture3_iface, riid, out);
360 static ULONG WINAPI d3drm_texture1_AddRef(IDirect3DRMTexture *iface)
362 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
364 TRACE("iface %p.\n", iface);
366 return IDirect3DRMTexture3_AddRef(&texture->IDirect3DRMTexture3_iface);
369 static ULONG WINAPI d3drm_texture1_Release(IDirect3DRMTexture *iface)
371 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
373 TRACE("iface %p.\n", iface);
375 return IDirect3DRMTexture3_Release(&texture->IDirect3DRMTexture3_iface);
378 static HRESULT WINAPI d3drm_texture1_Clone(IDirect3DRMTexture *iface,
379 IUnknown *outer, REFIID iid, void **out)
381 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
383 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
385 return IDirect3DRMTexture3_Clone(&texture->IDirect3DRMTexture3_iface, outer, iid, out);
388 static HRESULT WINAPI d3drm_texture1_AddDestroyCallback(IDirect3DRMTexture *iface,
389 D3DRMOBJECTCALLBACK cb, void *ctx)
391 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
393 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
395 return IDirect3DRMTexture3_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
398 static HRESULT WINAPI d3drm_texture1_DeleteDestroyCallback(IDirect3DRMTexture *iface,
399 D3DRMOBJECTCALLBACK cb, void *ctx)
401 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
403 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
405 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
408 static HRESULT WINAPI d3drm_texture1_SetAppData(IDirect3DRMTexture *iface, DWORD data)
410 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
412 TRACE("iface %p, data %#x.\n", iface, data);
414 return IDirect3DRMTexture3_SetAppData(&texture->IDirect3DRMTexture3_iface, data);
417 static DWORD WINAPI d3drm_texture1_GetAppData(IDirect3DRMTexture *iface)
419 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
421 TRACE("iface %p.\n", iface);
423 return IDirect3DRMTexture3_GetAppData(&texture->IDirect3DRMTexture3_iface);
426 static HRESULT WINAPI d3drm_texture1_SetName(IDirect3DRMTexture *iface, const char *name)
428 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
430 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
432 return IDirect3DRMTexture3_SetName(&texture->IDirect3DRMTexture3_iface, name);
435 static HRESULT WINAPI d3drm_texture1_GetName(IDirect3DRMTexture *iface, DWORD *size, char *name)
437 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
439 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
441 return IDirect3DRMTexture3_GetName(&texture->IDirect3DRMTexture3_iface, size, name);
444 static HRESULT WINAPI d3drm_texture1_GetClassName(IDirect3DRMTexture *iface, DWORD *size, char *name)
446 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
448 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
450 return IDirect3DRMTexture3_GetClassName(&texture->IDirect3DRMTexture3_iface, size, name);
453 static HRESULT WINAPI d3drm_texture1_InitFromFile(IDirect3DRMTexture *iface, const char *filename)
455 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
456 D3DRMIMAGE *image;
457 HRESULT hr;
459 TRACE("iface %p, filename %s.\n", iface, debugstr_a(filename));
461 if (FAILED(hr = d3drm_texture_load(texture, filename, FALSE, &image)))
462 return hr;
464 return IDirect3DRMTexture3_InitFromImage(&texture->IDirect3DRMTexture3_iface, image);
467 static HRESULT WINAPI d3drm_texture1_InitFromSurface(IDirect3DRMTexture *iface,
468 IDirectDrawSurface *surface)
470 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
472 TRACE("iface %p, surface %p.\n", iface, surface);
474 return IDirect3DRMTexture3_InitFromSurface(&texture->IDirect3DRMTexture3_iface, surface);
477 static HRESULT WINAPI d3drm_texture1_InitFromResource(IDirect3DRMTexture *iface, HRSRC resource)
479 FIXME("iface %p, resource %p stub!\n", iface, resource);
481 return E_NOTIMPL;
484 static HRESULT WINAPI d3drm_texture1_Changed(IDirect3DRMTexture *iface, BOOL pixels, BOOL palette)
486 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface, pixels, palette);
488 return E_NOTIMPL;
491 static HRESULT WINAPI d3drm_texture1_SetColors(IDirect3DRMTexture *iface, DWORD max_colors)
493 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
495 TRACE("iface %p, max_colors %u.\n", iface, max_colors);
497 return IDirect3DRMTexture3_SetColors(&texture->IDirect3DRMTexture3_iface, max_colors);
500 static HRESULT WINAPI d3drm_texture1_SetShades(IDirect3DRMTexture *iface, DWORD max_shades)
502 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
504 TRACE("iface %p, max_shades %u.\n", iface, max_shades);
506 return IDirect3DRMTexture3_SetShades(&texture->IDirect3DRMTexture3_iface, max_shades);
509 static HRESULT WINAPI d3drm_texture1_SetDecalSize(IDirect3DRMTexture *iface, D3DVALUE width, D3DVALUE height)
511 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
513 TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
515 return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
518 static HRESULT WINAPI d3drm_texture1_SetDecalOrigin(IDirect3DRMTexture *iface, LONG x, LONG y)
520 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
522 TRACE("iface %p, x %d, y %d.\n", iface, x, y);
524 return IDirect3DRMTexture3_SetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
527 static HRESULT WINAPI d3drm_texture1_SetDecalScale(IDirect3DRMTexture *iface, DWORD scale)
529 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
531 TRACE("iface %p, scale %u.\n", iface, scale);
533 return IDirect3DRMTexture3_SetDecalScale(&texture->IDirect3DRMTexture3_iface, scale);
536 static HRESULT WINAPI d3drm_texture1_SetDecalTransparency(IDirect3DRMTexture *iface, BOOL transparency)
538 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
540 TRACE("iface %p, transparency %#x.\n", iface, transparency);
542 return IDirect3DRMTexture3_SetDecalTransparency(&texture->IDirect3DRMTexture3_iface, transparency);
545 static HRESULT WINAPI d3drm_texture1_SetDecalTransparentColor(IDirect3DRMTexture *iface, D3DCOLOR color)
547 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
549 TRACE("iface %p, color 0x%08x.\n", iface, color);
551 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface, color);
554 static HRESULT WINAPI d3drm_texture1_GetDecalSize(IDirect3DRMTexture *iface, D3DVALUE *width, D3DVALUE *height)
556 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
558 TRACE("iface %p, width %p, height %p.\n", iface, width, height);
560 return IDirect3DRMTexture3_GetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
563 static HRESULT WINAPI d3drm_texture1_GetDecalOrigin(IDirect3DRMTexture *iface, LONG *x, LONG *y)
565 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
567 TRACE("iface %p, x %p, y %p.\n", iface, x, y);
569 return IDirect3DRMTexture3_GetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
572 static D3DRMIMAGE * WINAPI d3drm_texture1_GetImage(IDirect3DRMTexture *iface)
574 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
576 TRACE("iface %p.\n", iface);
578 return IDirect3DRMTexture3_GetImage(&texture->IDirect3DRMTexture3_iface);
581 static DWORD WINAPI d3drm_texture1_GetShades(IDirect3DRMTexture *iface)
583 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
585 TRACE("iface %p.\n", iface);
587 return IDirect3DRMTexture3_GetShades(&texture->IDirect3DRMTexture3_iface);
590 static DWORD WINAPI d3drm_texture1_GetColors(IDirect3DRMTexture *iface)
592 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
594 TRACE("iface %p.\n", iface);
596 return IDirect3DRMTexture3_GetColors(&texture->IDirect3DRMTexture3_iface);
599 static DWORD WINAPI d3drm_texture1_GetDecalScale(IDirect3DRMTexture *iface)
601 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
603 TRACE("iface %p.\n", iface);
605 return IDirect3DRMTexture3_GetDecalScale(&texture->IDirect3DRMTexture3_iface);
608 static BOOL WINAPI d3drm_texture1_GetDecalTransparency(IDirect3DRMTexture *iface)
610 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
612 TRACE("iface %p.\n", iface);
614 return IDirect3DRMTexture3_GetDecalTransparency(&texture->IDirect3DRMTexture3_iface);
617 static D3DCOLOR WINAPI d3drm_texture1_GetDecalTransparentColor(IDirect3DRMTexture *iface)
619 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
621 TRACE("iface %p.\n", iface);
623 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface);
626 static const struct IDirect3DRMTextureVtbl d3drm_texture1_vtbl =
628 d3drm_texture1_QueryInterface,
629 d3drm_texture1_AddRef,
630 d3drm_texture1_Release,
631 d3drm_texture1_Clone,
632 d3drm_texture1_AddDestroyCallback,
633 d3drm_texture1_DeleteDestroyCallback,
634 d3drm_texture1_SetAppData,
635 d3drm_texture1_GetAppData,
636 d3drm_texture1_SetName,
637 d3drm_texture1_GetName,
638 d3drm_texture1_GetClassName,
639 d3drm_texture1_InitFromFile,
640 d3drm_texture1_InitFromSurface,
641 d3drm_texture1_InitFromResource,
642 d3drm_texture1_Changed,
643 d3drm_texture1_SetColors,
644 d3drm_texture1_SetShades,
645 d3drm_texture1_SetDecalSize,
646 d3drm_texture1_SetDecalOrigin,
647 d3drm_texture1_SetDecalScale,
648 d3drm_texture1_SetDecalTransparency,
649 d3drm_texture1_SetDecalTransparentColor,
650 d3drm_texture1_GetDecalSize,
651 d3drm_texture1_GetDecalOrigin,
652 d3drm_texture1_GetImage,
653 d3drm_texture1_GetShades,
654 d3drm_texture1_GetColors,
655 d3drm_texture1_GetDecalScale,
656 d3drm_texture1_GetDecalTransparency,
657 d3drm_texture1_GetDecalTransparentColor,
660 static HRESULT WINAPI d3drm_texture2_QueryInterface(IDirect3DRMTexture2 *iface, REFIID riid, void **out)
662 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
664 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
666 return IDirect3DRMTexture3_QueryInterface(&texture->IDirect3DRMTexture3_iface, riid, out);
669 static ULONG WINAPI d3drm_texture2_AddRef(IDirect3DRMTexture2 *iface)
671 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
673 TRACE("iface %p.\n", iface);
675 return IDirect3DRMTexture3_AddRef(&texture->IDirect3DRMTexture3_iface);
678 static ULONG WINAPI d3drm_texture2_Release(IDirect3DRMTexture2 *iface)
680 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
682 TRACE("iface %p.\n", iface);
684 return IDirect3DRMTexture3_Release(&texture->IDirect3DRMTexture3_iface);
687 static HRESULT WINAPI d3drm_texture2_Clone(IDirect3DRMTexture2 *iface,
688 IUnknown *outer, REFIID iid, void **out)
690 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
692 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
694 return IDirect3DRMTexture3_Clone(&texture->IDirect3DRMTexture3_iface, outer, iid, out);
697 static HRESULT WINAPI d3drm_texture2_AddDestroyCallback(IDirect3DRMTexture2 *iface,
698 D3DRMOBJECTCALLBACK cb, void *ctx)
700 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
702 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
704 return IDirect3DRMTexture3_AddDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
707 static HRESULT WINAPI d3drm_texture2_DeleteDestroyCallback(IDirect3DRMTexture2 *iface,
708 D3DRMOBJECTCALLBACK cb, void *ctx)
710 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
712 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
714 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture->IDirect3DRMTexture3_iface, cb, ctx);
717 static HRESULT WINAPI d3drm_texture2_SetAppData(IDirect3DRMTexture2 *iface, DWORD data)
719 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
721 TRACE("iface %p, data %#x.\n", iface, data);
723 return IDirect3DRMTexture3_SetAppData(&texture->IDirect3DRMTexture3_iface, data);
726 static DWORD WINAPI d3drm_texture2_GetAppData(IDirect3DRMTexture2 *iface)
728 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
730 TRACE("iface %p.\n", iface);
732 return IDirect3DRMTexture3_GetAppData(&texture->IDirect3DRMTexture3_iface);
735 static HRESULT WINAPI d3drm_texture2_SetName(IDirect3DRMTexture2 *iface, const char *name)
737 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
739 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
741 return IDirect3DRMTexture3_SetName(&texture->IDirect3DRMTexture3_iface, name);
744 static HRESULT WINAPI d3drm_texture2_GetName(IDirect3DRMTexture2 *iface, DWORD *size, char *name)
746 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
748 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
750 return IDirect3DRMTexture3_GetName(&texture->IDirect3DRMTexture3_iface, size, name);
753 static HRESULT WINAPI d3drm_texture2_GetClassName(IDirect3DRMTexture2 *iface, DWORD *size, char *name)
755 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
757 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
759 return IDirect3DRMTexture3_GetClassName(&texture->IDirect3DRMTexture3_iface, size, name);
762 static HRESULT WINAPI d3drm_texture2_InitFromFile(IDirect3DRMTexture2 *iface, const char *filename)
764 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
766 TRACE("iface %p, filename %s.\n", iface, debugstr_a(filename));
768 return IDirect3DRMTexture3_InitFromFile(&texture->IDirect3DRMTexture3_iface, filename);
771 static HRESULT WINAPI d3drm_texture2_InitFromSurface(IDirect3DRMTexture2 *iface,
772 IDirectDrawSurface *surface)
774 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
776 TRACE("iface %p, surface %p.\n", iface, surface);
778 return IDirect3DRMTexture3_InitFromSurface(&texture->IDirect3DRMTexture3_iface, surface);
781 static HRESULT WINAPI d3drm_texture2_InitFromResource(IDirect3DRMTexture2 *iface, HRSRC resource)
783 FIXME("iface %p, resource %p stub!\n", iface, resource);
785 return E_NOTIMPL;
788 static HRESULT WINAPI d3drm_texture2_Changed(IDirect3DRMTexture2 *iface, BOOL pixels, BOOL palette)
790 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface, pixels, palette);
792 return E_NOTIMPL;
795 static HRESULT WINAPI d3drm_texture2_SetColors(IDirect3DRMTexture2 *iface, DWORD max_colors)
797 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
799 TRACE("iface %p, max_colors %u.\n", iface, max_colors);
801 return IDirect3DRMTexture3_SetColors(&texture->IDirect3DRMTexture3_iface, max_colors);
804 static HRESULT WINAPI d3drm_texture2_SetShades(IDirect3DRMTexture2 *iface, DWORD max_shades)
806 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
808 TRACE("iface %p, max_shades %u.\n", iface, max_shades);
810 return IDirect3DRMTexture3_SetShades(&texture->IDirect3DRMTexture3_iface, max_shades);
813 static HRESULT WINAPI d3drm_texture2_SetDecalSize(IDirect3DRMTexture2 *iface, D3DVALUE width, D3DVALUE height)
815 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
817 TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
819 return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
822 static HRESULT WINAPI d3drm_texture2_SetDecalOrigin(IDirect3DRMTexture2 *iface, LONG x, LONG y)
824 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
826 TRACE("iface %p, x %d, y %d.\n", iface, x, y);
828 return IDirect3DRMTexture3_SetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
831 static HRESULT WINAPI d3drm_texture2_SetDecalScale(IDirect3DRMTexture2 *iface, DWORD scale)
833 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
835 TRACE("iface %p, scale %u.\n", iface, scale);
837 return IDirect3DRMTexture3_SetDecalScale(&texture->IDirect3DRMTexture3_iface, scale);
840 static HRESULT WINAPI d3drm_texture2_SetDecalTransparency(IDirect3DRMTexture2 *iface, BOOL transparency)
842 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
844 TRACE("iface %p, transparency %#x.\n", iface, transparency);
846 return IDirect3DRMTexture3_SetDecalTransparency(&texture->IDirect3DRMTexture3_iface, transparency);
849 static HRESULT WINAPI d3drm_texture2_SetDecalTransparentColor(IDirect3DRMTexture2 *iface, D3DCOLOR color)
851 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
853 TRACE("iface %p, color 0x%08x.\n", iface, color);
855 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface, color);
858 static HRESULT WINAPI d3drm_texture2_GetDecalSize(IDirect3DRMTexture2 *iface, D3DVALUE *width, D3DVALUE *height)
860 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
862 TRACE("iface %p, width %p, height %p.\n", iface, width, height);
864 return IDirect3DRMTexture3_GetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
867 static HRESULT WINAPI d3drm_texture2_GetDecalOrigin(IDirect3DRMTexture2 *iface, LONG *x, LONG *y)
869 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
871 TRACE("iface %p, x %p, y %p.\n", iface, x, y);
873 return IDirect3DRMTexture3_GetDecalOrigin(&texture->IDirect3DRMTexture3_iface, x, y);
876 static D3DRMIMAGE * WINAPI d3drm_texture2_GetImage(IDirect3DRMTexture2 *iface)
878 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
880 TRACE("iface %p.\n", iface);
882 return IDirect3DRMTexture3_GetImage(&texture->IDirect3DRMTexture3_iface);
885 static DWORD WINAPI d3drm_texture2_GetShades(IDirect3DRMTexture2 *iface)
887 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
889 TRACE("iface %p.\n", iface);
891 return IDirect3DRMTexture3_GetShades(&texture->IDirect3DRMTexture3_iface);
894 static DWORD WINAPI d3drm_texture2_GetColors(IDirect3DRMTexture2 *iface)
896 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
898 TRACE("iface %p.\n", iface);
900 return IDirect3DRMTexture3_GetColors(&texture->IDirect3DRMTexture3_iface);
903 static DWORD WINAPI d3drm_texture2_GetDecalScale(IDirect3DRMTexture2 *iface)
905 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
907 TRACE("iface %p.\n", iface);
909 return IDirect3DRMTexture3_GetDecalScale(&texture->IDirect3DRMTexture3_iface);
912 static BOOL WINAPI d3drm_texture2_GetDecalTransparency(IDirect3DRMTexture2 *iface)
914 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
916 TRACE("iface %p.\n", iface);
918 return IDirect3DRMTexture3_GetDecalTransparency(&texture->IDirect3DRMTexture3_iface);
921 static D3DCOLOR WINAPI d3drm_texture2_GetDecalTransparentColor(IDirect3DRMTexture2 *iface)
923 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
925 TRACE("iface %p.\n", iface);
927 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture->IDirect3DRMTexture3_iface);
930 static HRESULT WINAPI d3drm_texture2_InitFromImage(IDirect3DRMTexture2 *iface, D3DRMIMAGE *image)
932 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
934 TRACE("iface %p, image %p.\n", iface, image);
936 return IDirect3DRMTexture3_InitFromImage(&texture->IDirect3DRMTexture3_iface, image);
939 static HRESULT WINAPI d3drm_texture2_InitFromResource2(IDirect3DRMTexture2 *iface,
940 HMODULE module, const char *name, const char *type)
942 FIXME("iface %p, module %p, name %s, type %s stub!\n",
943 iface, module, debugstr_a(name), debugstr_a(type));
945 return E_NOTIMPL;
948 static HRESULT WINAPI d3drm_texture2_GenerateMIPMap(IDirect3DRMTexture2 *iface, DWORD flags)
950 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
952 TRACE("iface %p, flags %#x.\n", iface, flags);
954 return IDirect3DRMTexture3_GenerateMIPMap(&texture->IDirect3DRMTexture3_iface, flags);
957 static const struct IDirect3DRMTexture2Vtbl d3drm_texture2_vtbl =
959 d3drm_texture2_QueryInterface,
960 d3drm_texture2_AddRef,
961 d3drm_texture2_Release,
962 d3drm_texture2_Clone,
963 d3drm_texture2_AddDestroyCallback,
964 d3drm_texture2_DeleteDestroyCallback,
965 d3drm_texture2_SetAppData,
966 d3drm_texture2_GetAppData,
967 d3drm_texture2_SetName,
968 d3drm_texture2_GetName,
969 d3drm_texture2_GetClassName,
970 d3drm_texture2_InitFromFile,
971 d3drm_texture2_InitFromSurface,
972 d3drm_texture2_InitFromResource,
973 d3drm_texture2_Changed,
974 d3drm_texture2_SetColors,
975 d3drm_texture2_SetShades,
976 d3drm_texture2_SetDecalSize,
977 d3drm_texture2_SetDecalOrigin,
978 d3drm_texture2_SetDecalScale,
979 d3drm_texture2_SetDecalTransparency,
980 d3drm_texture2_SetDecalTransparentColor,
981 d3drm_texture2_GetDecalSize,
982 d3drm_texture2_GetDecalOrigin,
983 d3drm_texture2_GetImage,
984 d3drm_texture2_GetShades,
985 d3drm_texture2_GetColors,
986 d3drm_texture2_GetDecalScale,
987 d3drm_texture2_GetDecalTransparency,
988 d3drm_texture2_GetDecalTransparentColor,
989 d3drm_texture2_InitFromImage,
990 d3drm_texture2_InitFromResource2,
991 d3drm_texture2_GenerateMIPMap,
994 static HRESULT WINAPI d3drm_texture3_QueryInterface(IDirect3DRMTexture3 *iface, REFIID riid, void **out)
996 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
998 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
1000 if (IsEqualGUID(riid, &IID_IDirect3DRMTexture)
1001 || IsEqualGUID(riid, &IID_IDirect3DRMVisual)
1002 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
1003 || IsEqualGUID(riid, &IID_IUnknown))
1005 *out = &texture->IDirect3DRMTexture_iface;
1007 else if (IsEqualGUID(riid, &IID_IDirect3DRMTexture2))
1009 *out = &texture->IDirect3DRMTexture2_iface;
1011 else if (IsEqualGUID(riid, &IID_IDirect3DRMTexture3))
1013 *out = &texture->IDirect3DRMTexture3_iface;
1015 else
1017 *out = NULL;
1018 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
1019 return CLASS_E_CLASSNOTAVAILABLE;
1022 IUnknown_AddRef((IUnknown *)*out);
1023 return S_OK;
1026 static ULONG WINAPI d3drm_texture3_AddRef(IDirect3DRMTexture3 *iface)
1028 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1029 ULONG refcount = InterlockedIncrement(&texture->obj.ref);
1031 TRACE("%p increasing refcount to %u.\n", iface, refcount);
1033 return refcount;
1036 static ULONG WINAPI d3drm_texture3_Release(IDirect3DRMTexture3 *iface)
1038 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1039 ULONG refcount = InterlockedDecrement(&texture->obj.ref);
1041 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
1043 if (!refcount)
1044 d3drm_texture_destroy(texture);
1046 return refcount;
1049 static HRESULT WINAPI d3drm_texture3_Clone(IDirect3DRMTexture3 *iface,
1050 IUnknown *outer, REFIID iid, void **out)
1052 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
1054 return E_NOTIMPL;
1057 static HRESULT WINAPI d3drm_texture3_AddDestroyCallback(IDirect3DRMTexture3 *iface,
1058 D3DRMOBJECTCALLBACK cb, void *ctx)
1060 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1062 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
1064 return d3drm_object_add_destroy_callback(&texture->obj, cb, ctx);
1067 static HRESULT WINAPI d3drm_texture3_DeleteDestroyCallback(IDirect3DRMTexture3 *iface,
1068 D3DRMOBJECTCALLBACK cb, void *ctx)
1070 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1072 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
1074 return d3drm_object_delete_destroy_callback(&texture->obj, cb, ctx);
1077 static HRESULT WINAPI d3drm_texture3_SetAppData(IDirect3DRMTexture3 *iface, DWORD data)
1079 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1081 TRACE("iface %p, data %#x.\n", iface, data);
1083 texture->obj.appdata = data;
1085 return D3DRM_OK;
1088 static DWORD WINAPI d3drm_texture3_GetAppData(IDirect3DRMTexture3 *iface)
1090 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1092 TRACE("iface %p.\n", iface);
1094 return texture->obj.appdata;
1097 static HRESULT WINAPI d3drm_texture3_SetName(IDirect3DRMTexture3 *iface, const char *name)
1099 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1101 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1103 return d3drm_object_set_name(&texture->obj, name);
1106 static HRESULT WINAPI d3drm_texture3_GetName(IDirect3DRMTexture3 *iface, DWORD *size, char *name)
1108 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1110 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1112 return d3drm_object_get_name(&texture->obj, size, name);
1115 static HRESULT WINAPI d3drm_texture3_GetClassName(IDirect3DRMTexture3 *iface, DWORD *size, char *name)
1117 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1119 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1121 return d3drm_object_get_class_name(&texture->obj, size, name);
1124 static HRESULT WINAPI d3drm_texture3_InitFromFile(IDirect3DRMTexture3 *iface, const char *filename)
1126 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1127 D3DRMIMAGE *image;
1128 HRESULT hr;
1130 TRACE("iface %p, filename %s.\n", iface, debugstr_a(filename));
1132 if (FAILED(hr = d3drm_texture_load(texture, filename, TRUE, &image)))
1133 return hr;
1135 return IDirect3DRMTexture3_InitFromImage(iface, image);
1138 static HRESULT WINAPI d3drm_texture3_InitFromSurface(IDirect3DRMTexture3 *iface,
1139 IDirectDrawSurface *surface)
1141 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1143 TRACE("iface %p, surface %p.\n", iface, surface);
1145 if (!surface)
1146 return D3DRMERR_BADOBJECT;
1148 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1149 IDirect3DRM_AddRef(texture->d3drm);
1151 if (texture->image || texture->surface)
1152 return D3DRMERR_BADOBJECT;
1154 texture->surface = surface;
1155 IDirectDrawSurface_AddRef(texture->surface);
1156 return D3DRM_OK;
1159 static HRESULT WINAPI d3drm_texture3_InitFromResource(IDirect3DRMTexture3 *iface, HRSRC resource)
1161 FIXME("iface %p, resource %p stub!\n", iface, resource);
1163 return E_NOTIMPL;
1166 static HRESULT WINAPI d3drm_texture3_Changed(IDirect3DRMTexture3 *iface,
1167 DWORD flags, DWORD rect_count, RECT *rects)
1169 FIXME("iface %p, flags %#x, rect_count %u, rects %p stub!\n", iface, flags, rect_count, rects);
1171 return E_NOTIMPL;
1174 static HRESULT WINAPI d3drm_texture3_SetColors(IDirect3DRMTexture3 *iface, DWORD max_colors)
1176 FIXME("iface %p, max_colors %u stub!\n", iface, max_colors);
1178 return E_NOTIMPL;
1181 static HRESULT WINAPI d3drm_texture3_SetShades(IDirect3DRMTexture3 *iface, DWORD max_shades)
1183 FIXME("iface %p, max_shades %u stub!\n", iface, max_shades);
1185 return E_NOTIMPL;
1188 static HRESULT WINAPI d3drm_texture3_SetDecalSize(IDirect3DRMTexture3 *iface, D3DVALUE width, D3DVALUE height)
1190 FIXME("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
1192 return E_NOTIMPL;
1195 static HRESULT WINAPI d3drm_texture3_SetDecalOrigin(IDirect3DRMTexture3 *iface, LONG x, LONG y)
1197 FIXME("iface %p, x %d, y %d stub!\n", iface, x, y);
1199 return E_NOTIMPL;
1202 static HRESULT WINAPI d3drm_texture3_SetDecalScale(IDirect3DRMTexture3 *iface, DWORD scale)
1204 FIXME("iface %p, scale %u stub!\n", iface, scale);
1206 return E_NOTIMPL;
1209 static HRESULT WINAPI d3drm_texture3_SetDecalTransparency(IDirect3DRMTexture3 *iface, BOOL transparency)
1211 FIXME("iface %p, transparency %#x stub!\n", iface, transparency);
1213 return E_NOTIMPL;
1216 static HRESULT WINAPI d3drm_texture3_SetDecalTransparentColor(IDirect3DRMTexture3 *iface, D3DCOLOR color)
1218 FIXME("iface %p, color 0x%08x stub!\n", iface, color);
1220 return E_NOTIMPL;
1223 static HRESULT WINAPI d3drm_texture3_GetDecalSize(IDirect3DRMTexture3 *iface, D3DVALUE *width, D3DVALUE *height)
1225 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1227 return E_NOTIMPL;
1230 static HRESULT WINAPI d3drm_texture3_GetDecalOrigin(IDirect3DRMTexture3 *iface, LONG *x, LONG *y)
1232 FIXME("iface %p, x %p, y %p stub!\n", iface, x, y);
1234 return E_NOTIMPL;
1237 static D3DRMIMAGE * WINAPI d3drm_texture3_GetImage(IDirect3DRMTexture3 *iface)
1239 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1241 TRACE("iface %p.\n", iface);
1243 return texture->image;
1246 static DWORD WINAPI d3drm_texture3_GetShades(IDirect3DRMTexture3 *iface)
1248 FIXME("iface %p stub!\n", iface);
1250 return 0;
1253 static DWORD WINAPI d3drm_texture3_GetColors(IDirect3DRMTexture3 *iface)
1255 FIXME("iface %p stub!\n", iface);
1257 return 0;
1260 static DWORD WINAPI d3drm_texture3_GetDecalScale(IDirect3DRMTexture3 *iface)
1262 FIXME("iface %p stub!\n", iface);
1264 return 0;
1267 static BOOL WINAPI d3drm_texture3_GetDecalTransparency(IDirect3DRMTexture3 *iface)
1269 FIXME("iface %p stub!\n", iface);
1271 return FALSE;
1274 static D3DCOLOR WINAPI d3drm_texture3_GetDecalTransparentColor(IDirect3DRMTexture3 *iface)
1276 FIXME("iface %p stub!\n", iface);
1278 return 0;
1281 static HRESULT WINAPI d3drm_texture3_InitFromImage(IDirect3DRMTexture3 *iface, D3DRMIMAGE *image)
1283 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1285 TRACE("iface %p, image %p.\n", iface, image);
1287 if (!d3drm_validate_image(image))
1288 return D3DRMERR_BADOBJECT;
1290 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1291 IDirect3DRM_AddRef(texture->d3drm);
1293 if (texture->image || texture->surface)
1294 return D3DRMERR_BADOBJECT;
1296 texture->image = image;
1298 return D3DRM_OK;
1301 static HRESULT WINAPI d3drm_texture3_InitFromResource2(IDirect3DRMTexture3 *iface,
1302 HMODULE module, const char *name, const char *type)
1304 FIXME("iface %p, module %p, name %s, type %s stub!\n",
1305 iface, module, debugstr_a(name), debugstr_a(type));
1307 return E_NOTIMPL;
1310 static HRESULT WINAPI d3drm_texture3_GenerateMIPMap(IDirect3DRMTexture3 *iface, DWORD flags)
1312 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1314 return E_NOTIMPL;
1317 static HRESULT WINAPI d3drm_texture3_GetSurface(IDirect3DRMTexture3 *iface,
1318 DWORD flags, IDirectDrawSurface **surface)
1320 struct d3drm_texture *texture = impl_from_IDirect3DRMTexture3(iface);
1322 TRACE("iface %p, flags %#x, surface %p.\n", iface, flags, surface);
1324 if (flags)
1325 FIXME("unexpected flags %#x.\n", flags);
1327 if (!surface)
1328 return D3DRMERR_BADVALUE;
1330 if (texture->image)
1331 return D3DRMERR_NOTCREATEDFROMDDS;
1333 *surface = texture->surface;
1334 IDirectDrawSurface_AddRef(*surface);
1336 return D3DRM_OK;
1339 static HRESULT WINAPI d3drm_texture3_SetCacheOptions(IDirect3DRMTexture3 *iface, LONG importance, DWORD flags)
1341 FIXME("iface %p, importance %d, flags %#x stub!\n", iface, importance, flags);
1343 return E_NOTIMPL;
1346 static HRESULT WINAPI d3drm_texture3_GetCacheOptions(IDirect3DRMTexture3 *iface,
1347 LONG *importance, DWORD *flags)
1349 FIXME("iface %p, importance %p, flags %p stub!\n", iface, importance, flags);
1351 return E_NOTIMPL;
1354 static HRESULT WINAPI d3drm_texture3_SetDownsampleCallback(IDirect3DRMTexture3 *iface,
1355 D3DRMDOWNSAMPLECALLBACK cb, void *ctx)
1357 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1359 return E_NOTIMPL;
1362 static HRESULT WINAPI d3drm_texture3_SetValidationCallback(IDirect3DRMTexture3 *iface,
1363 D3DRMVALIDATIONCALLBACK cb, void *ctx)
1365 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1367 return E_NOTIMPL;
1370 static const struct IDirect3DRMTexture3Vtbl d3drm_texture3_vtbl =
1372 d3drm_texture3_QueryInterface,
1373 d3drm_texture3_AddRef,
1374 d3drm_texture3_Release,
1375 d3drm_texture3_Clone,
1376 d3drm_texture3_AddDestroyCallback,
1377 d3drm_texture3_DeleteDestroyCallback,
1378 d3drm_texture3_SetAppData,
1379 d3drm_texture3_GetAppData,
1380 d3drm_texture3_SetName,
1381 d3drm_texture3_GetName,
1382 d3drm_texture3_GetClassName,
1383 d3drm_texture3_InitFromFile,
1384 d3drm_texture3_InitFromSurface,
1385 d3drm_texture3_InitFromResource,
1386 d3drm_texture3_Changed,
1387 d3drm_texture3_SetColors,
1388 d3drm_texture3_SetShades,
1389 d3drm_texture3_SetDecalSize,
1390 d3drm_texture3_SetDecalOrigin,
1391 d3drm_texture3_SetDecalScale,
1392 d3drm_texture3_SetDecalTransparency,
1393 d3drm_texture3_SetDecalTransparentColor,
1394 d3drm_texture3_GetDecalSize,
1395 d3drm_texture3_GetDecalOrigin,
1396 d3drm_texture3_GetImage,
1397 d3drm_texture3_GetShades,
1398 d3drm_texture3_GetColors,
1399 d3drm_texture3_GetDecalScale,
1400 d3drm_texture3_GetDecalTransparency,
1401 d3drm_texture3_GetDecalTransparentColor,
1402 d3drm_texture3_InitFromImage,
1403 d3drm_texture3_InitFromResource2,
1404 d3drm_texture3_GenerateMIPMap,
1405 d3drm_texture3_GetSurface,
1406 d3drm_texture3_SetCacheOptions,
1407 d3drm_texture3_GetCacheOptions,
1408 d3drm_texture3_SetDownsampleCallback,
1409 d3drm_texture3_SetValidationCallback,
1412 HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm)
1414 static const char classname[] = "Texture";
1415 struct d3drm_texture *object;
1417 TRACE("texture %p.\n", texture);
1419 if (!(object = heap_alloc_zero(sizeof(*object))))
1420 return E_OUTOFMEMORY;
1422 object->IDirect3DRMTexture_iface.lpVtbl = &d3drm_texture1_vtbl;
1423 object->IDirect3DRMTexture2_iface.lpVtbl = &d3drm_texture2_vtbl;
1424 object->IDirect3DRMTexture3_iface.lpVtbl = &d3drm_texture3_vtbl;
1425 object->d3drm = d3drm;
1427 d3drm_object_init(&object->obj, classname);
1429 *texture = object;
1431 return D3DRM_OK;