Henri Verbeet : wined3d: Pass a WINED3DCOLORVALUE structure to IWineD3DDeviceImpl_ClearRendertargetView ().

Alexandre Julliard julliard at winehq.org
Mon Aug 23 10:50:17 CDT 2010


Module: wine
Branch: master
Commit: b93a9b37faecef25b50f7499fd7b99cbd7f80aef
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b93a9b37faecef25b50f7499fd7b99cbd7f80aef

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Sun Aug 22 23:35:41 2010 +0200

wined3d: Pass a WINED3DCOLORVALUE structure to IWineD3DDeviceImpl_ClearRendertargetView().

The structure is nicer to work with than the array.

---

 dlls/d3d10core/device.c        |    3 ++-
 dlls/wined3d/device.c          |   26 ++++++++++++++------------
 dlls/wined3d/surface.c         |    4 ++--
 dlls/wined3d/wined3d_private.h |    2 +-
 include/wine/wined3d.idl       |    2 +-
 5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 191e681..9779511 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -373,11 +373,12 @@ static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *i
 {
     struct d3d10_device *This = (struct d3d10_device *)iface;
     IWineD3DRendertargetView *wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view;
+    const WINED3DCOLORVALUE color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
 
     TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
             iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
 
-    IWineD3DDevice_ClearRendertargetView(This->wined3d_device, wined3d_view, color_rgba);
+    IWineD3DDevice_ClearRendertargetView(This->wined3d_device, wined3d_view, &color);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 8790046..defcceb 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -655,7 +655,8 @@ static void prepare_ds_clear(IWineD3DSurfaceImpl *ds, struct wined3d_context *co
 }
 
 HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, IWineD3DSurfaceImpl **rts,
-        UINT rect_count, const WINED3DRECT *rects, DWORD flags, const float color[4], float depth, DWORD stencil)
+        UINT rect_count, const WINED3DRECT *rects, DWORD flags, const WINED3DCOLORVALUE *color,
+        float depth, DWORD stencil)
 {
     const RECT *clear_rect = (rect_count > 0 && rects) ? (const RECT *)rects : NULL;
     IWineD3DSurfaceImpl *depth_stencil = device->depth_stencil;
@@ -741,7 +742,7 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_COLORWRITEENABLE1));
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_COLORWRITEENABLE2));
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3));
-        glClearColor(color[0], color[1], color[2], color[3]);
+        glClearColor(color->r, color->g, color->b, color->a);
         checkGLcall("glClearColor");
         clear_mask = clear_mask | GL_COLOR_BUFFER_BIT;
     }
@@ -4578,7 +4579,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface,
 static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Count,
         const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR color, float Z, DWORD Stencil)
 {
-    const float c[] = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
+    const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
     TRACE("(%p) Count (%d), pRects (%p), Flags (%x), color (0x%08x), Z (%f), Stencil (%d)\n", This,
@@ -4592,7 +4593,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
     }
 
     return device_clear_render_targets(This, This->adapter->gl_info.limits.buffers,
-            This->render_targets, Count, pRects, Flags, c, Z, Stencil);
+            This->render_targets, Count, pRects, Flags, &c, Z, Stencil);
 }
 
 /*****
@@ -5506,11 +5507,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface,
         return WINED3DERR_INVALIDCALL;
     }
 
-    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
-        const float c[4] = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
+    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    {
+        const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
 
         return device_clear_render_targets((IWineD3DDeviceImpl *)iface, 1, &s,
-                !!pRect, pRect, WINED3DCLEAR_TARGET, c, 0.0f, 0);
+                !!pRect, pRect, WINED3DCLEAR_TARGET, &c, 0.0f, 0);
     }
     else
     {
@@ -5524,7 +5526,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface,
 }
 
 static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *iface,
-        IWineD3DRendertargetView *rendertarget_view, const float color[4])
+        IWineD3DRendertargetView *rendertarget_view, const WINED3DCOLORVALUE *color)
 {
     IWineD3DResource *resource;
     IWineD3DSurfaceImpl *surface;
@@ -5558,10 +5560,10 @@ static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *ifac
 
         WARN("Converting to WINED3DCOLOR, this might give incorrect results\n");
 
-        c = ((DWORD)(color[2] * 255.0f));
-        c |= ((DWORD)(color[1] * 255.0f)) << 8;
-        c |= ((DWORD)(color[0] * 255.0f)) << 16;
-        c |= ((DWORD)(color[3] * 255.0f)) << 24;
+        c = ((DWORD)(color->b * 255.0f));
+        c |= ((DWORD)(color->g * 255.0f)) << 8;
+        c |= ((DWORD)(color->r * 255.0f)) << 16;
+        c |= ((DWORD)(color->a * 255.0f)) << 24;
 
         /* Just forward this to the DirectDraw blitting engine */
         memset(&BltFx, 0, sizeof(BltFx));
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index dfa124d..7aab4ff 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -4872,10 +4872,10 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
 static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device,
         IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD color)
 {
-    const float c[] = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
+    const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
 
     return device_clear_render_targets(device, 1 /* rt_count */, &dst_surface, 1 /* rect_count */,
-            (const WINED3DRECT *)dst_rect, WINED3DCLEAR_TARGET, c, 0.0f /* depth */, 0 /* stencil */);
+            (const WINED3DRECT *)dst_rect, WINED3DCLEAR_TARGET, &c, 0.0f /* depth */, 0 /* stencil */);
 }
 
 const struct blit_shader ffp_blit =  {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b99dc8c..34a8eb2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1690,7 +1690,7 @@ struct IWineD3DDeviceImpl
 
 HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device,
         UINT rt_count, IWineD3DSurfaceImpl **rts, UINT rect_count, const WINED3DRECT *rects,
-        DWORD flags, const float color[4], float depth, DWORD stencil) DECLSPEC_HIDDEN;
+        DWORD flags, const WINED3DCOLORVALUE *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
 BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
 void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
 void device_get_draw_rect(IWineD3DDeviceImpl *device, RECT *rect) DECLSPEC_HIDDEN;
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index da5531a..ea2f855 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -3321,7 +3321,7 @@ interface IWineD3DDevice : IWineD3DBase
     );
     void ClearRendertargetView(
         [in] IWineD3DRendertargetView *rendertarget_view,
-        [in] const float color[4]
+        [in] const WINED3DCOLORVALUE *color
     );
     void SetPrimitiveType(
         [in] WINED3DPRIMITIVETYPE primitive_topology




More information about the wine-cvs mailing list