• R/O
  • HTTP
  • SSH
  • HTTPS

d2dbench: Commit


Commit MetaInfo

Revisión347220957cdcc848527e9de960bbb133f668733a (tree)
Tiempo2012-10-29 02:53:05
Autorkonekoneko <jbh03215@hotm...>
Commiterkonekoneko

Log Message

ベンチマーク項目を追加した

Cambiar Resumen

Diferencia incremental

--- a/D2DBench/D2DBench.csproj
+++ b/D2DBench/D2DBench.csproj
@@ -79,6 +79,7 @@
7979 <Compile Include="Method2.cs" />
8080 <Compile Include="Method3.cs" />
8181 <Compile Include="Method4.cs" />
82+ <Compile Include="Method5.cs" />
8283 <Compile Include="Program.cs" />
8384 <Compile Include="Properties\AssemblyInfo.cs" />
8485 <Compile Include="RenderAdapter.cs" />
--- a/D2DBench/Direct2D.cs
+++ b/D2DBench/Direct2D.cs
@@ -115,7 +115,17 @@ namespace D2DBench
115115 render.DrawLine(from, to, fore, 1.0f);
116116 }
117117
118- public void FillRectangle(int left,int top,int right,int bottom,int colorno)
118+ public void DrawEllipse(int x, int y, int radiusX, int radiusY, int colorno)
119+ {
120+ var fore = colors[colorno];
121+ D2D.Ellipse ellipse = new Ellipse();
122+ ellipse.Point = new PointF(x, y);
123+ ellipse.RadiusX = radiusX;
124+ ellipse.RadiusY = radiusY;
125+ render.DrawEllipse(ellipse, fore);
126+ }
127+
128+ public void FillRectangle(int left, int top, int right, int bottom, int colorno)
119129 {
120130 var fore = colors[colorno];
121131 SharpDX.RectangleF rect = new SharpDX.RectangleF();
--- a/D2DBench/Form1.cs
+++ b/D2DBench/Form1.cs
@@ -42,6 +42,7 @@ namespace D2DBench
4242 methods.Add(new Method2());
4343 methods.Add(new Method3());
4444 methods.Add(new Method4());
45+ methods.Add(new Method5());
4546
4647 foreach (IBench method in methods)
4748 {
--- a/D2DBench/GDI.cs
+++ b/D2DBench/GDI.cs
@@ -233,7 +233,8 @@ namespace D2DBench
233233 public static extern IntPtr DeleteDC(IntPtr hdc);
234234 [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")]
235235 public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc,int nWidth, int nHeight);
236-
236+ [DllImport("gdi32.dll", ExactSpelling = true, PreserveSig = true, SetLastError = true)]
237+ static extern bool Ellipse(IntPtr hdc, int nLeftRect, int nTopRect,int nRightRect, int nBottomRect);
237238 Graphics frontgrp;
238239 Rectangle ClientRect;
239240 IntPtr frontdc,backdc,backbmp;
@@ -285,6 +286,7 @@ namespace D2DBench
285286 DeleteObject(gbmp.hbmp);
286287 }
287288
289+
288290 public void DrawBitmap(IBitmap bmp,int left,int top,int right,int bottom)
289291 {
290292 GDIBitmap gbmp = (GDIBitmap)bmp;
@@ -303,6 +305,23 @@ namespace D2DBench
303305 SetTextColor(backdc, OldBackColor);
304306 }
305307
308+ public void DrawEllipse(int x, int y, int radiusX, int radiusY, int colorno)
309+ {
310+ PenStyle style = PenStyle.PS_SOLID;
311+ IntPtr pen = CreatePen(style, 1, (uint)ColorTranslator.ToWin32(this.colors[colorno]));
312+
313+ IntPtr oldpen = SelectObject(backdc, pen);
314+
315+ int left = x - radiusX;
316+ int top = y - radiusY;
317+ int right = x + radiusX;
318+ int bottom = y + radiusY;
319+ Ellipse(backdc, left, top, right, bottom);
320+
321+ DeleteObject(pen);
322+ SelectObject(backdc, oldpen);
323+ }
324+
306325 public void DrawLine(int x, int y, int tox, int toy, int colorno)
307326 {
308327 PenStyle style = PenStyle.PS_SOLID;
--- a/D2DBench/IRender.cs
+++ b/D2DBench/IRender.cs
@@ -11,6 +11,7 @@ namespace D2DBench
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);
14+ void DrawEllipse(int x, int y, int radiusX, int radiusY, int colorno);
1415 IBitmap Load(System.Drawing.Bitmap srcBitmap);
1516 void UnLoad(IBitmap bmp);
1617 }
--- /dev/null
+++ b/D2DBench/Method5.cs
@@ -0,0 +1,53 @@
1+using System;
2+using System.Drawing;
3+using System.Drawing.Imaging;
4+using System.Diagnostics;
5+using System.Windows.Forms;
6+using D2DBench.Properties;
7+using SharpDX;
8+using SharpDX.Direct2D1;
9+using SharpDX.DirectWrite;
10+using System.Runtime.InteropServices;
11+
12+using D2D1 = SharpDX.Direct2D1;
13+using DW = SharpDX.DirectWrite;
14+using Drawing = System.Drawing;
15+
16+namespace D2DBench
17+{
18+ class Method5 : IBench
19+ {
20+ public int fillAreaSize { get { return 0; } }
21+ public string methodName { get { return "円"; } }
22+ public int loopCount { get; set; }
23+
24+ Drawing.Size ClientSize;
25+ Random rnd;
26+ IRender d2d;
27+
28+ public void Init(Control ctrl, bool antialias, RenderMethod method)
29+ {
30+ ClientSize = ctrl.ClientSize;
31+ if (method == RenderMethod.Direct2D)
32+ this.d2d = new Direct2D(ctrl, ClientSize, antialias);
33+ else
34+ this.d2d = new GDI(ctrl);
35+ rnd = new Random();
36+ }
37+
38+ public void Dispose()
39+ {
40+ this.d2d.Dispose();
41+ }
42+
43+ public void Exec()
44+ {
45+ this.d2d.BeginDraw();
46+ for (int i = 0; i < this.loopCount; i++)
47+ {
48+ this.d2d.DrawEllipse(rnd.Next(ClientSize.Width), rnd.Next(ClientSize.Height), 25,25,rnd.Next(this.d2d.ColorCount - 1));
49+ }
50+ this.d2d.EndDraw();
51+ }
52+ }
53+}
Show on old repository browser