annotate test/testblitspeed.c @ 1663:11775724e3fe SDL-1.3

fine tuning indent output
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:29:03 +0000
parents 782fd950bd46
children 4da1ee79c9af
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
18 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
24 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
30 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
33 if ((strlen (str) + strlen (flagstr)) >= (strsize - 1))
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
34 strcpy (str + (strsize - 5), " ...");
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 else
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
36 strcat (str, flagstr);
1039
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
39 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
40 __append_sdl_surface_flag (SDL_Surface * _surface, char *str,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
51 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
54 const SDL_VideoInfo *info = SDL_GetVideoInfo ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
55 printf ("SDL_GetVideoInfo():\n");
1231
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)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
57 printf (" (null.)\n");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
58 else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
59 print_tf_state (" hardware surface available", info->hw_available);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
60 print_tf_state (" window manager available", info->wm_available);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
61 print_tf_state (" accelerated hardware->hardware blits",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
62 info->blit_hw);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
63 print_tf_state (" accelerated hardware->hardware colorkey blits",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
64 info->blit_hw_CC);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
65 print_tf_state (" accelerated hardware->hardware alpha blits",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
66 info->blit_hw_A);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
67 print_tf_state (" accelerated software->hardware blits",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
68 info->blit_sw);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
69 print_tf_state (" accelerated software->hardware colorkey blits",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
70 info->blit_sw_CC);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
71 print_tf_state (" accelerated software->hardware alpha blits",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
72 info->blit_sw_A);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
73 print_tf_state (" accelerated color fills", info->blit_fill);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
74 printf (" video memory: (%d)\n", info->video_mem);
1231
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
77 printf ("\n");
1231
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
80 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
83 printf ("Details for %s:\n", name);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
85 if (surface == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
86 printf ("-WARNING- You've got a NULL surface!");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
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];
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
89 printf (" width : %d\n", surface->w);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
90 printf (" height : %d\n", surface->h);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
91 printf (" depth : %d bits per pixel\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
92 surface->format->BitsPerPixel);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
93 printf (" pitch : %d\n", (int) surface->pitch);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
94 printf (" alpha : %d\n", (int) surface->format->alpha);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
95 printf (" colorkey : 0x%X\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
96 (unsigned int) surface->format->colorkey);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
98 printf (" red bits : 0x%08X mask, %d shift, %d loss\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
99 (int) surface->format->Rmask,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
100 (int) surface->format->Rshift, (int) surface->format->Rloss);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
101 printf (" green bits : 0x%08X mask, %d shift, %d loss\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
102 (int) surface->format->Gmask,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
103 (int) surface->format->Gshift, (int) surface->format->Gloss);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
104 printf (" blue bits : 0x%08X mask, %d shift, %d loss\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
105 (int) surface->format->Bmask,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
106 (int) surface->format->Bshift, (int) surface->format->Bloss);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
107 printf (" alpha bits : 0x%08X mask, %d shift, %d loss\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
108 (int) surface->format->Amask,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
109 (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
110
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 f[0] = '\0';
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
113 /*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
114 if ((surface->flags & SDL_HWSURFACE) == 0)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
115 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
116
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
117 append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWSURFACE);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
118 append_sdl_surface_flag (surface, f, sizeof (f), SDL_ASYNCBLIT);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
119 append_sdl_surface_flag (surface, f, sizeof (f), SDL_ANYFORMAT);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
120 append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWPALETTE);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
121 append_sdl_surface_flag (surface, f, sizeof (f), SDL_DOUBLEBUF);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
122 append_sdl_surface_flag (surface, f, sizeof (f), SDL_FULLSCREEN);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
123 append_sdl_surface_flag (surface, f, sizeof (f), SDL_OPENGL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
124 append_sdl_surface_flag (surface, f, sizeof (f), SDL_RESIZABLE);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
125 append_sdl_surface_flag (surface, f, sizeof (f), SDL_NOFRAME);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
126 append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWACCEL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
127 append_sdl_surface_flag (surface, f, sizeof (f), SDL_SRCCOLORKEY);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
128 append_sdl_surface_flag (surface, f, sizeof (f), SDL_RLEACCELOK);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
129 append_sdl_surface_flag (surface, f, sizeof (f), SDL_RLEACCEL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
130 append_sdl_surface_flag (surface, f, sizeof (f), SDL_SRCALPHA);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
131 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
132
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 if (f[0] == '\0')
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
134 strcpy (f, " (none)");
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
136 printf (" flags :%s\n", f);
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
137 }
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
139 printf ("\n");
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
142 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
143 output_details (void)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
145 output_videoinfo_details ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
146 output_surface_details ("Source Surface", src);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
147 output_surface_details ("Destination Surface", dest);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
150 static Uint32
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
151 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
152 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 Uint32 start = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 SDL_Rect srcRect;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 SDL_Rect dstRect;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 srcRect.x = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 srcRect.y = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 dstRect.x = x;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 dstRect.y = y;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
161 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
162 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
163
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
164 start = SDL_GetTicks ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
165 SDL_BlitSurface (src, &srcRect, dst, &dstRect);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
166 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
167 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
169 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
170 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
171 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 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
173 int y = (dst->h - src->h) / 2;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
174 blit (dst, src, x, y);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
177 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
178 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
179 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180 if (str == NULL)
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 return 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
183 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
184 int retval = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 if ((str[0] == '0') && (str[1] == 'x'))
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
186 sscanf (str + 2, "%X", &retval);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
187 return (retval);
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
190 return (atoi (str));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
194 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
195 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
196 {
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 const char *dumpfile = NULL;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 SDL_Surface *bmp = NULL;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199 Uint32 dstbpp = 32;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
200 Uint32 dstrmask = 0x00FF0000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 Uint32 dstgmask = 0x0000FF00;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 Uint32 dstbmask = 0x000000FF;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203 Uint32 dstamask = 0x00000000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 Uint32 dstflags = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 int dstw = 640;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206 int dsth = 480;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 Uint32 srcbpp = 32;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 Uint32 srcrmask = 0x00FF0000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209 Uint32 srcgmask = 0x0000FF00;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 Uint32 srcbmask = 0x000000FF;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 Uint32 srcamask = 0x00000000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 Uint32 srcflags = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213 int srcw = 640;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 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
215 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
216 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
217 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
218 Uint32 dstalphaflags = 0;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
219 int srcalpha = 255;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
220 int dstalpha = 255;
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 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
222 int i = 0;
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
224 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
225 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
226
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
227 if (strcmp (arg, "--dstbpp") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
228 dstbpp = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
229 else if (strcmp (arg, "--dstrmask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
230 dstrmask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
231 else if (strcmp (arg, "--dstgmask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
232 dstgmask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
233 else if (strcmp (arg, "--dstbmask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
234 dstbmask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
235 else if (strcmp (arg, "--dstamask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
236 dstamask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
237 else if (strcmp (arg, "--dstwidth") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
238 dstw = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
239 else if (strcmp (arg, "--dstheight") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
240 dsth = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
241 else if (strcmp (arg, "--dsthwsurface") == 0)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 dstflags |= SDL_HWSURFACE;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
243 else if (strcmp (arg, "--srcbpp") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
244 srcbpp = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
245 else if (strcmp (arg, "--srcrmask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
246 srcrmask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
247 else if (strcmp (arg, "--srcgmask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
248 srcgmask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
249 else if (strcmp (arg, "--srcbmask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
250 srcbmask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
251 else if (strcmp (arg, "--srcamask") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
252 srcamask = atoi_hex (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
253 else if (strcmp (arg, "--srcwidth") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
254 srcw = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
255 else if (strcmp (arg, "--srcheight") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
256 srch = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
257 else if (strcmp (arg, "--srchwsurface") == 0)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 srcflags |= SDL_HWSURFACE;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
259 else if (strcmp (arg, "--seconds") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
260 testSeconds = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
261 else if (strcmp (arg, "--screen") == 0)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 screenSurface = 1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
263 else if (strcmp (arg, "--dumpfile") == 0)
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 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
265 /* !!! FIXME: set colorkey. */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
266 else if (0) { /* !!! FIXME: we handle some commandlines elsewhere now */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
267 fprintf (stderr, "Unknown commandline option: %s\n", arg);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
268 return (0);
1039
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 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
272 if (SDL_Init (SDL_INIT_VIDEO) == -1) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
273 fprintf (stderr, "SDL_Init failed: %s\n", SDL_GetError ());
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
274 return (0);
1039
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
277 bmp = SDL_LoadBMP ("sample.bmp");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
278 if (bmp == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
279 fprintf (stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError ());
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
280 SDL_Quit ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
281 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
284 if ((dstflags & SDL_HWSURFACE) == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
285 dstflags |= SDL_SWSURFACE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
286 if ((srcflags & SDL_HWSURFACE) == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
287 srcflags |= SDL_SWSURFACE;
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 if (screenSurface)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
290 dest = SDL_SetVideoMode (dstw, dsth, dstbpp, dstflags);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
291 else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
292 dest = SDL_CreateRGBSurface (dstflags, dstw, dsth, dstbpp,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
293 dstrmask, dstgmask, dstbmask, dstamask);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
296 if (dest == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
297 fprintf (stderr, "dest surface creation failed: %s\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
298 SDL_GetError ());
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
299 SDL_Quit ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
300 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
303 src = SDL_CreateRGBSurface (srcflags, srcw, srch, srcbpp,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
304 srcrmask, srcgmask, srcbmask, srcamask);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
305 if (src == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
306 fprintf (stderr, "src surface creation failed: %s\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
307 SDL_GetError ());
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
308 SDL_Quit ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
309 return (0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311
1231
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
312 /* handle alpha settings... */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
313 srcalphaflags = (src->flags & SDL_SRCALPHA) | (src->flags & SDL_RLEACCEL);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
314 dstalphaflags =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
315 (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
316 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
317 origdstalphaflags = dstalphaflags;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
318 srcalpha = src->format->alpha;
cf59e7b91ed4 testblitspeed.c improvements: cleaned up output, and allow user to set surface
Ryan C. Gordon <icculus@icculus.org>
parents: 1039
diff changeset
319 dstalpha = dest->format->alpha;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
320 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
321 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
322
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
323 if (strcmp (arg, "--srcalpha") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
324 srcalpha = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
325 else if (strcmp (arg, "--dstalpha") == 0)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
326 dstalpha = atoi (argv[++i]);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
327 else if (strcmp (arg, "--srcsrcalpha") == 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
328 srcalphaflags |= SDL_SRCALPHA;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
329 else if (strcmp (arg, "--srcnosrcalpha") == 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
330 srcalphaflags &= ~SDL_SRCALPHA;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
331 else if (strcmp (arg, "--srcrleaccel") == 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
332 srcalphaflags |= SDL_RLEACCEL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
333 else if (strcmp (arg, "--srcnorleaccel") == 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
334 srcalphaflags &= ~SDL_RLEACCEL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
335 else if (strcmp (arg, "--dstsrcalpha") == 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
336 dstalphaflags |= SDL_SRCALPHA;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
337 else if (strcmp (arg, "--dstnosrcalpha") == 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
338 dstalphaflags &= ~SDL_SRCALPHA;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
339 else if (strcmp (arg, "--dstrleaccel") == 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
340 dstalphaflags |= SDL_RLEACCEL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
341 else if (strcmp (arg, "--dstnorleaccel") == 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
342 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
343 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
344 if ((dstalphaflags != origdstalphaflags)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
345 || (dstalpha != dest->format->alpha))
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
346 SDL_SetAlpha (dest, dstalphaflags, (Uint8) dstalpha);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
347 if ((srcalphaflags != origsrcalphaflags)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
348 || (srcalpha != src->format->alpha))
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
349 SDL_SetAlpha (src, srcalphaflags, (Uint8) 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
350
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 /* set some sane defaults so we can see if the blit code is broken... */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
352 SDL_FillRect (dest, NULL, SDL_MapRGB (dest->format, 0, 0, 0));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
353 SDL_FillRect (src, NULL, SDL_MapRGB (src->format, 0, 0, 0));
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
355 blitCentered (src, bmp);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
356 SDL_FreeSurface (bmp);
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 if (dumpfile)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
359 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
360
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
361 output_details ();
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
363 return (1);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
367 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
368 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
369 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
370 Uint32 clearColor = SDL_MapRGB (dest->format, 0, 0, 0);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 Uint32 iterations = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 Uint32 elasped = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 Uint32 end = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 Uint32 now = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 Uint32 last = 0;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 int testms = testSeconds * 1000;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 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
378 int hmax = (dest->h - src->h);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
379 int isScreen = (SDL_GetVideoSurface () == dest);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 SDL_Event event;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
382 printf ("Testing blit speed for %d seconds...\n", testSeconds);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
384 now = SDL_GetTicks ();
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 end = now + testms;
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
387 do {
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 /* pump the event queue occasionally to keep OS happy... */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
389 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
390 last = now;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
391 while (SDL_PollEvent (&event)) { /* no-op. */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
392 }
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 iterations++;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
396 elasped += blit (dest, src, randRange (0, wmax), randRange (0, hmax));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
397 if (isScreen) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
398 SDL_Flip (dest); /* show it! */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
399 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
400 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
402 now = SDL_GetTicks ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
403 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
404 while (now < end);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
406 printf ("Non-blitting crap accounted for %d percent of this run.\n",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
407 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
408
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
409 printf ("%d blits took %d ms (%d fps).\n",
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410 (int) iterations,
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 (int) elasped,
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
412 (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
413 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
415 int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
416 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
417 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
418 int initialized = setup_test (argc, argv);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
419 if (initialized) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
420 test_blit_speed ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
421 SDL_Quit ();
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
423 return (!initialized);
1039
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 }
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425
68f2b997758e Added testblitspeed to aid in profiling of SDL's blitters.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426 /* end of testblitspeed.c ... */