Henri Verbeet : wined3d: Implement IWineD3DDeviceImpl_ClearRendertargetView ().

Alexandre Julliard julliard at winehq.org
Wed Feb 25 09:22:40 CST 2009


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Feb 25 08:39:01 2009 +0100

wined3d: Implement IWineD3DDeviceImpl_ClearRendertargetView().

---

 dlls/d3d10core/device.c  |    7 ++++-
 dlls/wined3d/device.c    |   63 +++++++++++++++++++++++++++++++++++++++++++--
 include/wine/wined3d.idl |    4 +++
 3 files changed, 70 insertions(+), 4 deletions(-)

diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 0d79808..8d2b7e3 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -323,8 +323,13 @@ static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface
 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
         ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
 {
-    FIXME("iface %p, render_target_view %p, color_rgba [%f %f %f %f] stub!\n",
+    struct d3d10_device *This = (struct d3d10_device *)iface;
+    IWineD3DRendertargetView *wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view;
+
+    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);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 2196894..871a59a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -6219,7 +6219,9 @@ static IWineD3DSwapChain *get_swapchain(IWineD3DSurface *target) {
     return NULL;
 }
 
-static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, CONST WINED3DRECT *rect, WINED3DCOLOR color) {
+static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface,
+        const WINED3DRECT *rect, const float color[4])
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     IWineD3DSwapChain *swapchain;
 
@@ -6267,7 +6269,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, CONS
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE));
 
-    glClearColor(D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color));
+    glClearColor(color[0], color[1], color[2], color[3]);
     glClear(GL_COLOR_BUFFER_BIT);
     checkGLcall("glClear");
 
@@ -6406,7 +6408,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, IWineD
     }
 
     if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
-        color_fill_fbo(iface, pSurface, pRect, color);
+        const float c[4] = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
+        color_fill_fbo(iface, pSurface, pRect, c);
         return WINED3D_OK;
     } else {
         /* Just forward this to the DirectDraw blitting engine */
@@ -6418,6 +6421,59 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, IWineD
     }
 }
 
+static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *iface,
+        IWineD3DRendertargetView *rendertarget_view, const float color[4])
+{
+    IWineD3DResource *resource;
+    IWineD3DSurface *surface;
+    HRESULT hr;
+
+    hr = IWineD3DRendertargetView_GetResource(rendertarget_view, &resource);
+    if (FAILED(hr))
+    {
+        ERR("Failed to get resource, hr %#x\n", hr);
+        return;
+    }
+
+    if (IWineD3DResource_GetType(resource) != WINED3DRTYPE_SURFACE)
+    {
+        FIXME("Only supported on surface resources\n");
+        IWineD3DResource_Release(resource);
+        return;
+    }
+
+    surface = (IWineD3DSurface *)resource;
+
+    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    {
+        color_fill_fbo(iface, surface, NULL, color);
+    }
+    else
+    {
+        WINEDDBLTFX BltFx;
+        WINED3DCOLOR c;
+
+        WARN("Converting to WINED3DCOLOR, this might give incorrect results\n");
+
+        c = ((DWORD)(color[2] * 255.0));
+        c |= ((DWORD)(color[1] * 255.0)) << 8;
+        c |= ((DWORD)(color[0] * 255.0)) << 16;
+        c |= ((DWORD)(color[3] * 255.0)) << 24;
+
+        /* Just forward this to the DirectDraw blitting engine */
+        memset(&BltFx, 0, sizeof(BltFx));
+        BltFx.dwSize = sizeof(BltFx);
+        BltFx.u5.dwFillColor = argb_to_fmt(c, ((IWineD3DSurfaceImpl *)surface)->resource.format);
+        hr = IWineD3DSurface_Blt(surface, NULL, NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_NONE);
+        if (FAILED(hr))
+        {
+            ERR("Blt failed, hr %#x\n", hr);
+        }
+    }
+
+    IWineD3DResource_Release(resource);
+}
+
 /* rendertarget and depth stencil functions */
 static HRESULT  WINAPI  IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice* iface,DWORD RenderTargetIndex, IWineD3DSurface **ppRenderTarget) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -7710,6 +7766,7 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
     IWineD3DDeviceImpl_EndScene,
     IWineD3DDeviceImpl_Present,
     IWineD3DDeviceImpl_Clear,
+    IWineD3DDeviceImpl_ClearRendertargetView,
     /*** Drawing ***/
     IWineD3DDeviceImpl_DrawPrimitive,
     IWineD3DDeviceImpl_DrawIndexedPrimitive,
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 70e73b5..f924cbe 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -3476,6 +3476,10 @@ interface IWineD3DDevice : IWineD3DBase
         [in] float z,
         [in] DWORD stencil
     );
+    void ClearRendertargetView(
+        [in] IWineD3DRendertargetView *rendertarget_view,
+        [in] const float color[4]
+    );
     HRESULT DrawPrimitive(
         [in] WINED3DPRIMITIVETYPE primitive_type,
         [in] UINT start_vertex,




More information about the wine-cvs mailing list