Author: akhaldi
Date: Thu Nov 17 21:52:34 2016
New Revision: 73250
URL:
http://svn.reactos.org/svn/reactos?rev=73250&view=rev
Log:
[D3DRM] Sync with Wine Staging 1.9.23. CORE-12409
Modified:
trunk/reactos/dll/directx/wine/d3drm/d3drm_private.h
trunk/reactos/dll/directx/wine/d3drm/device.c
trunk/reactos/dll/directx/wine/d3drm/frame.c
trunk/reactos/dll/directx/wine/d3drm/light.c
trunk/reactos/dll/directx/wine/d3drm/math.c
trunk/reactos/dll/directx/wine/d3drm/meshbuilder.c
trunk/reactos/dll/directx/wine/d3drm/texture.c
trunk/reactos/dll/directx/wine/d3drm/viewport.c
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/directx/wine/d3drm/d3drm_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/d3d…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/d3drm_private.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/d3drm_private.h [iso-8859-1] Thu Nov 17 21:52:34
2016
@@ -29,6 +29,7 @@
#define NONAMELESSUNION
#include <assert.h>
+#include <math.h>
#include <windef.h>
#include <winbase.h>
@@ -156,4 +157,19 @@
extern char templates[] DECLSPEC_HIDDEN;
+static inline BYTE d3drm_color_component(float c)
+{
+ if (c <= 0.0f)
+ return 0u;
+ if (c >= 1.0f)
+ return 0xffu;
+ return floor(c * 255.0f);
+}
+
+static inline void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a)
+{
+ *color = RGBA_MAKE(d3drm_color_component(r), d3drm_color_component(g),
+ d3drm_color_component(b), d3drm_color_component(a));
+}
+
#endif /* __D3DRM_PRIVATE_INCLUDED__ */
Modified: trunk/reactos/dll/directx/wine/d3drm/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/dev…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/device.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/device.c [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -202,7 +202,7 @@
{
IDirectDraw *ddraw;
IDirectDrawSurface *surface;
- IDirect3DDevice2 *d3d_device2;
+ IDirect3DDevice2 *d3d_device2 = NULL;
DDSURFACEDESC desc;
HRESULT hr;
@@ -211,9 +211,6 @@
return hr;
IDirect3DRM_AddRef(device->d3drm);
IDirect3DDevice_AddRef(d3d_device);
-
- if (device->ddraw)
- return D3DRMERR_BADOBJECT;
/* Fetch render target and get width/height from there */
if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device,
&IID_IDirectDrawSurface, (void **)&surface)))
@@ -226,16 +223,26 @@
return hr;
}
+ if (device->ddraw)
+ {
+ if (d3d_device2)
+ IDirectDrawSurface_Release(surface);
+ return D3DRMERR_BADOBJECT;
+ }
+
desc.dwSize = sizeof(desc);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
- IDirectDrawSurface_Release(surface);
if (FAILED(hr))
+ {
+ IDirectDrawSurface_Release(surface);
return hr;
+ }
device->ddraw = ddraw;
device->width = desc.dwWidth;
device->height = desc.dwHeight;
device->device = d3d_device;
+ device->render_target = surface;
return hr;
}
@@ -1128,7 +1135,7 @@
{
struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
- TRACE("iface %p stub!\n", iface);
+ TRACE("iface %p.\n", iface);
return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
}
@@ -1562,7 +1569,7 @@
{
struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
- TRACE("iface %p, size %p, name %p stub!\n", iface, size, name);
+ TRACE("iface %p, size %p, name %p.\n", iface, size, name);
return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
}
Modified: trunk/reactos/dll/directx/wine/d3drm/frame.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/fra…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/frame.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/frame.c [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -1329,23 +1329,53 @@
static HRESULT WINAPI d3drm_frame3_GetScene(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3
**scene)
{
- FIXME("iface %p, scene %p stub!\n", iface, scene);
-
- return E_NOTIMPL;
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+
+ TRACE("iface %p, scene %p.\n", iface, scene);
+
+ if (!scene)
+ return D3DRMERR_BADVALUE;
+
+ while (frame->parent)
+ frame = frame->parent;
+
+ *scene = &frame->IDirect3DRMFrame3_iface;
+ IDirect3DRMFrame3_AddRef(*scene);
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_GetScene(IDirect3DRMFrame2 *iface, IDirect3DRMFrame
**scene)
{
- FIXME("iface %p, scene %p stub!\n", iface, scene);
-
- return E_NOTIMPL;
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
+ IDirect3DRMFrame3 *frame3;
+ HRESULT hr;
+
+ TRACE("iface %p, scene %p.\n", iface, scene);
+
+ if (!scene)
+ return D3DRMERR_BADVALUE;
+
+ hr = IDirect3DRMFrame3_GetScene(&frame->IDirect3DRMFrame3_iface,
&frame3);
+ if (FAILED(hr) || !frame3)
+ {
+ *scene = NULL;
+ return hr;
+ }
+
+ hr = IDirect3DRMFrame3_QueryInterface(frame3, &IID_IDirect3DRMFrame, (void
**)scene);
+ IDirect3DRMFrame3_Release(frame3);
+
+ return hr;
}
static HRESULT WINAPI d3drm_frame1_GetScene(IDirect3DRMFrame *iface, IDirect3DRMFrame
**scene)
{
- FIXME("iface %p, scene %p stub!\n", iface, scene);
-
- return E_NOTIMPL;
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
+
+ TRACE("iface %p, scene %p.\n", iface, scene);
+
+ return d3drm_frame2_GetScene(&frame->IDirect3DRMFrame2_iface, scene);
}
static D3DRMSORTMODE WINAPI d3drm_frame3_GetSortMode(IDirect3DRMFrame3 *iface)
@@ -1962,10 +1992,9 @@
{
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- TRACE("iface %p, red %.8e, green %.8e, blue %.8e stub!\n", iface, red,
green, blue);
-
- frame->scenebackground = RGBA_MAKE((BYTE)(red * 255.0f),
- (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
+ TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green,
blue);
+
+ d3drm_set_color(&frame->scenebackground, red, green, blue, 1.0f);
return D3DRM_OK;
}
@@ -2909,7 +2938,7 @@
object->IDirect3DRMFrame3_iface.lpVtbl = &d3drm_frame3_vtbl;
object->d3drm = d3drm;
object->ref = 1;
- object->scenebackground = RGBA_MAKE(0, 0, 0, 0xff);
+ d3drm_set_color(&object->scenebackground, 0.0f, 0.0f, 0.0f, 1.0f);
memcpy(object->transform, identity, sizeof(D3DRMMATRIX4D));
Modified: trunk/reactos/dll/directx/wine/d3drm/light.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/lig…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/light.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/light.c [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -174,7 +174,7 @@
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green,
blue);
- light->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue
* 255.0f), 0xff);
+ d3drm_set_color(&light->color, red, green, blue, 1.0f);
return D3DRM_OK;
}
Modified: trunk/reactos/dll/directx/wine/d3drm/math.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/mat…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/math.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/math.c [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -24,25 +24,16 @@
/* Create a RGB color from its components */
D3DCOLOR WINAPI D3DRMCreateColorRGB(D3DVALUE red, D3DVALUE green, D3DVALUE blue)
{
- return (D3DRMCreateColorRGBA(red, green, blue, 255.0));
+ return D3DRMCreateColorRGBA(red, green, blue, 1.0f);
}
/* Create a RGBA color from its components */
D3DCOLOR WINAPI D3DRMCreateColorRGBA(D3DVALUE red, D3DVALUE green, D3DVALUE blue,
D3DVALUE alpha)
{
- int Red, Green, Blue, Alpha;
- Red=floor(red*255);
- Green=floor(green*255);
- Blue=floor(blue*255);
- Alpha=floor(alpha*255);
- if (red < 0) Red=0;
- if (red > 1) Red=255;
- if (green < 0) Green=0;
- if (green > 1) Green=255;
- if (blue < 0) Blue=0;
- if (blue > 1) Blue=255;
- if (alpha < 0) Alpha=0;
- if (alpha > 1) Alpha=255;
- return (RGBA_MAKE(Red, Green, Blue, Alpha));
+ D3DCOLOR color;
+
+ d3drm_set_color(&color, red, green, blue, alpha);
+
+ return color;
}
/* Determine the alpha part of a color */
Modified: trunk/reactos/dll/directx/wine/d3drm/meshbuilder.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/mes…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/meshbuilder.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/meshbuilder.c [iso-8859-1] Thu Nov 17 21:52:34
2016
@@ -1222,8 +1222,7 @@
values = (float*)ptr;
- This->materials[i].color = RGBA_MAKE((BYTE)(values[0] * 255.0f),
(BYTE)(values[1] * 255.0f),
- (BYTE)(values[2] * 255.0f), (BYTE)(values[3] * 255.0f));
+ d3drm_set_color(&This->materials[i].color, values[0], values[1],
values[2], values[3]);
IDirect3DRMMaterial2_SetAmbient(This->materials[i].material,
values[0], values [1], values[2]); /* Alpha ignored */
IDirect3DRMMaterial2_SetPower(This->materials[i].material,
values[4]);
@@ -1681,7 +1680,7 @@
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green,
blue);
- mesh_builder->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f),
(BYTE)(blue * 255.0f), 0xff);
+ d3drm_set_color(&mesh_builder->color, red, green, blue, 1.0f);
return D3DRM_OK;
}
@@ -2198,7 +2197,7 @@
struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
DWORD count = mesh_builder->nb_normals - start_idx;
- TRACE("iface %p, start_idx %u, normal_count %p, normals %p stub!\n",
+ TRACE("iface %p, start_idx %u, normal_count %p, normals %p.\n",
iface, start_idx, normal_count, normals);
if (normal_count)
@@ -2582,7 +2581,7 @@
if (id >= mesh->nb_groups)
return D3DRMERR_BADVALUE;
- mesh->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f),
(BYTE)(blue * 255.0f), 0xff);
+ d3drm_set_color(&mesh->groups[id].color, red, green, blue, 1.0f);
return D3DRM_OK;
}
Modified: trunk/reactos/dll/directx/wine/d3drm/texture.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/tex…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/texture.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/texture.c [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -213,7 +213,7 @@
{
struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
- TRACE("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
+ TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface,
width, height);
}
@@ -513,7 +513,7 @@
{
struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
- TRACE("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
+ TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface,
width, height);
}
Modified: trunk/reactos/dll/directx/wine/d3drm/viewport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/vie…
==============================================================================
--- trunk/reactos/dll/directx/wine/d3drm/viewport.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/d3drm/viewport.c [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -30,6 +30,32 @@
return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport2_iface);
}
+static inline void d3drm_normalize_d3d_color(D3DCOLORVALUE *color_value, D3DCOLOR color)
+{
+ color_value->u1.r = RGBA_GETRED(color) / 255.0f;
+ color_value->u2.g = RGBA_GETGREEN(color) / 255.0f;
+ color_value->u3.b = RGBA_GETBLUE(color) / 255.0f;
+ color_value->u4.a = RGBA_GETALPHA(color) / 255.0f;
+}
+
+static HRESULT d3drm_update_background_material(struct d3drm_viewport *viewport)
+{
+ IDirect3DRMFrame *root_frame;
+ D3DCOLOR color;
+ D3DMATERIAL mat;
+ HRESULT hr;
+
+ if (FAILED(hr = IDirect3DRMFrame_GetScene(viewport->camera, &root_frame)))
+ return hr;
+ color = IDirect3DRMFrame_GetSceneBackground(root_frame);
+
+ memset(&mat, 0, sizeof(mat));
+ mat.dwSize = sizeof(mat);
+ d3drm_normalize_d3d_color(&mat.u.diffuse, color);
+
+ return IDirect3DMaterial_SetMaterial(viewport->material, &mat);
+}
+
static void d3drm_viewport_destroy(struct d3drm_viewport *viewport)
{
TRACE("viewport %p releasing attached interfaces.\n", viewport);
@@ -275,10 +301,8 @@
D3DVIEWPORT vp;
D3DVALUE scale;
IDirect3D *d3d1 = NULL;
- D3DCOLOR color;
IDirect3DDevice *d3d_device = NULL;
IDirect3DMaterial *material = NULL;
- D3DMATERIAL mat;
D3DMATERIALHANDLE hmat;
HRESULT hr = D3DRM_OK;
@@ -328,19 +352,7 @@
if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(camera, &IID_IDirect3DRMFrame,
(void **)&viewport->camera)))
goto cleanup;
- color = IDirect3DRMFrame3_GetSceneBackground(camera);
- /* Create material (ambient/diffuse/emissive?), set material */
if (FAILED(hr = IDirect3D_CreateMaterial(d3d1, &material, NULL)))
- goto cleanup;
-
- memset(&mat, 0, sizeof(mat));
- mat.dwSize = sizeof(mat);
- mat.u.diffuse.u1.r = RGBA_GETRED(color) / 255.0f;
- mat.u.diffuse.u2.g = RGBA_GETGREEN(color) / 255.0f;
- mat.u.diffuse.u3.b = RGBA_GETBLUE(color) / 255.0f;
- mat.u.diffuse.u4.a = RGBA_GETALPHA(color) / 255.0f;
-
- if (FAILED(hr = IDirect3DMaterial_SetMaterial(material, &mat)))
goto cleanup;
if (FAILED(hr = IDirect3DMaterial_GetHandle(material, d3d_device, &hmat)))
@@ -399,16 +411,49 @@
static HRESULT WINAPI d3drm_viewport2_Clear(IDirect3DRMViewport2 *iface, DWORD flags)
{
- FIXME("iface %p, flags %#x.\n", iface, flags);
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+ DDSCAPS caps = { DDSCAPS_ZBUFFER };
+ HRESULT hr;
+ D3DRECT clear_rect;
+ IDirectDrawSurface *ds;
+ DWORD clear_flags = 0;
+
+ TRACE("iface %p, flags %#x.\n", iface, flags);
+
+ clear_rect.u1.x1 = clear_rect.u2.y1 = 0;
+ clear_rect.u3.x2 = viewport->device->width;
+ clear_rect.u4.y2 = viewport->device->height;
+
+ if (flags & D3DRMCLEAR_TARGET)
+ {
+ clear_flags |= D3DCLEAR_TARGET;
+ d3drm_update_background_material(viewport);
+ }
+ if (flags & D3DRMCLEAR_ZBUFFER)
+ {
+ hr = IDirectDrawSurface_GetAttachedSurface(viewport->device->render_target,
&caps, &ds);
+ if (SUCCEEDED(hr))
+ {
+ clear_flags |= D3DCLEAR_ZBUFFER;
+ IDirectDrawSurface_Release(ds);
+ }
+ }
+ if (flags & D3DRMCLEAR_DIRTYRECTS)
+ FIXME("Flag D3DRMCLEAR_DIRTYRECT not implemented yet.\n");
+
+ if (FAILED(hr = IDirect3DViewport_Clear(viewport->d3d_viewport, 1,
&clear_rect, clear_flags)))
+ return hr;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport1_Clear(IDirect3DRMViewport *iface)
{
- FIXME("iface %p.\n", iface);
-
- return D3DRM_OK;
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+
+ TRACE("iface %p.\n", iface);
+
+ return d3drm_viewport2_Clear(&viewport->IDirect3DRMViewport2_iface,
D3DRMCLEAR_ALL);
}
static HRESULT WINAPI d3drm_viewport2_Render(IDirect3DRMViewport2 *iface,
IDirect3DRMFrame3 *frame)
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 21:52:34 2016
@@ -25,7 +25,7 @@
reactos/dll/directx/wine/d3d8 # Synced to WineStaging-1.9.4
reactos/dll/directx/wine/d3d9 # Synced to WineStaging-1.9.4
reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-1.9.4
-reactos/dll/directx/wine/d3drm # Synced to WineStaging-1.9.16
+reactos/dll/directx/wine/d3drm # Synced to WineStaging-1.9.23
reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-1.9.4
reactos/dll/directx/wine/d3dxof # Synced to WineStaging-1.9.16
reactos/dll/directx/wine/ddraw # Synced to WineStaging-1.9.4