Background
I'm working on an application that is supposed to work on every windows platform from XP onwards in the same manner. Through the .NET framework this has been very easy, for the most part. The application runs across a variety of touch surfaces. The application targets .Net 3.0, but if for some reason I should move to .Net 3.5, I can do that. I am unable to use 4.0.
The application makes heavy use of GDI+ through the System.Drawing namespace. Now, I understand that GDI+ either isn't hardware accelerated at all or is only accelerated in a very small number of graphics cards, so I expect to have some performance issues. However, this issue is blaring and makes the application's usability significantly lower. I would rather not rewrite the entire application to target DirectX or OpenGL if it can be avoided with an easy fix.
The Problem
We recently installed Windows 7 64-bit on one of the touch tables. It was the first time the application was run on a Windows 7 64-bit machine. In any event, any drawing (specifically DrawLine) with more than one finger on the device at a time causes a ridiculous amount of lag. This lag isn't apparent on 32-bit Windows XP or 32-bit Windows 7, so I think it might be specific to 64-bit Windows 7 (I don't have a 64-bit XP machine to test with).
The application was also forced to run as a 32-bit application due to one of the .dll files only have 32-bit libraries available to compile it. I read somewhere that forcing a process into 32-bit mode on a 64-bit system could cause performance issues, but when I upgraded the SDK we were using and made a 64-bit specific .dll and application, the problem persisted.
I read on this other StackOverflow thread that there should be no differences between a 32-bit and a 64-bit application with relation to GDI+. This doesn't seem to be the case here.
So what it comes down to: Do any of you know why there might be such a huge performance difference between Windows 32-bit and Windows 64-bit? If I can't find a solution, I'll have to spend a bit of time making everything use hardware accelerated drawing. I would like to avoid that if at all possible.
Thanks everyone!
EDIT: Requested code snippet
public delegate void drawLineDelegate(Color color, float width, int x1, int y1, int x2, int y2);
public void drawLine(Color color, float width, int x1, int y1, int x2, int y2)
{
if (InvokeRequired)
{
Invoke(new drawLineDelegate(drawLine), new object[] { color, width, x1, y1, x2, y2 });
}
else
{
try
{
lock (drawLock)
{
pen.Width = width;
pen.Color = color;
scaledPen.Width = width * this.Width / Canvas.Width;
scaledPen.Color = color;
Point p1 = scalePointToScreen(new Point(x1, y1));
Point p2 = scalePointToScreen(new Point(x2, y2));
graphics.DrawLine(pen, x1, y1, x2, y2);
scaledGraphics.DrawLine(scaledPen, p1.X, p1.Y, p2.X, p2.Y);
this.Invalidate(new Rectangle(Math.Min(p1.X, p2.X) - (int)scaledPen.Width, Math.Min(p1.Y, p2.Y) - (int)scaledPen.Width,
Math.Abs(p2.X - p1.X) + 2 * (int)scaledPen.Width, Math.Abs(p2.Y - p1.Y) + 2 * (int)scaledPen.Width));
}
}
catch (Exception ex)
{
if (Scribbler.Properties.Settings.Default.LogLevel >= 2)
{
Scribbler.ScribblerForm.WriteLogMessage(ex.ToString());
}
}
}
Edit: Further Research I did some more scouring of the internet with relation to the NVidia cards we use on our machines. This lead me to several posts on the NVidia Developer Forums about people with the same issue. The common answer is that GDI is deprecated on Windows 7 and the newer NVidia graphics drivers (from 182.5 onwards) suffer from GDI performance issues. The solutions were either to update to Direct3D or use old drivers. Does anyone know for certain whether this is the best course of action?