annotate test/testblitspeed.c @ 3566:07c8339c95c6

Fixed bug #905 Give the foreign window message proc more control over Windows events. This may need to be adjusted when we add the capability for the app to specify whether it wants SDL to handle input for the window or not.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 15 Dec 2009 09:20:10 +0000
parents 204be4fc2726
children
rev   line source
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 * Benchmarks surface-to-surface blits in various formats.
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 *
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4 * Written by Ryan C. Gordon.
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 */
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 #include <stdio.h>
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 #include <stdlib.h>
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 #include <string.h>
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 #include "SDL.h"
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 static SDL_Surface *dest = NULL;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 static SDL_Surface *src = NULL;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 static int testSeconds = 10;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
18 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
19 percent(int val, int total)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
21 return ((int) ((((float) val) / ((float) total)) * 100.0f));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
24 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
25 randRange(int lo, int hi)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
27 return (lo + (int) (((double) hi) * rand() / (RAND_MAX + 1.0)));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
30 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
31 copy_trunc_str(char *str, size_t strsize, const char *flagstr)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
33 if ((strlen(str) + strlen(flagstr)) >= (strsize - 1))
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 strcpy(str + (strsize - 5), " ...");
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 else
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 strcat(str, flagstr);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
39 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
40 __append_sdl_surface_flag(SDL_Surface * _surface, char *str,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
41 size_t strsize, Uint32 flag, const char *flagstr)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 if (_surface->flags & flag)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 copy_trunc_str(str, strsize, flagstr);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
45 }
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 #define append_sdl_surface_flag(a, b, c, fl) __append_sdl_surface_flag(a, b, c, fl, " " #fl)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 #define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" )
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
51 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
52 output_videoinfo_details(void)
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
53 {
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
54 const SDL_VideoInfo *info = SDL_GetVideoInfo();
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
55 printf("SDL_GetVideoInfo():\n");
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
56 if (info == NULL)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
57 printf(" (null.)\n");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
58 else {
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
59 print_tf_state(" hardware surface available", info->hw_available);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
60 print_tf_state(" window manager available", info->wm_available);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
61 print_tf_state(" accelerated hardware->hardware blits",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
62 info->blit_hw);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
63 print_tf_state(" accelerated hardware->hardware colorkey blits",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
64 info->blit_hw_CC);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
65 print_tf_state(" accelerated hardware->hardware alpha blits",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
66 info->blit_hw_A);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
67 print_tf_state(" accelerated software->hardware blits",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
68 info->blit_sw);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
69 print_tf_state(" accelerated software->hardware colorkey blits",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
70 info->blit_sw_CC);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
71 print_tf_state(" accelerated software->hardware alpha blits",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
72 info->blit_sw_A);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
73 print_tf_state(" accelerated color fills", info->blit_fill);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
74 printf(" video memory: (%d)\n", info->video_mem);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
75 }
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
76
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
77 printf("\n");
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
78 }
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
79
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
80 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
81 output_surface_details(const char *name, SDL_Surface * surface)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 printf("Details for %s:\n", name);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
85 if (surface == NULL) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 printf("-WARNING- You've got a NULL surface!");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
87 } else {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 char f[256];
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
89 printf(" width : %d\n", surface->w);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
90 printf(" height : %d\n", surface->h);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
91 printf(" depth : %d bits per pixel\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
92 surface->format->BitsPerPixel);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
93 printf(" pitch : %d\n", (int) surface->pitch);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
94
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
95 printf(" red bits : 0x%08X mask, %d shift, %d loss\n",
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
96 (int) surface->format->Rmask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
97 (int) surface->format->Rshift, (int) surface->format->Rloss);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
98 printf(" green bits : 0x%08X mask, %d shift, %d loss\n",
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
99 (int) surface->format->Gmask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
100 (int) surface->format->Gshift, (int) surface->format->Gloss);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
101 printf(" blue bits : 0x%08X mask, %d shift, %d loss\n",
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
102 (int) surface->format->Bmask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
103 (int) surface->format->Bshift, (int) surface->format->Bloss);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
104 printf(" alpha bits : 0x%08X mask, %d shift, %d loss\n",
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
105 (int) surface->format->Amask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
106 (int) surface->format->Ashift, (int) surface->format->Aloss);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108 f[0] = '\0';
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
110 /*append_sdl_surface_flag(surface, f, sizeof (f), SDL_SWSURFACE); */
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 if ((surface->flags & SDL_HWSURFACE) == 0)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
112 copy_trunc_str(f, sizeof(f), " SDL_SWSURFACE");
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
114 append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWSURFACE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
115 append_sdl_surface_flag(surface, f, sizeof(f), SDL_ASYNCBLIT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
116 append_sdl_surface_flag(surface, f, sizeof(f), SDL_ANYFORMAT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
117 append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWPALETTE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
118 append_sdl_surface_flag(surface, f, sizeof(f), SDL_DOUBLEBUF);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
119 append_sdl_surface_flag(surface, f, sizeof(f), SDL_FULLSCREEN);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
120 append_sdl_surface_flag(surface, f, sizeof(f), SDL_OPENGL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
121 append_sdl_surface_flag(surface, f, sizeof(f), SDL_RESIZABLE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
122 append_sdl_surface_flag(surface, f, sizeof(f), SDL_NOFRAME);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
123 append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWACCEL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
124 append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCCOLORKEY);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
125 append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCELOK);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
126 append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCEL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
127 append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCALPHA);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
128 append_sdl_surface_flag(surface, f, sizeof(f), SDL_PREALLOC);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 if (f[0] == '\0')
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 strcpy(f, " (none)");
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
133 printf(" flags :%s\n", f);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
134 }
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 printf("\n");
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
139 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
140 output_details(void)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 {
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
142 output_videoinfo_details();
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143 output_surface_details("Source Surface", src);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 output_surface_details("Destination Surface", dest);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
147 static Uint32
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
148 blit(SDL_Surface * dst, SDL_Surface * src, int x, int y)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150 Uint32 start = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 SDL_Rect srcRect;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 SDL_Rect dstRect;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 srcRect.x = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 srcRect.y = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 dstRect.x = x;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 dstRect.y = y;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
158 dstRect.w = srcRect.w = src->w; /* SDL will clip as appropriate. */
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 dstRect.h = srcRect.h = src->h;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 start = SDL_GetTicks();
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 SDL_BlitSurface(src, &srcRect, dst, &dstRect);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
163 return (SDL_GetTicks() - start);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
166 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
167 blitCentered(SDL_Surface * dst, SDL_Surface * src)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 int x = (dst->w - src->w) / 2;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 int y = (dst->h - src->h) / 2;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 blit(dst, src, x, y);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
174 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
175 atoi_hex(const char *str)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
177 if (str == NULL)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 return 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
180 if (strlen(str) > 2) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 int retval = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182 if ((str[0] == '0') && (str[1] == 'x'))
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 sscanf(str + 2, "%X", &retval);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
184 return (retval);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
187 return (atoi(str));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
191 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
192 setup_test(int argc, char **argv)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 const char *dumpfile = NULL;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195 SDL_Surface *bmp = NULL;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 Uint32 dstbpp = 32;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 Uint32 dstrmask = 0x00FF0000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 Uint32 dstgmask = 0x0000FF00;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199 Uint32 dstbmask = 0x000000FF;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
200 Uint32 dstamask = 0x00000000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 Uint32 dstflags = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 int dstw = 640;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203 int dsth = 480;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 Uint32 srcbpp = 32;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 Uint32 srcrmask = 0x00FF0000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206 Uint32 srcgmask = 0x0000FF00;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 Uint32 srcbmask = 0x000000FF;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 Uint32 srcamask = 0x00000000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209 Uint32 srcflags = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 int srcw = 640;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 int srch = 480;
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
212 Uint32 origsrcalphaflags = 0;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
213 Uint32 origdstalphaflags = 0;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
214 Uint32 srcalphaflags = 0;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
215 Uint32 dstalphaflags = 0;
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
216 Uint8 origsrcalpha = 255;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
217 Uint8 origdstalpha = 255;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
218 Uint8 srcalpha = 255;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
219 Uint8 dstalpha = 255;
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220 int screenSurface = 0;
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
221 int i = 0;
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
223 for (i = 1; i < argc; i++) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 const char *arg = argv[i];
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 if (strcmp(arg, "--dstbpp") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227 dstbpp = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 else if (strcmp(arg, "--dstrmask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
229 dstrmask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 else if (strcmp(arg, "--dstgmask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 dstgmask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232 else if (strcmp(arg, "--dstbmask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 dstbmask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 else if (strcmp(arg, "--dstamask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 dstamask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 else if (strcmp(arg, "--dstwidth") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 dstw = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 else if (strcmp(arg, "--dstheight") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239 dsth = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 else if (strcmp(arg, "--dsthwsurface") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 dstflags |= SDL_HWSURFACE;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 else if (strcmp(arg, "--srcbpp") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 srcbpp = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 else if (strcmp(arg, "--srcrmask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 srcrmask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246 else if (strcmp(arg, "--srcgmask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 srcgmask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 else if (strcmp(arg, "--srcbmask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 srcbmask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 else if (strcmp(arg, "--srcamask") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 srcamask = atoi_hex(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 else if (strcmp(arg, "--srcwidth") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 srcw = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 else if (strcmp(arg, "--srcheight") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255 srch = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 else if (strcmp(arg, "--srchwsurface") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 srcflags |= SDL_HWSURFACE;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 else if (strcmp(arg, "--seconds") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259 testSeconds = atoi(argv[++i]);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 else if (strcmp(arg, "--screen") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 screenSurface = 1;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 else if (strcmp(arg, "--dumpfile") == 0)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 dumpfile = argv[++i];
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
264 /* !!! FIXME: set colorkey. */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
265 else if (0) { /* !!! FIXME: we handle some commandlines elsewhere now */
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266 fprintf(stderr, "Unknown commandline option: %s\n", arg);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
267 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
271 if (SDL_Init(SDL_INIT_VIDEO) == -1) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
273 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276 bmp = SDL_LoadBMP("sample.bmp");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
277 if (bmp == NULL) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278 fprintf(stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError());
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 SDL_Quit();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
280 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
283 if ((dstflags & SDL_HWSURFACE) == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
284 dstflags |= SDL_SWSURFACE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
285 if ((srcflags & SDL_HWSURFACE) == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
286 srcflags |= SDL_SWSURFACE;
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 if (screenSurface)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 dest = SDL_SetVideoMode(dstw, dsth, dstbpp, dstflags);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
290 else {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291 dest = SDL_CreateRGBSurface(dstflags, dstw, dsth, dstbpp,
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 dstrmask, dstgmask, dstbmask, dstamask);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
295 if (dest == NULL) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 fprintf(stderr, "dest surface creation failed: %s\n", SDL_GetError());
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 SDL_Quit();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
298 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 src = SDL_CreateRGBSurface(srcflags, srcw, srch, srcbpp,
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302 srcrmask, srcgmask, srcbmask, srcamask);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
303 if (src == NULL) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304 fprintf(stderr, "src surface creation failed: %s\n", SDL_GetError());
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 SDL_Quit();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
306 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
309 /* handle alpha settings... */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
310 srcalphaflags = (src->flags & SDL_SRCALPHA) | (src->flags & SDL_RLEACCEL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
311 dstalphaflags =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
312 (dest->flags & SDL_SRCALPHA) | (dest->flags & SDL_RLEACCEL);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
313 origsrcalphaflags = srcalphaflags;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
314 origdstalphaflags = dstalphaflags;
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
315 SDL_GetSurfaceAlphaMod(src, &srcalpha);
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
316 SDL_GetSurfaceAlphaMod(dest, &dstalpha);
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
317 origsrcalpha = srcalpha;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
318 origdstalpha = dstalpha;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
319 for (i = 1; i < argc; i++) {
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
320 const char *arg = argv[i];
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
321
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
322 if (strcmp(arg, "--srcalpha") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
323 srcalpha = atoi(argv[++i]);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
324 else if (strcmp(arg, "--dstalpha") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
325 dstalpha = atoi(argv[++i]);
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
326 else if (strcmp(arg, "--srcsrcalpha") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
327 srcalphaflags |= SDL_SRCALPHA;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
328 else if (strcmp(arg, "--srcnosrcalpha") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
329 srcalphaflags &= ~SDL_SRCALPHA;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
330 else if (strcmp(arg, "--srcrleaccel") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
331 srcalphaflags |= SDL_RLEACCEL;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
332 else if (strcmp(arg, "--srcnorleaccel") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
333 srcalphaflags &= ~SDL_RLEACCEL;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
334 else if (strcmp(arg, "--dstsrcalpha") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
335 dstalphaflags |= SDL_SRCALPHA;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
336 else if (strcmp(arg, "--dstnosrcalpha") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
337 dstalphaflags &= ~SDL_SRCALPHA;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
338 else if (strcmp(arg, "--dstrleaccel") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
339 dstalphaflags |= SDL_RLEACCEL;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
340 else if (strcmp(arg, "--dstnorleaccel") == 0)
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
341 dstalphaflags &= ~SDL_RLEACCEL;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
342 }
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
343 if ((dstalphaflags != origdstalphaflags) || (origdstalpha != dstalpha))
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
344 SDL_SetAlpha(dest, dstalphaflags, dstalpha);
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
345 if ((srcalphaflags != origsrcalphaflags) || (origsrcalpha != srcalpha))
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
346 SDL_SetAlpha(src, srcalphaflags, srcalpha);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
347
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 /* set some sane defaults so we can see if the blit code is broken... */
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350 SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0));
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 blitCentered(src, bmp);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 SDL_FreeSurface(bmp);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 if (dumpfile)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
356 SDL_SaveBMP(src, dumpfile); /* make sure initial convert is sane. */
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 output_details();
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
360 return (1);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
364 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
365 test_blit_speed(void)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 Uint32 clearColor = SDL_MapRGB(dest->format, 0, 0, 0);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 Uint32 iterations = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 Uint32 elasped = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 Uint32 end = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 Uint32 now = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 Uint32 last = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 int testms = testSeconds * 1000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 int wmax = (dest->w - src->w);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 int hmax = (dest->h - src->h);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 int isScreen = (SDL_GetVideoSurface() == dest);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 SDL_Event event;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 printf("Testing blit speed for %d seconds...\n", testSeconds);
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 now = SDL_GetTicks();
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 end = now + testms;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
384 do {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 /* pump the event queue occasionally to keep OS happy... */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
386 if (now - last > 1000) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 last = now;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
388 while (SDL_PollEvent(&event)) { /* no-op. */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
389 }
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392 iterations++;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 elasped += blit(dest, src, randRange(0, wmax), randRange(0, hmax));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
394 if (isScreen) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
395 SDL_Flip(dest); /* show it! */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
396 SDL_FillRect(dest, NULL, clearColor); /* blank it for next time! */
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 now = SDL_GetTicks();
2735
204be4fc2726 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2267
diff changeset
400 } while (now < end);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 printf("Non-blitting crap accounted for %d percent of this run.\n",
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
403 percent(testms - elasped, testms));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 printf("%d blits took %d ms (%d fps).\n",
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
406 (int) iterations,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
407 (int) elasped,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
408 (int) (((float) iterations) / (((float) elasped) / 1000.0f)));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
411 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
412 main(int argc, char **argv)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414 int initialized = setup_test(argc, argv);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
415 if (initialized) {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 test_blit_speed();
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 SDL_Quit();
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1231
diff changeset
419 return (!initialized);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 /* end of testblitspeed.c ... */