[Spice-devel] [PATCH qxl-win] display/*: add PDev->enabled

Alon Levy alevy at redhat.com
Mon Jun 20 04:08:33 PDT 2011


GDI will continue using any callback we registered even after a
DrvAssertMode(FALSE). We are expected to move any surface we own to GDI handled
and ignore any new requests to create a surface. This is called punting and we
use PDev->enabled to indicate if this is required.

A later patch will set PDev->enabled to FALSE on DrvAssertMode.
---
 display/driver.c |    5 +++++
 display/qxldd.h  |   10 ++++++++++
 display/rop.c    |   12 ++++++++++++
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/display/driver.c b/display/driver.c
index f511dc8..791d930 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -517,6 +517,7 @@ DHPDEV DrvEnablePDEV(DEVMODEW *dev_mode, PWSTR ignore1, ULONG ignore2, HSURF *ig
     RtlCopyMemory(dev_caps, &gdi_info, dev_caps_size);
     RtlCopyMemory(in_dev_info, &dev_info, dev_inf_size);
 
+    pdev->enabled = TRUE; /* assume no operations before a DrvEnablePDEV. */
     DEBUG_PRINT((NULL, 1, "%s: 0x%lx\n", __FUNCTION__, pdev));
     return(DHPDEV)pdev;
 
@@ -1172,6 +1173,8 @@ BOOL APIENTRY DrvStrokePath(SURFOBJ *surf, PATHOBJ *path, CLIPOBJ *clip, XFORMOB
         return TRUE;
     }
 
+    PUNT_IF_DISABLED(pdev);
+
     CountCall(pdev, CALL_COUNTER_STROKE_PATH);
 
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
@@ -1264,6 +1267,8 @@ HBITMAP APIENTRY DrvCreateDeviceBitmap(DHPDEV dhpdev, SIZEL size, ULONG format)
         return 0;
     }
 
+    PUNT_IF_DISABLED(pdev);
+
     surface_id = GetFreeSurface(pdev);
     if (!surface_id) {
         goto out_error;
diff --git a/display/qxldd.h b/display/qxldd.h
index 46af39c..f768eb8 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -60,6 +60,14 @@
     EngDebugBreak();                                            \
 }
 
+#define PUNT_IF_DISABLED(pdev) \
+    do { \
+        if (!pdev->enabled) { \
+            DEBUG_PRINT((pdev, 0, "%s: punting\n", __FUNCTION__)); \
+            return FALSE; \
+        } \
+    } while (0)
+
 typedef enum {
     QXL_SUCCESS,
     QXL_FAILED,
@@ -331,6 +339,8 @@ typedef struct PDev {
 
     UINT32 n_surfaces;
     SurfaceInfo surface0_info;
+
+    UINT32 enabled; /* 1 between DrvAssertMode(TRUE) and DrvAssertMode(FALSE) */
 } PDev;
 
 
diff --git a/display/rop.c b/display/rop.c
index dce6e44..9fb3527 100644
--- a/display/rop.c
+++ b/display/rop.c
@@ -1265,6 +1265,8 @@ BOOL APIENTRY DrvBitBlt(SURFOBJ *dest, SURFOBJ *src, SURFOBJ *mask, CLIPOBJ *cli
         pdev = (PDev *)dest->dhpdev;
     }
 
+    PUNT_IF_DISABLED(pdev);
+
     CountCall(pdev, CALL_COUNTER_BIT_BLT);
 
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
@@ -1294,6 +1296,8 @@ BOOL APIENTRY DrvCopyBits(SURFOBJ *dest, SURFOBJ *src, CLIPOBJ *clip,
         pdev = (PDev *)dest->dhpdev;
     }
 
+    PUNT_IF_DISABLED(pdev);
+
     CountCall(pdev, CALL_COUNTER_BIT_BLT);
 
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
@@ -1461,6 +1465,8 @@ BOOL APIENTRY DrvStretchBltROP(SURFOBJ *dest, SURFOBJ *src, SURFOBJ *mask, CLIPO
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
     CountCall(pdev, CALL_COUNTER_STRETCH_BLT_ROP);
 
+    PUNT_IF_DISABLED(pdev);
+
     if ((res = _StretchBlt(pdev, dest, src, mask, clip, color_trans,
                            mode == HALFTONE ? color_adjust: NULL, brush_pos,
                            dest_rect, src_rect, mask_pos, mode, brush,rop4))) {
@@ -1494,6 +1500,8 @@ BOOL APIENTRY DrvStretchBlt(SURFOBJ *dest, SURFOBJ *src, SURFOBJ *mask, CLIPOBJ
 
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
     CountCall(pdev, CALL_COUNTER_STRETCH_BLT);
+    PUNT_IF_DISABLED(pdev);
+
     if ((res = _StretchBlt(pdev, dest, src, mask, clip, color_trans,
                            mode == HALFTONE ? color_adjust: NULL, NULL, dest_rect,
                            src_rect, mask_pos, mode, NULL, (mask) ? 0xccaa:  0xcccc))) {
@@ -1590,6 +1598,8 @@ BOOL APIENTRY DrvAlphaBlend(SURFOBJ *dest, SURFOBJ *src, CLIPOBJ *clip, XLATEOBJ
     pdev = (PDev *)dest->dhpdev;
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
 
+    PUNT_IF_DISABLED(pdev);
+
     ASSERT(pdev, src_rect && src_rect->left < src_rect->right &&
            src_rect->top < src_rect->bottom);
     ASSERT(pdev, dest_rect && dest_rect->left < dest_rect->right &&
@@ -1688,6 +1698,8 @@ BOOL APIENTRY DrvTransparentBlt(SURFOBJ *dest, SURFOBJ *src, CLIPOBJ *clip, XLAT
 
     DEBUG_PRINT((pdev, 3, "%s\n", __FUNCTION__));
 
+    PUNT_IF_DISABLED(pdev);
+
     ASSERT(pdev, src_rect && src_rect->left < src_rect->right &&
            src_rect->top < src_rect->bottom);
     ASSERT(pdev, dest_rect && dest_rect->left < dest_rect->right &&
-- 
1.7.5.2



More information about the Spice-devel mailing list