• R/O
  • HTTP
  • SSH
  • HTTPS

d2dbench: Commit


Commit MetaInfo

Revisión3566a662ae00582090dad98c6fa0e3fec7d6a85f (tree)
Tiempo2012-10-29 07:36:54
Autorkonekoneko <jbh03215@hotm...>
Commiterkonekoneko

Log Message

描写を固定サイズで行うようにした

Cambiar Resumen

Diferencia incremental

--- a/D2DBench/Direct2D.cs
+++ b/D2DBench/Direct2D.cs
@@ -107,14 +107,6 @@ namespace D2DBench
107107 render.DrawTextLayout(new Point(x,y), layout, colors[colorno]);
108108 }
109109
110- public void DrawLine(int x, int y,int tox,int toy, int colorno)
111- {
112- var fore = colors[colorno];
113- Point from = new Point(x,y);
114- Point to = new Point(tox,toy);
115- render.DrawLine(from, to, fore, 1.0f);
116- }
117-
118110 public void DrawEllipse(int x, int y, int radiusX, int radiusY, int colorno)
119111 {
120112 var fore = colors[colorno];
@@ -125,6 +117,17 @@ namespace D2DBench
125117 render.DrawEllipse(ellipse, fore);
126118 }
127119
120+ public void DrawRectangle(int left, int top, int right, int bottom, int colorno)
121+ {
122+ var fore = colors[colorno];
123+ SharpDX.RectangleF rect = new SharpDX.RectangleF();
124+ rect.Left = left;
125+ rect.Top = top;
126+ rect.Right = right;
127+ rect.Bottom = bottom;
128+ render.DrawRectangle(rect, fore);
129+ }
130+
128131 public void FillRectangle(int left, int top, int right, int bottom, int colorno)
129132 {
130133 var fore = colors[colorno];
--- a/D2DBench/Form1.cs
+++ b/D2DBench/Form1.cs
@@ -23,12 +23,12 @@ namespace D2DBench
2323 this.comboBox3.SelectedIndex = 1;
2424 }
2525
26- public const int ExecuteCountPerOneset = 50;
26+ public const int FigureHeight = 256;
2727
2828 private void button1_Click(object sender, EventArgs e)
2929 {
3030 int maxcount = Int32.Parse(this.comboBox1.SelectedItem.ToString());
31- int loopCountAtOneLoop = ExecuteCountPerOneset;
31+ int loopCountAtOneLoop = 50;
3232 if(this.comboBox2.SelectedItem != null)
3333 loopCountAtOneLoop = Int32.Parse(this.comboBox2.SelectedItem.ToString());
3434
--- a/D2DBench/GDI.cs
+++ b/D2DBench/GDI.cs
@@ -205,13 +205,11 @@ namespace D2DBench
205205 static extern bool DeleteObject(IntPtr hObject);
206206 [DllImport("gdi32.dll", EntryPoint = "GetTextExtentExPointW"), SuppressUnmanagedCodeSecurity]
207207 static extern bool GetTextExtentExPoint(IntPtr hdc, [MarshalAs(UnmanagedType.LPWStr)] string lpszStr, int cchString, int nMaxExtent, out int lpnFit, int[] alpDx, out SIZE lpSize);
208+ [DllImport("gdi32.dll"), SuppressUnmanagedCodeSecurity]
209+ static extern bool Rectangle(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
208210 [DllImport("gdi32.dll", EntryPoint = "ExtTextOutW"), SuppressUnmanagedCodeSecurity]
209211 static extern bool ExtTextOut(IntPtr hdc, int X, int Y, uint fuOptions, [In] ref RECT lprc, [MarshalAs(UnmanagedType.LPWStr)] string lpString, uint cbCount, [In] int[] lpDx);
210212 [DllImport("gdi32.dll"), SuppressUnmanagedCodeSecurity]
211- static extern bool LineTo(IntPtr hdc, int nXEnd, int nYEnd);
212- [DllImport("gdi32.dll"), SuppressUnmanagedCodeSecurity]
213- static extern bool MoveToEx(IntPtr hdc, int X, int Y, IntPtr lpPoint);
214- [DllImport("gdi32.dll"), SuppressUnmanagedCodeSecurity]
215213 static extern IntPtr CreatePen(PenStyle fnPenStyle, int nWidth, uint crColor);
216214 [DllImport("gdi32.dll"), SuppressUnmanagedCodeSecurity]
217215 static extern IntPtr CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, FontWeight fnWeight, uint fdwItalic, uint fdwUnderline, uint fdwStrikeOut, FontCharSet fdwCharSet, FontPrecision fdwOutputPrecision, FontClipPrecision fdwClipPrecision, FontQuality fdwQuality, FontPitchAndFamily fdwPitchAndFamily, string lpszFace);
@@ -322,18 +320,18 @@ namespace D2DBench
322320 SelectObject(backdc, oldpen);
323321 }
324322
325- public void DrawLine(int x, int y, int tox, int toy, int colorno)
323+ public void DrawRectangle(int left, int top, int right, int bottom, int colorno)
326324 {
327325 PenStyle style = PenStyle.PS_SOLID;
328326 IntPtr pen = CreatePen(style, 1, (uint)ColorTranslator.ToWin32(this.colors[colorno]));
329327
330328 IntPtr oldpen = SelectObject(backdc, pen);
331329
332- MoveToEx(backdc, x, y, IntPtr.Zero);
333- LineTo(backdc, tox, toy);
334-
330+ Rectangle(backdc, left, top, right, bottom);
331+
335332 DeleteObject(pen);
336333 SelectObject(backdc, oldpen);
334+
337335 }
338336
339337 const string showStr = "D2DBenchMark";
--- a/D2DBench/IRender.cs
+++ b/D2DBench/IRender.cs
@@ -7,7 +7,7 @@ namespace D2DBench
77 int ColorCount { get; }
88 void Dispose();
99 void DrawBitmap(IBitmap bmp, int left, int top, int right, int bottom);
10- void DrawLine(int x, int y, int tox, int toy, int colorno);
10+ void DrawRectangle(int left, int top, int right, int bottom, int colorno);
1111 void DrawString(int x, int y, int colorno);
1212 void EndDraw();
1313 void FillRectangle(int left, int top, int right, int bottom, int colorno);
--- a/D2DBench/Method2.cs
+++ b/D2DBench/Method2.cs
@@ -5,6 +5,7 @@ using System.Windows.Forms;
55 using SharpDX;
66 using SharpDX.Direct2D1;
77 using SharpDX.DirectWrite;
8+using D2DBench.Properties;
89
910 using D2D = SharpDX.Direct2D1;
1011 using DW = SharpDX.DirectWrite;
@@ -15,11 +16,12 @@ namespace D2DBench
1516 class Method2: IBench
1617 {
1718 public int fillAreaSize { get { return 0; } }
18- public string methodName { get { return "線"; } }
19+ public string methodName { get { return "四角形"; } }
1920 public int loopCount { get; set; }
2021
2122 IRender d2d;
2223 Drawing.Size ClientSize;
24+ const int Height = 256;
2325 Random rnd;
2426
2527 public void Init(Control ctrl, bool antialias, RenderMethod method)
@@ -37,10 +39,12 @@ namespace D2DBench
3739 this.d2d.BeginDraw();
3840 for (int i = 0; i < this.loopCount; i++)
3941 {
40- this.d2d.DrawLine(rnd.Next(ClientSize.Width),
41- rnd.Next(ClientSize.Height),
42- rnd.Next(ClientSize.Width),
43- rnd.Next(ClientSize.Height),
42+ int left = rnd.Next(ClientSize.Width);
43+ int top = rnd.Next(ClientSize.Height);
44+ this.d2d.DrawRectangle(left,
45+ top,
46+ left + Form1.FigureHeight,
47+ top + Form1.FigureHeight,
4448 rnd.Next(this.d2d.ColorCount - 1));
4549 }
4650 this.d2d.EndDraw();
--- a/D2DBench/Method3.cs
+++ b/D2DBench/Method3.cs
@@ -39,11 +39,13 @@ namespace D2DBench
3939 this.d2d.BeginDraw();
4040 for (int i = 0; i < this.loopCount; i++)
4141 {
42+ int left = rnd.Next(ClientSize.Width);
43+ int top = rnd.Next(ClientSize.Height);
4244 this.d2d.FillRectangle(
43- rnd.Next(ClientSize.Width),
44- rnd.Next(ClientSize.Height),
45- rnd.Next(ClientSize.Width),
46- rnd.Next(ClientSize.Height),
45+ left,
46+ top,
47+ left + Form1.FigureHeight,
48+ top + Form1.FigureHeight,
4749 rnd.Next(this.d2d.ColorCount - 1));
4850 }
4951 this.d2d.EndDraw();
--- a/D2DBench/Method5.cs
+++ b/D2DBench/Method5.cs
@@ -42,10 +42,11 @@ namespace D2DBench
4242
4343 public void Exec()
4444 {
45+ int radius = Form1.FigureHeight/2;
4546 this.d2d.BeginDraw();
4647 for (int i = 0; i < this.loopCount; i++)
4748 {
48- this.d2d.DrawEllipse(rnd.Next(ClientSize.Width), rnd.Next(ClientSize.Height), 25,25,rnd.Next(this.d2d.ColorCount - 1));
49+ this.d2d.DrawEllipse(rnd.Next(ClientSize.Width), rnd.Next(ClientSize.Height), radius, radius, rnd.Next(this.d2d.ColorCount - 1));
4950 }
5051 this.d2d.EndDraw();
5152 }
Show on old repository browser