24 if ( flags & SDL_FULLSCREEN ) { |
24 if ( flags & SDL_FULLSCREEN ) { |
25 printf(" | SDL_FULLSCREEN"); |
25 printf(" | SDL_FULLSCREEN"); |
26 } |
26 } |
27 if ( flags & SDL_DOUBLEBUF ) { |
27 if ( flags & SDL_DOUBLEBUF ) { |
28 printf(" | SDL_DOUBLEBUF"); |
28 printf(" | SDL_DOUBLEBUF"); |
|
29 } |
|
30 if ( flags & SDL_SRCCOLORKEY ) { |
|
31 printf(" | SDL_SRCCOLORKEY"); |
|
32 } |
|
33 if ( flags & SDL_RLEACCEL ) { |
|
34 printf(" | SDL_RLEACCEL"); |
29 } |
35 } |
30 } |
36 } |
31 |
37 |
32 int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount) |
38 int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount) |
33 { |
39 { |
114 while ( SDL_PollEvent(&event) ) { |
120 while ( SDL_PollEvent(&event) ) { |
115 if ( event.type == SDL_KEYDOWN ) |
121 if ( event.type == SDL_KEYDOWN ) |
116 return 0; |
122 return 0; |
117 } |
123 } |
118 |
124 |
|
125 /* run the generic blit test */ |
119 bmp = SDL_LoadBMP("sample.bmp"); |
126 bmp = SDL_LoadBMP("sample.bmp"); |
120 if ( ! bmp ) { |
127 if ( ! bmp ) { |
121 printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); |
128 printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); |
122 return 0; |
129 return 0; |
123 } |
130 } |
133 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); |
140 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); |
134 } else { |
141 } else { |
135 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); |
142 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); |
136 } |
143 } |
137 |
144 |
|
145 /* run the colorkeyed blit test */ |
|
146 bmpcc = SDL_LoadBMP("sample.bmp"); |
|
147 if ( ! bmpcc ) { |
|
148 printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); |
|
149 return 0; |
|
150 } |
|
151 printf("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ", |
|
152 bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); |
|
153 SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels); |
|
154 |
|
155 PrintFlags(bmpcc->flags); |
|
156 printf("\n"); |
|
157 then = SDL_GetTicks(); |
|
158 frames = RunBlitTests(screen, bmpcc, NUM_BLITS); |
|
159 now = SDL_GetTicks(); |
|
160 seconds = (float)(now - then) / 1000.0f; |
|
161 if ( seconds > 0.0f ) { |
|
162 printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); |
|
163 } else { |
|
164 printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); |
|
165 } |
|
166 |
|
167 /* run the generic blit test */ |
138 tmp = bmp; |
168 tmp = bmp; |
139 bmp = SDL_DisplayFormat(bmp); |
169 bmp = SDL_DisplayFormat(bmp); |
140 SDL_FreeSurface(tmp); |
170 SDL_FreeSurface(tmp); |
141 if ( ! bmp ) { |
171 if ( ! bmp ) { |
142 printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); |
172 printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); |
153 if ( seconds > 0.0f ) { |
183 if ( seconds > 0.0f ) { |
154 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); |
184 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); |
155 } else { |
185 } else { |
156 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); |
186 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); |
157 } |
187 } |
|
188 |
|
189 /* run the colorkeyed blit test */ |
|
190 tmp = bmpcc; |
|
191 bmpcc = SDL_DisplayFormat(bmpcc); |
|
192 SDL_FreeSurface(tmp); |
|
193 if ( ! bmpcc ) { |
|
194 printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); |
|
195 return 0; |
|
196 } |
|
197 printf("Running display format cc blit test: %dx%d at %d bpp, flags: ", |
|
198 bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); |
|
199 PrintFlags(bmpcc->flags); |
|
200 printf("\n"); |
|
201 then = SDL_GetTicks(); |
|
202 frames = RunBlitTests(screen, bmpcc, NUM_BLITS); |
|
203 now = SDL_GetTicks(); |
|
204 seconds = (float)(now - then) / 1000.0f; |
|
205 if ( seconds > 0.0f ) { |
|
206 printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); |
|
207 } else { |
|
208 printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); |
|
209 } |
|
210 |
|
211 SDL_FreeSurface(bmpcc); |
158 SDL_FreeSurface(bmp); |
212 SDL_FreeSurface(bmp); |
159 |
213 |
160 while ( SDL_PollEvent(&event) ) { |
214 while ( SDL_PollEvent(&event) ) { |
161 if ( event.type == SDL_KEYDOWN ) |
215 if ( event.type == SDL_KEYDOWN ) |
162 return 0; |
216 return 0; |