butcher rendering performance test for more speed
This commit is contained in:
parent
35d31c418b
commit
d5d2c87d68
|
@ -42,6 +42,17 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
|
||||
#endregion
|
||||
|
||||
public NativeTextRenderer(System.Windows.Forms.Control c)
|
||||
{
|
||||
_c = c;
|
||||
_hdc = GetDC(c.Handle);
|
||||
}
|
||||
|
||||
System.Windows.Forms.Control _c;
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetDC(IntPtr hWnd);
|
||||
|
||||
/// <summary>
|
||||
/// Init.
|
||||
|
@ -50,14 +61,14 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
{
|
||||
_g = g;
|
||||
|
||||
var clip = _g.Clip.GetHrgn(_g);
|
||||
//var clip = _g.Clip.GetHrgn(_g);
|
||||
|
||||
_hdc = _g.GetHdc();
|
||||
SetBkMode(_hdc, 1);
|
||||
|
||||
SelectClipRgn(_hdc, clip);
|
||||
//SelectClipRgn(_hdc, clip);
|
||||
|
||||
DeleteObject(clip);
|
||||
//DeleteObject(clip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -107,11 +118,14 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
/// <param name="color">the text color to set</param>
|
||||
/// <param name="point">the location to start string draw (top-left)</param>
|
||||
public void DrawString(String str, Font font, Color color, Point point)
|
||||
{
|
||||
TextOut(_hdc, point.X, point.Y, str, str.Length);
|
||||
}
|
||||
|
||||
public void PrepDrawString(String str, Font font, Color color, Point point)
|
||||
{
|
||||
SetFont(font);
|
||||
SetTextColor(color);
|
||||
|
||||
TextOut(_hdc, point.X, point.Y, str, str.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -137,6 +151,12 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_c != null)
|
||||
{
|
||||
ReleaseDC(_c.Handle, _hdc);
|
||||
_hdc = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (_hdc != IntPtr.Zero)
|
||||
{
|
||||
SelectClipRgn(_hdc, IntPtr.Zero);
|
||||
|
@ -200,6 +220,14 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
SetTextColor(_hdc, rgb);
|
||||
}
|
||||
|
||||
public void DrawRectangle(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect)
|
||||
{
|
||||
Rectangle(_hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
|
||||
}
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern int Rectangle(IntPtr hdc,int nLeftRect,int nTopRect,int nRightRect,int nBottomRect);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern int SetBkMode(IntPtr hdc, int mode);
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@
|
|||
//
|
||||
// NameTableView
|
||||
//
|
||||
this.NameTableView.BackColor = System.Drawing.Color.Transparent;
|
||||
this.NameTableView.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.NameTableView.Location = new System.Drawing.Point(6, 19);
|
||||
this.NameTableView.Name = "NameTableView";
|
||||
|
|
|
@ -23,11 +23,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
Nametables = new Bitmap(pSize.Width, pSize.Height);
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
//SetStyle(ControlStyles.Opaque, true);
|
||||
SetStyle(ControlStyles.DoubleBuffer, false);
|
||||
// SetStyle(ControlStyles.SupportsTransparentBackColor, false);
|
||||
SetStyle(ControlStyles.Opaque, true);
|
||||
Size = new Size(256, 224);
|
||||
BackColor = Color.Transparent;
|
||||
//BackColor = Color.Transparent;
|
||||
//Paint += NameTableViewer_Paint;
|
||||
}
|
||||
|
||||
|
@ -38,38 +38,43 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public WhichNametable Which = WhichNametable.NT_ALL;
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs pevent)
|
||||
{
|
||||
|
||||
using (var ntr = new NativeTextRenderer(e.Graphics))
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random r = new Random((int)DateTime.Now.Ticks);
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
sb.Append((char)r.Next(0, 255));
|
||||
}
|
||||
}
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var font = this.Font;
|
||||
|
||||
ntr.DrawString(sb.ToString(), this.Font, Color.Black, new Point(15, y * 30));
|
||||
//e.Graphics.DrawString(sb.ToString(), this.Font, Brushes.Black, new Point(15, y * 30));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random r = new Random((int)DateTime.Now.Ticks);
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
sb.Append((char)r.Next(0, 255));
|
||||
}
|
||||
|
||||
e.Graphics.DrawString(sb.ToString(), this.Font, Brushes.Black, new Point(15, y * 30));
|
||||
StringBuilder sb = new StringBuilder(128);
|
||||
Random r = new Random((int)DateTime.Now.Ticks);
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
sb.Append((char)r.Next('a', 'z'));
|
||||
}
|
||||
*/
|
||||
string junk = sb.ToString();
|
||||
|
||||
|
||||
using (var ntr = new NativeTextRenderer(this))
|
||||
{
|
||||
ntr.PrepDrawString(junk, font, Color.Black, new Point(0, 0));
|
||||
ntr.DrawRectangle(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
ntr.DrawString(junk, font, Color.Black, new Point(15, y * 30));
|
||||
//e.Graphics.DrawString(sb.ToString(), this.Font, Brushes.Black, new Point(15, y * 30));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//e.Graphics.FillRectangle(Brushes.White, ClientRectangle);
|
||||
//for (int y = 0; y < 16; y++)
|
||||
//{
|
||||
// e.Graphics.DrawString(junk, font, Brushes.Black, new Point(15, y * 30));
|
||||
//}
|
||||
|
||||
//base.OnPaint(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue