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
)
58 TRACE("size (%d, %d), aspect (%d, %d), depth %d, red %#lx, green %#lx, blue %#lx, "
59 "buffer1 %p, buffer2 %p, rgb %d, pal %p, size %d\n",
60 image
->width
, image
->height
, image
->aspectx
, image
->aspecty
,
61 image
->depth
, image
->red_mask
, image
->green_mask
, image
->blue_mask
, image
->buffer1
,
62 image
->buffer2
, image
->rgb
, image
->palette
, image
->palette_size
);
69 if (!image
->red_mask
|| !image
->green_mask
|| !image
->blue_mask
)
74 if (!image
->palette
|| !image
->palette_size
)
81 static BOOL
d3drm_image_palettise(D3DRMIMAGE
*image
, unsigned char *src_data
,
82 SIZE_T w
, SIZE_T h
, BOOL flip
)
84 unsigned char *dst_data
, *src_ptr
, *dst_ptr
;
85 SIZE_T src_pitch
, dst_pitch
, i
, x
, y
;
86 D3DRMPALETTEENTRY
*palette
, *entry
;
87 unsigned int colour_count
= 0;
89 if (w
> (~(SIZE_T
)0 - 3) / h
)
92 src_pitch
= flip
? -w
* 3 : w
* 3;
93 dst_pitch
= (w
+ 3) & ~3;
95 if (!(dst_data
= malloc(dst_pitch
* h
)))
97 WARN("Failed to allocate image buffer.\n");
100 memset(dst_data
, 0xff, dst_pitch
* h
);
102 if (!(palette
= malloc(256 * sizeof(*palette
))))
104 WARN("Failed to allocate palette.\n");
109 src_ptr
= flip
? &src_data
[(h
- 1) * w
* 3] : src_data
;
112 for (y
= 0; y
< h
; ++y
)
114 for (x
= 0; x
< w
; ++x
)
116 for (i
= 0; i
< colour_count
; ++i
)
119 if (entry
->red
== src_ptr
[x
* 3 + 2]
120 && entry
->green
== src_ptr
[x
* 3 + 1]
121 && entry
->blue
== src_ptr
[x
* 3 + 0])
125 if (i
== colour_count
)
127 if (colour_count
== 256)
134 entry
= &palette
[colour_count
++];
135 entry
->red
= src_ptr
[x
* 3 + 2];
136 entry
->green
= src_ptr
[x
* 3 + 1];
137 entry
->blue
= src_ptr
[x
* 3 + 0];
138 entry
->flags
= D3DRMPALETTE_READONLY
;
144 src_ptr
+= src_pitch
;
145 dst_ptr
+= dst_pitch
;
150 image
->bytes_per_line
= dst_pitch
;
151 image
->buffer1
= dst_data
;
152 image
->red_mask
= 0xff;
153 image
->green_mask
= 0xff;
154 image
->blue_mask
= 0xff;
155 image
->palette_size
= colour_count
;
156 image
->palette
= palette
;
157 if ((palette
= realloc(palette
, colour_count
* sizeof(*palette
))))
158 image
->palette
= palette
;
163 static HRESULT
d3drm_image_load_32(D3DRMIMAGE
*image
, unsigned char *src_data
,
164 LONGLONG src_data_size
, SIZE_T w
, SIZE_T h
, BOOL flip
)
166 unsigned char *dst_data
, *src_ptr
, *dst_ptr
;
167 SIZE_T src_pitch
, dst_pitch
, x
, y
;
169 if (d3drm_image_palettise(image
, src_data
, w
, h
, flip
))
172 if (w
> (~(SIZE_T
)0 / 4) / h
)
173 return D3DRMERR_BADALLOC
;
175 src_pitch
= flip
? -w
* 3 : w
* 3;
178 if (!(dst_data
= malloc(dst_pitch
* h
)))
180 WARN("Failed to allocate image buffer.\n");
181 return D3DRMERR_BADALLOC
;
184 src_ptr
= flip
? &src_data
[(h
- 1) * w
* 3] : src_data
;
187 for (y
= 0; y
< h
; ++y
)
189 for (x
= 0; x
< w
; ++x
)
191 dst_ptr
[x
* 4 + 0] = src_ptr
[x
* 3 + 0];
192 dst_ptr
[x
* 4 + 1] = src_ptr
[x
* 3 + 1];
193 dst_ptr
[x
* 4 + 2] = src_ptr
[x
* 3 + 2];
194 dst_ptr
[x
* 4 + 3] = 0xff;
197 src_ptr
+= src_pitch
;
198 dst_ptr
+= dst_pitch
;
203 image
->bytes_per_line
= dst_pitch
;
204 image
->buffer1
= dst_data
;
205 image
->red_mask
= 0xff0000;
206 image
->green_mask
= 0x00ff00;
207 image
->blue_mask
= 0x0000ff;
208 image
->palette_size
= 0;
209 image
->palette
= NULL
;
214 static HRESULT
d3drm_image_load_8(D3DRMIMAGE
*image
, const RGBQUAD
*palette
,
215 unsigned char *src_data
, LONGLONG src_data_size
, SIZE_T w
, SIZE_T h
, BOOL flip
)
217 unsigned char *dst_data
;
220 if (w
> ~(SIZE_T
)0 / h
)
221 return D3DRMERR_BADALLOC
;
223 if (!(dst_data
= malloc(w
* h
)))
225 WARN("Failed to allocate image buffer.\n");
226 return D3DRMERR_BADALLOC
;
229 if (!(image
->palette
= malloc(256 * sizeof(*image
->palette
))))
231 WARN("Failed to allocate palette.\n");
233 return D3DRMERR_BADALLOC
;
236 for (i
= 0; i
< 256; ++i
)
238 image
->palette
[i
].red
= palette
[i
].rgbRed
;
239 image
->palette
[i
].green
= palette
[i
].rgbGreen
;
240 image
->palette
[i
].blue
= palette
[i
].rgbBlue
;
241 image
->palette
[i
].flags
= D3DRMPALETTE_READONLY
;
246 for (i
= 0; i
< h
; ++i
)
248 memcpy(&dst_data
[i
* w
], &src_data
[(h
- 1 - i
) * w
], w
);
253 memcpy(dst_data
, src_data
, w
* h
);
258 image
->bytes_per_line
= w
;
259 image
->buffer1
= dst_data
;
260 image
->red_mask
= 0xff;
261 image
->green_mask
= 0xff;
262 image
->blue_mask
= 0xff;
263 image
->palette_size
= 256;
268 static void CDECL
destroy_image_callback(IDirect3DRMObject
*obj
, void *arg
)
270 D3DRMIMAGE
*image
= arg
;
272 TRACE("texture object %p, image %p.\n", obj
, image
);
274 free(image
->buffer1
);
278 static HRESULT
d3drm_texture_load(struct d3drm_texture
*texture
,
279 const char *path
, BOOL flip
, D3DRMIMAGE
**image_out
)
281 BITMAPFILEHEADER
*header
;
282 unsigned int w
, h
, bpp
;
283 HANDLE file
, mapping
;
290 if ((file
= CreateFileA(path
, GENERIC_READ
, FILE_SHARE_READ
, 0, OPEN_EXISTING
, 0, 0)) == INVALID_HANDLE_VALUE
)
291 return D3DRMERR_BADOBJECT
;
293 mapping
= CreateFileMappingW(file
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
295 if (!mapping
|| mapping
== INVALID_HANDLE_VALUE
)
296 return D3DRMERR_BADVALUE
;
298 if (!GetFileSizeEx(mapping
, &size
))
300 CloseHandle(mapping
);
301 return D3DRMERR_BADVALUE
;
305 header
= MapViewOfFile(mapping
, FILE_MAP_READ
, 0, 0, 0);
306 CloseHandle(mapping
);
308 return D3DRMERR_BADVALUE
;
310 hr
= D3DRMERR_BADALLOC
;
311 if (!(image
= calloc(1, sizeof(*image
))))
314 hr
= D3DRMERR_BADFILE
;
315 if (rem
< sizeof(*header
) || header
->bfType
!= 0x4d42 /* BM */)
317 rem
-= sizeof(*header
);
319 info
= (BITMAPINFO
*)&header
[1];
320 /* Only allow version 1 DIB's (BITMAPINFOHEADER) to be loaded. */
321 if (rem
< sizeof(info
->bmiHeader
) || info
->bmiHeader
.biSize
!= sizeof(info
->bmiHeader
))
323 rem
-= sizeof(info
->bmiHeader
);
325 w
= info
->bmiHeader
.biWidth
;
326 h
= abs(info
->bmiHeader
.biHeight
);
327 bpp
= info
->bmiHeader
.biBitCount
== 24 ? 32 : info
->bmiHeader
.biBitCount
;
328 if (bpp
!= 8 && bpp
!= 32)
337 rem
-= 256 * sizeof(*info
->bmiColors
);
340 hr
= d3drm_image_load_8(image
, info
->bmiColors
, (unsigned char *)&info
->bmiColors
[256], rem
, w
, h
, flip
);
344 if (w
> (rem
/ 3) / h
)
346 hr
= d3drm_image_load_32(image
, (unsigned char *)&info
->bmiColors
, rem
, w
, h
, flip
);
351 /* Use an internal destroy callback to destroy the image struct. */
352 hr
= IDirect3DRMObject_AddDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, destroy_image_callback
, image
);
356 UnmapViewOfFile(header
);
362 UnmapViewOfFile(header
);
367 static HRESULT WINAPI
d3drm_texture1_QueryInterface(IDirect3DRMTexture
*iface
, REFIID riid
, void **out
)
369 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
371 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
373 return IDirect3DRMTexture3_QueryInterface(&texture
->IDirect3DRMTexture3_iface
, riid
, out
);
376 static ULONG WINAPI
d3drm_texture1_AddRef(IDirect3DRMTexture
*iface
)
378 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
380 TRACE("iface %p.\n", iface
);
382 return IDirect3DRMTexture3_AddRef(&texture
->IDirect3DRMTexture3_iface
);
385 static ULONG WINAPI
d3drm_texture1_Release(IDirect3DRMTexture
*iface
)
387 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
389 TRACE("iface %p.\n", iface
);
391 return IDirect3DRMTexture3_Release(&texture
->IDirect3DRMTexture3_iface
);
394 static HRESULT WINAPI
d3drm_texture1_Clone(IDirect3DRMTexture
*iface
,
395 IUnknown
*outer
, REFIID iid
, void **out
)
397 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
399 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
401 return IDirect3DRMTexture3_Clone(&texture
->IDirect3DRMTexture3_iface
, outer
, iid
, out
);
404 static HRESULT WINAPI
d3drm_texture1_AddDestroyCallback(IDirect3DRMTexture
*iface
,
405 D3DRMOBJECTCALLBACK cb
, void *ctx
)
407 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
409 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
411 return IDirect3DRMTexture3_AddDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
414 static HRESULT WINAPI
d3drm_texture1_DeleteDestroyCallback(IDirect3DRMTexture
*iface
,
415 D3DRMOBJECTCALLBACK cb
, void *ctx
)
417 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
419 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
421 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
424 static HRESULT WINAPI
d3drm_texture1_SetAppData(IDirect3DRMTexture
*iface
, DWORD data
)
426 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
428 TRACE("iface %p, data %#lx.\n", iface
, data
);
430 return IDirect3DRMTexture3_SetAppData(&texture
->IDirect3DRMTexture3_iface
, data
);
433 static DWORD WINAPI
d3drm_texture1_GetAppData(IDirect3DRMTexture
*iface
)
435 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
437 TRACE("iface %p.\n", iface
);
439 return IDirect3DRMTexture3_GetAppData(&texture
->IDirect3DRMTexture3_iface
);
442 static HRESULT WINAPI
d3drm_texture1_SetName(IDirect3DRMTexture
*iface
, const char *name
)
444 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
446 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
448 return IDirect3DRMTexture3_SetName(&texture
->IDirect3DRMTexture3_iface
, name
);
451 static HRESULT WINAPI
d3drm_texture1_GetName(IDirect3DRMTexture
*iface
, DWORD
*size
, char *name
)
453 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
455 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
457 return IDirect3DRMTexture3_GetName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
460 static HRESULT WINAPI
d3drm_texture1_GetClassName(IDirect3DRMTexture
*iface
, DWORD
*size
, char *name
)
462 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
464 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
466 return IDirect3DRMTexture3_GetClassName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
469 static HRESULT WINAPI
d3drm_texture1_InitFromFile(IDirect3DRMTexture
*iface
, const char *filename
)
471 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
475 TRACE("iface %p, filename %s.\n", iface
, debugstr_a(filename
));
477 if (FAILED(hr
= d3drm_texture_load(texture
, filename
, FALSE
, &image
)))
480 return IDirect3DRMTexture3_InitFromImage(&texture
->IDirect3DRMTexture3_iface
, image
);
483 static HRESULT WINAPI
d3drm_texture1_InitFromSurface(IDirect3DRMTexture
*iface
,
484 IDirectDrawSurface
*surface
)
486 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
488 TRACE("iface %p, surface %p.\n", iface
, surface
);
490 return IDirect3DRMTexture3_InitFromSurface(&texture
->IDirect3DRMTexture3_iface
, surface
);
493 static HRESULT WINAPI
d3drm_texture1_InitFromResource(IDirect3DRMTexture
*iface
, HRSRC resource
)
495 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
500 static HRESULT WINAPI
d3drm_texture1_Changed(IDirect3DRMTexture
*iface
, BOOL pixels
, BOOL palette
)
502 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface
, pixels
, palette
);
507 static HRESULT WINAPI
d3drm_texture1_SetColors(IDirect3DRMTexture
*iface
, DWORD max_colors
)
509 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
511 TRACE("iface %p, max_colors %lu.\n", iface
, max_colors
);
513 return IDirect3DRMTexture3_SetColors(&texture
->IDirect3DRMTexture3_iface
, max_colors
);
516 static HRESULT WINAPI
d3drm_texture1_SetShades(IDirect3DRMTexture
*iface
, DWORD max_shades
)
518 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
520 TRACE("iface %p, max_shades %lu.\n", iface
, max_shades
);
522 return IDirect3DRMTexture3_SetShades(&texture
->IDirect3DRMTexture3_iface
, max_shades
);
525 static HRESULT WINAPI
d3drm_texture1_SetDecalSize(IDirect3DRMTexture
*iface
, D3DVALUE width
, D3DVALUE height
)
527 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
529 TRACE("iface %p, width %.8e, height %.8e.\n", iface
, width
, height
);
531 return IDirect3DRMTexture3_SetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
534 static HRESULT WINAPI
d3drm_texture1_SetDecalOrigin(IDirect3DRMTexture
*iface
, LONG x
, LONG y
)
536 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
538 TRACE("iface %p, x %ld, y %ld.\n", iface
, x
, y
);
540 return IDirect3DRMTexture3_SetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
543 static HRESULT WINAPI
d3drm_texture1_SetDecalScale(IDirect3DRMTexture
*iface
, DWORD scale
)
545 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
547 TRACE("iface %p, scale %lu.\n", iface
, scale
);
549 return IDirect3DRMTexture3_SetDecalScale(&texture
->IDirect3DRMTexture3_iface
, scale
);
552 static HRESULT WINAPI
d3drm_texture1_SetDecalTransparency(IDirect3DRMTexture
*iface
, BOOL transparency
)
554 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
556 TRACE("iface %p, transparency %#x.\n", iface
, transparency
);
558 return IDirect3DRMTexture3_SetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
, transparency
);
561 static HRESULT WINAPI
d3drm_texture1_SetDecalTransparentColor(IDirect3DRMTexture
*iface
, D3DCOLOR color
)
563 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
565 TRACE("iface %p, color 0x%08lx.\n", iface
, color
);
567 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
, color
);
570 static HRESULT WINAPI
d3drm_texture1_GetDecalSize(IDirect3DRMTexture
*iface
, D3DVALUE
*width
, D3DVALUE
*height
)
572 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
574 TRACE("iface %p, width %p, height %p.\n", iface
, width
, height
);
576 return IDirect3DRMTexture3_GetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
579 static HRESULT WINAPI
d3drm_texture1_GetDecalOrigin(IDirect3DRMTexture
*iface
, LONG
*x
, LONG
*y
)
581 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
583 TRACE("iface %p, x %p, y %p.\n", iface
, x
, y
);
585 return IDirect3DRMTexture3_GetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
588 static D3DRMIMAGE
* WINAPI
d3drm_texture1_GetImage(IDirect3DRMTexture
*iface
)
590 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
592 TRACE("iface %p.\n", iface
);
594 return IDirect3DRMTexture3_GetImage(&texture
->IDirect3DRMTexture3_iface
);
597 static DWORD WINAPI
d3drm_texture1_GetShades(IDirect3DRMTexture
*iface
)
599 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
601 TRACE("iface %p.\n", iface
);
603 return IDirect3DRMTexture3_GetShades(&texture
->IDirect3DRMTexture3_iface
);
606 static DWORD WINAPI
d3drm_texture1_GetColors(IDirect3DRMTexture
*iface
)
608 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
610 TRACE("iface %p.\n", iface
);
612 return IDirect3DRMTexture3_GetColors(&texture
->IDirect3DRMTexture3_iface
);
615 static DWORD WINAPI
d3drm_texture1_GetDecalScale(IDirect3DRMTexture
*iface
)
617 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
619 TRACE("iface %p.\n", iface
);
621 return IDirect3DRMTexture3_GetDecalScale(&texture
->IDirect3DRMTexture3_iface
);
624 static BOOL WINAPI
d3drm_texture1_GetDecalTransparency(IDirect3DRMTexture
*iface
)
626 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
628 TRACE("iface %p.\n", iface
);
630 return IDirect3DRMTexture3_GetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
);
633 static D3DCOLOR WINAPI
d3drm_texture1_GetDecalTransparentColor(IDirect3DRMTexture
*iface
)
635 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture(iface
);
637 TRACE("iface %p.\n", iface
);
639 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
);
642 static const struct IDirect3DRMTextureVtbl d3drm_texture1_vtbl
=
644 d3drm_texture1_QueryInterface
,
645 d3drm_texture1_AddRef
,
646 d3drm_texture1_Release
,
647 d3drm_texture1_Clone
,
648 d3drm_texture1_AddDestroyCallback
,
649 d3drm_texture1_DeleteDestroyCallback
,
650 d3drm_texture1_SetAppData
,
651 d3drm_texture1_GetAppData
,
652 d3drm_texture1_SetName
,
653 d3drm_texture1_GetName
,
654 d3drm_texture1_GetClassName
,
655 d3drm_texture1_InitFromFile
,
656 d3drm_texture1_InitFromSurface
,
657 d3drm_texture1_InitFromResource
,
658 d3drm_texture1_Changed
,
659 d3drm_texture1_SetColors
,
660 d3drm_texture1_SetShades
,
661 d3drm_texture1_SetDecalSize
,
662 d3drm_texture1_SetDecalOrigin
,
663 d3drm_texture1_SetDecalScale
,
664 d3drm_texture1_SetDecalTransparency
,
665 d3drm_texture1_SetDecalTransparentColor
,
666 d3drm_texture1_GetDecalSize
,
667 d3drm_texture1_GetDecalOrigin
,
668 d3drm_texture1_GetImage
,
669 d3drm_texture1_GetShades
,
670 d3drm_texture1_GetColors
,
671 d3drm_texture1_GetDecalScale
,
672 d3drm_texture1_GetDecalTransparency
,
673 d3drm_texture1_GetDecalTransparentColor
,
676 static HRESULT WINAPI
d3drm_texture2_QueryInterface(IDirect3DRMTexture2
*iface
, REFIID riid
, void **out
)
678 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
680 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
682 return IDirect3DRMTexture3_QueryInterface(&texture
->IDirect3DRMTexture3_iface
, riid
, out
);
685 static ULONG WINAPI
d3drm_texture2_AddRef(IDirect3DRMTexture2
*iface
)
687 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
689 TRACE("iface %p.\n", iface
);
691 return IDirect3DRMTexture3_AddRef(&texture
->IDirect3DRMTexture3_iface
);
694 static ULONG WINAPI
d3drm_texture2_Release(IDirect3DRMTexture2
*iface
)
696 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
698 TRACE("iface %p.\n", iface
);
700 return IDirect3DRMTexture3_Release(&texture
->IDirect3DRMTexture3_iface
);
703 static HRESULT WINAPI
d3drm_texture2_Clone(IDirect3DRMTexture2
*iface
,
704 IUnknown
*outer
, REFIID iid
, void **out
)
706 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
708 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
710 return IDirect3DRMTexture3_Clone(&texture
->IDirect3DRMTexture3_iface
, outer
, iid
, out
);
713 static HRESULT WINAPI
d3drm_texture2_AddDestroyCallback(IDirect3DRMTexture2
*iface
,
714 D3DRMOBJECTCALLBACK cb
, void *ctx
)
716 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
718 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
720 return IDirect3DRMTexture3_AddDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
723 static HRESULT WINAPI
d3drm_texture2_DeleteDestroyCallback(IDirect3DRMTexture2
*iface
,
724 D3DRMOBJECTCALLBACK cb
, void *ctx
)
726 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
728 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
730 return IDirect3DRMTexture3_DeleteDestroyCallback(&texture
->IDirect3DRMTexture3_iface
, cb
, ctx
);
733 static HRESULT WINAPI
d3drm_texture2_SetAppData(IDirect3DRMTexture2
*iface
, DWORD data
)
735 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
737 TRACE("iface %p, data %#lx.\n", iface
, data
);
739 return IDirect3DRMTexture3_SetAppData(&texture
->IDirect3DRMTexture3_iface
, data
);
742 static DWORD WINAPI
d3drm_texture2_GetAppData(IDirect3DRMTexture2
*iface
)
744 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
746 TRACE("iface %p.\n", iface
);
748 return IDirect3DRMTexture3_GetAppData(&texture
->IDirect3DRMTexture3_iface
);
751 static HRESULT WINAPI
d3drm_texture2_SetName(IDirect3DRMTexture2
*iface
, const char *name
)
753 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
755 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
757 return IDirect3DRMTexture3_SetName(&texture
->IDirect3DRMTexture3_iface
, name
);
760 static HRESULT WINAPI
d3drm_texture2_GetName(IDirect3DRMTexture2
*iface
, DWORD
*size
, char *name
)
762 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
764 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
766 return IDirect3DRMTexture3_GetName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
769 static HRESULT WINAPI
d3drm_texture2_GetClassName(IDirect3DRMTexture2
*iface
, DWORD
*size
, char *name
)
771 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
773 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
775 return IDirect3DRMTexture3_GetClassName(&texture
->IDirect3DRMTexture3_iface
, size
, name
);
778 static HRESULT WINAPI
d3drm_texture2_InitFromFile(IDirect3DRMTexture2
*iface
, const char *filename
)
780 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
782 TRACE("iface %p, filename %s.\n", iface
, debugstr_a(filename
));
784 return IDirect3DRMTexture3_InitFromFile(&texture
->IDirect3DRMTexture3_iface
, filename
);
787 static HRESULT WINAPI
d3drm_texture2_InitFromSurface(IDirect3DRMTexture2
*iface
,
788 IDirectDrawSurface
*surface
)
790 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
792 TRACE("iface %p, surface %p.\n", iface
, surface
);
794 return IDirect3DRMTexture3_InitFromSurface(&texture
->IDirect3DRMTexture3_iface
, surface
);
797 static HRESULT WINAPI
d3drm_texture2_InitFromResource(IDirect3DRMTexture2
*iface
, HRSRC resource
)
799 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
804 static HRESULT WINAPI
d3drm_texture2_Changed(IDirect3DRMTexture2
*iface
, BOOL pixels
, BOOL palette
)
806 FIXME("iface %p, pixels %#x, palette %#x stub!\n", iface
, pixels
, palette
);
811 static HRESULT WINAPI
d3drm_texture2_SetColors(IDirect3DRMTexture2
*iface
, DWORD max_colors
)
813 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
815 TRACE("iface %p, max_colors %lu.\n", iface
, max_colors
);
817 return IDirect3DRMTexture3_SetColors(&texture
->IDirect3DRMTexture3_iface
, max_colors
);
820 static HRESULT WINAPI
d3drm_texture2_SetShades(IDirect3DRMTexture2
*iface
, DWORD max_shades
)
822 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
824 TRACE("iface %p, max_shades %lu.\n", iface
, max_shades
);
826 return IDirect3DRMTexture3_SetShades(&texture
->IDirect3DRMTexture3_iface
, max_shades
);
829 static HRESULT WINAPI
d3drm_texture2_SetDecalSize(IDirect3DRMTexture2
*iface
, D3DVALUE width
, D3DVALUE height
)
831 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
833 TRACE("iface %p, width %.8e, height %.8e.\n", iface
, width
, height
);
835 return IDirect3DRMTexture3_SetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
838 static HRESULT WINAPI
d3drm_texture2_SetDecalOrigin(IDirect3DRMTexture2
*iface
, LONG x
, LONG y
)
840 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
842 TRACE("iface %p, x %ld, y %ld.\n", iface
, x
, y
);
844 return IDirect3DRMTexture3_SetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
847 static HRESULT WINAPI
d3drm_texture2_SetDecalScale(IDirect3DRMTexture2
*iface
, DWORD scale
)
849 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
851 TRACE("iface %p, scale %lu.\n", iface
, scale
);
853 return IDirect3DRMTexture3_SetDecalScale(&texture
->IDirect3DRMTexture3_iface
, scale
);
856 static HRESULT WINAPI
d3drm_texture2_SetDecalTransparency(IDirect3DRMTexture2
*iface
, BOOL transparency
)
858 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
860 TRACE("iface %p, transparency %#x.\n", iface
, transparency
);
862 return IDirect3DRMTexture3_SetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
, transparency
);
865 static HRESULT WINAPI
d3drm_texture2_SetDecalTransparentColor(IDirect3DRMTexture2
*iface
, D3DCOLOR color
)
867 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
869 TRACE("iface %p, color 0x%08lx.\n", iface
, color
);
871 return IDirect3DRMTexture3_SetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
, color
);
874 static HRESULT WINAPI
d3drm_texture2_GetDecalSize(IDirect3DRMTexture2
*iface
, D3DVALUE
*width
, D3DVALUE
*height
)
876 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
878 TRACE("iface %p, width %p, height %p.\n", iface
, width
, height
);
880 return IDirect3DRMTexture3_GetDecalSize(&texture
->IDirect3DRMTexture3_iface
, width
, height
);
883 static HRESULT WINAPI
d3drm_texture2_GetDecalOrigin(IDirect3DRMTexture2
*iface
, LONG
*x
, LONG
*y
)
885 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
887 TRACE("iface %p, x %p, y %p.\n", iface
, x
, y
);
889 return IDirect3DRMTexture3_GetDecalOrigin(&texture
->IDirect3DRMTexture3_iface
, x
, y
);
892 static D3DRMIMAGE
* WINAPI
d3drm_texture2_GetImage(IDirect3DRMTexture2
*iface
)
894 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
896 TRACE("iface %p.\n", iface
);
898 return IDirect3DRMTexture3_GetImage(&texture
->IDirect3DRMTexture3_iface
);
901 static DWORD WINAPI
d3drm_texture2_GetShades(IDirect3DRMTexture2
*iface
)
903 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
905 TRACE("iface %p.\n", iface
);
907 return IDirect3DRMTexture3_GetShades(&texture
->IDirect3DRMTexture3_iface
);
910 static DWORD WINAPI
d3drm_texture2_GetColors(IDirect3DRMTexture2
*iface
)
912 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
914 TRACE("iface %p.\n", iface
);
916 return IDirect3DRMTexture3_GetColors(&texture
->IDirect3DRMTexture3_iface
);
919 static DWORD WINAPI
d3drm_texture2_GetDecalScale(IDirect3DRMTexture2
*iface
)
921 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
923 TRACE("iface %p.\n", iface
);
925 return IDirect3DRMTexture3_GetDecalScale(&texture
->IDirect3DRMTexture3_iface
);
928 static BOOL WINAPI
d3drm_texture2_GetDecalTransparency(IDirect3DRMTexture2
*iface
)
930 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
932 TRACE("iface %p.\n", iface
);
934 return IDirect3DRMTexture3_GetDecalTransparency(&texture
->IDirect3DRMTexture3_iface
);
937 static D3DCOLOR WINAPI
d3drm_texture2_GetDecalTransparentColor(IDirect3DRMTexture2
*iface
)
939 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
941 TRACE("iface %p.\n", iface
);
943 return IDirect3DRMTexture3_GetDecalTransparentColor(&texture
->IDirect3DRMTexture3_iface
);
946 static HRESULT WINAPI
d3drm_texture2_InitFromImage(IDirect3DRMTexture2
*iface
, D3DRMIMAGE
*image
)
948 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
950 TRACE("iface %p, image %p.\n", iface
, image
);
952 return IDirect3DRMTexture3_InitFromImage(&texture
->IDirect3DRMTexture3_iface
, image
);
955 static HRESULT WINAPI
d3drm_texture2_InitFromResource2(IDirect3DRMTexture2
*iface
,
956 HMODULE module
, const char *name
, const char *type
)
958 FIXME("iface %p, module %p, name %s, type %s stub!\n",
959 iface
, module
, debugstr_a(name
), debugstr_a(type
));
964 static HRESULT WINAPI
d3drm_texture2_GenerateMIPMap(IDirect3DRMTexture2
*iface
, DWORD flags
)
966 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture2(iface
);
968 TRACE("iface %p, flags %#lx.\n", iface
, flags
);
970 return IDirect3DRMTexture3_GenerateMIPMap(&texture
->IDirect3DRMTexture3_iface
, flags
);
973 static const struct IDirect3DRMTexture2Vtbl d3drm_texture2_vtbl
=
975 d3drm_texture2_QueryInterface
,
976 d3drm_texture2_AddRef
,
977 d3drm_texture2_Release
,
978 d3drm_texture2_Clone
,
979 d3drm_texture2_AddDestroyCallback
,
980 d3drm_texture2_DeleteDestroyCallback
,
981 d3drm_texture2_SetAppData
,
982 d3drm_texture2_GetAppData
,
983 d3drm_texture2_SetName
,
984 d3drm_texture2_GetName
,
985 d3drm_texture2_GetClassName
,
986 d3drm_texture2_InitFromFile
,
987 d3drm_texture2_InitFromSurface
,
988 d3drm_texture2_InitFromResource
,
989 d3drm_texture2_Changed
,
990 d3drm_texture2_SetColors
,
991 d3drm_texture2_SetShades
,
992 d3drm_texture2_SetDecalSize
,
993 d3drm_texture2_SetDecalOrigin
,
994 d3drm_texture2_SetDecalScale
,
995 d3drm_texture2_SetDecalTransparency
,
996 d3drm_texture2_SetDecalTransparentColor
,
997 d3drm_texture2_GetDecalSize
,
998 d3drm_texture2_GetDecalOrigin
,
999 d3drm_texture2_GetImage
,
1000 d3drm_texture2_GetShades
,
1001 d3drm_texture2_GetColors
,
1002 d3drm_texture2_GetDecalScale
,
1003 d3drm_texture2_GetDecalTransparency
,
1004 d3drm_texture2_GetDecalTransparentColor
,
1005 d3drm_texture2_InitFromImage
,
1006 d3drm_texture2_InitFromResource2
,
1007 d3drm_texture2_GenerateMIPMap
,
1010 static HRESULT WINAPI
d3drm_texture3_QueryInterface(IDirect3DRMTexture3
*iface
, REFIID riid
, void **out
)
1012 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1014 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
1016 if (IsEqualGUID(riid
, &IID_IDirect3DRMTexture
)
1017 || IsEqualGUID(riid
, &IID_IDirect3DRMVisual
)
1018 || IsEqualGUID(riid
, &IID_IDirect3DRMObject
)
1019 || IsEqualGUID(riid
, &IID_IUnknown
))
1021 *out
= &texture
->IDirect3DRMTexture_iface
;
1023 else if (IsEqualGUID(riid
, &IID_IDirect3DRMTexture2
))
1025 *out
= &texture
->IDirect3DRMTexture2_iface
;
1027 else if (IsEqualGUID(riid
, &IID_IDirect3DRMTexture3
))
1029 *out
= &texture
->IDirect3DRMTexture3_iface
;
1034 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid
));
1035 return CLASS_E_CLASSNOTAVAILABLE
;
1038 IUnknown_AddRef((IUnknown
*)*out
);
1042 static ULONG WINAPI
d3drm_texture3_AddRef(IDirect3DRMTexture3
*iface
)
1044 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1045 ULONG refcount
= InterlockedIncrement(&texture
->obj
.ref
);
1047 TRACE("%p increasing refcount to %lu.\n", iface
, refcount
);
1052 static ULONG WINAPI
d3drm_texture3_Release(IDirect3DRMTexture3
*iface
)
1054 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1055 ULONG refcount
= InterlockedDecrement(&texture
->obj
.ref
);
1057 TRACE("%p decreasing refcount to %lu.\n", iface
, refcount
);
1060 d3drm_texture_destroy(texture
);
1065 static HRESULT WINAPI
d3drm_texture3_Clone(IDirect3DRMTexture3
*iface
,
1066 IUnknown
*outer
, REFIID iid
, void **out
)
1068 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
1073 static HRESULT WINAPI
d3drm_texture3_AddDestroyCallback(IDirect3DRMTexture3
*iface
,
1074 D3DRMOBJECTCALLBACK cb
, void *ctx
)
1076 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1078 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
1080 return d3drm_object_add_destroy_callback(&texture
->obj
, cb
, ctx
);
1083 static HRESULT WINAPI
d3drm_texture3_DeleteDestroyCallback(IDirect3DRMTexture3
*iface
,
1084 D3DRMOBJECTCALLBACK cb
, void *ctx
)
1086 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1088 TRACE("iface %p, cb %p, ctx %p\n", iface
, cb
, ctx
);
1090 return d3drm_object_delete_destroy_callback(&texture
->obj
, cb
, ctx
);
1093 static HRESULT WINAPI
d3drm_texture3_SetAppData(IDirect3DRMTexture3
*iface
, DWORD data
)
1095 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1097 TRACE("iface %p, data %#lx.\n", iface
, data
);
1099 texture
->obj
.appdata
= data
;
1104 static DWORD WINAPI
d3drm_texture3_GetAppData(IDirect3DRMTexture3
*iface
)
1106 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1108 TRACE("iface %p.\n", iface
);
1110 return texture
->obj
.appdata
;
1113 static HRESULT WINAPI
d3drm_texture3_SetName(IDirect3DRMTexture3
*iface
, const char *name
)
1115 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1117 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
1119 return d3drm_object_set_name(&texture
->obj
, name
);
1122 static HRESULT WINAPI
d3drm_texture3_GetName(IDirect3DRMTexture3
*iface
, DWORD
*size
, char *name
)
1124 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1126 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
1128 return d3drm_object_get_name(&texture
->obj
, size
, name
);
1131 static HRESULT WINAPI
d3drm_texture3_GetClassName(IDirect3DRMTexture3
*iface
, DWORD
*size
, char *name
)
1133 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1135 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
1137 return d3drm_object_get_class_name(&texture
->obj
, size
, name
);
1140 static HRESULT WINAPI
d3drm_texture3_InitFromFile(IDirect3DRMTexture3
*iface
, const char *filename
)
1142 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1146 TRACE("iface %p, filename %s.\n", iface
, debugstr_a(filename
));
1148 if (FAILED(hr
= d3drm_texture_load(texture
, filename
, TRUE
, &image
)))
1151 return IDirect3DRMTexture3_InitFromImage(iface
, image
);
1154 static HRESULT WINAPI
d3drm_texture3_InitFromSurface(IDirect3DRMTexture3
*iface
,
1155 IDirectDrawSurface
*surface
)
1157 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1159 TRACE("iface %p, surface %p.\n", iface
, surface
);
1162 return D3DRMERR_BADOBJECT
;
1164 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1165 IDirect3DRM_AddRef(texture
->d3drm
);
1167 if (texture
->image
|| texture
->surface
)
1168 return D3DRMERR_BADOBJECT
;
1170 texture
->surface
= surface
;
1171 IDirectDrawSurface_AddRef(texture
->surface
);
1175 static HRESULT WINAPI
d3drm_texture3_InitFromResource(IDirect3DRMTexture3
*iface
, HRSRC resource
)
1177 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
1182 static HRESULT WINAPI
d3drm_texture3_Changed(IDirect3DRMTexture3
*iface
,
1183 DWORD flags
, DWORD rect_count
, RECT
*rects
)
1185 FIXME("iface %p, flags %#lx, rect_count %lu, rects %p stub!\n", iface
, flags
, rect_count
, rects
);
1190 static HRESULT WINAPI
d3drm_texture3_SetColors(IDirect3DRMTexture3
*iface
, DWORD max_colors
)
1192 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1193 TRACE("iface %p, max_colors %lu\n", iface
, max_colors
);
1195 texture
->max_colors
= max_colors
;
1200 static HRESULT WINAPI
d3drm_texture3_SetShades(IDirect3DRMTexture3
*iface
, DWORD max_shades
)
1202 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1203 TRACE("iface %p, max_shades %lu\n", iface
, max_shades
);
1205 texture
->max_shades
= max_shades
;
1210 static HRESULT WINAPI
d3drm_texture3_SetDecalSize(IDirect3DRMTexture3
*iface
, D3DVALUE width
, D3DVALUE height
)
1212 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1214 TRACE("iface %p, width %.8e, height %.8e.\n", iface
, width
, height
);
1216 texture
->decal_width
= width
;
1217 texture
->decal_height
= height
;
1222 static HRESULT WINAPI
d3drm_texture3_SetDecalOrigin(IDirect3DRMTexture3
*iface
, LONG x
, LONG y
)
1224 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1226 TRACE("iface %p, x %ld, y %ld\n", iface
, x
, y
);
1228 texture
->decal_x
= x
;
1229 texture
->decal_y
= y
;
1234 static HRESULT WINAPI
d3drm_texture3_SetDecalScale(IDirect3DRMTexture3
*iface
, DWORD scale
)
1236 FIXME("iface %p, scale %lu stub!\n", iface
, scale
);
1241 static HRESULT WINAPI
d3drm_texture3_SetDecalTransparency(IDirect3DRMTexture3
*iface
, BOOL transparency
)
1243 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1245 TRACE("iface %p, transparency %#x.\n", iface
, transparency
);
1247 texture
->transparency
= transparency
;
1252 static HRESULT WINAPI
d3drm_texture3_SetDecalTransparentColor(IDirect3DRMTexture3
*iface
, D3DCOLOR color
)
1254 FIXME("iface %p, color 0x%08lx stub!\n", iface
, color
);
1259 static HRESULT WINAPI
d3drm_texture3_GetDecalSize(IDirect3DRMTexture3
*iface
, D3DVALUE
*width
, D3DVALUE
*height
)
1261 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1263 TRACE("iface %p, width %p, height %p.\n", iface
, width
, height
);
1265 *width
= texture
->decal_width
;
1266 *height
= texture
->decal_height
;
1271 static HRESULT WINAPI
d3drm_texture3_GetDecalOrigin(IDirect3DRMTexture3
*iface
, LONG
*x
, LONG
*y
)
1273 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1275 TRACE("iface %p, x %p, y %p\n", iface
, x
, y
);
1277 *x
= texture
->decal_x
;
1278 *y
= texture
->decal_y
;
1283 static D3DRMIMAGE
* WINAPI
d3drm_texture3_GetImage(IDirect3DRMTexture3
*iface
)
1285 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1287 TRACE("iface %p.\n", iface
);
1289 return texture
->image
;
1292 static DWORD WINAPI
d3drm_texture3_GetShades(IDirect3DRMTexture3
*iface
)
1294 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1295 TRACE("iface %p\n", iface
);
1296 return texture
->max_shades
;
1299 static DWORD WINAPI
d3drm_texture3_GetColors(IDirect3DRMTexture3
*iface
)
1301 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1302 TRACE("iface %p\n", iface
);
1303 return texture
->max_colors
;
1306 static DWORD WINAPI
d3drm_texture3_GetDecalScale(IDirect3DRMTexture3
*iface
)
1308 FIXME("iface %p stub!\n", iface
);
1313 static BOOL WINAPI
d3drm_texture3_GetDecalTransparency(IDirect3DRMTexture3
*iface
)
1315 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1317 TRACE("iface %p.\n", iface
);
1319 return texture
->transparency
;
1322 static D3DCOLOR WINAPI
d3drm_texture3_GetDecalTransparentColor(IDirect3DRMTexture3
*iface
)
1324 FIXME("iface %p stub!\n", iface
);
1329 static HRESULT WINAPI
d3drm_texture3_InitFromImage(IDirect3DRMTexture3
*iface
, D3DRMIMAGE
*image
)
1331 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1333 TRACE("iface %p, image %p.\n", iface
, image
);
1335 if (!d3drm_validate_image(image
))
1336 return D3DRMERR_BADOBJECT
;
1338 /* d3drm intentionally leaks a reference to IDirect3DRM here if texture has already been initialized. */
1339 IDirect3DRM_AddRef(texture
->d3drm
);
1341 if (texture
->image
|| texture
->surface
)
1342 return D3DRMERR_BADOBJECT
;
1344 texture
->image
= image
;
1349 static HRESULT WINAPI
d3drm_texture3_InitFromResource2(IDirect3DRMTexture3
*iface
,
1350 HMODULE module
, const char *name
, const char *type
)
1352 FIXME("iface %p, module %p, name %s, type %s stub!\n",
1353 iface
, module
, debugstr_a(name
), debugstr_a(type
));
1358 static HRESULT WINAPI
d3drm_texture3_GenerateMIPMap(IDirect3DRMTexture3
*iface
, DWORD flags
)
1360 FIXME("iface %p, flags %#lx stub!\n", iface
, flags
);
1365 static HRESULT WINAPI
d3drm_texture3_GetSurface(IDirect3DRMTexture3
*iface
,
1366 DWORD flags
, IDirectDrawSurface
**surface
)
1368 struct d3drm_texture
*texture
= impl_from_IDirect3DRMTexture3(iface
);
1370 TRACE("iface %p, flags %#lx, surface %p.\n", iface
, flags
, surface
);
1373 FIXME("unexpected flags %#lx.\n", flags
);
1376 return D3DRMERR_BADVALUE
;
1379 return D3DRMERR_NOTCREATEDFROMDDS
;
1381 *surface
= texture
->surface
;
1382 IDirectDrawSurface_AddRef(*surface
);
1387 static HRESULT WINAPI
d3drm_texture3_SetCacheOptions(IDirect3DRMTexture3
*iface
, LONG importance
, DWORD flags
)
1389 FIXME("iface %p, importance %ld, flags %#lx stub!\n", iface
, importance
, flags
);
1394 static HRESULT WINAPI
d3drm_texture3_GetCacheOptions(IDirect3DRMTexture3
*iface
,
1395 LONG
*importance
, DWORD
*flags
)
1397 FIXME("iface %p, importance %p, flags %p stub!\n", iface
, importance
, flags
);
1402 static HRESULT WINAPI
d3drm_texture3_SetDownsampleCallback(IDirect3DRMTexture3
*iface
,
1403 D3DRMDOWNSAMPLECALLBACK cb
, void *ctx
)
1405 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1410 static HRESULT WINAPI
d3drm_texture3_SetValidationCallback(IDirect3DRMTexture3
*iface
,
1411 D3DRMVALIDATIONCALLBACK cb
, void *ctx
)
1413 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1418 static const struct IDirect3DRMTexture3Vtbl d3drm_texture3_vtbl
=
1420 d3drm_texture3_QueryInterface
,
1421 d3drm_texture3_AddRef
,
1422 d3drm_texture3_Release
,
1423 d3drm_texture3_Clone
,
1424 d3drm_texture3_AddDestroyCallback
,
1425 d3drm_texture3_DeleteDestroyCallback
,
1426 d3drm_texture3_SetAppData
,
1427 d3drm_texture3_GetAppData
,
1428 d3drm_texture3_SetName
,
1429 d3drm_texture3_GetName
,
1430 d3drm_texture3_GetClassName
,
1431 d3drm_texture3_InitFromFile
,
1432 d3drm_texture3_InitFromSurface
,
1433 d3drm_texture3_InitFromResource
,
1434 d3drm_texture3_Changed
,
1435 d3drm_texture3_SetColors
,
1436 d3drm_texture3_SetShades
,
1437 d3drm_texture3_SetDecalSize
,
1438 d3drm_texture3_SetDecalOrigin
,
1439 d3drm_texture3_SetDecalScale
,
1440 d3drm_texture3_SetDecalTransparency
,
1441 d3drm_texture3_SetDecalTransparentColor
,
1442 d3drm_texture3_GetDecalSize
,
1443 d3drm_texture3_GetDecalOrigin
,
1444 d3drm_texture3_GetImage
,
1445 d3drm_texture3_GetShades
,
1446 d3drm_texture3_GetColors
,
1447 d3drm_texture3_GetDecalScale
,
1448 d3drm_texture3_GetDecalTransparency
,
1449 d3drm_texture3_GetDecalTransparentColor
,
1450 d3drm_texture3_InitFromImage
,
1451 d3drm_texture3_InitFromResource2
,
1452 d3drm_texture3_GenerateMIPMap
,
1453 d3drm_texture3_GetSurface
,
1454 d3drm_texture3_SetCacheOptions
,
1455 d3drm_texture3_GetCacheOptions
,
1456 d3drm_texture3_SetDownsampleCallback
,
1457 d3drm_texture3_SetValidationCallback
,
1460 HRESULT
d3drm_texture_create(struct d3drm_texture
**texture
, IDirect3DRM
*d3drm
)
1462 static const char classname
[] = "Texture";
1463 struct d3drm_texture
*object
;
1465 TRACE("texture %p.\n", texture
);
1467 if (!(object
= calloc(1, sizeof(*object
))))
1468 return E_OUTOFMEMORY
;
1470 object
->IDirect3DRMTexture_iface
.lpVtbl
= &d3drm_texture1_vtbl
;
1471 object
->IDirect3DRMTexture2_iface
.lpVtbl
= &d3drm_texture2_vtbl
;
1472 object
->IDirect3DRMTexture3_iface
.lpVtbl
= &d3drm_texture3_vtbl
;
1473 object
->d3drm
= d3drm
;
1474 object
->max_colors
= 8;
1475 object
->max_shades
= 16;
1476 object
->transparency
= FALSE
;
1477 object
->decal_width
= 1.0f
;
1478 object
->decal_height
= 1.0f
;
1480 d3drm_object_init(&object
->obj
, classname
);