summaryrefslogtreecommitdiff
path: root/src/bench.cpp
diff options
context:
space:
mode:
authorErkin Bahceci <erkinbah@gmail.com>2009-07-29 18:23:16 -0500
committerErkin Bahceci <erkinbah@gmail.com>2009-07-29 18:23:16 -0500
commitf2382a962d341e8f9956db523cb3d40335da74ee (patch)
treeab0b43b0c0de0ba16204b167f0f1e04e8a355709 /src/bench.cpp
parent63bece64e5c758f33c40e773869a5d6337f48531 (diff)
downloadbench-f2382a962d341e8f9956db523cb3d40335da74ee.tar.gz
bench-f2382a962d341e8f9956db523cb3d40335da74ee.tar.bz2
Track core changes. Add FPS limiter mode option.
Diffstat (limited to 'src/bench.cpp')
-rw-r--r--src/bench.cpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/bench.cpp b/src/bench.cpp
index fdb2bf3..673c14a 100644
--- a/src/bench.cpp
+++ b/src/bench.cpp
@@ -62,7 +62,7 @@ BenchScreen::preparePaint (int msSinceLastPaint)
}
}
- cScreen->preparePaint ((mAlpha > 0.0) ? timediff : msSinceLastPaint);
+ cScreen->preparePaint (msSinceLastPaint);
if (mActive)
mAlpha += timediff / 1000.0;
@@ -80,15 +80,6 @@ BenchScreen::donePaint ()
cScreen->damageScreen ();
glFlush();
XSync (::screen->dpy (), false);
-
- if (optionGetDisableLimiter ())
- {
- cScreen->setLastRedraw (mInitTime);
- cScreen->resetTimeMult ();
- }
-
- if (!mActive)
- cScreen->resetTimeMult ();
}
cScreen->donePaint ();
@@ -264,6 +255,14 @@ BenchScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
return status;
}
+void
+BenchScreen::limiterModeChanged (CompOption *opt)
+{
+ if (mActive)
+ cScreen->setFPSLimiterMode ((CompositeFPSLimiterMode)
+ opt->value ().i ());
+}
+
BenchScreen::BenchScreen (CompScreen *screen) :
PluginClassHandler<BenchScreen, CompScreen> (screen),
cScreen (CompositeScreen::get (screen)),
@@ -271,11 +270,16 @@ BenchScreen::BenchScreen (CompScreen *screen) :
mAlpha (0),
mCtime (0),
mFrames (0),
- mActive (false)
+ mActive (false),
+ mOldLimiterMode ((CompositeFPSLimiterMode)
+ BenchOptions::FpsLimiterModeDefaultLimiter)
{
optionSetInitiateKeyInitiate (boost::bind (&BenchScreen::initiate, this,
_3));
+ optionSetFpsLimiterModeNotify
+ (boost::bind (&BenchScreen::limiterModeChanged, this, _1));
+
CompositeScreenInterface::setHandler (cScreen, false);
GLScreenInterface::setHandler (gScreen, false);
@@ -362,12 +366,17 @@ BenchScreen::BenchScreen (CompScreen *screen) :
glEnd();
glEndList();
- gettimeofday (&mInitTime, 0);
gettimeofday (&mLastRedraw, 0);
}
BenchScreen::~BenchScreen ()
{
+ if (mActive)
+ {
+ // Restore FPS limiter mode
+ cScreen->setFPSLimiterMode (mOldLimiterMode);
+ }
+
glDeleteLists (mDList, 2);
glDeleteTextures (10, mNumTex);
@@ -387,6 +396,20 @@ BenchScreen::initiate (CompOption::Vector &options)
if (xid != ::screen->root ())
return false;
+ if (mActive)
+ {
+ // Store current FPS limiter mode
+ mOldLimiterMode = cScreen->FPSLimiterMode ();
+
+ cScreen->setFPSLimiterMode ((CompositeFPSLimiterMode)
+ optionGetFpsLimiterMode ());
+ }
+ else
+ {
+ // Restore FPS limiter mode
+ cScreen->setFPSLimiterMode (mOldLimiterMode);
+ }
+
cScreen->preparePaintSetEnabled (this, mActive);
cScreen->donePaintSetEnabled (this, mActive);
gScreen->glPaintOutputSetEnabled (this, mActive);