[D3DRM] Sync with Wine Staging 4.18. CORE-16441
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 26 Oct 2019 12:01:38 +0000 (13:01 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 26 Oct 2019 12:01:38 +0000 (13:01 +0100)
13 files changed:
dll/directx/wine/d3drm/d3drm.c
dll/directx/wine/d3drm/d3drm_main.c
dll/directx/wine/d3drm/d3drm_private.h
dll/directx/wine/d3drm/device.c
dll/directx/wine/d3drm/face.c
dll/directx/wine/d3drm/frame.c
dll/directx/wine/d3drm/light.c
dll/directx/wine/d3drm/material.c
dll/directx/wine/d3drm/math.c
dll/directx/wine/d3drm/meshbuilder.c
dll/directx/wine/d3drm/texture.c
dll/directx/wine/d3drm/viewport.c
media/doc/README.WINE

index d0f2023..0b3af02 100644 (file)
@@ -20,9 +20,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
@@ -416,17 +413,13 @@ static HRESULT WINAPI d3drm1_CreateMaterial(IDirect3DRM *iface,
 static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface,
         DWORD width, DWORD height, IDirect3DRMDevice **device)
 {
-    struct d3drm_device *object;
-    HRESULT hr;
-
-    FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
-
-    if (FAILED(hr = d3drm_device_create(&object, iface)))
-        return hr;
+    TRACE("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
 
-    *device = &object->IDirect3DRMDevice_iface;
+    if (!device)
+        return D3DRMERR_BADVALUE;
+    *device = NULL;
 
-    return D3DRM_OK;
+    return D3DRMERR_BADDEVICE;
 }
 
 static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *guid,
@@ -575,10 +568,12 @@ static HRESULT WINAPI d3drm1_CreateViewport(IDirect3DRM *iface, IDirect3DRMDevic
     TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
             iface, device, camera, x, y, width, height, viewport);
 
-    if (!device || !camera)
-        return D3DRMERR_BADOBJECT;
     if (!viewport)
         return D3DRMERR_BADVALUE;
+    *viewport = NULL;
+
+    if (!device || !camera)
+        return D3DRMERR_BADOBJECT;
 
     if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
         return hr;
@@ -972,18 +967,13 @@ static HRESULT WINAPI d3drm2_CreateMaterial(IDirect3DRM2 *iface,
 static HRESULT WINAPI d3drm2_CreateDevice(IDirect3DRM2 *iface,
         DWORD width, DWORD height, IDirect3DRMDevice2 **device)
 {
-    struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
-    struct d3drm_device *object;
-    HRESULT hr;
-
-    FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
-
-    if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
-        return hr;
+    TRACE("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
 
-    *device = &object->IDirect3DRMDevice2_iface;
+    if (!device)
+        return D3DRMERR_BADVALUE;
+    *device = NULL;
 
-    return D3DRM_OK;
+    return D3DRMERR_BADDEVICE;
 }
 
 static HRESULT WINAPI d3drm2_CreateDeviceFromSurface(IDirect3DRM2 *iface, GUID *guid,
@@ -1102,10 +1092,12 @@ static HRESULT WINAPI d3drm2_CreateViewport(IDirect3DRM2 *iface, IDirect3DRMDevi
     TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
           iface, device, camera, x, y, width, height, viewport);
 
-    if (!device || !camera)
-        return D3DRMERR_BADOBJECT;
     if (!viewport)
         return D3DRMERR_BADVALUE;
+    *viewport = NULL;
+
+    if (!device || !camera)
+        return D3DRMERR_BADOBJECT;
 
     if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
         return hr;
@@ -1611,18 +1603,13 @@ static HRESULT WINAPI d3drm3_CreateMaterial(IDirect3DRM3 *iface,
 static HRESULT WINAPI d3drm3_CreateDevice(IDirect3DRM3 *iface,
         DWORD width, DWORD height, IDirect3DRMDevice3 **device)
 {
-    struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
-    struct d3drm_device *object;
-    HRESULT hr;
-
-    FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
+    TRACE("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
 
-    if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
-        return hr;
-
-    *device = &object->IDirect3DRMDevice3_iface;
+    if (!device)
+        return D3DRMERR_BADVALUE;
+    *device = NULL;
 
-    return D3DRM_OK;
+    return D3DRMERR_BADDEVICE;
 }
 
 static HRESULT WINAPI d3drm3_CreateDeviceFromSurface(IDirect3DRM3 *iface, GUID *guid,
@@ -1778,10 +1765,12 @@ static HRESULT WINAPI d3drm3_CreateViewport(IDirect3DRM3 *iface, IDirect3DRMDevi
     TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
             iface, device, camera, x, y, width, height, viewport);
 
-    if (!device || !camera)
-        return D3DRMERR_BADOBJECT;
     if (!viewport)
         return D3DRMERR_BADVALUE;
+    *viewport = NULL;
+
+    if (!device || !camera)
+        return D3DRMERR_BADOBJECT;
 
     if (FAILED(hr = d3drm_viewport_create(&object, &d3drm->IDirect3DRM_iface)))
         return hr;
index 1abfe6f..075b331 100644 (file)
@@ -17,9 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "initguid.h"
 #include "d3drm_private.h"
 
index 858911f..b5d60e5 100644 (file)
 #include "wine/heap.h"
 #include "wine/list.h"
 
+struct d3drm_matrix
+{
+    float _11, _12, _13, _14;
+    float _21, _22, _23, _24;
+    float _31, _32, _33, _34;
+    float _41, _42, _43, _44;
+};
+
+static inline struct d3drm_matrix *d3drm_matrix(D3DRMMATRIX4D m)
+{
+    return (struct d3drm_matrix *)m;
+}
+
 struct d3drm_object
 {
     LONG ref;
@@ -71,11 +84,21 @@ struct d3drm_frame
     SIZE_T nb_lights;
     SIZE_T lights_size;
     IDirect3DRMLight **lights;
-    D3DRMMATRIX4D transform;
+    struct d3drm_matrix transform;
     D3DCOLOR scenebackground;
     DWORD traversal_options;
 };
 
+struct d3drm_box
+{
+    float left;
+    float top;
+    float right;
+    float bottom;
+    float front;
+    float back;
+};
+
 struct d3drm_viewport
 {
     struct d3drm_object obj;
@@ -86,9 +109,7 @@ struct d3drm_viewport
     IDirect3DViewport *d3d_viewport;
     IDirect3DMaterial *material;
     IDirect3DRM *d3drm;
-    D3DVALUE back;
-    D3DVALUE front;
-    D3DVALUE field;
+    struct d3drm_box clip;
     D3DRMPROJECTIONTYPE projection;
 };
 
@@ -260,6 +281,8 @@ HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name) DEC
 void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN;
 
 struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface) DECLSPEC_HIDDEN;
+struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface) DECLSPEC_HIDDEN;
+
 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) DECLSPEC_HIDDEN;
 
 HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
index 2aa7e48..2e1b5f2 100644 (file)
@@ -18,9 +18,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
index 324b1de..1799ad9 100644 (file)
@@ -18,9 +18,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
index 11105db..265afdf 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
 
-static D3DRMMATRIX4D identity = {
-    { 1.0f, 0.0f, 0.0f, 0.0f },
-    { 0.0f, 1.0f, 0.0f, 0.0f },
-    { 0.0f, 0.0f, 1.0f, 0.0f },
-    { 0.0f, 0.0f, 0.0f, 1.0f }
+static const struct d3drm_matrix identity =
+{
+    1.0f, 0.0f, 0.0f, 0.0f,
+    0.0f, 1.0f, 0.0f, 0.0f,
+    0.0f, 0.0f, 1.0f, 0.0f,
+    0.0f, 0.0f, 0.0f, 1.0f,
 };
 
 struct d3drm_frame_array
@@ -72,8 +70,6 @@ static inline struct d3drm_frame *impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3
     return CONTAINING_RECORD(iface, struct d3drm_frame, IDirect3DRMFrame3_iface);
 }
 
-static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface);
-
 static inline struct d3drm_frame_array *impl_from_IDirect3DRMFrameArray(IDirect3DRMFrameArray *iface)
 {
     return CONTAINING_RECORD(iface, struct d3drm_frame_array, IDirect3DRMFrameArray_iface);
@@ -99,6 +95,75 @@ static inline struct d3drm_animation *impl_from_IDirect3DRMAnimation2(IDirect3DR
     return CONTAINING_RECORD(iface, struct d3drm_animation, IDirect3DRMAnimation2_iface);
 }
 
+static void d3drm_matrix_multiply_affine(struct d3drm_matrix *dst,
+        const struct d3drm_matrix *src1, const struct d3drm_matrix *src2)
+{
+    struct d3drm_matrix tmp;
+
+    tmp._11 = src1->_11 * src2->_11 + src1->_12 * src2->_21 + src1->_13 * src2->_31;
+    tmp._12 = src1->_11 * src2->_12 + src1->_12 * src2->_22 + src1->_13 * src2->_32;
+    tmp._13 = src1->_11 * src2->_13 + src1->_12 * src2->_23 + src1->_13 * src2->_33;
+    tmp._14 = 0.0f;
+
+    tmp._21 = src1->_21 * src2->_11 + src1->_22 * src2->_21 + src1->_23 * src2->_31;
+    tmp._22 = src1->_21 * src2->_12 + src1->_22 * src2->_22 + src1->_23 * src2->_32;
+    tmp._23 = src1->_21 * src2->_13 + src1->_22 * src2->_23 + src1->_23 * src2->_33;
+    tmp._24 = 0.0f;
+
+    tmp._31 = src1->_31 * src2->_11 + src1->_32 * src2->_21 + src1->_33 * src2->_31;
+    tmp._32 = src1->_31 * src2->_12 + src1->_32 * src2->_22 + src1->_33 * src2->_32;
+    tmp._33 = src1->_31 * src2->_13 + src1->_32 * src2->_23 + src1->_33 * src2->_33;
+    tmp._34 = 0.0f;
+
+    tmp._41 = src1->_41 * src2->_11 + src1->_42 * src2->_21 + src1->_43 * src2->_31 + src2->_41;
+    tmp._42 = src1->_41 * src2->_12 + src1->_42 * src2->_22 + src1->_43 * src2->_32 + src2->_42;
+    tmp._43 = src1->_41 * src2->_13 + src1->_42 * src2->_23 + src1->_43 * src2->_33 + src2->_43;
+    tmp._44 = 1.0f;
+
+    *dst = tmp;
+}
+
+static void d3drm_matrix_set_rotation(struct d3drm_matrix *matrix, D3DVECTOR *axis, float theta)
+{
+    float sin_theta, cos_theta, vers_theta;
+
+    D3DRMVectorNormalize(axis);
+    sin_theta = sinf(theta);
+    cos_theta = cosf(theta);
+    vers_theta = 1.0f - cos_theta;
+
+    matrix->_11 = vers_theta * axis->u1.x * axis->u1.x + cos_theta;
+    matrix->_21 = vers_theta * axis->u1.x * axis->u2.y - sin_theta * axis->u3.z;
+    matrix->_31 = vers_theta * axis->u1.x * axis->u3.z + sin_theta * axis->u2.y;
+    matrix->_41 = 0.0f;
+
+    matrix->_12 = vers_theta * axis->u2.y * axis->u1.x + sin_theta * axis->u3.z;
+    matrix->_22 = vers_theta * axis->u2.y * axis->u2.y + cos_theta;
+    matrix->_32 = vers_theta * axis->u2.y * axis->u3.z - sin_theta * axis->u1.x;
+    matrix->_42 = 0.0f;
+
+    matrix->_13 = vers_theta * axis->u3.z * axis->u1.x - sin_theta * axis->u2.y;
+    matrix->_23 = vers_theta * axis->u3.z * axis->u2.y + sin_theta * axis->u1.x;
+    matrix->_33 = vers_theta * axis->u3.z * axis->u3.z + cos_theta;
+    matrix->_43 = 0.0f;
+
+    matrix->_14 = 0.0f;
+    matrix->_24 = 0.0f;
+    matrix->_34 = 0.0f;
+    matrix->_44 = 1.0f;
+}
+
+static void d3drm_vector_transform_affine(D3DVECTOR *dst, const D3DVECTOR *v, const struct d3drm_matrix *m)
+{
+    D3DVECTOR tmp;
+
+    tmp.u1.x = v->u1.x * m->_11 + v->u2.y * m->_21 + v->u3.z * m->_31 + m->_41;
+    tmp.u2.y = v->u1.x * m->_12 + v->u2.y * m->_22 + v->u3.z * m->_32 + m->_42;
+    tmp.u3.z = v->u1.x * m->_13 + v->u2.y * m->_23 + v->u3.z * m->_33 + m->_43;
+
+    *dst = tmp;
+}
+
 static HRESULT WINAPI d3drm_frame_array_QueryInterface(IDirect3DRMFrameArray *iface, REFIID riid, void **out)
 {
     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
@@ -944,25 +1009,29 @@ static HRESULT WINAPI d3drm_frame3_AddTransform(IDirect3DRMFrame3 *iface,
         D3DRMCOMBINETYPE type, D3DRMMATRIX4D matrix)
 {
     struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+    const struct d3drm_matrix *m = d3drm_matrix(matrix);
 
     TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);
 
+    if (m->_14 != 0.0f || m->_24 != 0.0f || m->_34 != 0.0f || m->_44 != 1.0f)
+        return D3DRMERR_BADVALUE;
+
     switch (type)
     {
         case D3DRMCOMBINE_REPLACE:
-            memcpy(frame->transform, matrix, sizeof(D3DRMMATRIX4D));
+            frame->transform = *m;
             break;
 
         case D3DRMCOMBINE_BEFORE:
-            FIXME("D3DRMCOMBINE_BEFORE not supported yet\n");
+            d3drm_matrix_multiply_affine(&frame->transform, m, &frame->transform);
             break;
 
         case D3DRMCOMBINE_AFTER:
-            FIXME("D3DRMCOMBINE_AFTER not supported yet\n");
+            d3drm_matrix_multiply_affine(&frame->transform, &frame->transform, m);
             break;
 
         default:
-            WARN("Unknown Combine Type %u\n", type);
+            FIXME("Unhandled type %#x.\n", type);
             return D3DRMERR_BADVALUE;
     }
 
@@ -992,74 +1061,185 @@ static HRESULT WINAPI d3drm_frame1_AddTransform(IDirect3DRMFrame *iface,
 static HRESULT WINAPI d3drm_frame3_AddTranslation(IDirect3DRMFrame3 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+    switch (type)
+    {
+        case D3DRMCOMBINE_REPLACE:
+            frame->transform = identity;
+            frame->transform._41 = x;
+            frame->transform._42 = y;
+            frame->transform._43 = z;
+            break;
+
+        case D3DRMCOMBINE_BEFORE:
+            frame->transform._41 += x * frame->transform._11 + y * frame->transform._21 + z * frame->transform._31;
+            frame->transform._42 += x * frame->transform._12 + y * frame->transform._22 + z * frame->transform._32;
+            frame->transform._43 += x * frame->transform._13 + y * frame->transform._23 + z * frame->transform._33;
+            break;
+
+        case D3DRMCOMBINE_AFTER:
+            frame->transform._41 += x;
+            frame->transform._42 += y;
+            frame->transform._43 += z;
+            break;
+
+        default:
+            FIXME("Unhandled type %#x.\n", type);
+            return D3DRMERR_BADVALUE;
+    }
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_frame2_AddTranslation(IDirect3DRMFrame2 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+    return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
 }
 
 static HRESULT WINAPI d3drm_frame1_AddTranslation(IDirect3DRMFrame *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+    return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
 }
 
 static HRESULT WINAPI d3drm_frame3_AddScale(IDirect3DRMFrame3 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
 {
-    FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);
+
+    switch (type)
+    {
+        case D3DRMCOMBINE_REPLACE:
+            frame->transform = identity;
+            frame->transform._11 = sx;
+            frame->transform._22 = sy;
+            frame->transform._33 = sz;
+            break;
+
+        case D3DRMCOMBINE_BEFORE:
+            frame->transform._11 *= sx;
+            frame->transform._12 *= sx;
+            frame->transform._13 *= sx;
+            frame->transform._21 *= sy;
+            frame->transform._22 *= sy;
+            frame->transform._23 *= sy;
+            frame->transform._31 *= sz;
+            frame->transform._32 *= sz;
+            frame->transform._33 *= sz;
+            break;
+
+        case D3DRMCOMBINE_AFTER:
+            frame->transform._11 *= sx;
+            frame->transform._12 *= sy;
+            frame->transform._13 *= sz;
+            frame->transform._21 *= sx;
+            frame->transform._22 *= sy;
+            frame->transform._23 *= sz;
+            frame->transform._31 *= sx;
+            frame->transform._32 *= sy;
+            frame->transform._33 *= sz;
+            frame->transform._41 *= sx;
+            frame->transform._42 *= sy;
+            frame->transform._43 *= sz;
+            break;
+
+        default:
+            FIXME("Unhandled type %#x.\n", type);
+            return D3DRMERR_BADVALUE;
+    }
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_frame2_AddScale(IDirect3DRMFrame2 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
 {
-    FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);
+
+    return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz);
 }
 
 static HRESULT WINAPI d3drm_frame1_AddScale(IDirect3DRMFrame *iface,
         D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
 {
-    FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);
+
+    return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz);
 }
 
 static HRESULT WINAPI d3drm_frame3_AddRotation(IDirect3DRMFrame3 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n",
-            iface, type, x, y, z, theta);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+    struct d3drm_matrix m;
+    D3DVECTOR axis;
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);
+
+    axis.u1.x = x;
+    axis.u2.y = y;
+    axis.u3.z = z;
+
+    switch (type)
+    {
+        case D3DRMCOMBINE_REPLACE:
+            d3drm_matrix_set_rotation(&frame->transform, &axis, theta);
+            break;
+
+        case D3DRMCOMBINE_BEFORE:
+            d3drm_matrix_set_rotation(&m, &axis, theta);
+            d3drm_matrix_multiply_affine(&frame->transform, &m, &frame->transform);
+            break;
+
+        case D3DRMCOMBINE_AFTER:
+            d3drm_matrix_set_rotation(&m, &axis, theta);
+            d3drm_matrix_multiply_affine(&frame->transform, &frame->transform, &m);
+            break;
+
+        default:
+            FIXME("Unhandled type %#x.\n", type);
+            return D3DRMERR_BADVALUE;
+    }
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_frame2_AddRotation(IDirect3DRMFrame2 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", iface, type, x, y, z, theta);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);
+
+    return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta);
 }
 
 static HRESULT WINAPI d3drm_frame1_AddRotation(IDirect3DRMFrame *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", iface, type, x, y, z, theta);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);
+
+    return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta);
 }
 
 static HRESULT WINAPI d3drm_frame3_AddVisual(IDirect3DRMFrame3 *iface, IUnknown *visual)
@@ -1418,13 +1598,14 @@ static HRESULT WINAPI d3drm_frame3_GetTransform(IDirect3DRMFrame3 *iface,
         IDirect3DRMFrame3 *reference, D3DRMMATRIX4D matrix)
 {
     struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+    struct d3drm_matrix *m = d3drm_matrix(matrix);
 
     TRACE("iface %p, reference %p, matrix %p.\n", iface, reference, matrix);
 
     if (reference)
-        FIXME("Specifying a frame as the root of the scene different from the current root frame is not supported yet\n");
+        FIXME("Ignoring reference frame %p.\n", reference);
 
-    memcpy(matrix, frame->transform, sizeof(D3DRMMATRIX4D));
+    *m = frame->transform;
 
     return D3DRM_OK;
 }
@@ -1432,10 +1613,11 @@ static HRESULT WINAPI d3drm_frame3_GetTransform(IDirect3DRMFrame3 *iface,
 static HRESULT WINAPI d3drm_frame2_GetTransform(IDirect3DRMFrame2 *iface, D3DRMMATRIX4D matrix)
 {
     struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
+    struct d3drm_matrix *m = d3drm_matrix(matrix);
 
     TRACE("iface %p, matrix %p.\n", iface, matrix);
 
-    memcpy(matrix, frame->transform, sizeof(D3DRMMATRIX4D));
+    *m = frame->transform;
 
     return D3DRM_OK;
 }
@@ -2419,23 +2601,35 @@ static HRESULT WINAPI d3drm_frame1_SetZbufferMode(IDirect3DRMFrame *iface, D3DRM
 
 static HRESULT WINAPI d3drm_frame3_Transform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
 {
-    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+    d3drm_vector_transform_affine(d, s, &frame->transform);
+    while ((frame = frame->parent))
+    {
+        d3drm_vector_transform_affine(d, d, &frame->transform);
+    }
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_frame2_Transform(IDirect3DRMFrame2 *iface, D3DVECTOR *d, D3DVECTOR *s)
 {
-    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+    return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
 }
 
 static HRESULT WINAPI d3drm_frame1_Transform(IDirect3DRMFrame *iface, D3DVECTOR *d, D3DVECTOR *s)
 {
-    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+    return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
 }
 
 static HRESULT WINAPI d3drm_frame2_AddMoveCallback2(IDirect3DRMFrame2 *iface,
@@ -2914,7 +3108,7 @@ static const struct IDirect3DRMFrameVtbl d3drm_frame1_vtbl =
     d3drm_frame1_Transform,
 };
 
-static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
+struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
 {
     if (!iface)
         return NULL;
@@ -2953,7 +3147,7 @@ HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, I
 
     d3drm_object_init(&object->obj, classname);
 
-    memcpy(object->transform, identity, sizeof(D3DRMMATRIX4D));
+    object->transform = identity;
 
     if (parent_frame)
     {
index e31c026..2f53f20 100644 (file)
@@ -18,9 +18,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
index 62acb5a..e402ea6 100644 (file)
@@ -18,9 +18,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
index a6c0c85..01d596b 100644 (file)
@@ -17,9 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 /* Create a RGB color from its components */
index 0090555..9b85c2d 100644 (file)
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
index 7741718..07f0896 100644 (file)
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
index 5c0e24b..8e959d5 100644 (file)
@@ -18,9 +18,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "config.h"
-#include "wine/port.h"
-
 #include "d3drm_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
@@ -53,6 +50,7 @@ static HRESULT d3drm_update_background_material(struct d3drm_viewport *viewport)
     if (FAILED(hr = IDirect3DRMFrame_GetScene(viewport->camera, &root_frame)))
         return hr;
     color = IDirect3DRMFrame_GetSceneBackground(root_frame);
+    IDirect3DRMFrame_Release(root_frame);
 
     memset(&mat, 0, sizeof(mat));
     mat.dwSize = sizeof(mat);
@@ -371,6 +369,13 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
     viewport->material = material;
     viewport->device = device_obj;
 
+    viewport->clip.left = -0.5f;
+    viewport->clip.top = 0.5f;
+    viewport->clip.right = 0.5f;
+    viewport->clip.bottom = -0.5f;
+    viewport->clip.front = 1.0f;
+    viewport->clip.back = 100.0f;
+
 cleanup:
 
     if (FAILED(hr))
@@ -485,7 +490,13 @@ static HRESULT WINAPI d3drm_viewport2_SetFront(IDirect3DRMViewport2 *iface, D3DV
 
     TRACE("iface %p, front %.8e.\n", iface, front);
 
-    viewport->front = front;
+    if (!viewport->d3d_viewport)
+        return D3DRMERR_BADOBJECT;
+
+    if (front <= 0.0f)
+        return D3DRMERR_BADVALUE;
+
+    viewport->clip.front = front;
 
     return D3DRM_OK;
 }
@@ -505,7 +516,13 @@ static HRESULT WINAPI d3drm_viewport2_SetBack(IDirect3DRMViewport2 *iface, D3DVA
 
     TRACE("iface %p, back %.8e.\n", iface, back);
 
-    viewport->back = back;
+    if (!viewport->d3d_viewport)
+        return D3DRMERR_BADOBJECT;
+
+    if (back <= viewport->clip.front)
+        return D3DRMERR_BADVALUE;
+
+    viewport->clip.back = back;
 
     return D3DRM_OK;
 }
@@ -525,7 +542,16 @@ static HRESULT WINAPI d3drm_viewport2_SetField(IDirect3DRMViewport2 *iface, D3DV
 
     TRACE("iface %p, field %.8e.\n", iface, field);
 
-    viewport->field = field;
+    if (!viewport->d3d_viewport)
+        return D3DRMERR_BADOBJECT;
+
+    if (field <= 0.0f)
+        return D3DRMERR_BADVALUE;
+
+    viewport->clip.left = -field;
+    viewport->clip.right = field;
+    viewport->clip.bottom = -field;
+    viewport->clip.top = field;
 
     return D3DRM_OK;
 }
@@ -555,16 +581,30 @@ static HRESULT WINAPI d3drm_viewport1_SetUniformScaling(IDirect3DRMViewport *ifa
 
 static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera)
 {
-    FIXME("iface %p, camera %p stub!\n", iface, camera);
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+    struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame3(camera);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, camera %p.\n", iface, camera);
+
+    if (!camera || !viewport->camera)
+        return D3DRMERR_BADOBJECT;
+
+    IDirect3DRMFrame_AddRef(&frame->IDirect3DRMFrame_iface);
+    IDirect3DRMFrame_Release(viewport->camera);
+    viewport->camera = &frame->IDirect3DRMFrame_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_viewport1_SetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame *camera)
 {
-    FIXME("iface %p, camera %p stub!\n", iface, camera);
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+    struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, camera %p.\n", iface, camera);
+
+    return d3drm_viewport2_SetCamera(&viewport->IDirect3DRMViewport2_iface,
+            frame ? &frame->IDirect3DRMFrame3_iface : NULL);
 }
 
 static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type)
@@ -650,33 +690,67 @@ static HRESULT WINAPI d3drm_viewport1_ForceUpdate(IDirect3DRMViewport *iface,
 static HRESULT WINAPI d3drm_viewport2_SetPlane(IDirect3DRMViewport2 *iface,
         D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
 {
-    FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n",
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+
+    TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n",
             iface, left, right, bottom, top);
 
-    return E_NOTIMPL;
+    if (!viewport->d3d_viewport)
+        return D3DRMERR_BADOBJECT;
+
+    viewport->clip.left = left;
+    viewport->clip.right = right;
+    viewport->clip.bottom = bottom;
+    viewport->clip.top = top;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface,
         D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
 {
-    FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n",
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+
+    TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n",
             iface, left, right, bottom, top);
 
-    return E_NOTIMPL;
+    return d3drm_viewport2_SetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
 }
 
 static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera)
 {
-    FIXME("iface %p, camera %p stub!\n", iface, camera);
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, camera %p.\n", iface, camera);
+
+    if (!camera)
+        return D3DRMERR_BADVALUE;
+
+    if (!viewport->camera)
+        return D3DRMERR_BADOBJECT;
+
+    return IDirect3DRMFrame_QueryInterface(viewport->camera, &IID_IDirect3DRMFrame3, (void **)camera);
 }
 
 static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame **camera)
 {
-    FIXME("iface %p, camera %p stub!\n", iface, camera);
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+    struct d3drm_frame *camera_impl;
+    IDirect3DRMFrame3 *camera3;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("iface %p, camera %p.\n", iface, camera);
+
+    if (!camera)
+        return D3DRMERR_BADVALUE;
+
+    if (FAILED(hr = d3drm_viewport2_GetCamera(&viewport->IDirect3DRMViewport2_iface, &camera3)))
+        return hr;
+
+    camera_impl = unsafe_impl_from_IDirect3DRMFrame3(camera3);
+    *camera = &camera_impl->IDirect3DRMFrame_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
@@ -685,6 +759,9 @@ static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDi
 
     TRACE("iface %p, device %p.\n", iface, device);
 
+    if (!device)
+        return D3DRMERR_BADVALUE;
+
     if (!viewport->device)
         return D3DRMERR_BADOBJECT;
 
@@ -700,6 +777,9 @@ static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDir
 
     TRACE("iface %p, device %p.\n\n", iface, device);
 
+    if (!device)
+        return D3DRMERR_BADVALUE;
+
     if (!viewport->device)
         return D3DRMERR_BADOBJECT;
 
@@ -712,19 +792,31 @@ static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDir
 static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface,
         D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
 {
-    FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+
+    TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
             iface, left, right, bottom, top);
 
-    return E_NOTIMPL;
+    if (!viewport->d3d_viewport)
+        return D3DRMERR_BADOBJECT;
+
+    *left = viewport->clip.left;
+    *right = viewport->clip.right;
+    *bottom = viewport->clip.bottom;
+    *top = viewport->clip.top;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_viewport1_GetPlane(IDirect3DRMViewport *iface,
         D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
 {
-    FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
+    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+
+    TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
             iface, left, right, bottom, top);
 
-    return E_NOTIMPL;
+    return d3drm_viewport2_GetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
 }
 
 static HRESULT WINAPI d3drm_viewport2_Pick(IDirect3DRMViewport2 *iface,
@@ -819,7 +911,11 @@ static D3DVALUE WINAPI d3drm_viewport2_GetField(IDirect3DRMViewport2 *iface)
 
     TRACE("iface %p.\n", iface);
 
-    return viewport->field;
+    if (!viewport->d3d_viewport)
+        return -1.0f;
+
+    return (viewport->clip.right - viewport->clip.left
+            + viewport->clip.top - viewport->clip.bottom) / 4.0f;
 }
 
 static D3DVALUE WINAPI d3drm_viewport1_GetField(IDirect3DRMViewport *iface)
@@ -837,7 +933,10 @@ static D3DVALUE WINAPI d3drm_viewport2_GetBack(IDirect3DRMViewport2 *iface)
 
     TRACE("iface %p.\n", iface);
 
-    return viewport->back;
+    if (!viewport->d3d_viewport)
+        return -1.0f;
+
+    return viewport->clip.back;
 }
 
 static D3DVALUE WINAPI d3drm_viewport1_GetBack(IDirect3DRMViewport *iface)
@@ -855,7 +954,10 @@ static D3DVALUE WINAPI d3drm_viewport2_GetFront(IDirect3DRMViewport2 *iface)
 
     TRACE("iface %p.\n", iface);
 
-    return viewport->front;
+    if (!viewport->d3d_viewport)
+        return -1.0f;
+
+    return viewport->clip.front;
 }
 
 static D3DVALUE WINAPI d3drm_viewport1_GetFront(IDirect3DRMViewport *iface)
@@ -892,6 +994,9 @@ static HRESULT WINAPI d3drm_viewport2_GetDirect3DViewport(IDirect3DRMViewport2 *
 
     TRACE("iface %p, viewport %p.\n", iface, viewport);
 
+    if (!viewport)
+        return D3DRMERR_BADVALUE;
+
     if (!viewport_object->d3d_viewport)
         return D3DRMERR_BADOBJECT;
 
index 128045d..7fc878f 100644 (file)
@@ -25,7 +25,7 @@ dll/directx/wine/amstream       # Synced to WineStaging-3.9
 dll/directx/wine/d3d8           # Synced to WineStaging-3.3
 dll/directx/wine/d3d9           # Synced to WineStaging-3.3
 dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-4.18
-dll/directx/wine/d3drm          # Synced to WineStaging-4.0
+dll/directx/wine/d3drm          # Synced to WineStaging-4.18
 dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-4.0
 dll/directx/wine/d3dxof         # Synced to WineStaging-3.17
 dll/directx/wine/ddraw          # Synced to WineStaging-3.3