[Spice-devel,qxl-win,v4,2/3] display/*: add PDev->enabled

Submitted by Alon Levy on July 27, 2011, 11:17 p.m.

Details

Message ID 1311783443-7040-3-git-send-email-alevy@redhat.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy July 27, 2011, 11:17 p.m.
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(-)

Patch hide | download patch | download mbox

diff --git a/display/driver.c b/display/driver.c
index 6b12540..54913b8 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -516,6 +516,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;
 
@@ -1173,6 +1174,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__));
@@ -1265,6 +1268,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 c9c2300..9b613c1 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -61,6 +61,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,
@@ -345,6 +353,8 @@  typedef struct PDev {
     UINT32 n_surfaces;
     SurfaceInfo surface0_info;
 
+    UINT32 enabled; /* 1 between DrvAssertMode(TRUE) and DrvAssertMode(FALSE) */
+
     UCHAR  pci_revision;
 } 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 &&