~ubuntu-branches/debian/experimental/mednafen/experimental

« back to all changes in this revision

Viewing changes to src/drivers/fps.cpp

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-11-19 07:00:37 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20121119070037-jvknrm13zvim88oc
Tags: 0.9.26-1
* New upstream WIP version.
* Change priority to "extra" to match libvorbisidec1's.
* Drop "DM-Upload-Allowed" since it is no longer appropriate.
* Refresh patches, replacing MPC_STATUS_FAIL constant from older mpcdec
  versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
static uint32 VirtualTime[128], DrawnTime[128], BlittedTime[128];
23
23
static uint32 VirtualIndex, DrawnIndex, BlittedIndex;
24
 
static SDL_Surface *FPSSurface = NULL;
25
 
static SDL_Rect FPSRect;
 
24
static MDFN_Surface *FPSSurface = NULL;
 
25
static MDFN_Rect FPSRect;
26
26
 
27
27
void FPS_Init(void)
28
28
{
144
144
 DrawTextTrans(target->pixels + xpos + (ypos + 7 * 2) * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)blitfps, text_color, FALSE, TRUE);
145
145
}
146
146
 
147
 
#define MK_COLOR_A(surface, r,g,b,a) ( ((a)<<surface->format->Ashift) | ((r)<<surface->format->Rshift) | ((g) << surface->format->Gshift) |((b) << surface->format->Bshift))
 
147
#define MK_COLOR_A(surface, r,g,b,a) ( surface->MakeColor(r, g, b, a))
148
148
void FPS_DrawToScreen(SDL_Surface *screen, int rs, int gs, int bs, int as)
149
149
{
150
150
 if(!isactive) 
151
151
 {
152
152
  if(FPSSurface)
153
153
  {
154
 
   SDL_FreeSurface(FPSSurface);
 
154
   delete FPSSurface;
155
155
   FPSSurface = NULL;
156
156
  }
157
157
  return;
159
159
 
160
160
 if(!FPSSurface)
161
161
 {
162
 
  FPSSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, box_width, box_height, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as);
 
162
  FPSSurface = new MDFN_Surface(NULL, box_width, box_height, box_width, MDFN_PixelFormat(MDFN_COLORSPACE_RGB, rs, gs, bs, as));
163
163
  FPSRect.w = box_width;
164
164
  FPSRect.h = box_height;
165
165
  FPSRect.x = FPSRect.y = 0;
169
169
 
170
170
 CalcFramerates(virtfps, drawnfps, blitfps, 64);
171
171
 
172
 
 SDL_FillRect(FPSSurface, NULL, MK_COLOR_A(FPSSurface, 0, 0, 0, 0x80));
173
 
 DrawTextTrans((uint32 *)FPSSurface->pixels, FPSSurface->pitch, FPSSurface->w, (UTF8*)virtfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
174
 
 DrawTextTrans((uint32 *)FPSSurface->pixels + 7 * (FPSSurface->pitch >> 2), FPSSurface->pitch, FPSSurface->w, (UTF8*)drawnfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
175
 
 DrawTextTrans((uint32 *)FPSSurface->pixels + 7 * 2 * (FPSSurface->pitch >> 2), FPSSurface->pitch, FPSSurface->w, (UTF8*)blitfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
176
 
 
177
 
 SDL_Rect drect;
 
172
 FPSSurface->Fill(0, 0, 0, 0x80);
 
173
 
 
174
 DrawTextTrans(FPSSurface->pixels, FPSSurface->pitchinpix << 2, FPSSurface->w, (UTF8*)virtfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
 
175
 DrawTextTrans(FPSSurface->pixels + 7 * FPSSurface->pitchinpix, FPSSurface->pitchinpix << 2, FPSSurface->w, (UTF8*)drawnfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
 
176
 DrawTextTrans(FPSSurface->pixels + 7 * 2 * FPSSurface->pitchinpix, FPSSurface->pitchinpix << 2, FPSSurface->w, (UTF8*)blitfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
 
177
 
 
178
 MDFN_Rect drect;
178
179
 drect.x = 0;
179
180
 drect.y = 0;
180
181
 drect.w = FPSRect.w;
181
182
 drect.h = FPSRect.h;
182
183
 
183
 
 BlitRaw(FPSSurface, &FPSRect, &drect);
 
184
 BlitRaw(FPSSurface, &FPSRect, &drect, -1);
184
185
}