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
);
49 IDirectDrawSurface_Release(texture
->surface
);
53 static BOOL
d3drm_validate_image(D3DRMIMAGE
*image
)
60 || !(image
->rgb
|| (image
->palette
&& image
->palette_size
)))
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
)
79 src_pitch
= flip
? -w
* 3 : w
* 3;
80 dst_pitch
= (w
+ 3) & ~3;
82 if (!(dst_data
= malloc(dst_pitch
* h
)))
84 WARN("Failed to allocate image buffer.\n");
87 memset(dst_data
, 0xff, dst_pitch
* h
);
89 if (!(palette
= malloc(256 * sizeof(*palette
))))
91 WARN("Failed to allocate palette.\n");
96 src_ptr
= flip
? &src_data
[(h
- 1) * w
* 3] : src_data
;
99 for (y
= 0; y
< h
; ++y
)
101 for (x
= 0; x
< w
; ++x
)
103 for (i
= 0; i
< colour_count
; ++i
)
106 if (entry
->red
== src_ptr
[x
* 3 + 2]
107 && entry
->green
== src_ptr
[x
* 3 + 1]
108 && entry
->blue
== src_ptr
[x
* 3 + 0])
112 if (i
== colour_count
)
114 if (colour_count
== 256)
121 entry
= &palette
[colour_count
++];
122 entry
->red
= src_ptr
[x
* 3 + 2];
123 entry
->green
= src_ptr
[x
* 3 + 1];
124 entry
->blue
= src_ptr
[x
* 3 + 0];
125 entry
->flags
= D3DRMPALETTE_READONLY
;
131 src_ptr
+= src_pitch
;
132 dst_ptr
+= dst_pitch
;
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
= realloc(palette
, colour_count
* sizeof(*palette
))))
144 image
->palette
= palette
;
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
))
158 if (w
> (~(SIZE_T
)0 / 4) / h
)
159 return D3DRMERR_BADALLOC
;
161 src_pitch
= flip
? -w
* 3 : w
* 3;
164 if (!(dst_data
= malloc(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
;
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
;
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
;
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
;
206 if (w
> ~(SIZE_T
)0 / h
)
207 return D3DRMERR_BADALLOC
;
209 if (!(dst_data
= malloc(w
* h
)))
211 WARN("Failed to allocate image buffer.\n");
212 return D3DRMERR_BADALLOC
;
215 if (!(image
->palette
= malloc(256 * sizeof(*image
->palette
))))
217 WARN("Failed to allocate palette.\n");
219 return D3DRMERR_BADALLOC
;
222 for (i
= 0; i
< 256; ++i
)
224 image
->palette
[i
].red
= palette
[i
].rgbRed
;
225 image
->palette
[i
].green
= palette
[i
].rgbGreen
;
226 image
->palette
[i
].blue
= palette
[i
].rgbBlue
;
227 image
->palette
[i
].flags
= D3DRMPALETTE_READONLY
;
232 for (i
= 0; i
< h
; ++i
)
234 memcpy(&dst_data
[i
* w
], &src_data
[(h
- 1 - i
) * w
], w
);
239 memcpy(dst_data
, src_data
, w
* h
);
244 image
->bytes_per_line
= w
;
245 image
->buffer1
= dst_data
;
246 image
->red_mask
= 0xff;
247 image
->green_mask
= 0xff;
248 image
->blue_mask
= 0xff;
249 image
->palette_size
= 256;
254 static void CDECL
destroy_image_callback(IDirect3DRMObject
*obj
, void *arg
)
256 D3DRMIMAGE
*image
= arg
;
258 TRACE("texture object %p, image %p.\n", obj
, image
);
260 free(image
->buffer1
);
264 static HRESULT
d3drm_texture_load(struct d3drm_texture
*texture
,
265 const char *path
, BOOL flip
, D3DRMIMAGE
**image_out
)
267 BITMAPFILEHEADER
*header
;
268 unsigned int w
, h
, bpp
;
269 HANDLE file
, mapping
;
276 if ((file
= CreateFileA(path
, GENERIC_READ
, FILE_SHARE_READ
, 0, OPEN_EXISTING
, 0, 0)) == INVALID_HANDLE_VALUE
)
277 return D3DRMERR_BADOBJECT
;
279 mapping
= CreateFileMappingW(file
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
281 if (!mapping
|| mapping
== INVALID_HANDLE_VALUE
)
282 return D3DRMERR_BADVALUE
;
284 if (!GetFileSizeEx(mapping
, &size
))
286 CloseHandle(mapping
);
287 return D3DRMERR_BADVALUE
;
291 header
= MapViewOfFile(mapping
, FILE_MAP_READ
, 0, 0, 0);
292 CloseHandle(mapping
);
294 return D3DRMERR_BADVALUE
;
296 hr
= D3DRMERR_BADALLOC
;
297 if (!(image
= calloc(1, sizeof(*image
))))
300 hr
= D3DRMERR_BADFILE
;
301 if (rem
< sizeof(*header
) || header
->bfType
!= 0x4d42 /* BM */)
303 rem
-= sizeof(*header
);
305 info
= (BITMAPINFO
*)&header
[1];
306 /* Only allow version 1 DIB's (BITMAPINFOHEADER) to be loaded. */
307 if (rem
< sizeof(info
->bmiHeader
) || info
->bmiHeader
.biSize
!= sizeof(info
->bmiHeader
))
309 rem
-= sizeof(info
->bmiHeader
);
311 w
= info
->bmiHeader
.biWidth
;
312 h
= abs(info
->bmiHeader
.biHeight
);
313 bpp
= info
->bmiHeader
.biBitCount
== 24 ? 32 : info
->bmiHeader
.biBitCount
;
314 if (bpp
!= 8 && bpp
!= 32)
323 rem
-= 256 * sizeof(*info
->bmiColors
);
326 hr
= d3drm_image_load_8(image
, info
->bmiColors
, (unsigned char *)&info
->bmiColors
[256], rem
, w
, h
, flip
);
330 if (w
> (rem
/ 3) / h
)
332 hr
= d3drm_image_load_32(image
, (unsigned char *)&info
->bmiColors
, rem
, w
, h
, flip
);
337 /* Use an internal destroy callback to destroy the image struct. */
338 hr
= IDirect3DRMObject_AddDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, destroy_image_callback
, image
);
342 UnmapViewOfFile(header
);
348 UnmapViewOfFile(header
);
353 static HRESULT WINAPI
d3drm_texture1_QueryInterface(IDirect3DRMTexture
*iface
, REFIID riid
, void **out
)
355 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
357 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
359 return IDirect3DRMTexture3_QueryInterface(&texture
->IDirect3DRMTexture3_iface
, riid
, out
);
362 static ULONG WINAPI
d3drm_texture1_AddRef(IDirect3DRMTexture
*iface
)
364 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
366 TRACE("iface %p.\n", iface
);
368 return IDirect3DRMTexture3_AddRef(&texture
->IDirect3DRMTexture3_iface
);
371 static ULONG WINAPI
d3drm_texture1_Release(IDirect3DRMTexture
*iface
)
373 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
375 TRACE("iface %p.\n", iface
);
377 return IDirect3DRMTexture3_Release(&texture
->IDirect3DRMTexture3_iface
);
380 static HRESULT WINAPI
d3drm_texture1_Clone(IDirect3DRMTexture
*iface
,
381 IUnknown
*outer
, REFIID iid
, void **out
)
383 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
385 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
387 return IDirect3DRMTexture3_Clone(&texture
->IDirect3DRMTexture3_iface
, outer
, iid
, out
);
390 static HRESULT WINAPI
d3drm_texture1_AddDestroyCallback(IDirect3DRMTexture
*iface
,
391 D3DRMOBJECTCALLBACK cb
, void *ctx
)
393 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
395 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
397 return IDirect3DRMTexture3_AddDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
400 static HRESULT WINAPI
d3drm_texture1_DeleteDestroyCallback(IDirect3DRMTexture
*iface
,
401 D3DRMOBJECTCALLBACK cb
, void *ctx
)
403 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
405 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
407 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
410 static HRESULT WINAPI
d3drm_texture1_SetAppData(IDirect3DRMTexture
*iface
, DWORD data
)
412 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
414 TRACE("iface %p, data %#lx.\n", iface
, data
);
416 return IDirect3DRMTexture3_SetAppData(&texture
->IDirect3DRMTexture3_iface
, data
);
419 static DWORD WINAPI
d3drm_texture1_GetAppData(IDirect3DRMTexture
*iface
)
421 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
423 TRACE("iface %p.\n", iface
);
425 return IDirect3DRMTexture3_GetAppData(&texture
->IDirect3DRMTexture3_iface
);
428 static HRESULT WINAPI
d3drm_texture1_SetName(IDirect3DRMTexture
*iface
, const char *name
)
430 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
432 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
434 return IDirect3DRMTexture3_SetName(&texture
->IDirect3DRMTexture3_iface
, name
);
437 static HRESULT WINAPI
d3drm_texture1_GetName(IDirect3DRMTexture
*iface
, DWORD
*size
, char *name
)
439 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
441 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
443 return IDirect3DRMTexture3_GetName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
446 static HRESULT WINAPI
d3drm_texture1_GetClassName(IDirect3DRMTexture
*iface
, DWORD
*size
, char *name
)
448 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
450 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
452 return IDirect3DRMTexture3_GetClassName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
455 static HRESULT WINAPI
d3drm_texture1_InitFromFile(IDirect3DRMTexture
*iface
, const char *filename
)
457 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
461 TRACE("iface %p, filename %s.\n", iface
, debugstr_a(filename
));
463 if (FAILED(hr
= d3drm_texture_load(texture
, filename
, FALSE
, &image
)))
466 return IDirect3DRMTexture3_InitFromImage(&texture
->IDirect3DRMTexture3_iface
, image
);
469 static HRESULT WINAPI
d3drm_texture1_InitFromSurface(IDirect3DRMTexture
*iface
,
470 IDirectDrawSurface
*surface
)
472 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
474 TRACE("iface %p, surface %p.\n", iface
, surface
);
476 return IDirect3DRMTexture3_InitFromSurface(&texture
->IDirect3DRMTexture3_iface
, surface
);
479 static HRESULT WINAPI
d3drm_texture1_InitFromResource(IDirect3DRMTexture
*iface
, HRSRC resource
)
481 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
486 static HRESULT WINAPI
d3drm_texture1_Changed(IDirect3DRMTexture
*iface
, BOOL pixels
, BOOL palette
)
488 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface
, pixels
, palette
);
493 static HRESULT WINAPI
d3drm_texture1_SetColors(IDirect3DRMTexture
*iface
, DWORD max_colors
)
495 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
497 TRACE("iface %p, max_colors %lu.\n", iface
, max_colors
);
499 return IDirect3DRMTexture3_SetColors(&texture
->IDirect3DRMTexture3_iface
, max_colors
);
502 static HRESULT WINAPI
d3drm_texture1_SetShades(IDirect3DRMTexture
*iface
, DWORD max_shades
)
504 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
506 TRACE("iface %p, max_shades %lu.\n", iface
, max_shades
);
508 return IDirect3DRMTexture3_SetShades(&texture
->IDirect3DRMTexture3_iface
, max_shades
);
511 static HRESULT WINAPI
d3drm_texture1_SetDecalSize(IDirect3DRMTexture
*iface
, D3DVALUE width
, D3DVALUE height
)
513 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
515 TRACE("iface %p, width %.8e, height %.8e.\n", iface
, width
, height
);
517 return IDirect3DRMTexture3_SetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
520 static HRESULT WINAPI
d3drm_texture1_SetDecalOrigin(IDirect3DRMTexture
*iface
, LONG x
, LONG y
)
522 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
524 TRACE("iface %p, x %ld, y %ld.\n", iface
, x
, y
);
526 return IDirect3DRMTexture3_SetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
529 static HRESULT WINAPI
d3drm_texture1_SetDecalScale(IDirect3DRMTexture
*iface
, DWORD scale
)
531 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
533 TRACE("iface %p, scale %lu.\n", iface
, scale
);
535 return IDirect3DRMTexture3_SetDecalScale(&texture
->IDirect3DRMTexture3_iface
, scale
);
538 static HRESULT WINAPI
d3drm_texture1_SetDecalTransparency(IDirect3DRMTexture
*iface
, BOOL transparency
)
540 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
542 TRACE("iface %p, transparency %#x.\n", iface
, transparency
);
544 return IDirect3DRMTexture3_SetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
, transparency
);
547 static HRESULT WINAPI
d3drm_texture1_SetDecalTransparentColor(IDirect3DRMTexture
*iface
, D3DCOLOR color
)
549 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
551 TRACE("iface %p, color 0x%08lx.\n", iface
, color
);
553 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
, color
);
556 static HRESULT WINAPI
d3drm_texture1_GetDecalSize(IDirect3DRMTexture
*iface
, D3DVALUE
*width
, D3DVALUE
*height
)
558 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
560 TRACE("iface %p, width %p, height %p.\n", iface
, width
, height
);
562 return IDirect3DRMTexture3_GetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
565 static HRESULT WINAPI
d3drm_texture1_GetDecalOrigin(IDirect3DRMTexture
*iface
, LONG
*x
, LONG
*y
)
567 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
569 TRACE("iface %p, x %p, y %p.\n", iface
, x
, y
);
571 return IDirect3DRMTexture3_GetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
574 static D3DRMIMAGE
* WINAPI
d3drm_texture1_GetImage(IDirect3DRMTexture
*iface
)
576 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
578 TRACE("iface %p.\n", iface
);
580 return IDirect3DRMTexture3_GetImage(&texture
->IDirect3DRMTexture3_iface
);
583 static DWORD WINAPI
d3drm_texture1_GetShades(IDirect3DRMTexture
*iface
)
585 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
587 TRACE("iface %p.\n", iface
);
589 return IDirect3DRMTexture3_GetShades(&texture
->IDirect3DRMTexture3_iface
);
592 static DWORD WINAPI
d3drm_texture1_GetColors(IDirect3DRMTexture
*iface
)
594 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
596 TRACE("iface %p.\n", iface
);
598 return IDirect3DRMTexture3_GetColors(&texture
->IDirect3DRMTexture3_iface
);
601 static DWORD WINAPI
d3drm_texture1_GetDecalScale(IDirect3DRMTexture
*iface
)
603 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
605 TRACE("iface %p.\n", iface
);
607 return IDirect3DRMTexture3_GetDecalScale(&texture
->IDirect3DRMTexture3_iface
);
610 static BOOL WINAPI
d3drm_texture1_GetDecalTransparency(IDirect3DRMTexture
*iface
)
612 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
614 TRACE("iface %p.\n", iface
);
616 return IDirect3DRMTexture3_GetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
);
619 static D3DCOLOR WINAPI
d3drm_texture1_GetDecalTransparentColor(IDirect3DRMTexture
*iface
)
621 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
623 TRACE("iface %p.\n", iface
);
625 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
);
628 static const struct IDirect3DRMTextureVtbl d3drm_texture1_vtbl
=
630 d3drm_texture1_QueryInterface
,
631 d3drm_texture1_AddRef
,
632 d3drm_texture1_Release
,
633 d3drm_texture1_Clone
,
634 d3drm_texture1_AddDestroyCallback
,
635 d3drm_texture1_DeleteDestroyCallback
,
636 d3drm_texture1_SetAppData
,
637 d3drm_texture1_GetAppData
,
638 d3drm_texture1_SetName
,
639 d3drm_texture1_GetName
,
640 d3drm_texture1_GetClassName
,
641 d3drm_texture1_InitFromFile
,
642 d3drm_texture1_InitFromSurface
,
643 d3drm_texture1_InitFromResource
,
644 d3drm_texture1_Changed
,
645 d3drm_texture1_SetColors
,
646 d3drm_texture1_SetShades
,
647 d3drm_texture1_SetDecalSize
,
648 d3drm_texture1_SetDecalOrigin
,
649 d3drm_texture1_SetDecalScale
,
650 d3drm_texture1_SetDecalTransparency
,
651 d3drm_texture1_SetDecalTransparentColor
,
652 d3drm_texture1_GetDecalSize
,
653 d3drm_texture1_GetDecalOrigin
,
654 d3drm_texture1_GetImage
,
655 d3drm_texture1_GetShades
,
656 d3drm_texture1_GetColors
,
657 d3drm_texture1_GetDecalScale
,
658 d3drm_texture1_GetDecalTransparency
,
659 d3drm_texture1_GetDecalTransparentColor
,
662 static HRESULT WINAPI
d3drm_texture2_QueryInterface(IDirect3DRMTexture2
*iface
, REFIID riid
, void **out
)
664 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
666 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
668 return IDirect3DRMTexture3_QueryInterface(&texture
->IDirect3DRMTexture3_iface
, riid
, out
);
671 static ULONG WINAPI
d3drm_texture2_AddRef(IDirect3DRMTexture2
*iface
)
673 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
675 TRACE("iface %p.\n", iface
);
677 return IDirect3DRMTexture3_AddRef(&texture
->IDirect3DRMTexture3_iface
);
680 static ULONG WINAPI
d3drm_texture2_Release(IDirect3DRMTexture2
*iface
)
682 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
684 TRACE("iface %p.\n", iface
);
686 return IDirect3DRMTexture3_Release(&texture
->IDirect3DRMTexture3_iface
);
689 static HRESULT WINAPI
d3drm_texture2_Clone(IDirect3DRMTexture2
*iface
,
690 IUnknown
*outer
, REFIID iid
, void **out
)
692 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
694 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
696 return IDirect3DRMTexture3_Clone(&texture
->IDirect3DRMTexture3_iface
, outer
, iid
, out
);
699 static HRESULT WINAPI
d3drm_texture2_AddDestroyCallback(IDirect3DRMTexture2
*iface
,
700 D3DRMOBJECTCALLBACK cb
, void *ctx
)
702 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
704 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
706 return IDirect3DRMTexture3_AddDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
709 static HRESULT WINAPI
d3drm_texture2_DeleteDestroyCallback(IDirect3DRMTexture2
*iface
,
710 D3DRMOBJECTCALLBACK cb
, void *ctx
)
712 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
714 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
716 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
719 static HRESULT WINAPI
d3drm_texture2_SetAppData(IDirect3DRMTexture2
*iface
, DWORD data
)
721 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
723 TRACE("iface %p, data %#lx.\n", iface
, data
);
725 return IDirect3DRMTexture3_SetAppData(&texture
->IDirect3DRMTexture3_iface
, data
);
728 static DWORD WINAPI
d3drm_texture2_GetAppData(IDirect3DRMTexture2
*iface
)
730 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
732 TRACE("iface %p.\n", iface
);
734 return IDirect3DRMTexture3_GetAppData(&texture
->IDirect3DRMTexture3_iface
);
737 static HRESULT WINAPI
d3drm_texture2_SetName(IDirect3DRMTexture2
*iface
, const char *name
)
739 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
741 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
743 return IDirect3DRMTexture3_SetName(&texture
->IDirect3DRMTexture3_iface
, name
);
746 static HRESULT WINAPI
d3drm_texture2_GetName(IDirect3DRMTexture2
*iface
, DWORD
*size
, char *name
)
748 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
750 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
752 return IDirect3DRMTexture3_GetName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
755 static HRESULT WINAPI
d3drm_texture2_GetClassName(IDirect3DRMTexture2
*iface
, DWORD
*size
, char *name
)
757 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
759 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
761 return IDirect3DRMTexture3_GetClassName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
764 static HRESULT WINAPI
d3drm_texture2_InitFromFile(IDirect3DRMTexture2
*iface
, const char *filename
)
766 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
768 TRACE("iface %p, filename %s.\n", iface
, debugstr_a(filename
));
770 return IDirect3DRMTexture3_InitFromFile(&texture
->IDirect3DRMTexture3_iface
, filename
);
773 static HRESULT WINAPI
d3drm_texture2_InitFromSurface(IDirect3DRMTexture2
*iface
,
774 IDirectDrawSurface
*surface
)
776 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
778 TRACE("iface %p, surface %p.\n", iface
, surface
);
780 return IDirect3DRMTexture3_InitFromSurface(&texture
->IDirect3DRMTexture3_iface
, surface
);
783 static HRESULT WINAPI
d3drm_texture2_InitFromResource(IDirect3DRMTexture2
*iface
, HRSRC resource
)
785 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
790 static HRESULT WINAPI
d3drm_texture2_Changed(IDirect3DRMTexture2
*iface
, BOOL pixels
, BOOL palette
)
792 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface
, pixels
, palette
);
797 static HRESULT WINAPI
d3drm_texture2_SetColors(IDirect3DRMTexture2
*iface
, DWORD max_colors
)
799 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
801 TRACE("iface %p, max_colors %lu.\n", iface
, max_colors
);
803 return IDirect3DRMTexture3_SetColors(&texture
->IDirect3DRMTexture3_iface
, max_colors
);
806 static HRESULT WINAPI
d3drm_texture2_SetShades(IDirect3DRMTexture2
*iface
, DWORD max_shades
)
808 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
810 TRACE("iface %p, max_shades %lu.\n", iface
, max_shades
);
812 return IDirect3DRMTexture3_SetShades(&texture
->IDirect3DRMTexture3_iface
, max_shades
);
815 static HRESULT WINAPI
d3drm_texture2_SetDecalSize(IDirect3DRMTexture2
*iface
, D3DVALUE width
, D3DVALUE height
)
817 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
819 TRACE("iface %p, width %.8e, height %.8e.\n", iface
, width
, height
);
821 return IDirect3DRMTexture3_SetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
824 static HRESULT WINAPI
d3drm_texture2_SetDecalOrigin(IDirect3DRMTexture2
*iface
, LONG x
, LONG y
)
826 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
828 TRACE("iface %p, x %ld, y %ld.\n", iface
, x
, y
);
830 return IDirect3DRMTexture3_SetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
833 static HRESULT WINAPI
d3drm_texture2_SetDecalScale(IDirect3DRMTexture2
*iface
, DWORD scale
)
835 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
837 TRACE("iface %p, scale %lu.\n", iface
, scale
);
839 return IDirect3DRMTexture3_SetDecalScale(&texture
->IDirect3DRMTexture3_iface
, scale
);
842 static HRESULT WINAPI
d3drm_texture2_SetDecalTransparency(IDirect3DRMTexture2
*iface
, BOOL transparency
)
844 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
846 TRACE("iface %p, transparency %#x.\n", iface
, transparency
);
848 return IDirect3DRMTexture3_SetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
, transparency
);
851 static HRESULT WINAPI
d3drm_texture2_SetDecalTransparentColor(IDirect3DRMTexture2
*iface
, D3DCOLOR color
)
853 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
855 TRACE("iface %p, color 0x%08lx.\n", iface
, color
);
857 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
, color
);
860 static HRESULT WINAPI
d3drm_texture2_GetDecalSize(IDirect3DRMTexture2
*iface
, D3DVALUE
*width
, D3DVALUE
*height
)
862 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
864 TRACE("iface %p, width %p, height %p.\n", iface
, width
, height
);
866 return IDirect3DRMTexture3_GetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
869 static HRESULT WINAPI
d3drm_texture2_GetDecalOrigin(IDirect3DRMTexture2
*iface
, LONG
*x
, LONG
*y
)
871 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
873 TRACE("iface %p, x %p, y %p.\n", iface
, x
, y
);
875 return IDirect3DRMTexture3_GetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
878 static D3DRMIMAGE
* WINAPI
d3drm_texture2_GetImage(IDirect3DRMTexture2
*iface
)
880 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
882 TRACE("iface %p.\n", iface
);
884 return IDirect3DRMTexture3_GetImage(&texture
->IDirect3DRMTexture3_iface
);
887 static DWORD WINAPI
d3drm_texture2_GetShades(IDirect3DRMTexture2
*iface
)
889 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
891 TRACE("iface %p.\n", iface
);
893 return IDirect3DRMTexture3_GetShades(&texture
->IDirect3DRMTexture3_iface
);
896 static DWORD WINAPI
d3drm_texture2_GetColors(IDirect3DRMTexture2
*iface
)
898 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
900 TRACE("iface %p.\n", iface
);
902 return IDirect3DRMTexture3_GetColors(&texture
->IDirect3DRMTexture3_iface
);
905 static DWORD WINAPI
d3drm_texture2_GetDecalScale(IDirect3DRMTexture2
*iface
)
907 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
909 TRACE("iface %p.\n", iface
);
911 return IDirect3DRMTexture3_GetDecalScale(&texture
->IDirect3DRMTexture3_iface
);
914 static BOOL WINAPI
d3drm_texture2_GetDecalTransparency(IDirect3DRMTexture2
*iface
)
916 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
918 TRACE("iface %p.\n", iface
);
920 return IDirect3DRMTexture3_GetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
);
923 static D3DCOLOR WINAPI
d3drm_texture2_GetDecalTransparentColor(IDirect3DRMTexture2
*iface
)
925 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
927 TRACE("iface %p.\n", iface
);
929 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
);
932 static HRESULT WINAPI
d3drm_texture2_InitFromImage(IDirect3DRMTexture2
*iface
, D3DRMIMAGE
*image
)
934 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
936 TRACE("iface %p, image %p.\n", iface
, image
);
938 return IDirect3DRMTexture3_InitFromImage(&texture
->IDirect3DRMTexture3_iface
, image
);
941 static HRESULT WINAPI
d3drm_texture2_InitFromResource2(IDirect3DRMTexture2
*iface
,
942 HMODULE module
, const char *name
, const char *type
)
944 FIXME("iface %p, module %p, name %s, type %s stub!\n",
945 iface
, module
, debugstr_a(name
), debugstr_a(type
));
950 static HRESULT WINAPI
d3drm_texture2_GenerateMIPMap(IDirect3DRMTexture2
*iface
, DWORD flags
)
952 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
954 TRACE("iface %p, flags %#lx.\n", iface
, flags
);
956 return IDirect3DRMTexture3_GenerateMIPMap(&texture
->IDirect3DRMTexture3_iface
, flags
);
959 static const struct IDirect3DRMTexture2Vtbl d3drm_texture2_vtbl
=
961 d3drm_texture2_QueryInterface
,
962 d3drm_texture2_AddRef
,
963 d3drm_texture2_Release
,
964 d3drm_texture2_Clone
,
965 d3drm_texture2_AddDestroyCallback
,
966 d3drm_texture2_DeleteDestroyCallback
,
967 d3drm_texture2_SetAppData
,
968 d3drm_texture2_GetAppData
,
969 d3drm_texture2_SetName
,
970 d3drm_texture2_GetName
,
971 d3drm_texture2_GetClassName
,
972 d3drm_texture2_InitFromFile
,
973 d3drm_texture2_InitFromSurface
,
974 d3drm_texture2_InitFromResource
,
975 d3drm_texture2_Changed
,
976 d3drm_texture2_SetColors
,
977 d3drm_texture2_SetShades
,
978 d3drm_texture2_SetDecalSize
,
979 d3drm_texture2_SetDecalOrigin
,
980 d3drm_texture2_SetDecalScale
,
981 d3drm_texture2_SetDecalTransparency
,
982 d3drm_texture2_SetDecalTransparentColor
,
983 d3drm_texture2_GetDecalSize
,
984 d3drm_texture2_GetDecalOrigin
,
985 d3drm_texture2_GetImage
,
986 d3drm_texture2_GetShades
,
987 d3drm_texture2_GetColors
,
988 d3drm_texture2_GetDecalScale
,
989 d3drm_texture2_GetDecalTransparency
,
990 d3drm_texture2_GetDecalTransparentColor
,
991 d3drm_texture2_InitFromImage
,
992 d3drm_texture2_InitFromResource2
,
993 d3drm_texture2_GenerateMIPMap
,
996 static HRESULT WINAPI
d3drm_texture3_QueryInterface(IDirect3DRMTexture3
*iface
, REFIID riid
, void **out
)
998 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1000 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
1002 if (IsEqualGUID(riid
, &IID_IDirect3DRMTexture
)
1003 || IsEqualGUID(riid
, &IID_IDirect3DRMVisual
)
1004 || IsEqualGUID(riid
, &IID_IDirect3DRMObject
)
1005 || IsEqualGUID(riid
, &IID_IUnknown
))
1007 *out
= &texture
->IDirect3DRMTexture_iface
;
1009 else if (IsEqualGUID(riid
, &IID_IDirect3DRMTexture2
))
1011 *out
= &texture
->IDirect3DRMTexture2_iface
;
1013 else if (IsEqualGUID(riid
, &IID_IDirect3DRMTexture3
))
1015 *out
= &texture
->IDirect3DRMTexture3_iface
;
1020 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid
));
1021 return CLASS_E_CLASSNOTAVAILABLE
;
1024 IUnknown_AddRef((IUnknown
*)*out
);
1028 static ULONG WINAPI
d3drm_texture3_AddRef(IDirect3DRMTexture3
*iface
)
1030 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1031 ULONG refcount
= InterlockedIncrement(&texture
->obj
.ref
);
1033 TRACE("%p increasing refcount to %lu.\n", iface
, refcount
);
1038 static ULONG WINAPI
d3drm_texture3_Release(IDirect3DRMTexture3
*iface
)
1040 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1041 ULONG refcount
= InterlockedDecrement(&texture
->obj
.ref
);
1043 TRACE("%p decreasing refcount to %lu.\n", iface
, refcount
);
1046 d3drm_texture_destroy(texture
);
1051 static HRESULT WINAPI
d3drm_texture3_Clone(IDirect3DRMTexture3
*iface
,
1052 IUnknown
*outer
, REFIID iid
, void **out
)
1054 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
1059 static HRESULT WINAPI
d3drm_texture3_AddDestroyCallback(IDirect3DRMTexture3
*iface
,
1060 D3DRMOBJECTCALLBACK cb
, void *ctx
)
1062 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1064 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
1066 return d3drm_object_add_destroy_callback(&texture
->obj
, cb
, ctx
);
1069 static HRESULT WINAPI
d3drm_texture3_DeleteDestroyCallback(IDirect3DRMTexture3
*iface
,
1070 D3DRMOBJECTCALLBACK cb
, void *ctx
)
1072 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1074 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
1076 return d3drm_object_delete_destroy_callback(&texture
->obj
, cb
, ctx
);
1079 static HRESULT WINAPI
d3drm_texture3_SetAppData(IDirect3DRMTexture3
*iface
, DWORD data
)
1081 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1083 TRACE("iface %p, data %#lx.\n", iface
, data
);
1085 texture
->obj
.appdata
= data
;
1090 static DWORD WINAPI
d3drm_texture3_GetAppData(IDirect3DRMTexture3
*iface
)
1092 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1094 TRACE("iface %p.\n", iface
);
1096 return texture
->obj
.appdata
;
1099 static HRESULT WINAPI
d3drm_texture3_SetName(IDirect3DRMTexture3
*iface
, const char *name
)
1101 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1103 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
1105 return d3drm_object_set_name(&texture
->obj
, name
);
1108 static HRESULT WINAPI
d3drm_texture3_GetName(IDirect3DRMTexture3
*iface
, DWORD
*size
, char *name
)
1110 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1112 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
1114 return d3drm_object_get_name(&texture
->obj
, size
, name
);
1117 static HRESULT WINAPI
d3drm_texture3_GetClassName(IDirect3DRMTexture3
*iface
, DWORD
*size
, char *name
)
1119 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1121 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
1123 return d3drm_object_get_class_name(&texture
->obj
, size
, name
);
1126 static HRESULT WINAPI
d3drm_texture3_InitFromFile(IDirect3DRMTexture3
*iface
, const char *filename
)
1128 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1132 TRACE("iface %p, filename %s.\n", iface
, debugstr_a(filename
));
1134 if (FAILED(hr
= d3drm_texture_load(texture
, filename
, TRUE
, &image
)))
1137 return IDirect3DRMTexture3_InitFromImage(iface
, image
);
1140 static HRESULT WINAPI
d3drm_texture3_InitFromSurface(IDirect3DRMTexture3
*iface
,
1141 IDirectDrawSurface
*surface
)
1143 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1145 TRACE("iface %p, surface %p.\n", iface
, surface
);
1148 return D3DRMERR_BADOBJECT
;
1150 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1151 IDirect3DRM_AddRef(texture
->d3drm
);
1153 if (texture
->image
|| texture
->surface
)
1154 return D3DRMERR_BADOBJECT
;
1156 texture
->surface
= surface
;
1157 IDirectDrawSurface_AddRef(texture
->surface
);
1161 static HRESULT WINAPI
d3drm_texture3_InitFromResource(IDirect3DRMTexture3
*iface
, HRSRC resource
)
1163 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1168 static HRESULT WINAPI
d3drm_texture3_Changed(IDirect3DRMTexture3
*iface
,
1169 DWORD flags
, DWORD rect_count
, RECT
*rects
)
1171 FIXME("iface %p, flags %#lx, rect_count %lu, rects %p stub!\n", iface
, flags
, rect_count
, rects
);
1176 static HRESULT WINAPI
d3drm_texture3_SetColors(IDirect3DRMTexture3
*iface
, DWORD max_colors
)
1178 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1179 TRACE("iface %p, max_colors %lu\n", iface
, max_colors
);
1181 texture
->max_colors
= max_colors
;
1186 static HRESULT WINAPI
d3drm_texture3_SetShades(IDirect3DRMTexture3
*iface
, DWORD max_shades
)
1188 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1189 TRACE("iface %p, max_shades %lu\n", iface
, max_shades
);
1191 texture
->max_shades
= max_shades
;
1196 static HRESULT WINAPI
d3drm_texture3_SetDecalSize(IDirect3DRMTexture3
*iface
, D3DVALUE width
, D3DVALUE height
)
1198 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1200 TRACE("iface %p, width %.8e, height %.8e.\n", iface
, width
, height
);
1202 texture
->decal_width
= width
;
1203 texture
->decal_height
= height
;
1208 static HRESULT WINAPI
d3drm_texture3_SetDecalOrigin(IDirect3DRMTexture3
*iface
, LONG x
, LONG y
)
1210 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1212 TRACE("iface %p, x %ld, y %ld\n", iface
, x
, y
);
1214 texture
->decal_x
= x
;
1215 texture
->decal_y
= y
;
1220 static HRESULT WINAPI
d3drm_texture3_SetDecalScale(IDirect3DRMTexture3
*iface
, DWORD scale
)
1222 FIXME("iface %p, scale %lu stub!\n", iface
, scale
);
1227 static HRESULT WINAPI
d3drm_texture3_SetDecalTransparency(IDirect3DRMTexture3
*iface
, BOOL transparency
)
1229 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1231 TRACE("iface %p, transparency %#x.\n", iface
, transparency
);
1233 texture
->transparency
= transparency
;
1238 static HRESULT WINAPI
d3drm_texture3_SetDecalTransparentColor(IDirect3DRMTexture3
*iface
, D3DCOLOR color
)
1240 FIXME("iface %p, color 0x%08lx stub!\n", iface
, color
);
1245 static HRESULT WINAPI
d3drm_texture3_GetDecalSize(IDirect3DRMTexture3
*iface
, D3DVALUE
*width
, D3DVALUE
*height
)
1247 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1249 TRACE("iface %p, width %p, height %p.\n", iface
, width
, height
);
1251 *width
= texture
->decal_width
;
1252 *height
= texture
->decal_height
;
1257 static HRESULT WINAPI
d3drm_texture3_GetDecalOrigin(IDirect3DRMTexture3
*iface
, LONG
*x
, LONG
*y
)
1259 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1261 TRACE("iface %p, x %p, y %p\n", iface
, x
, y
);
1263 *x
= texture
->decal_x
;
1264 *y
= texture
->decal_y
;
1269 static D3DRMIMAGE
* WINAPI
d3drm_texture3_GetImage(IDirect3DRMTexture3
*iface
)
1271 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1273 TRACE("iface %p.\n", iface
);
1275 return texture
->image
;
1278 static DWORD WINAPI
d3drm_texture3_GetShades(IDirect3DRMTexture3
*iface
)
1280 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1281 TRACE("iface %p\n", iface
);
1282 return texture
->max_shades
;
1285 static DWORD WINAPI
d3drm_texture3_GetColors(IDirect3DRMTexture3
*iface
)
1287 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1288 TRACE("iface %p\n", iface
);
1289 return texture
->max_colors
;
1292 static DWORD WINAPI
d3drm_texture3_GetDecalScale(IDirect3DRMTexture3
*iface
)
1294 FIXME("iface %p stub!\n", iface
);
1299 static BOOL WINAPI
d3drm_texture3_GetDecalTransparency(IDirect3DRMTexture3
*iface
)
1301 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1303 TRACE("iface %p.\n", iface
);
1305 return texture
->transparency
;
1308 static D3DCOLOR WINAPI
d3drm_texture3_GetDecalTransparentColor(IDirect3DRMTexture3
*iface
)
1310 FIXME("iface %p stub!\n", iface
);
1315 static HRESULT WINAPI
d3drm_texture3_InitFromImage(IDirect3DRMTexture3
*iface
, D3DRMIMAGE
*image
)
1317 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1319 TRACE("iface %p, image %p.\n", iface
, image
);
1321 if (!d3drm_validate_image(image
))
1322 return D3DRMERR_BADOBJECT
;
1324 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1325 IDirect3DRM_AddRef(texture
->d3drm
);
1327 if (texture
->image
|| texture
->surface
)
1328 return D3DRMERR_BADOBJECT
;
1330 texture
->image
= image
;
1335 static HRESULT WINAPI
d3drm_texture3_InitFromResource2(IDirect3DRMTexture3
*iface
,
1336 HMODULE module
, const char *name
, const char *type
)
1338 FIXME("iface %p, module %p, name %s, type %s stub!\n",
1339 iface
, module
, debugstr_a(name
), debugstr_a(type
));
1344 static HRESULT WINAPI
d3drm_texture3_GenerateMIPMap(IDirect3DRMTexture3
*iface
, DWORD flags
)
1346 FIXME("iface %p, flags %#lx stub!\n", iface
, flags
);
1351 static HRESULT WINAPI
d3drm_texture3_GetSurface(IDirect3DRMTexture3
*iface
,
1352 DWORD flags
, IDirectDrawSurface
**surface
)
1354 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1356 TRACE("iface %p, flags %#lx, surface %p.\n", iface
, flags
, surface
);
1359 FIXME("unexpected flags %#lx.\n", flags
);
1362 return D3DRMERR_BADVALUE
;
1365 return D3DRMERR_NOTCREATEDFROMDDS
;
1367 *surface
= texture
->surface
;
1368 IDirectDrawSurface_AddRef(*surface
);
1373 static HRESULT WINAPI
d3drm_texture3_SetCacheOptions(IDirect3DRMTexture3
*iface
, LONG importance
, DWORD flags
)
1375 FIXME("iface %p, importance %ld, flags %#lx stub!\n", iface
, importance
, flags
);
1380 static HRESULT WINAPI
d3drm_texture3_GetCacheOptions(IDirect3DRMTexture3
*iface
,
1381 LONG
*importance
, DWORD
*flags
)
1383 FIXME("iface %p, importance %p, flags %p stub!\n", iface
, importance
, flags
);
1388 static HRESULT WINAPI
d3drm_texture3_SetDownsampleCallback(IDirect3DRMTexture3
*iface
,
1389 D3DRMDOWNSAMPLECALLBACK cb
, void *ctx
)
1391 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1396 static HRESULT WINAPI
d3drm_texture3_SetValidationCallback(IDirect3DRMTexture3
*iface
,
1397 D3DRMVALIDATIONCALLBACK cb
, void *ctx
)
1399 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1404 static const struct IDirect3DRMTexture3Vtbl d3drm_texture3_vtbl
=
1406 d3drm_texture3_QueryInterface
,
1407 d3drm_texture3_AddRef
,
1408 d3drm_texture3_Release
,
1409 d3drm_texture3_Clone
,
1410 d3drm_texture3_AddDestroyCallback
,
1411 d3drm_texture3_DeleteDestroyCallback
,
1412 d3drm_texture3_SetAppData
,
1413 d3drm_texture3_GetAppData
,
1414 d3drm_texture3_SetName
,
1415 d3drm_texture3_GetName
,
1416 d3drm_texture3_GetClassName
,
1417 d3drm_texture3_InitFromFile
,
1418 d3drm_texture3_InitFromSurface
,
1419 d3drm_texture3_InitFromResource
,
1420 d3drm_texture3_Changed
,
1421 d3drm_texture3_SetColors
,
1422 d3drm_texture3_SetShades
,
1423 d3drm_texture3_SetDecalSize
,
1424 d3drm_texture3_SetDecalOrigin
,
1425 d3drm_texture3_SetDecalScale
,
1426 d3drm_texture3_SetDecalTransparency
,
1427 d3drm_texture3_SetDecalTransparentColor
,
1428 d3drm_texture3_GetDecalSize
,
1429 d3drm_texture3_GetDecalOrigin
,
1430 d3drm_texture3_GetImage
,
1431 d3drm_texture3_GetShades
,
1432 d3drm_texture3_GetColors
,
1433 d3drm_texture3_GetDecalScale
,
1434 d3drm_texture3_GetDecalTransparency
,
1435 d3drm_texture3_GetDecalTransparentColor
,
1436 d3drm_texture3_InitFromImage
,
1437 d3drm_texture3_InitFromResource2
,
1438 d3drm_texture3_GenerateMIPMap
,
1439 d3drm_texture3_GetSurface
,
1440 d3drm_texture3_SetCacheOptions
,
1441 d3drm_texture3_GetCacheOptions
,
1442 d3drm_texture3_SetDownsampleCallback
,
1443 d3drm_texture3_SetValidationCallback
,
1446 HRESULT
d3drm_texture_create(struct d3drm_texture
**texture
, IDirect3DRM
*d3drm
)
1448 static const char classname
[] = "Texture";
1449 struct d3drm_texture
*object
;
1451 TRACE("texture %p.\n", texture
);
1453 if (!(object
= calloc(1, sizeof(*object
))))
1454 return E_OUTOFMEMORY
;
1456 object
->IDirect3DRMTexture_iface
.lpVtbl
= &d3drm_texture1_vtbl
;
1457 object
->IDirect3DRMTexture2_iface
.lpVtbl
= &d3drm_texture2_vtbl
;
1458 object
->IDirect3DRMTexture3_iface
.lpVtbl
= &d3drm_texture3_vtbl
;
1459 object
->d3drm
= d3drm
;
1460 object
->max_colors
= 8;
1461 object
->max_shades
= 16;
1462 object
->transparency
= FALSE
;
1463 object
->decal_width
= 1.0f
;
1464 object
->decal_height
= 1.0f
;
1466 d3drm_object_init(&object
->obj
, classname
);