2 Copyright © 2011, The AROS Development Team. All rights reserved.
9 /*****************************************************************************
29 ******************************************************************************/
31 #if !defined(ONLY_BENCH_CODE)
32 #include <cybergraphx/cybergraphics.h>
33 #include <devices/timer.h>
35 #include <proto/exec.h>
36 #include <proto/dos.h>
37 #include <proto/graphics.h>
38 #include <proto/intuition.h>
39 #include <proto/cybergraphics.h>
40 #include <proto/diskfont.h>
45 #include <aros/debug.h>
47 /****************************************************************************************/
49 #define ARG_TEMPLATE "WIDTH=W/N/K,HEIGHT=H/N/K,LEN=W/N/K,MODE=P/K,ANTIALIAS/S"
54 #define ARG_ANTIALIAS 4
57 /****************************************************************************************/
59 struct RDArgs
*myargs
;
65 STRPTR modename
= "JAM1";
66 STRPTR aa
= "NON-ANTIALIASED";
68 BOOL antialias
= FALSE
;
69 STRPTR consttext
= "The AROS Development Team. All rights reserved.";
73 /****************************************************************************************/
75 static void cleanup(STRPTR msg
, ULONG retcode
)
79 fprintf(stderr
, "text: %s\n", msg
);
82 if (myargs
) FreeArgs(myargs
);
87 /****************************************************************************************/
89 static void getarguments(void)
91 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0)))
93 Fault(IoErr(), 0, s
, 255);
94 cleanup(s
, RETURN_FAIL
);
97 if (args
[ARG_W
]) width
= *(LONG
*)args
[ARG_W
];
99 if (args
[ARG_H
]) height
= *(LONG
*)args
[ARG_H
];
101 if (args
[ARG_LEN
]) linelen
= *(LONG
*)args
[ARG_LEN
];
105 if (strcasecmp((STRPTR
)args
[ARG_MODE
], "JAM1") == 0)
111 if (strcasecmp((STRPTR
)args
[ARG_MODE
], "JAM2") == 0)
117 if (strcasecmp((STRPTR
)args
[ARG_MODE
], "COMPLEMENT") == 0)
120 modename
= "COMPLEMENT";
123 antialias
= (BOOL
)args
[ARG_ANTIALIAS
];
124 if (antialias
) aa
= "ANTIALIASED";
129 /****************************************************************************************/
130 static void printresults(LONG t
, LONG i
)
135 printf("Mode : %s, %s\n", modename
, aa
);
136 printf("Elapsed time : %d us (%f s)\n", (int)t
, (double)t
/ 1000000);
137 printf("Blits : %d\n", (int)i
);
138 printf("Blits/sec : %f\n", i
* 1000000.0 / t
);
139 printf("Time/blit : %f us (%f s) (%d%% of 25Hz Frame)\n",
141 (double)t
/ i
/ 1000000.0,
142 (int)(100.0 * ((double)t
/ i
) / (1000000.0 / 25.0)));
144 bpp
= GetCyberMapAttr(win
->WScreen
->RastPort
.BitMap
, CYBRMATTR_BPPIX
);
145 printf("\nScreen Bytes Per Pixel: %d\n", (int)bpp
);
146 printf("Area size in Pixels : %d\n", (int)(width
* height
));
147 printf("Area size in Bytes : %d\n", (int)(width
* height
* bpp
));
149 q
= ((QUAD
)width
) * ((QUAD
)height
) * ((QUAD
)bpp
) * ((QUAD
)i
) * ((QUAD
)1000000) / (QUAD
)t
;
150 printf("Bytes/sec to gfx card : %lld (%lld MB)\n", (long long)q
, (long long)q
/ 1048576);
152 #endif /* !defined(ONLY_BENCH_CODE) */
154 /****************************************************************************************/
156 static void action_text(void)
158 struct timeval tv_start
, tv_end
;
160 STRPTR buffer
= NULL
;
162 ULONG consttextlen
= strlen(consttext
);
164 struct TextExtent extend
;
166 win
= OpenWindowTags(NULL
, WA_Borderless
, TRUE
,
167 WA_InnerWidth
, width
,
168 WA_InnerHeight
, height
,
170 WA_IDCMP
, IDCMP_VANILLAKEY
,
175 cleanup("Can't open window!", RETURN_FAIL
);
179 height
= win
->Height
;
181 SetAPen(win
->RPort
, 2);
182 RectFill(win
->RPort
, 0, 0, width
, height
);
186 CurrentTime(&tv_start
.tv_secs
, &tv_start
.tv_micro
);
189 SetAPen(win
->RPort
, 1);
190 SetDrMd(win
->RPort
, mode
);
195 struct TextFont
* font
;
196 ta
.ta_Name
= "Vera Sans.font";
201 font
= OpenDiskFont(&ta
);
204 SetFont(win
->RPort
, font
);
208 printf("Failed to set antialiazed font\n");
213 /* Generate repetetive content buffer */
214 buffer
= AllocVec(linelen
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
215 for (i
= 0; i
< linelen
; i
++)
216 buffer
[i
] = consttext
[i
% consttextlen
];
218 TextExtent(win
->RPort
, buffer
, linelen
, &extend
);
222 CurrentTime(&tv_end
.tv_secs
, &tv_end
.tv_micro
);
223 t
= (tv_end
.tv_sec
- tv_start
.tv_sec
) * 1000000 + tv_end
.tv_micro
- tv_start
.tv_micro
;
224 if (t
>= 10 * 1000000) break;
226 for (y
= i
% extend
.te_Height
; y
< height
; y
+= extend
.te_Height
)
227 for (x
= 0; x
< width
; x
+= extend
.te_Width
)
229 Move(win
->RPort
, x
, y
);
230 Text(win
->RPort
, buffer
, linelen
);
242 #if !defined(ONLY_BENCH_CODE)
243 /****************************************************************************************/