问题
In my application i am drawing some set of lines (like a vertical graph), and the refresh rate will be around 30 times in a second. I have calculated the performance and it is taking 400 milliseconds to draw complete lines, but this won't be fast enough since we have to refresh the screen every 34 milliseconds.
I am drawing on CDC.
We will be drawing on a Windows CE device with a 400 MHz processor. Drawing involves the simple MFC APIs like MoveTo
, LineTo
, FillRect
, etc. on DC of View:
CDC* pDC = GetDC(); //draw vertical line from one end of screen to the other
pDC->MoveTo(some xy Cordinates);
pDC->LineTo(some xy Points);
How we can optimize the drawing routines? Please suggest any pointers.
回答1:
Since Windows Vista, GDI operations (other than BitBlt) are no longer hardware accelerated, but done in software.
To get the performance you need, you probably need to use Direct3D or OpenGl.
All though this msdn document implies that, since NT 6.1, hw acceleration of GDI is back on the table. Still I expect the vector based APIs offered by OpenGL and D3D should perform far more reliably - GDI line drawing is not something driver writers strive to optimize.
In answer to the update re Windows CE being the target: Direct X has apparently been available on Windows CE since at least CE 2.1
Im still betting that GDI is not particularly hw accelerated on CE; if there is any hw support at all, DirectX would be the way to access it.
来源:https://stackoverflow.com/questions/4524527/how-can-drawing-routines-be-optimized-to-achieve-the-maximum-refresh-rate-in-win