Revisión | 3566a662ae00582090dad98c6fa0e3fec7d6a85f (tree) |
---|---|
Tiempo | 2012-10-29 07:36:54 |
Autor | konekoneko <jbh03215@hotm...> |
Commiter | konekoneko |
描写を固定サイズで行うようにした
@@ -107,14 +107,6 @@ namespace D2DBench | ||
107 | 107 | render.DrawTextLayout(new Point(x,y), layout, colors[colorno]); |
108 | 108 | } |
109 | 109 | |
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 | - | |
118 | 110 | public void DrawEllipse(int x, int y, int radiusX, int radiusY, int colorno) |
119 | 111 | { |
120 | 112 | var fore = colors[colorno]; |
@@ -125,6 +117,17 @@ namespace D2DBench | ||
125 | 117 | render.DrawEllipse(ellipse, fore); |
126 | 118 | } |
127 | 119 | |
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 | + | |
128 | 131 | public void FillRectangle(int left, int top, int right, int bottom, int colorno) |
129 | 132 | { |
130 | 133 | var fore = colors[colorno]; |
@@ -23,12 +23,12 @@ namespace D2DBench | ||
23 | 23 | this.comboBox3.SelectedIndex = 1; |
24 | 24 | } |
25 | 25 | |
26 | - public const int ExecuteCountPerOneset = 50; | |
26 | + public const int FigureHeight = 256; | |
27 | 27 | |
28 | 28 | private void button1_Click(object sender, EventArgs e) |
29 | 29 | { |
30 | 30 | int maxcount = Int32.Parse(this.comboBox1.SelectedItem.ToString()); |
31 | - int loopCountAtOneLoop = ExecuteCountPerOneset; | |
31 | + int loopCountAtOneLoop = 50; | |
32 | 32 | if(this.comboBox2.SelectedItem != null) |
33 | 33 | loopCountAtOneLoop = Int32.Parse(this.comboBox2.SelectedItem.ToString()); |
34 | 34 |
@@ -205,13 +205,11 @@ namespace D2DBench | ||
205 | 205 | static extern bool DeleteObject(IntPtr hObject); |
206 | 206 | [DllImport("gdi32.dll", EntryPoint = "GetTextExtentExPointW"), SuppressUnmanagedCodeSecurity] |
207 | 207 | 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); | |
208 | 210 | [DllImport("gdi32.dll", EntryPoint = "ExtTextOutW"), SuppressUnmanagedCodeSecurity] |
209 | 211 | 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); |
210 | 212 | [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] | |
215 | 213 | static extern IntPtr CreatePen(PenStyle fnPenStyle, int nWidth, uint crColor); |
216 | 214 | [DllImport("gdi32.dll"), SuppressUnmanagedCodeSecurity] |
217 | 215 | 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 | ||
322 | 320 | SelectObject(backdc, oldpen); |
323 | 321 | } |
324 | 322 | |
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) | |
326 | 324 | { |
327 | 325 | PenStyle style = PenStyle.PS_SOLID; |
328 | 326 | IntPtr pen = CreatePen(style, 1, (uint)ColorTranslator.ToWin32(this.colors[colorno])); |
329 | 327 | |
330 | 328 | IntPtr oldpen = SelectObject(backdc, pen); |
331 | 329 | |
332 | - MoveToEx(backdc, x, y, IntPtr.Zero); | |
333 | - LineTo(backdc, tox, toy); | |
334 | - | |
330 | + Rectangle(backdc, left, top, right, bottom); | |
331 | + | |
335 | 332 | DeleteObject(pen); |
336 | 333 | SelectObject(backdc, oldpen); |
334 | + | |
337 | 335 | } |
338 | 336 | |
339 | 337 | const string showStr = "D2DBenchMark"; |
@@ -7,7 +7,7 @@ namespace D2DBench | ||
7 | 7 | int ColorCount { get; } |
8 | 8 | void Dispose(); |
9 | 9 | 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); | |
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); |
@@ -5,6 +5,7 @@ using System.Windows.Forms; | ||
5 | 5 | using SharpDX; |
6 | 6 | using SharpDX.Direct2D1; |
7 | 7 | using SharpDX.DirectWrite; |
8 | +using D2DBench.Properties; | |
8 | 9 | |
9 | 10 | using D2D = SharpDX.Direct2D1; |
10 | 11 | using DW = SharpDX.DirectWrite; |
@@ -15,11 +16,12 @@ namespace D2DBench | ||
15 | 16 | class Method2: IBench |
16 | 17 | { |
17 | 18 | public int fillAreaSize { get { return 0; } } |
18 | - public string methodName { get { return "線"; } } | |
19 | + public string methodName { get { return "四角形"; } } | |
19 | 20 | public int loopCount { get; set; } |
20 | 21 | |
21 | 22 | IRender d2d; |
22 | 23 | Drawing.Size ClientSize; |
24 | + const int Height = 256; | |
23 | 25 | Random rnd; |
24 | 26 | |
25 | 27 | public void Init(Control ctrl, bool antialias, RenderMethod method) |
@@ -37,10 +39,12 @@ namespace D2DBench | ||
37 | 39 | this.d2d.BeginDraw(); |
38 | 40 | for (int i = 0; i < this.loopCount; i++) |
39 | 41 | { |
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, | |
44 | 48 | rnd.Next(this.d2d.ColorCount - 1)); |
45 | 49 | } |
46 | 50 | this.d2d.EndDraw(); |
@@ -39,11 +39,13 @@ namespace D2DBench | ||
39 | 39 | this.d2d.BeginDraw(); |
40 | 40 | for (int i = 0; i < this.loopCount; i++) |
41 | 41 | { |
42 | + int left = rnd.Next(ClientSize.Width); | |
43 | + int top = rnd.Next(ClientSize.Height); | |
42 | 44 | 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, | |
47 | 49 | rnd.Next(this.d2d.ColorCount - 1)); |
48 | 50 | } |
49 | 51 | this.d2d.EndDraw(); |
@@ -42,10 +42,11 @@ namespace D2DBench | ||
42 | 42 | |
43 | 43 | public void Exec() |
44 | 44 | { |
45 | + int radius = Form1.FigureHeight/2; | |
45 | 46 | this.d2d.BeginDraw(); |
46 | 47 | for (int i = 0; i < this.loopCount; i++) |
47 | 48 | { |
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)); | |
49 | 50 | } |
50 | 51 | this.d2d.EndDraw(); |
51 | 52 | } |