Henri Verbeet : ddraw: Verify that surfaces with an indexed format have a palette attached in d3d_device_set_render_target ().

Alexandre Julliard julliard at winehq.org
Wed Sep 18 15:49:59 CDT 2013


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Sep 18 10:57:11 2013 +0200

ddraw: Verify that surfaces with an indexed format have a palette attached in d3d_device_set_render_target().

---

 dlls/ddraw/device.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 9f537c1..3f3cb18 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -1796,6 +1796,15 @@ static HRESULT WINAPI d3d_device2_GetCurrentViewport(IDirect3DDevice2 *iface, ID
             (IDirect3DViewport3 **)viewport);
 }
 
+static BOOL validate_surface_palette(struct ddraw_surface *surface)
+{
+    return !(surface->surface_desc.u4.ddpfPixelFormat.dwFlags
+            & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2
+            | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8
+            | DDPF_PALETTEINDEXEDTO8))
+            || wined3d_surface_get_palette(surface->wined3d_surface);
+}
+
 static HRESULT d3d_device_set_render_target(struct d3d_device *device,
         struct ddraw_surface *target, IUnknown *rt_iface)
 {
@@ -1803,6 +1812,13 @@ static HRESULT d3d_device_set_render_target(struct d3d_device *device,
 
     wined3d_mutex_lock();
 
+    if (!validate_surface_palette(target))
+    {
+        WARN("Surface %p has an indexed pixel format, but no palette.\n", target);
+        wined3d_mutex_unlock();
+        return DDERR_INVALIDCAPS;
+    }
+
     if (device->rt_iface == rt_iface)
     {
         TRACE("No-op SetRenderTarget operation, not doing anything\n");
@@ -6752,11 +6768,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUn
         return DDERR_INVALIDCAPS;
     }
 
-    if ((target->surface_desc.u4.ddpfPixelFormat.dwFlags
-            & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2
-            | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8
-            | DDPF_PALETTEINDEXEDTO8))
-            && !wined3d_surface_get_palette(target->wined3d_surface))
+    if (!validate_surface_palette(target))
     {
         WARN("Surface %p has an indexed pixel format, but no palette.\n", target);
         return DDERR_NOPALETTEATTACHED;




More information about the wine-cvs mailing list