summaryrefslogtreecommitdiff
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
parent63bece64e5c758f33c40e773869a5d6337f48531 (diff)
downloadbench-f2382a962d341e8f9956db523cb3d40335da74ee.tar.gz
bench-f2382a962d341e8f9956db523cb3d40335da74ee.tar.bz2
Track core changes. Add FPS limiter mode option.
-rw-r--r--bench.xml.in24
-rw-r--r--src/bench.cpp47
-rw-r--r--src/bench.h5
3 files changed, 58 insertions, 18 deletions
diff --git a/bench.xml.in b/bench.xml.in
index 2279ef1..0f62574 100644
--- a/bench.xml.in
+++ b/bench.xml.in
@@ -12,11 +12,25 @@
<_long>Start benchmark</_long>
<default>&lt;Super&gt;F12</default>
</option>
- <option name="disable_limiter" type="bool">
- <_short>Disable limiter</_short>
- <_long>Disable Compiz integrated FPS limiter</_long>
- <default>true</default>
- </option>
+ <option name="fps_limiter_mode" type="int">
+ <_short>FPS Limiter Mode</_short>
+ <_long>Integrated Compiz FPS limiter mode</_long>
+ <default>0</default>
+ <min>0</min>
+ <max>2</max>
+ <desc>
+ <value>0</value>
+ <_name>Limiter disabled</_name>
+ </desc>
+ <desc>
+ <value>1</value>
+ <_name>Default limiter</_name>
+ </desc>
+ <desc>
+ <value>2</value>
+ <_name>V-Sync-like limiter</_name>
+ </desc>
+ </option>
<subgroup>
<_short>Screen Output</_short>
<option name="output_screen" type="bool">
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);
diff --git a/src/bench.h b/src/bench.h
index 032f871..fbf3521 100644
--- a/src/bench.h
+++ b/src/bench.h
@@ -73,7 +73,6 @@ class BenchScreen :
float mFps;
float mAlpha;
- struct timeval mInitTime;
struct timeval mLastRedraw;
float mCtime;
@@ -84,8 +83,12 @@ class BenchScreen :
bool mActive;
+ CompositeFPSLimiterMode mOldLimiterMode;
+
bool initiate (CompOption::Vector &options);
+ void limiterModeChanged (CompOption *opt);
+
void preparePaint (int msSinceLastPaint);
void donePaint ();