[Spice-devel,RFC,qxl-wddm-dod,1/3] Move code for discarding drawable to separate procedure

Submitted by Yuri Benditovich on April 16, 2017, 7:43 p.m.

Details

Message ID 1492371783-19724-2-git-send-email-yuri.benditovich@daynix.com
State New
Headers show
Series "Synchronization of display mode change and pushing drawables" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Yuri Benditovich April 16, 2017, 7:43 p.m.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
 qxldod/QxlDod.cpp | 20 +++++++++++++-------
 qxldod/QxlDod.h   |  1 +
 2 files changed, 14 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 1953688..c60cf31 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -4500,6 +4500,18 @@  BOOLEAN QxlDevice::AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src
     return TRUE;
 }
 
+void QxlDevice::DiscardDrawable(QXLDrawable *drawable)
+{
+    PAGED_CODE();
+    PLIST_ENTRY pDelayedList = DelayedList(drawable);
+    // if some delayed chunks were allocated, free them
+    while (!IsListEmpty(pDelayedList)) {
+        DelayedChunk *pdc = (DelayedChunk *)RemoveHeadList(pDelayedList);
+        delete[] reinterpret_cast<BYTE*>(pdc);
+    }
+    ReleaseOutput(drawable->release_info.id);
+}
+
 QXLDrawable *QxlDevice::PrepareBltBits (
     BLT_INFO* pDst,
     CONST BLT_INFO* pSrc,
@@ -4549,13 +4561,7 @@  QXLDrawable *QxlDevice::PrepareBltBits (
     src += pSrc->Pitch * (height - 1);
 
     if (!AttachNewBitmap(drawable, src, src_end, (INT)pSrc->Pitch, !g_bSupportVSync)) {
-        PLIST_ENTRY pDelayedList = DelayedList(drawable);
-        // if some delayed chunks were allocated, free them
-        while (!IsListEmpty(pDelayedList)) {
-            DelayedChunk *pdc = (DelayedChunk *)RemoveHeadList(pDelayedList);
-            delete[] reinterpret_cast<BYTE*>(pdc);
-        }
-        ReleaseOutput(drawable->release_info.id);
+        DiscardDrawable(drawable);
         drawable = NULL;
     } else {
         DbgPrint(TRACE_LEVEL_INFORMATION, ("%s drawable= %p type = %d, effect = %d Dest right(%d) left(%d) top(%d) bottom(%d) src_bitmap= %p.\n", __FUNCTION__,
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index e865032..b524577 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -603,6 +603,7 @@  private:
     void WaitForCursorRing(void);
     void PushCursor(void);
     BOOLEAN AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src_end, INT pitch, BOOLEAN bForce);
+    void DiscardDrawable(QXLDrawable *drawable);
     BOOLEAN PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr,
                             UINT8 **end_ptr, UINT8 *src, int size,
                             size_t alloc_size, PLIST_ENTRY pDelayed);