1 /* 2 * Implementation of IDirect3DRMDevice Interface 3 * 4 * Copyright 2011, 2012 André Hentschel 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #include "d3drm_private.h" 22 23 WINE_DEFAULT_DEBUG_CHANNEL(d3drm); 24 25 static inline struct d3drm_device *impl_from_IDirect3DRMDevice(IDirect3DRMDevice *iface) 26 { 27 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice_iface); 28 } 29 30 static inline struct d3drm_device *impl_from_IDirect3DRMDevice2(IDirect3DRMDevice2 *iface) 31 { 32 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice2_iface); 33 } 34 35 static inline struct d3drm_device *impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) 36 { 37 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice3_iface); 38 } 39 40 void d3drm_device_destroy(struct d3drm_device *device) 41 { 42 d3drm_object_cleanup((IDirect3DRMObject *)&device->IDirect3DRMDevice_iface, &device->obj); 43 if (device->device) 44 { 45 TRACE("Releasing attached ddraw interfaces.\n"); 46 IDirect3DDevice_Release(device->device); 47 } 48 if (device->render_target) 49 IDirectDrawSurface_Release(device->render_target); 50 if (device->primary_surface) 51 { 52 TRACE("Releasing primary surface and attached clipper.\n"); 53 IDirectDrawSurface_Release(device->primary_surface); 54 IDirectDrawClipper_Release(device->clipper); 55 } 56 if (device->ddraw) 57 { 58 IDirectDraw_Release(device->ddraw); 59 IDirect3DRM_Release(device->d3drm); 60 } 61 heap_free(device); 62 } 63 64 static inline struct d3drm_device *impl_from_IDirect3DRMWinDevice(IDirect3DRMWinDevice *iface) 65 { 66 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMWinDevice_iface); 67 } 68 69 HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) 70 { 71 DDSURFACEDESC surface_desc; 72 IDirectDrawSurface *primary_surface, *render_target; 73 HWND window; 74 HRESULT hr; 75 76 hr = IDirectDrawClipper_GetHWnd(clipper, &window); 77 if (FAILED(hr)) 78 return hr; 79 80 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); 81 if (FAILED(hr)) 82 return hr; 83 84 memset(&surface_desc, 0, sizeof(surface_desc)); 85 surface_desc.dwSize = sizeof(surface_desc); 86 surface_desc.dwFlags = DDSD_CAPS; 87 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; 88 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary_surface, NULL); 89 if (FAILED(hr)) 90 return hr; 91 hr = IDirectDrawSurface_SetClipper(primary_surface, clipper); 92 if (FAILED(hr)) 93 { 94 IDirectDrawSurface_Release(primary_surface); 95 return hr; 96 } 97 98 memset(&surface_desc, 0, sizeof(surface_desc)); 99 surface_desc.dwSize = sizeof(surface_desc); 100 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; 101 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; 102 surface_desc.dwWidth = width; 103 surface_desc.dwHeight = height; 104 105 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &render_target, NULL); 106 if (FAILED(hr)) 107 { 108 IDirectDrawSurface_Release(primary_surface); 109 return hr; 110 } 111 112 object->primary_surface = primary_surface; 113 object->clipper = clipper; 114 IDirectDrawClipper_AddRef(clipper); 115 *surface = render_target; 116 117 return D3DRM_OK; 118 } 119 120 HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw, IDirectDrawSurface *surface, 121 BOOL create_z_surface) 122 { 123 DDSCAPS caps = { DDSCAPS_ZBUFFER }; 124 IDirectDrawSurface *ds = NULL; 125 IDirect3DDevice *device1 = NULL; 126 IDirect3DDevice2 *device2 = NULL; 127 IDirect3D2 *d3d2 = NULL; 128 DDSURFACEDESC desc, surface_desc; 129 HRESULT hr; 130 131 device->ddraw = ddraw; 132 IDirectDraw_AddRef(ddraw); 133 IDirect3DRM_AddRef(device->d3drm); 134 device->render_target = surface; 135 IDirectDrawSurface_AddRef(surface); 136 137 desc.dwSize = sizeof(desc); 138 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc); 139 if (FAILED(hr)) 140 return hr; 141 142 if (!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE)) 143 return DDERR_INVALIDCAPS; 144 145 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds); 146 if (SUCCEEDED(hr)) 147 { 148 create_z_surface = FALSE; 149 IDirectDrawSurface_Release(ds); 150 ds = NULL; 151 } 152 153 if (create_z_surface) 154 { 155 memset(&surface_desc, 0, sizeof(surface_desc)); 156 surface_desc.dwSize = sizeof(surface_desc); 157 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT; 158 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; 159 surface_desc.u2.dwZBufferBitDepth = 16; 160 surface_desc.dwWidth = desc.dwWidth; 161 surface_desc.dwHeight = desc.dwHeight; 162 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &ds, NULL); 163 if (FAILED(hr)) 164 return hr; 165 166 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds); 167 IDirectDrawSurface_Release(ds); 168 if (FAILED(hr)) 169 return hr; 170 } 171 172 if (version == 1) 173 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DRGBDevice, (void **)&device1); 174 else 175 { 176 IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D2, (void**)&d3d2); 177 hr = IDirect3D2_CreateDevice(d3d2, &IID_IDirect3DRGBDevice, surface, &device2); 178 IDirect3D2_Release(d3d2); 179 } 180 if (FAILED(hr)) 181 { 182 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds); 183 return hr; 184 } 185 186 if (version != 1) 187 { 188 hr = IDirect3DDevice2_QueryInterface(device2, &IID_IDirect3DDevice, (void**)&device1); 189 IDirect3DDevice2_Release(device2); 190 if (FAILED(hr)) 191 { 192 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds); 193 return hr; 194 } 195 } 196 device->device = device1; 197 device->width = desc.dwWidth; 198 device->height = desc.dwHeight; 199 200 return hr; 201 } 202 203 static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device) 204 { 205 IDirectDraw *ddraw; 206 IDirectDrawSurface *surface; 207 IDirect3DDevice2 *d3d_device2 = NULL; 208 DDSURFACEDESC desc; 209 HRESULT hr; 210 211 /* AddRef these interfaces beforehand for the intentional leak on reinitialization. */ 212 if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&ddraw))) 213 return hr; 214 IDirect3DRM_AddRef(device->d3drm); 215 IDirect3DDevice_AddRef(d3d_device); 216 217 /* Fetch render target and get width/height from there */ 218 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface))) 219 { 220 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirect3DDevice2, (void **)&d3d_device2))) 221 return hr; 222 hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface); 223 IDirect3DDevice2_Release(d3d_device2); 224 if (FAILED(hr)) 225 return hr; 226 } 227 228 if (device->ddraw) 229 { 230 if (d3d_device2) 231 IDirectDrawSurface_Release(surface); 232 return D3DRMERR_BADOBJECT; 233 } 234 235 desc.dwSize = sizeof(desc); 236 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc); 237 if (FAILED(hr)) 238 { 239 IDirectDrawSurface_Release(surface); 240 return hr; 241 } 242 243 device->ddraw = ddraw; 244 device->width = desc.dwWidth; 245 device->height = desc.dwHeight; 246 device->device = d3d_device; 247 device->render_target = surface; 248 249 return hr; 250 } 251 252 static HRESULT WINAPI d3drm_device3_QueryInterface(IDirect3DRMDevice3 *iface, REFIID riid, void **out) 253 { 254 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 255 256 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); 257 258 if (IsEqualGUID(riid, &IID_IDirect3DRMDevice) 259 || IsEqualGUID(riid, &IID_IDirect3DRMObject) 260 || IsEqualGUID(riid, &IID_IUnknown)) 261 { 262 *out = &device->IDirect3DRMDevice_iface; 263 } 264 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice2)) 265 { 266 *out = &device->IDirect3DRMDevice2_iface; 267 } 268 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice3)) 269 { 270 *out = &device->IDirect3DRMDevice3_iface; 271 } 272 else if (IsEqualGUID(riid, &IID_IDirect3DRMWinDevice)) 273 { 274 *out = &device->IDirect3DRMWinDevice_iface; 275 } 276 else 277 { 278 *out = NULL; 279 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid)); 280 return CLASS_E_CLASSNOTAVAILABLE; 281 } 282 283 IUnknown_AddRef((IUnknown *)*out); 284 return S_OK; 285 } 286 287 static HRESULT WINAPI d3drm_device2_QueryInterface(IDirect3DRMDevice2 *iface, REFIID riid, void **out) 288 { 289 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 290 291 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); 292 293 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out); 294 } 295 296 static HRESULT WINAPI d3drm_device1_QueryInterface(IDirect3DRMDevice *iface, REFIID riid, void **out) 297 { 298 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 299 300 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); 301 302 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out); 303 } 304 305 static ULONG WINAPI d3drm_device3_AddRef(IDirect3DRMDevice3 *iface) 306 { 307 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 308 ULONG refcount = InterlockedIncrement(&device->obj.ref); 309 310 TRACE("%p increasing refcount to %u.\n", iface, refcount); 311 312 return refcount; 313 } 314 315 static ULONG WINAPI d3drm_device2_AddRef(IDirect3DRMDevice2 *iface) 316 { 317 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 318 319 TRACE("iface %p.\n", iface); 320 321 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface); 322 } 323 324 static ULONG WINAPI d3drm_device1_AddRef(IDirect3DRMDevice *iface) 325 { 326 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 327 328 TRACE("iface %p.\n", iface); 329 330 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface); 331 } 332 333 static ULONG WINAPI d3drm_device3_Release(IDirect3DRMDevice3 *iface) 334 { 335 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 336 ULONG refcount = InterlockedDecrement(&device->obj.ref); 337 338 TRACE("%p decreasing refcount to %u.\n", iface, refcount); 339 340 if (!refcount) 341 d3drm_device_destroy(device); 342 343 return refcount; 344 } 345 346 static ULONG WINAPI d3drm_device2_Release(IDirect3DRMDevice2 *iface) 347 { 348 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 349 350 TRACE("iface %p.\n", iface); 351 352 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface); 353 } 354 355 static ULONG WINAPI d3drm_device1_Release(IDirect3DRMDevice *iface) 356 { 357 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 358 359 TRACE("iface %p.\n", iface); 360 361 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface); 362 } 363 364 static HRESULT WINAPI d3drm_device3_Clone(IDirect3DRMDevice3 *iface, 365 IUnknown *outer, REFIID iid, void **out) 366 { 367 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out); 368 369 return E_NOTIMPL; 370 } 371 372 static HRESULT WINAPI d3drm_device2_Clone(IDirect3DRMDevice2 *iface, 373 IUnknown *outer, REFIID iid, void **out) 374 { 375 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 376 377 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out); 378 379 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out); 380 } 381 382 static HRESULT WINAPI d3drm_device1_Clone(IDirect3DRMDevice *iface, 383 IUnknown *outer, REFIID iid, void **out) 384 { 385 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 386 387 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out); 388 389 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out); 390 } 391 392 static HRESULT WINAPI d3drm_device3_AddDestroyCallback(IDirect3DRMDevice3 *iface, 393 D3DRMOBJECTCALLBACK cb, void *ctx) 394 { 395 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 396 397 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx); 398 399 return d3drm_object_add_destroy_callback(&device->obj, cb, ctx); 400 } 401 402 static HRESULT WINAPI d3drm_device2_AddDestroyCallback(IDirect3DRMDevice2 *iface, 403 D3DRMOBJECTCALLBACK cb, void *ctx) 404 { 405 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 406 407 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx); 408 409 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx); 410 } 411 412 static HRESULT WINAPI d3drm_device1_AddDestroyCallback(IDirect3DRMDevice *iface, 413 D3DRMOBJECTCALLBACK cb, void *ctx) 414 { 415 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 416 417 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx); 418 419 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx); 420 } 421 422 static HRESULT WINAPI d3drm_device3_DeleteDestroyCallback(IDirect3DRMDevice3 *iface, 423 D3DRMOBJECTCALLBACK cb, void *ctx) 424 { 425 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 426 427 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx); 428 429 return d3drm_object_delete_destroy_callback(&device->obj, cb, ctx); 430 } 431 432 static HRESULT WINAPI d3drm_device2_DeleteDestroyCallback(IDirect3DRMDevice2 *iface, 433 D3DRMOBJECTCALLBACK cb, void *ctx) 434 { 435 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 436 437 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx); 438 439 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx); 440 } 441 442 static HRESULT WINAPI d3drm_device1_DeleteDestroyCallback(IDirect3DRMDevice *iface, 443 D3DRMOBJECTCALLBACK cb, void *ctx) 444 { 445 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 446 447 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx); 448 449 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx); 450 } 451 452 static HRESULT WINAPI d3drm_device3_SetAppData(IDirect3DRMDevice3 *iface, DWORD data) 453 { 454 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 455 456 TRACE("iface %p, data %#x.\n", iface, data); 457 458 device->obj.appdata = data; 459 460 return D3DRM_OK; 461 } 462 463 static HRESULT WINAPI d3drm_device2_SetAppData(IDirect3DRMDevice2 *iface, DWORD data) 464 { 465 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 466 467 TRACE("iface %p, data %#x.\n", iface, data); 468 469 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data); 470 } 471 472 static HRESULT WINAPI d3drm_device1_SetAppData(IDirect3DRMDevice *iface, DWORD data) 473 { 474 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 475 476 TRACE("iface %p, data %#x.\n", iface, data); 477 478 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data); 479 } 480 481 static DWORD WINAPI d3drm_device3_GetAppData(IDirect3DRMDevice3 *iface) 482 { 483 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 484 485 TRACE("iface %p.\n", iface); 486 487 return device->obj.appdata; 488 } 489 490 static DWORD WINAPI d3drm_device2_GetAppData(IDirect3DRMDevice2 *iface) 491 { 492 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 493 494 TRACE("iface %p.\n", iface); 495 496 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface); 497 } 498 499 static DWORD WINAPI d3drm_device1_GetAppData(IDirect3DRMDevice *iface) 500 { 501 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 502 503 TRACE("iface %p.\n", iface); 504 505 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface); 506 } 507 508 static HRESULT WINAPI d3drm_device3_SetName(IDirect3DRMDevice3 *iface, const char *name) 509 { 510 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 511 512 TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); 513 514 return d3drm_object_set_name(&device->obj, name); 515 } 516 517 static HRESULT WINAPI d3drm_device2_SetName(IDirect3DRMDevice2 *iface, const char *name) 518 { 519 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 520 521 TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); 522 523 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name); 524 } 525 526 static HRESULT WINAPI d3drm_device1_SetName(IDirect3DRMDevice *iface, const char *name) 527 { 528 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 529 530 TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); 531 532 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name); 533 } 534 535 static HRESULT WINAPI d3drm_device3_GetName(IDirect3DRMDevice3 *iface, DWORD *size, char *name) 536 { 537 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 538 539 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 540 541 return d3drm_object_get_name(&device->obj, size, name); 542 } 543 544 static HRESULT WINAPI d3drm_device2_GetName(IDirect3DRMDevice2 *iface, DWORD *size, char *name) 545 { 546 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 547 548 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 549 550 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name); 551 } 552 553 static HRESULT WINAPI d3drm_device1_GetName(IDirect3DRMDevice *iface, DWORD *size, char *name) 554 { 555 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 556 557 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 558 559 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name); 560 } 561 562 static HRESULT WINAPI d3drm_device3_GetClassName(IDirect3DRMDevice3 *iface, DWORD *size, char *name) 563 { 564 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 565 566 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 567 568 return d3drm_object_get_class_name(&device->obj, size, name); 569 } 570 571 static HRESULT WINAPI d3drm_device2_GetClassName(IDirect3DRMDevice2 *iface, DWORD *size, char *name) 572 { 573 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 574 575 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 576 577 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name); 578 } 579 580 static HRESULT WINAPI d3drm_device1_GetClassName(IDirect3DRMDevice *iface, DWORD *size, char *name) 581 { 582 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 583 584 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 585 586 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name); 587 } 588 589 static HRESULT WINAPI d3drm_device3_Init(IDirect3DRMDevice3 *iface, ULONG width, ULONG height) 590 { 591 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 592 593 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height); 594 595 device->height = height; 596 device->width = width; 597 598 return D3DRM_OK; 599 } 600 601 static HRESULT WINAPI d3drm_device2_Init(IDirect3DRMDevice2 *iface, ULONG width, ULONG height) 602 { 603 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 604 605 TRACE("iface %p, width %u, height %u.\n", iface, width, height); 606 607 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height); 608 } 609 610 static HRESULT WINAPI d3drm_device1_Init(IDirect3DRMDevice *iface, ULONG width, ULONG height) 611 { 612 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 613 614 TRACE("iface %p, width %u, height %u.\n", iface, width, height); 615 616 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height); 617 } 618 619 static HRESULT WINAPI d3drm_device3_InitFromD3D(IDirect3DRMDevice3 *iface, 620 IDirect3D *d3d, IDirect3DDevice *d3d_device) 621 { 622 FIXME("iface %p, d3d %p, d3d_device %p stub!\n", iface, d3d, d3d_device); 623 624 if (!d3d || !d3d_device) 625 return D3DRMERR_BADVALUE; 626 627 return E_NOINTERFACE; 628 } 629 630 static HRESULT WINAPI d3drm_device2_InitFromD3D(IDirect3DRMDevice2 *iface, 631 IDirect3D *d3d, IDirect3DDevice *d3d_device) 632 { 633 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 634 635 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device); 636 637 return d3drm_device3_InitFromD3D(&device->IDirect3DRMDevice3_iface, d3d, d3d_device); 638 } 639 640 static HRESULT WINAPI d3drm_device1_InitFromD3D(IDirect3DRMDevice *iface, 641 IDirect3D *d3d, IDirect3DDevice *d3d_device) 642 { 643 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 644 645 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device); 646 647 if (!d3d || !d3d_device) 648 return D3DRMERR_BADVALUE; 649 650 return d3drm_device_set_ddraw_device_d3d(device, d3d, d3d_device); 651 } 652 653 static HRESULT WINAPI d3drm_device3_InitFromClipper(IDirect3DRMDevice3 *iface, 654 IDirectDrawClipper *clipper, GUID *guid, int width, int height) 655 { 656 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 657 658 FIXME("iface %p, clipper %p, guid %s, width %d, height %d stub!\n", 659 iface, clipper, debugstr_guid(guid), width, height); 660 661 device->height = height; 662 device->width = width; 663 664 return D3DRM_OK; 665 } 666 667 static HRESULT WINAPI d3drm_device2_InitFromClipper(IDirect3DRMDevice2 *iface, 668 IDirectDrawClipper *clipper, GUID *guid, int width, int height) 669 { 670 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 671 672 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n", 673 iface, clipper, debugstr_guid(guid), width, height); 674 675 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface, 676 clipper, guid, width, height); 677 } 678 679 static HRESULT WINAPI d3drm_device1_InitFromClipper(IDirect3DRMDevice *iface, 680 IDirectDrawClipper *clipper, GUID *guid, int width, int height) 681 { 682 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 683 684 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n", 685 iface, clipper, debugstr_guid(guid), width, height); 686 687 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface, 688 clipper, guid, width, height); 689 } 690 691 static HRESULT WINAPI d3drm_device3_Update(IDirect3DRMDevice3 *iface) 692 { 693 FIXME("iface %p stub!\n", iface); 694 695 return D3DRM_OK; 696 } 697 698 static HRESULT WINAPI d3drm_device2_Update(IDirect3DRMDevice2 *iface) 699 { 700 FIXME("iface %p stub!\n", iface); 701 702 return D3DRM_OK; 703 } 704 705 static HRESULT WINAPI d3drm_device1_Update(IDirect3DRMDevice *iface) 706 { 707 FIXME("iface %p stub!\n", iface); 708 709 return D3DRM_OK; 710 } 711 712 static HRESULT WINAPI d3drm_device3_AddUpdateCallback(IDirect3DRMDevice3 *iface, 713 D3DRMUPDATECALLBACK cb, void *ctx) 714 { 715 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 716 717 return E_NOTIMPL; 718 } 719 720 static HRESULT WINAPI d3drm_device2_AddUpdateCallback(IDirect3DRMDevice2 *iface, 721 D3DRMUPDATECALLBACK cb, void *ctx) 722 { 723 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 724 725 return E_NOTIMPL; 726 } 727 728 static HRESULT WINAPI d3drm_device1_AddUpdateCallback(IDirect3DRMDevice *iface, 729 D3DRMUPDATECALLBACK cb, void *ctx) 730 { 731 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 732 733 return E_NOTIMPL; 734 } 735 736 static HRESULT WINAPI d3drm_device3_DeleteUpdateCallback(IDirect3DRMDevice3 *iface, 737 D3DRMUPDATECALLBACK cb, void *ctx) 738 { 739 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 740 741 return E_NOTIMPL; 742 } 743 744 static HRESULT WINAPI d3drm_device2_DeleteUpdateCallback(IDirect3DRMDevice2 *iface, 745 D3DRMUPDATECALLBACK cb, void *ctx) 746 { 747 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 748 749 return E_NOTIMPL; 750 } 751 752 static HRESULT WINAPI d3drm_device1_DeleteUpdateCallback(IDirect3DRMDevice *iface, 753 D3DRMUPDATECALLBACK cb, void *ctx) 754 { 755 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 756 757 return E_NOTIMPL; 758 } 759 760 static HRESULT WINAPI d3drm_device3_SetBufferCount(IDirect3DRMDevice3 *iface, DWORD count) 761 { 762 FIXME("iface %p, count %u stub!\n", iface, count); 763 764 return E_NOTIMPL; 765 } 766 767 static HRESULT WINAPI d3drm_device2_SetBufferCount(IDirect3DRMDevice2 *iface, DWORD count) 768 { 769 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 770 771 TRACE("iface %p, count %u.\n", iface, count); 772 773 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count); 774 } 775 776 static HRESULT WINAPI d3drm_device1_SetBufferCount(IDirect3DRMDevice *iface, DWORD count) 777 { 778 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 779 780 TRACE("iface %p, count %u.\n", iface, count); 781 782 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count); 783 } 784 785 static DWORD WINAPI d3drm_device3_GetBufferCount(IDirect3DRMDevice3 *iface) 786 { 787 FIXME("iface %p stub!\n", iface); 788 789 return E_NOTIMPL; 790 } 791 792 static DWORD WINAPI d3drm_device2_GetBufferCount(IDirect3DRMDevice2 *iface) 793 { 794 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 795 796 TRACE("iface %p.\n", iface); 797 798 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface); 799 } 800 801 static DWORD WINAPI d3drm_device1_GetBufferCount(IDirect3DRMDevice *iface) 802 { 803 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 804 805 TRACE("iface %p.\n", iface); 806 807 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface); 808 } 809 810 static HRESULT WINAPI d3drm_device3_SetDither(IDirect3DRMDevice3 *iface, BOOL enable) 811 { 812 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 813 814 TRACE("iface %p, enable %#x.\n", iface, enable); 815 816 device->dither = enable; 817 818 return D3DRM_OK; 819 } 820 821 static HRESULT WINAPI d3drm_device2_SetDither(IDirect3DRMDevice2 *iface, BOOL enable) 822 { 823 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 824 825 TRACE("iface %p, enabled %#x.\n", iface, enable); 826 827 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable); 828 } 829 830 static HRESULT WINAPI d3drm_device1_SetDither(IDirect3DRMDevice *iface, BOOL enable) 831 { 832 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 833 834 TRACE("iface %p, enabled %#x.\n", iface, enable); 835 836 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable); 837 } 838 839 static HRESULT WINAPI d3drm_device3_SetShades(IDirect3DRMDevice3 *iface, DWORD count) 840 { 841 FIXME("iface %p, count %u stub!\n", iface, count); 842 843 return E_NOTIMPL; 844 } 845 846 static HRESULT WINAPI d3drm_device2_SetShades(IDirect3DRMDevice2 *iface, DWORD count) 847 { 848 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 849 850 TRACE("iface %p, count %u.\n", iface, count); 851 852 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count); 853 } 854 855 static HRESULT WINAPI d3drm_device1_SetShades(IDirect3DRMDevice *iface, DWORD count) 856 { 857 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 858 859 TRACE("iface %p, count %u.\n", iface, count); 860 861 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count); 862 } 863 864 static HRESULT WINAPI d3drm_device3_SetQuality(IDirect3DRMDevice3 *iface, D3DRMRENDERQUALITY quality) 865 { 866 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 867 868 TRACE("iface %p, quality %u.\n", iface, quality); 869 870 device->quality = quality; 871 872 return D3DRM_OK; 873 } 874 875 static HRESULT WINAPI d3drm_device2_SetQuality(IDirect3DRMDevice2 *iface, D3DRMRENDERQUALITY quality) 876 { 877 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 878 879 TRACE("iface %p, quality %u.\n", iface, quality); 880 881 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality); 882 } 883 884 static HRESULT WINAPI d3drm_device1_SetQuality(IDirect3DRMDevice *iface, D3DRMRENDERQUALITY quality) 885 { 886 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 887 888 TRACE("iface %p, quality %u.\n", iface, quality); 889 890 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality); 891 } 892 893 static HRESULT WINAPI d3drm_device3_SetTextureQuality(IDirect3DRMDevice3 *iface, D3DRMTEXTUREQUALITY quality) 894 { 895 FIXME("iface %p, quality %u stub!\n", iface, quality); 896 897 return E_NOTIMPL; 898 } 899 900 static HRESULT WINAPI d3drm_device2_SetTextureQuality(IDirect3DRMDevice2 *iface, D3DRMTEXTUREQUALITY quality) 901 { 902 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 903 904 TRACE("iface %p, quality %u.\n", iface, quality); 905 906 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality); 907 } 908 909 static HRESULT WINAPI d3drm_device1_SetTextureQuality(IDirect3DRMDevice *iface, D3DRMTEXTUREQUALITY quality) 910 { 911 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 912 913 TRACE("iface %p, quality %u.\n", iface, quality); 914 915 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality); 916 } 917 918 static HRESULT WINAPI d3drm_device3_GetViewports(IDirect3DRMDevice3 *iface, IDirect3DRMViewportArray **array) 919 { 920 FIXME("iface %p, array %p stub!\n", iface, array); 921 922 return E_NOTIMPL; 923 } 924 925 static HRESULT WINAPI d3drm_device2_GetViewports(IDirect3DRMDevice2 *iface, IDirect3DRMViewportArray **array) 926 { 927 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 928 929 TRACE("iface %p, array %p.\n", iface, array); 930 931 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array); 932 } 933 934 static HRESULT WINAPI d3drm_device1_GetViewports(IDirect3DRMDevice *iface, IDirect3DRMViewportArray **array) 935 { 936 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 937 938 TRACE("iface %p, array %p.\n", iface, array); 939 940 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array); 941 } 942 943 static BOOL WINAPI d3drm_device3_GetDither(IDirect3DRMDevice3 *iface) 944 { 945 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 946 947 TRACE("iface %p.\n", iface); 948 949 return device->dither; 950 } 951 952 static BOOL WINAPI d3drm_device2_GetDither(IDirect3DRMDevice2 *iface) 953 { 954 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 955 956 TRACE("iface %p.\n", iface); 957 958 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface); 959 } 960 961 static BOOL WINAPI d3drm_device1_GetDither(IDirect3DRMDevice *iface) 962 { 963 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 964 965 TRACE("iface %p.\n", iface); 966 967 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface); 968 } 969 970 static DWORD WINAPI d3drm_device3_GetShades(IDirect3DRMDevice3 *iface) 971 { 972 FIXME("iface %p stub!\n", iface); 973 974 return E_NOTIMPL; 975 } 976 977 static DWORD WINAPI d3drm_device2_GetShades(IDirect3DRMDevice2 *iface) 978 { 979 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 980 981 TRACE("iface %p.\n", iface); 982 983 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface); 984 } 985 986 static DWORD WINAPI d3drm_device1_GetShades(IDirect3DRMDevice *iface) 987 { 988 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 989 990 TRACE("iface %p.\n", iface); 991 992 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface); 993 } 994 995 static DWORD WINAPI d3drm_device3_GetHeight(IDirect3DRMDevice3 *iface) 996 { 997 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 998 999 TRACE("iface %p.\n", iface); 1000 1001 return device->height; 1002 } 1003 1004 static DWORD WINAPI d3drm_device2_GetHeight(IDirect3DRMDevice2 *iface) 1005 { 1006 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1007 1008 TRACE("iface %p.\n", iface); 1009 1010 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface); 1011 } 1012 1013 static DWORD WINAPI d3drm_device1_GetHeight(IDirect3DRMDevice *iface) 1014 { 1015 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1016 1017 TRACE("iface %p.\n", iface); 1018 1019 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface); 1020 } 1021 1022 static DWORD WINAPI d3drm_device3_GetWidth(IDirect3DRMDevice3 *iface) 1023 { 1024 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1025 1026 TRACE("iface %p.\n", iface); 1027 1028 return device->width; 1029 } 1030 1031 static DWORD WINAPI d3drm_device2_GetWidth(IDirect3DRMDevice2 *iface) 1032 { 1033 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1034 1035 TRACE("iface %p.\n", iface); 1036 1037 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface); 1038 } 1039 1040 static DWORD WINAPI d3drm_device1_GetWidth(IDirect3DRMDevice *iface) 1041 { 1042 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1043 1044 TRACE("iface %p.\n", iface); 1045 1046 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface); 1047 } 1048 1049 static DWORD WINAPI d3drm_device3_GetTrianglesDrawn(IDirect3DRMDevice3 *iface) 1050 { 1051 FIXME("iface %p stub!\n", iface); 1052 1053 return E_NOTIMPL; 1054 } 1055 1056 static DWORD WINAPI d3drm_device2_GetTrianglesDrawn(IDirect3DRMDevice2 *iface) 1057 { 1058 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1059 1060 TRACE("iface %p.\n", iface); 1061 1062 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface); 1063 } 1064 1065 static DWORD WINAPI d3drm_device1_GetTrianglesDrawn(IDirect3DRMDevice *iface) 1066 { 1067 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1068 1069 TRACE("iface %p.\n", iface); 1070 1071 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface); 1072 } 1073 1074 static DWORD WINAPI d3drm_device3_GetWireframeOptions(IDirect3DRMDevice3 *iface) 1075 { 1076 FIXME("iface %p stub!\n", iface); 1077 1078 return E_NOTIMPL; 1079 } 1080 1081 static DWORD WINAPI d3drm_device2_GetWireframeOptions(IDirect3DRMDevice2 *iface) 1082 { 1083 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1084 1085 TRACE("iface %p.\n", iface); 1086 1087 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface); 1088 } 1089 1090 static DWORD WINAPI d3drm_device1_GetWireframeOptions(IDirect3DRMDevice *iface) 1091 { 1092 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1093 1094 TRACE("iface %p.\n", iface); 1095 1096 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface); 1097 } 1098 1099 static D3DRMRENDERQUALITY WINAPI d3drm_device3_GetQuality(IDirect3DRMDevice3 *iface) 1100 { 1101 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1102 1103 TRACE("iface %p.\n", iface); 1104 1105 return device->quality; 1106 } 1107 1108 static D3DRMRENDERQUALITY WINAPI d3drm_device2_GetQuality(IDirect3DRMDevice2 *iface) 1109 { 1110 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1111 1112 TRACE("iface %p.\n", iface); 1113 1114 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface); 1115 } 1116 1117 static D3DRMRENDERQUALITY WINAPI d3drm_device1_GetQuality(IDirect3DRMDevice *iface) 1118 { 1119 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1120 1121 TRACE("iface %p.\n", iface); 1122 1123 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface); 1124 } 1125 1126 static D3DCOLORMODEL WINAPI d3drm_device3_GetColorModel(IDirect3DRMDevice3 *iface) 1127 { 1128 FIXME("iface %p stub!\n", iface); 1129 1130 return E_NOTIMPL; 1131 } 1132 1133 static D3DCOLORMODEL WINAPI d3drm_device2_GetColorModel(IDirect3DRMDevice2 *iface) 1134 { 1135 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1136 1137 TRACE("iface %p.\n", iface); 1138 1139 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface); 1140 } 1141 1142 static D3DCOLORMODEL WINAPI d3drm_device1_GetColorModel(IDirect3DRMDevice *iface) 1143 { 1144 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1145 1146 TRACE("iface %p.\n", iface); 1147 1148 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface); 1149 } 1150 1151 static D3DRMTEXTUREQUALITY WINAPI d3drm_device3_GetTextureQuality(IDirect3DRMDevice3 *iface) 1152 { 1153 FIXME("iface %p stub!\n", iface); 1154 1155 return E_NOTIMPL; 1156 } 1157 1158 static D3DRMTEXTUREQUALITY WINAPI d3drm_device2_GetTextureQuality(IDirect3DRMDevice2 *iface) 1159 { 1160 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1161 1162 TRACE("iface %p.\n", iface); 1163 1164 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface); 1165 } 1166 1167 static D3DRMTEXTUREQUALITY WINAPI d3drm_device1_GetTextureQuality(IDirect3DRMDevice *iface) 1168 { 1169 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1170 1171 TRACE("iface %p.\n", iface); 1172 1173 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface); 1174 } 1175 1176 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice(IDirect3DRMDevice3 *iface, IDirect3DDevice **d3d_device) 1177 { 1178 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1179 TRACE("iface %p, d3d_device %p!\n", iface, d3d_device); 1180 1181 *d3d_device = device->device; 1182 IDirect3DDevice_AddRef(*d3d_device); 1183 1184 return D3DRM_OK; 1185 } 1186 1187 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice(IDirect3DRMDevice2 *iface, IDirect3DDevice **d3d_device) 1188 { 1189 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1190 1191 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device); 1192 1193 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device); 1194 } 1195 1196 static HRESULT WINAPI d3drm_device1_GetDirect3DDevice(IDirect3DRMDevice *iface, IDirect3DDevice **d3d_device) 1197 { 1198 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); 1199 1200 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device); 1201 1202 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device); 1203 } 1204 1205 static HRESULT WINAPI d3drm_device3_InitFromD3D2(IDirect3DRMDevice3 *iface, 1206 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device) 1207 { 1208 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1209 IDirect3D *d3d1; 1210 IDirect3DDevice *d3d_device1; 1211 HRESULT hr; 1212 1213 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device); 1214 1215 if (!d3d || !d3d_device) 1216 return D3DRMERR_BADVALUE; 1217 1218 if (FAILED(hr = IDirect3D2_QueryInterface(d3d, &IID_IDirect3D, (void **)&d3d1))) 1219 return hr; 1220 if (FAILED(hr = IDirect3DDevice2_QueryInterface(d3d_device, &IID_IDirect3DDevice, (void **)&d3d_device1))) 1221 { 1222 IDirect3D_Release(d3d1); 1223 return hr; 1224 } 1225 1226 hr = d3drm_device_set_ddraw_device_d3d(device, d3d1, d3d_device1); 1227 IDirect3D_Release(d3d1); 1228 IDirect3DDevice_Release(d3d_device1); 1229 1230 return hr; 1231 } 1232 1233 static HRESULT WINAPI d3drm_device2_InitFromD3D2(IDirect3DRMDevice2 *iface, 1234 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device) 1235 { 1236 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1237 1238 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device); 1239 1240 return d3drm_device3_InitFromD3D2(&device->IDirect3DRMDevice3_iface, d3d, d3d_device); 1241 } 1242 1243 static HRESULT WINAPI d3drm_device3_InitFromSurface(IDirect3DRMDevice3 *iface, 1244 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer) 1245 { 1246 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p stub!\n", 1247 iface, debugstr_guid(guid), ddraw, backbuffer); 1248 1249 return E_NOTIMPL; 1250 } 1251 1252 static HRESULT WINAPI d3drm_device2_InitFromSurface(IDirect3DRMDevice2 *iface, 1253 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer) 1254 { 1255 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1256 1257 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p.\n", 1258 iface, debugstr_guid(guid), ddraw, backbuffer); 1259 1260 return d3drm_device3_InitFromSurface(&device->IDirect3DRMDevice3_iface, guid, ddraw, backbuffer); 1261 } 1262 1263 static HRESULT WINAPI d3drm_device3_SetRenderMode(IDirect3DRMDevice3 *iface, DWORD flags) 1264 { 1265 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1266 1267 TRACE("iface %p, flags %#x.\n", iface, flags); 1268 1269 device->rendermode = flags; 1270 1271 return D3DRM_OK; 1272 } 1273 1274 static HRESULT WINAPI d3drm_device2_SetRenderMode(IDirect3DRMDevice2 *iface, DWORD flags) 1275 { 1276 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1277 1278 TRACE("iface %p, flags %#x.\n", iface, flags); 1279 1280 return d3drm_device3_SetRenderMode(&device->IDirect3DRMDevice3_iface, flags); 1281 } 1282 1283 static DWORD WINAPI d3drm_device3_GetRenderMode(IDirect3DRMDevice3 *iface) 1284 { 1285 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1286 1287 TRACE("iface %p.\n", iface); 1288 1289 return device->rendermode; 1290 } 1291 1292 static DWORD WINAPI d3drm_device2_GetRenderMode(IDirect3DRMDevice2 *iface) 1293 { 1294 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1295 1296 TRACE("iface %p.\n", iface); 1297 1298 return d3drm_device3_GetRenderMode(&device->IDirect3DRMDevice3_iface); 1299 } 1300 1301 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice2(IDirect3DRMDevice3 *iface, IDirect3DDevice2 **d3d_device) 1302 { 1303 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); 1304 1305 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device); 1306 1307 if (FAILED(IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device))) 1308 return D3DRMERR_BADOBJECT; 1309 1310 return D3DRM_OK; 1311 } 1312 1313 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice2(IDirect3DRMDevice2 *iface, IDirect3DDevice2 **d3d_device) 1314 { 1315 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface); 1316 1317 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device); 1318 1319 IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device); 1320 1321 /* d3drm returns D3DRM_OK even if the call fails. */ 1322 return D3DRM_OK; 1323 } 1324 1325 static HRESULT WINAPI d3drm_device3_FindPreferredTextureFormat(IDirect3DRMDevice3 *iface, 1326 DWORD bitdepths, DWORD flags, DDPIXELFORMAT *pf) 1327 { 1328 FIXME("iface %p, bitdepths %u, flags %#x, pf %p stub!\n", iface, bitdepths, flags, pf); 1329 1330 return E_NOTIMPL; 1331 } 1332 1333 static HRESULT WINAPI d3drm_device3_RenderStateChange(IDirect3DRMDevice3 *iface, 1334 D3DRENDERSTATETYPE state, DWORD value, DWORD flags) 1335 { 1336 FIXME("iface %p, state %#x, value %#x, flags %#x stub!\n", iface, state, value, flags); 1337 1338 return E_NOTIMPL; 1339 } 1340 1341 static HRESULT WINAPI d3drm_device3_LightStateChange(IDirect3DRMDevice3 *iface, 1342 D3DLIGHTSTATETYPE state, DWORD value, DWORD flags) 1343 { 1344 FIXME("iface %p, state %#x, value %#x, flags %#x stub!\n", iface, state, value, flags); 1345 1346 return E_NOTIMPL; 1347 } 1348 1349 static HRESULT WINAPI d3drm_device3_GetStateChangeOptions(IDirect3DRMDevice3 *iface, 1350 DWORD state_class, DWORD state_idx, DWORD *flags) 1351 { 1352 FIXME("iface %p, state_class %#x, state_idx %#x, flags %p stub!\n", 1353 iface, state_class, state_idx, flags); 1354 1355 return E_NOTIMPL; 1356 } 1357 1358 static HRESULT WINAPI d3drm_device3_SetStateChangeOptions(IDirect3DRMDevice3 *iface, 1359 DWORD state_class, DWORD state_idx, DWORD flags) 1360 { 1361 FIXME("iface %p, state_class %#x, state_idx %#x, flags %#x stub!\n", 1362 iface, state_class, state_idx, flags); 1363 1364 return E_NOTIMPL; 1365 } 1366 1367 static const struct IDirect3DRMDevice3Vtbl d3drm_device3_vtbl = 1368 { 1369 d3drm_device3_QueryInterface, 1370 d3drm_device3_AddRef, 1371 d3drm_device3_Release, 1372 d3drm_device3_Clone, 1373 d3drm_device3_AddDestroyCallback, 1374 d3drm_device3_DeleteDestroyCallback, 1375 d3drm_device3_SetAppData, 1376 d3drm_device3_GetAppData, 1377 d3drm_device3_SetName, 1378 d3drm_device3_GetName, 1379 d3drm_device3_GetClassName, 1380 d3drm_device3_Init, 1381 d3drm_device3_InitFromD3D, 1382 d3drm_device3_InitFromClipper, 1383 d3drm_device3_Update, 1384 d3drm_device3_AddUpdateCallback, 1385 d3drm_device3_DeleteUpdateCallback, 1386 d3drm_device3_SetBufferCount, 1387 d3drm_device3_GetBufferCount, 1388 d3drm_device3_SetDither, 1389 d3drm_device3_SetShades, 1390 d3drm_device3_SetQuality, 1391 d3drm_device3_SetTextureQuality, 1392 d3drm_device3_GetViewports, 1393 d3drm_device3_GetDither, 1394 d3drm_device3_GetShades, 1395 d3drm_device3_GetHeight, 1396 d3drm_device3_GetWidth, 1397 d3drm_device3_GetTrianglesDrawn, 1398 d3drm_device3_GetWireframeOptions, 1399 d3drm_device3_GetQuality, 1400 d3drm_device3_GetColorModel, 1401 d3drm_device3_GetTextureQuality, 1402 d3drm_device3_GetDirect3DDevice, 1403 d3drm_device3_InitFromD3D2, 1404 d3drm_device3_InitFromSurface, 1405 d3drm_device3_SetRenderMode, 1406 d3drm_device3_GetRenderMode, 1407 d3drm_device3_GetDirect3DDevice2, 1408 d3drm_device3_FindPreferredTextureFormat, 1409 d3drm_device3_RenderStateChange, 1410 d3drm_device3_LightStateChange, 1411 d3drm_device3_GetStateChangeOptions, 1412 d3drm_device3_SetStateChangeOptions, 1413 }; 1414 1415 static const struct IDirect3DRMDevice2Vtbl d3drm_device2_vtbl = 1416 { 1417 d3drm_device2_QueryInterface, 1418 d3drm_device2_AddRef, 1419 d3drm_device2_Release, 1420 d3drm_device2_Clone, 1421 d3drm_device2_AddDestroyCallback, 1422 d3drm_device2_DeleteDestroyCallback, 1423 d3drm_device2_SetAppData, 1424 d3drm_device2_GetAppData, 1425 d3drm_device2_SetName, 1426 d3drm_device2_GetName, 1427 d3drm_device2_GetClassName, 1428 d3drm_device2_Init, 1429 d3drm_device2_InitFromD3D, 1430 d3drm_device2_InitFromClipper, 1431 d3drm_device2_Update, 1432 d3drm_device2_AddUpdateCallback, 1433 d3drm_device2_DeleteUpdateCallback, 1434 d3drm_device2_SetBufferCount, 1435 d3drm_device2_GetBufferCount, 1436 d3drm_device2_SetDither, 1437 d3drm_device2_SetShades, 1438 d3drm_device2_SetQuality, 1439 d3drm_device2_SetTextureQuality, 1440 d3drm_device2_GetViewports, 1441 d3drm_device2_GetDither, 1442 d3drm_device2_GetShades, 1443 d3drm_device2_GetHeight, 1444 d3drm_device2_GetWidth, 1445 d3drm_device2_GetTrianglesDrawn, 1446 d3drm_device2_GetWireframeOptions, 1447 d3drm_device2_GetQuality, 1448 d3drm_device2_GetColorModel, 1449 d3drm_device2_GetTextureQuality, 1450 d3drm_device2_GetDirect3DDevice, 1451 d3drm_device2_InitFromD3D2, 1452 d3drm_device2_InitFromSurface, 1453 d3drm_device2_SetRenderMode, 1454 d3drm_device2_GetRenderMode, 1455 d3drm_device2_GetDirect3DDevice2, 1456 }; 1457 1458 static const struct IDirect3DRMDeviceVtbl d3drm_device1_vtbl = 1459 { 1460 d3drm_device1_QueryInterface, 1461 d3drm_device1_AddRef, 1462 d3drm_device1_Release, 1463 d3drm_device1_Clone, 1464 d3drm_device1_AddDestroyCallback, 1465 d3drm_device1_DeleteDestroyCallback, 1466 d3drm_device1_SetAppData, 1467 d3drm_device1_GetAppData, 1468 d3drm_device1_SetName, 1469 d3drm_device1_GetName, 1470 d3drm_device1_GetClassName, 1471 d3drm_device1_Init, 1472 d3drm_device1_InitFromD3D, 1473 d3drm_device1_InitFromClipper, 1474 d3drm_device1_Update, 1475 d3drm_device1_AddUpdateCallback, 1476 d3drm_device1_DeleteUpdateCallback, 1477 d3drm_device1_SetBufferCount, 1478 d3drm_device1_GetBufferCount, 1479 d3drm_device1_SetDither, 1480 d3drm_device1_SetShades, 1481 d3drm_device1_SetQuality, 1482 d3drm_device1_SetTextureQuality, 1483 d3drm_device1_GetViewports, 1484 d3drm_device1_GetDither, 1485 d3drm_device1_GetShades, 1486 d3drm_device1_GetHeight, 1487 d3drm_device1_GetWidth, 1488 d3drm_device1_GetTrianglesDrawn, 1489 d3drm_device1_GetWireframeOptions, 1490 d3drm_device1_GetQuality, 1491 d3drm_device1_GetColorModel, 1492 d3drm_device1_GetTextureQuality, 1493 d3drm_device1_GetDirect3DDevice, 1494 }; 1495 1496 static HRESULT WINAPI d3drm_device_win_QueryInterface(IDirect3DRMWinDevice *iface, REFIID riid, void **out) 1497 { 1498 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1499 1500 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); 1501 1502 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out); 1503 } 1504 1505 static ULONG WINAPI d3drm_device_win_AddRef(IDirect3DRMWinDevice *iface) 1506 { 1507 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1508 1509 TRACE("iface %p.\n", iface); 1510 1511 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface); 1512 } 1513 1514 static ULONG WINAPI d3drm_device_win_Release(IDirect3DRMWinDevice *iface) 1515 { 1516 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1517 1518 TRACE("iface %p.\n", iface); 1519 1520 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface); 1521 } 1522 1523 static HRESULT WINAPI d3drm_device_win_Clone(IDirect3DRMWinDevice *iface, 1524 IUnknown *outer, REFIID iid, void **out) 1525 { 1526 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1527 1528 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out); 1529 1530 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out); 1531 } 1532 1533 static HRESULT WINAPI d3drm_device_win_AddDestroyCallback(IDirect3DRMWinDevice *iface, 1534 D3DRMOBJECTCALLBACK cb, void *ctx) 1535 { 1536 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 1537 1538 return E_NOTIMPL; 1539 } 1540 1541 static HRESULT WINAPI d3drm_device_win_DeleteDestroyCallback(IDirect3DRMWinDevice *iface, 1542 D3DRMOBJECTCALLBACK cb, void *ctx) 1543 { 1544 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx); 1545 1546 return E_NOTIMPL; 1547 } 1548 1549 static HRESULT WINAPI d3drm_device_win_SetAppData(IDirect3DRMWinDevice *iface, DWORD data) 1550 { 1551 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1552 1553 TRACE("iface %p, data %#x.\n", iface, data); 1554 1555 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data); 1556 } 1557 1558 static DWORD WINAPI d3drm_device_win_GetAppData(IDirect3DRMWinDevice *iface) 1559 { 1560 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1561 1562 TRACE("iface %p.\n", iface); 1563 1564 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface); 1565 } 1566 1567 static HRESULT WINAPI d3drm_device_win_SetName(IDirect3DRMWinDevice *iface, const char *name) 1568 { 1569 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1570 1571 TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); 1572 1573 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name); 1574 } 1575 1576 static HRESULT WINAPI d3drm_device_win_GetName(IDirect3DRMWinDevice *iface, DWORD *size, char *name) 1577 { 1578 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1579 1580 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 1581 1582 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name); 1583 } 1584 1585 static HRESULT WINAPI d3drm_device_win_GetClassName(IDirect3DRMWinDevice *iface, DWORD *size, char *name) 1586 { 1587 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface); 1588 1589 TRACE("iface %p, size %p, name %p.\n", iface, size, name); 1590 1591 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name); 1592 } 1593 1594 static HRESULT WINAPI d3drm_device_win_HandlePaint(IDirect3DRMWinDevice *iface, HDC dc) 1595 { 1596 FIXME("iface %p, dc %p stub!\n", iface, dc); 1597 1598 return D3DRM_OK; 1599 } 1600 1601 static HRESULT WINAPI d3drm_device_win_HandleActivate(IDirect3DRMWinDevice *iface, WORD wparam) 1602 { 1603 FIXME("iface %p, wparam %#x stub!\n", iface, wparam); 1604 1605 return D3DRM_OK; 1606 } 1607 1608 static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl = 1609 { 1610 d3drm_device_win_QueryInterface, 1611 d3drm_device_win_AddRef, 1612 d3drm_device_win_Release, 1613 d3drm_device_win_Clone, 1614 d3drm_device_win_AddDestroyCallback, 1615 d3drm_device_win_DeleteDestroyCallback, 1616 d3drm_device_win_SetAppData, 1617 d3drm_device_win_GetAppData, 1618 d3drm_device_win_SetName, 1619 d3drm_device_win_GetName, 1620 d3drm_device_win_GetClassName, 1621 d3drm_device_win_HandlePaint, 1622 d3drm_device_win_HandleActivate, 1623 }; 1624 1625 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) 1626 { 1627 if (!iface) 1628 return NULL; 1629 assert(iface->lpVtbl == &d3drm_device3_vtbl); 1630 1631 return impl_from_IDirect3DRMDevice3(iface); 1632 } 1633 1634 HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) 1635 { 1636 static const char classname[] = "Device"; 1637 struct d3drm_device *object; 1638 1639 TRACE("device %p, d3drm %p.\n", device, d3drm); 1640 1641 if (!(object = heap_alloc_zero(sizeof(*object)))) 1642 return E_OUTOFMEMORY; 1643 1644 object->IDirect3DRMDevice_iface.lpVtbl = &d3drm_device1_vtbl; 1645 object->IDirect3DRMDevice2_iface.lpVtbl = &d3drm_device2_vtbl; 1646 object->IDirect3DRMDevice3_iface.lpVtbl = &d3drm_device3_vtbl; 1647 object->IDirect3DRMWinDevice_iface.lpVtbl = &d3drm_device_win_vtbl; 1648 object->d3drm = d3drm; 1649 d3drm_object_init(&object->obj, classname); 1650 1651 *device = object; 1652 1653 return D3DRM_OK; 1654 } 1655