Author: jpobst
Date: 2007-01-17 17:10:46 -0500 (Wed, 17 Jan 2007)
New Revision: 71232
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
Log:
2007-01-16 Jonathan Pobst <[EMAIL PROTECTED]>
* XplatUIWin32.cs: Implement proper double buffering for Windows.
[Fixes bug #80447, and probably speeds up things as well]
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-01-17 21:35:11 UTC (rev 71231)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-01-17 22:10:46 UTC (rev 71232)
@@ -1,3 +1,8 @@
+2007-01-16 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * XplatUIWin32.cs: Implement proper double buffering for Windows.
+ [Fixes bug #80447, and probably speeds up things as well]
+
2007-01-16 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* XplatUIX11.cs: Caption height for MDI children is 19, not 26.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
2007-01-17 21:35:11 UTC (rev 71231)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
2007-01-17 22:10:46 UTC (rev 71232)
@@ -404,8 +404,27 @@
internal byte tmStruckOut;
internal byte tmPitchAndFamily;
internal byte tmCharSet;
- }
+ }
+ public enum TernaryRasterOperations : uint
+ {
+ SRCCOPY = 0x00CC0020,
+ SRCPAINT = 0x00EE0086,
+ SRCAND = 0x008800C6,
+ SRCINVERT = 0x00660046,
+ SRCERASE = 0x00440328,
+ NOTSRCCOPY = 0x00330008,
+ NOTSRCERASE = 0x001100A6,
+ MERGECOPY = 0x00C000CA,
+ MERGEPAINT = 0x00BB0226,
+ PATCOPY = 0x00F00021,
+ PATPAINT = 0x00FB0A09,
+ PATINVERT = 0x005A0049,
+ DSTINVERT = 0x00550009,
+ BLACKNESS = 0x00000042,
+ WHITENESS = 0x00FF0062
+ }
+
[Flags]
private enum ScrollWindowExFlags {
SW_NONE = 0x0000,
@@ -2611,9 +2630,55 @@
return 1;
}
}
-
+
+ private class WinBuffer
+ {
+ public IntPtr hdc;
+ public IntPtr bitmap;
+
+ public WinBuffer (IntPtr hdc, IntPtr bitmap)
+ {
+ this.hdc = hdc;
+ this.bitmap = bitmap;
+ }
+ }
+
+ internal override void CreateOffscreenDrawable (IntPtr handle,
int width, int height, out object offscreen_drawable)
+ {
+ Graphics destG = Graphics.FromHwnd (handle);
+ IntPtr destHdc = destG.GetHdc ();
+
+ IntPtr srcHdc = Win32CreateCompatibleDC (destHdc);
+ IntPtr srcBmp = Win32CreateCompatibleBitmap (destHdc,
width, height);
+ Win32SelectObject (srcHdc, srcBmp);
+
+ offscreen_drawable = new WinBuffer (srcHdc, srcBmp);
+
+ destG.ReleaseHdc ();
+ }
+
+ internal override Graphics GetOffscreenGraphics (object
offscreen_drawable)
+ {
+ return Graphics.FromHdc
(((WinBuffer)offscreen_drawable).hdc);
+ }
+
+ internal override void BlitFromOffscreen (IntPtr dest_handle,
Graphics dest_dc, object offscreen_drawable, Graphics offscreen_dc, Rectangle r)
+ {
+ WinBuffer wb = (WinBuffer)offscreen_drawable;
+
+ Win32BitBlt (dest_dc.GetHdc (), r.Left, r.Top, r.Width,
r.Height, wb.hdc, r.Left, r.Top, TernaryRasterOperations.SRCCOPY);
+ dest_dc.ReleaseHdc ();
+ }
+
+ internal override void DestroyOffscreenDrawable (object
offscreen_drawable)
+ {
+ WinBuffer wb = (WinBuffer)offscreen_drawable;
+
+ Win32DeleteObject (wb.bitmap);
+ Win32DeleteDC (wb.hdc);
+ }
+
internal override event EventHandler Idle;
-
#endregion // Public Static Methods
#region Win32 Imports
@@ -2973,6 +3038,19 @@
[DllImport ("user32.dll", EntryPoint="GetClipCursor",
CallingConvention=CallingConvention.StdCall)]
internal extern static bool Win32GetClipCursor (out RECT
lpRect);
+
+ [DllImport ("gdi32.dll", EntryPoint="BitBlt",
CallingConvention=CallingConvention.StdCall)]
+ internal static extern bool Win32BitBlt (IntPtr hObject, int
nXDest, int nYDest, int nWidth,
+ int nHeight, IntPtr hObjSource, int nXSrc, int nYSrc,
TernaryRasterOperations dwRop);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreateCompatibleDC",
CallingConvention=CallingConvention.StdCall, ExactSpelling = true, SetLastError
= true)]
+ internal static extern IntPtr Win32CreateCompatibleDC (IntPtr
hdc);
+
+ [DllImport ("gdi32.dll", EntryPoint="DeleteDC",
CallingConvention=CallingConvention.StdCall, ExactSpelling = true, SetLastError
= true)]
+ internal static extern bool Win32DeleteDC (IntPtr hdc);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreateCompatibleBitmap",
CallingConvention=CallingConvention.StdCall)]
+ internal static extern IntPtr Win32CreateCompatibleBitmap
(IntPtr hdc, int nWidth, int nHeight);
#endregion
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches