[PATCH 5/5] wined3d: Pass a wined3d_color struct to wined3d_device_clear().

Henri Verbeet hverbeet at codeweavers.com
Tue Nov 15 14:18:28 CST 2011


---
 dlls/d3d8/device.c       |   15 +++++++++++----
 dlls/d3d9/device.c       |   16 +++++++++++-----
 dlls/ddraw/device.c      |   21 +++++++++++----------
 dlls/wined3d/device.c    |   12 ++++++------
 dlls/wined3d/swapchain.c |    4 +++-
 include/wine/wined3d.h   |    4 +---
 6 files changed, 43 insertions(+), 29 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 1ead518..4ba3bbd 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1200,17 +1200,24 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(IDirect3DD
     return hr;
 }
 
-static HRESULT WINAPI IDirect3DDevice8Impl_Clear(IDirect3DDevice8 *iface, DWORD Count,
-        const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil)
+static HRESULT WINAPI IDirect3DDevice8Impl_Clear(IDirect3DDevice8 *iface, DWORD rect_count,
+        const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil)
 {
+    const struct wined3d_color c =
+    {
+        ((color >> 16) & 0xff) / 255.0f,
+        ((color >>  8) & 0xff) / 255.0f,
+        (color & 0xff) / 255.0f,
+        ((color >> 24) & 0xff) / 255.0f,
+    };
     IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
     HRESULT hr;
 
     TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
-            iface, Count, pRects, Flags, Color, Z, Stencil);
+            iface, rect_count, rects, flags, color, z, stencil);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_clear(This->wined3d_device, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
+    hr = wined3d_device_clear(This->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 4e8eee1..9dea7fb 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1218,18 +1218,24 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_EndScene(IDirect3DD
     return hr;
 }
 
-static HRESULT WINAPI IDirect3DDevice9Impl_Clear(IDirect3DDevice9Ex *iface, DWORD Count,
-        const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil)
+static HRESULT WINAPI IDirect3DDevice9Impl_Clear(IDirect3DDevice9Ex *iface, DWORD rect_count,
+        const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil)
 {
+    const struct wined3d_color c =
+    {
+        ((color >> 16) & 0xff) / 255.0f,
+        ((color >>  8) & 0xff) / 255.0f,
+        (color & 0xff) / 255.0f,
+        ((color >> 24) & 0xff) / 255.0f,
+    };
     IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
     HRESULT hr;
 
     TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
-            iface, Count, pRects, Flags, Color, Z, Stencil);
+            iface, rect_count, rects, flags, color, z, stencil);
 
-    /* Note: D3DRECT is compatible with WINED3DRECT */
     wined3d_mutex_lock();
-    hr = wined3d_device_clear(This->wined3d_device, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
+    hr = wined3d_device_clear(This->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 2c4de3b..ecff7fa 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -5065,23 +5065,24 @@ static HRESULT WINAPI IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3 *ifa
  *  For details, see IWineD3DDevice::Clear
  *
  *****************************************************************************/
-static HRESULT
-IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
-                            DWORD Count,
-                            D3DRECT *Rects,
-                            DWORD Flags,
-                            D3DCOLOR Color,
-                            D3DVALUE Z,
-                            DWORD Stencil)
+static HRESULT IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface, DWORD count,
+        D3DRECT *rects, DWORD flags, D3DCOLOR color, D3DVALUE z, DWORD stencil)
 {
+    const struct wined3d_color c =
+    {
+        ((color >> 16) & 0xff) / 255.0f,
+        ((color >>  8) & 0xff) / 255.0f,
+        (color & 0xff) / 255.0f,
+        ((color >> 24) & 0xff) / 255.0f,
+    };
     IDirect3DDeviceImpl *This = impl_from_IDirect3DDevice7(iface);
     HRESULT hr;
 
     TRACE("iface %p, count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %#x.\n",
-            iface, Count, Rects, Flags, Color, Z, Stencil);
+            iface, count, rects, flags, color, z, stencil);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_clear(This->wined3d_device, Count, (RECT *)Rects, Flags, Color, Z, Stencil);
+    hr = wined3d_device_clear(This->wined3d_device, count, (RECT *)rects, flags, &c, z, stencil);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index fb51b39..177f41a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1199,6 +1199,7 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
 HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
         WINED3DPRESENT_PARAMETERS *present_parameters)
 {
+    static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f};
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     struct wined3d_swapchain *swapchain = NULL;
     struct wined3d_context *context;
@@ -1345,7 +1346,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
     /* Clear the screen */
     wined3d_device_clear(device, 0, NULL, WINED3DCLEAR_TARGET
             | (present_parameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0),
-            0x00, 1.0f, 0);
+            &black, 1.0f, 0);
 
     device->d3d_initialized = TRUE;
 
@@ -4025,13 +4026,12 @@ HRESULT CDECL wined3d_device_present(const struct wined3d_device *device, const
 
 /* Do not call while under the GL lock. */
 HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count,
-        const RECT *rects, DWORD flags, WINED3DCOLOR color, float depth, DWORD stencil)
+        const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
 {
-    const struct wined3d_color c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
     RECT draw_rect;
 
-    TRACE("device %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n",
-            device, rect_count, rects, flags, color, depth, stencil);
+    TRACE("device %p, rect_count %u, rects %p, flags %#x, color {%.8e, %.8e, %.8e, %.8e}, depth %.8e, stencil %u.\n",
+            device, rect_count, rects, flags, color->r, color->g, color->b, color->a, depth, stencil);
 
     if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
     {
@@ -4057,7 +4057,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
 
     return device_clear_render_targets(device, device->adapter->gl_info.limits.buffers,
             &device->fb, rect_count, rects,
-            &draw_rect, flags, &c, depth, stencil);
+            &draw_rect, flags, color, depth, stencil);
 }
 
 void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device,
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index d04d9c1..321d8ea 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -591,10 +591,12 @@ static HRESULT swapchain_gl_present(struct wined3d_swapchain *swapchain, const R
      * (The Max Payne bug has been confirmed on Windows with the debug runtime) */
     if (FALSE && swapchain->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD)
     {
+        static const struct wined3d_color cyan = {0.0f, 1.0f, 1.0f, 1.0f};
+
         TRACE("Clearing the color buffer with cyan color\n");
 
         wined3d_device_clear(swapchain->device, 0, NULL,
-                WINED3DCLEAR_TARGET, 0xff00ffff, 1.0f, 0);
+                WINED3DCLEAR_TARGET, &cyan, 1.0f, 0);
     }
 
     if (!swapchain->render_to_fbo && ((swapchain->front_buffer->flags & SFLAG_INSYSMEM)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index c1dbaa3..4224c6c 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -65,8 +65,6 @@
 #define WINEDDERR_NOCLIPLIST                                    MAKE_WINED3DHRESULT(205)
 #define WINEDDERR_OVERLAYNOTVISIBLE                             MAKE_WINED3DHRESULT(577)
 
-typedef DWORD WINED3DCOLOR;
-
 typedef enum _WINED3DLIGHTTYPE
 {
     WINED3DLIGHT_POINT                      = 1,
@@ -2168,7 +2166,7 @@ HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *devic
 HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
 HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device);
 HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags,
-        WINED3DCOLOR color, float z, DWORD stencil);
+        const struct wined3d_color *color, float z, DWORD stencil);
 void __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
         struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color);
 HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface,
-- 
1.7.3.4




More information about the wine-patches mailing list