Revisión | 347220957cdcc848527e9de960bbb133f668733a (tree) |
---|---|
Tiempo | 2012-10-29 02:53:05 |
Autor | konekoneko <jbh03215@hotm...> |
Commiter | konekoneko |
ベンチマーク項目を追加した
@@ -79,6 +79,7 @@ | ||
79 | 79 | <Compile Include="Method2.cs" /> |
80 | 80 | <Compile Include="Method3.cs" /> |
81 | 81 | <Compile Include="Method4.cs" /> |
82 | + <Compile Include="Method5.cs" /> | |
82 | 83 | <Compile Include="Program.cs" /> |
83 | 84 | <Compile Include="Properties\AssemblyInfo.cs" /> |
84 | 85 | <Compile Include="RenderAdapter.cs" /> |
@@ -115,7 +115,17 @@ namespace D2DBench | ||
115 | 115 | render.DrawLine(from, to, fore, 1.0f); |
116 | 116 | } |
117 | 117 | |
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) | |
119 | 129 | { |
120 | 130 | var fore = colors[colorno]; |
121 | 131 | SharpDX.RectangleF rect = new SharpDX.RectangleF(); |
@@ -42,6 +42,7 @@ namespace D2DBench | ||
42 | 42 | methods.Add(new Method2()); |
43 | 43 | methods.Add(new Method3()); |
44 | 44 | methods.Add(new Method4()); |
45 | + methods.Add(new Method5()); | |
45 | 46 | |
46 | 47 | foreach (IBench method in methods) |
47 | 48 | { |
@@ -233,7 +233,8 @@ namespace D2DBench | ||
233 | 233 | public static extern IntPtr DeleteDC(IntPtr hdc); |
234 | 234 | [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")] |
235 | 235 | 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); | |
237 | 238 | Graphics frontgrp; |
238 | 239 | Rectangle ClientRect; |
239 | 240 | IntPtr frontdc,backdc,backbmp; |
@@ -285,6 +286,7 @@ namespace D2DBench | ||
285 | 286 | DeleteObject(gbmp.hbmp); |
286 | 287 | } |
287 | 288 | |
289 | + | |
288 | 290 | public void DrawBitmap(IBitmap bmp,int left,int top,int right,int bottom) |
289 | 291 | { |
290 | 292 | GDIBitmap gbmp = (GDIBitmap)bmp; |
@@ -303,6 +305,23 @@ namespace D2DBench | ||
303 | 305 | SetTextColor(backdc, OldBackColor); |
304 | 306 | } |
305 | 307 | |
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 | + | |
306 | 325 | public void DrawLine(int x, int y, int tox, int toy, int colorno) |
307 | 326 | { |
308 | 327 | PenStyle style = PenStyle.PS_SOLID; |
@@ -11,6 +11,7 @@ namespace D2DBench | ||
11 | 11 | void DrawString(int x, int y, int colorno); |
12 | 12 | void EndDraw(); |
13 | 13 | 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); | |
14 | 15 | IBitmap Load(System.Drawing.Bitmap srcBitmap); |
15 | 16 | void UnLoad(IBitmap bmp); |
16 | 17 | } |
@@ -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 | +} |