Wintab32 (Patch 1 of 2) -- fix a nuber of issues with tablet queues.
Robert North
7ownq0k402 at sneakemail.com
Thu Nov 25 14:47:23 CST 2004
This patch fixes the following:
Changelog:
In the functions that access the Wintab packet queue:
* Ensure that if buffer pointer is null, queue is flushed.
* Ensure that correct packets are copied into output buffer.
* Use memmove when moving packets within queue, as source and dest will
typically overlap.
* When moving packets in queue, ensure correct number of packets are moved.
This results in improved tablet drawing in Painter 5, when combined with
the next patch I'll send.
Bye
-Rob.
-------------- next part --------------
Index: dlls/wintab32/context.c
===================================================================
--- dlls/wintab32/context.c (revision 129)
+++ dlls/wintab32/context.c (revision 135)
@@ -463,26 +463,36 @@
TRACE("(%p, %d, %p)\n", hCtx, cMaxPkts, lpPkts);
- if (!hCtx || !lpPkts) return 0;
+ if (!hCtx)
+ return 0;
EnterCriticalSection(&csTablet);
context = TABLET_FindOpenContext(hCtx);
- TABLET_BlankPacketData(context,lpPkts,cMaxPkts);
+ if (lpPkts != NULL)
+ TABLET_BlankPacketData(context,lpPkts,cMaxPkts);
+
if (context->PacketsQueued == 0)
{
LeaveCriticalSection(&csTablet);
return 0;
}
- for(limit = 0; limit < cMaxPkts && limit < context->PacketsQueued; limit++)
- ptr=TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[limit]);
+ limit = min(cMaxPkts,context->PacketsQueued);
+ if(ptr != NULL)
+ {
+ int i = 0;
+ for(i = 0; i < limit; i++)
+ ptr=TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[i]);
+ }
+
+
if (limit < context->PacketsQueued)
{
- memcpy(context->PacketQueue, &context->PacketQueue[limit],
- (context->QueueSize - (limit))*sizeof(WTPACKET));
+ memmove(context->PacketQueue, &context->PacketQueue[limit],
+ (context->PacketsQueued - (limit))*sizeof(WTPACKET));
}
context->PacketsQueued -= limit;
LeaveCriticalSection(&csTablet);
@@ -503,7 +513,8 @@
TRACE("(%p, %d, %p)\n", hCtx, wSerial, lpPkt);
- if (!hCtx) return 0;
+ if (!hCtx)
+ return 0;
EnterCriticalSection(&csTablet);
@@ -518,8 +529,8 @@
if ((rc+1) < context->QueueSize)
{
- memcpy(context->PacketQueue, &context->PacketQueue[rc+1],
- (context->QueueSize - (rc+1))*sizeof(WTPACKET));
+ memmove(context->PacketQueue, &context->PacketQueue[rc+1],
+ (context->PacketsQueued - (rc+1))*sizeof(WTPACKET));
}
context->PacketsQueued -= (rc+1);
}
@@ -583,7 +594,7 @@
EnterCriticalSection(&csTablet);
context = TABLET_FindOpenContext(hCtx);
- memcpy(lpLogCtx,&context->context,sizeof(LOGCONTEXTA));
+ memmove(lpLogCtx,&context->context,sizeof(LOGCONTEXTA));
LeaveCriticalSection(&csTablet);
return TRUE;
@@ -747,12 +758,12 @@
}
for (num = bgn; num <= end; num++)
- ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[end]);
+ ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[num]);
/* remove read packets */
if ((end+1) < context->PacketsQueued)
- memcpy( &context->PacketQueue[bgn], &context->PacketQueue[end+1],
- (context->PacketsQueued - ((end-bgn)+1)) * sizeof (WTPACKET));
+ memmove( &context->PacketQueue[bgn], &context->PacketQueue[end+1],
+ (context->PacketsQueued - (end+1)) * sizeof (WTPACKET));
context->PacketsQueued -= ((end-bgn)+1);
*lpNPkts = ((end-bgn)+1);
@@ -777,7 +788,7 @@
TRACE("(%p, %u, %u, %d, %p, %p)\n",
hCtx, wBegin, wEnd, cMaxPkts, lpPkts, lpNPkts);
- if (!hCtx) return 0;
+ if (!hCtx || !lpPkts) return 0;
EnterCriticalSection(&csTablet);
@@ -806,7 +817,7 @@
}
for (num = bgn; num <= end; num++)
- ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[end]);
+ ptr = TABLET_CopyPacketData(context ,ptr, &context->PacketQueue[num]);
*lpNPkts = ((end-bgn)+1);
LeaveCriticalSection(&csTablet);
More information about the wine-patches
mailing list