Here, I fixed an easy-to-use template class for your enjoyment.. First some figures running on a stationary PC (I didn't have time to try it out on my Pocket PC):
GapiDraw 1.04:
BltFast 32x32, 22, ms
BltFast 32x32 with 50% opacity, 86, ms
BltFast 32x32 with 10% opacity, 101, ms
BltFast 128x128, 307, ms
BltFast 128x128 with 50% opacity, 1338, ms
BltFast 128x128 with 10% opacity, 1540, ms
BltFastColorkey 32x32, 70, ms
BltFastColorkey 32x32 with 50% opacity, 76, ms
BltFastColorkey 32x32 with 10% opacity, 85, ms
BltFastColorkey 128x128, 1045, ms
BltFastColorkey 128x128 with 50% opacity, 1165, ms
BltFastColorkey 128x128 with 10% opacity, 1301, ms
AlphaBltFast 32x32, 233, ms
AlphaBltFast 128x128, 2035, ms
FillRect 32x32, 94, ms
FillRect 32x32 with 50% opacity, 72, ms
FillRect 32x32 with 10% opacity, 109, ms
FillRect 128x128, 184, ms
FillRect 128x128 with 50% opacity, 1110, ms
FillRect 128x128 with 10% opacity, 1679, ms
GapiDraw 3.0 (32-bit):
BltFast 32x32, 23, ms
BltFast 32x32 with 50% opacity, 57, ms
BltFast 32x32 with 10% opacity, 100, ms
BltFast 128x128, 272, ms
BltFast 128x128 with 50% opacity, 851, ms
BltFast 128x128 with 10% opacity, 1512, ms
BltFastColorkey 32x32, 36, ms
BltFastColorkey 32x32 with 50% opacity, 59, ms
BltFastColorkey 32x32 with 10% opacity, 116, ms
BltFastColorkey 128x128, 503, ms
BltFastColorkey 128x128 with 50% opacity, 850, ms
BltFastColorkey 128x128 with 10% opacity, 1482, ms
AlphaBltFast 32x32, 101, ms
AlphaBltFast 128x128, 1467, ms
FillRect 32x32, 12, ms
FillRect 32x32 with 50% opacity, 21, ms
FillRect 32x32 with 10% opacity, 101, ms
FillRect 128x128, 125, ms
FillRect 128x128 with 50% opacity, 227, ms
FillRect 128x128 with 10% opacity, 1507, ms
Here's how to use the class:
1. Initialization. Add the following to your initialization:
- Code:
m_gfxbench.Initialize(TEXT("\\gfxbench.txt"), &m_sprite32x32, &m_sprite128x128, &m_sprite32x32alpha, &m_sprite128x128alpha, pDisplay->GetBackBuffer());
2. In your main loop, add something like:
- Code:
// PASTE THE FOLLOWING CODE IN YOUR BLIT LOOP -------------------------------
static DWORD bTestDone = FALSE;
static DWORD dwTestStatus = 0;
if (!bTestDone)
{
str1 = TEXT("<Processing benchmarks>");
str2 = TEXT("Please wait...");
if (0 == dwTestStatus)
{
m_gfxbench.WriteFile(TEXT("Starting with default display mode"), 0);
m_gfxbench.WriteFile(TEXT("-----"), 0);
}
m_gfxbench.RunTests();
dwTestStatus++;
}
else
{
str1 = TEXT("All done!");
str2 = TEXT("<Press any key to exit>");
}
switch (dwTestStatus)
{
case 1:
SetDisplayMode(GDDISPMODE_ROTATE90CCW);
m_gfxbench.WriteFile(TEXT("-----"), 0);
m_gfxbench.WriteFile(TEXT("Changing display mode to 90 degrees counter clockwise rotation"), 0);
m_gfxbench.WriteFile(TEXT("-----"), 0);
break;
case 2:
SetDisplayMode(GDDISPMODE_ROTATE90CW);
m_gfxbench.WriteFile(TEXT("-----"), 0);
m_gfxbench.WriteFile(TEXT("Changing display mode to 90 degrees clockwise rotation"), 0);
m_gfxbench.WriteFile(TEXT("-----"), 0);
break;
case 3:
SetDisplayMode(GDDISPMODE_ROTATE180);
m_gfxbench.WriteFile(TEXT("-----"), 0);
m_gfxbench.WriteFile(TEXT("Changing display mode to 180 degrees rotation"), 0);
m_gfxbench.WriteFile(TEXT("-----"), 0);
break;
case 4:
bTestDone = TRUE;
break;
default:
break;
}
// --------------------------------------------------------------------------
3. Finally, subclass the GfxBench template class and add calls to your own blit routines:
- Code:
// PASTE THE FOLLOWING CODE TO YOUR PROJECT ---------------------------------
template<class _Surface>
class CGapiDrawBench : public GfxBench<_Surface>
{
// Attributes
private:
GDALPHABLTFASTFX m_alphabltfastfx;
GDBLTFASTFX m_bltfastfx;
GDFILLRECTFX m_fillrectfx;
COLORREF m_clrFillColor;
// Construction
public:
CGapiDrawBench()
{
m_clrFillColor = RGB(0, 0, 255);
};
// Implementation
public:
// A simple 1:1 blit with variable dwOpacity from the entire source to destination at [x,y]
virtual void BltFast(_Surface* pSourceSurface, _Surface* pAlphaSurface, _Surface* pDestinationSurface, DWORD dwOpacity, DWORD x, DWORD y)
{
m_bltfastfx.dwOpacity = dwOpacity;
pDestinationSurface->BltFast(x, y, pSourceSurface, NULL, GDBLTFAST_OPACITY, &m_bltfastfx);
}
// A simple 1:1 color keyed blit with variable dwOpacity from the entire source to destination at [x,y]
virtual void BltFastColorkey(_Surface* pSourceSurface, _Surface* pAlphaSurface, _Surface* pDestinationSurface, DWORD dwOpacity, DWORD x, DWORD y)
{
m_bltfastfx.dwOpacity = dwOpacity;
pDestinationSurface->BltFast(x, y, pSourceSurface, NULL, GDBLTFAST_KEYSRC | GDBLTFAST_OPACITY, &m_bltfastfx);
}
// Alpha blend source surface with destination based on the opacity in the alpha surface and dwOpacity
virtual void AlphaBltFast(_Surface* pSourceSurface, _Surface* pAlphaSurface, _Surface* pDestinationSurface, DWORD dwOpacity, DWORD x, DWORD y)
{
m_alphabltfastfx.dwOpacity = dwOpacity;
pDestinationSurface->AlphaBltFast(x, y, pSourceSurface, NULL, pAlphaSurface, NULL, GDALPHABLTFAST_OPACITY, &m_alphabltfastfx);
}
// Fill a blue rectangle on the destination surface the size of the source surface using dwOpacity
virtual void FillRect(_Surface* pSourceSurface, _Surface* pAlphaSurface, _Surface* pDestinationSurface, DWORD dwOpacity, DWORD x, DWORD y)
{
m_fillrectfx.dwOpacity = dwOpacity;
pDestinationSurface->FillRect(CRect(x, y, x+pSourceSurface->GetWidth(), y+pSourceSurface->GetHeight()), m_clrFillColor, GDFILLRECT_OPACITY, &m_fillrectfx);
}
virtual ~CGapiDrawBench()
{
};
};
// --------------------------------------------------------------------------
It should take less than 10 minutes to benchmark PocketFrog or other libraries with it... I have posted the benchclass and the source for two sample programs here:
http://www.sanneblad.se/johan/temp/gfxbench.h
http://www.sanneblad.se/johan/temp/minimal104.zip
http://www.sanneblad.se/johan/temp/minimal300.zip
I'm in quite a rush so please if anyone has the time feel free to bench ahead (I spent less than two hours on the code)...
