diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 86: CompositeTestSimpleFade: Fix the set up and update of the Fader object to allow

Message ID 20120713154211.16682.23395.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker July 13, 2012, 3:42 p.m. UTC
------------------------------------------------------------
revno: 86
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Fri 2012-07-13 08:40:15 -0700
message:
  CompositeTestSimpleFade: Fix the set up and update of the Fader object to allow
  for multiple runs with different (duration) parameters.  Detected during the
  development of the similar "scale" test.
modified:
  src/composite-test-simple-fade.cc
  src/composite-test.h


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/composite-test-simple-fade.cc'
--- src/composite-test-simple-fade.cc	2011-12-05 19:01:24 +0000
+++ src/composite-test-simple-fade.cc	2012-07-13 15:40:15 +0000
@@ -28,6 +28,7 @@ 
 #include <sstream>
 
 using std::string;
+using std::list;
 
 const string CompositeTestSimpleFade::fade_bias_name_("alpha_bias");
 
@@ -53,11 +54,14 @@ 
     uint64_t last_eof_;
     float bias_;
     float duration_;
-    Fader();
 public:
-    Fader(const string& duration) :
+    Fader() :
+        start_time_(0),
         last_eof_(0),
-        bias_(0.0)
+        bias_(0.0),
+        duration_(0.0) {}
+    ~Fader() {}
+    void init(const string& duration)
     {
         // Convert the string representation of the duration in seconds
         // to microseconds as that's what we'll need to track the time.
@@ -66,7 +70,6 @@ 
         duration_ *= 1000000;
         start_time_ = Profiler::get_timestamp_us();
     }
-    ~Fader() {}
     void update()
     {
         last_eof_ = Profiler::get_timestamp_us();
@@ -84,8 +87,17 @@ 
     float bias() const { return bias_; }
 };
 
-void
-CompositeTestSimpleFade::draw(std::list<CompositeWindow *> &window_list)
+static Fader fader;
+
+void
+CompositeTestSimpleFade::prepare_for_run(list<CompositeWindow*>& window_list)
+{
+    CompositeTestSimpleBase::prepare_for_run(window_list);
+    fader.init(options_["duration"].value);
+}
+
+void
+CompositeTestSimpleFade::draw(list<CompositeWindow*>& window_list)
 {
     vboData_.bind();
     glActiveTexture(GL_TEXTURE0);
@@ -100,7 +112,6 @@ 
     glEnableVertexAttribArray(texcoordIndex_);
 
     program_[projection_matrix_name_] = projection_matrix.getCurrent();
-    static Fader fader(options_["duration"].value);
     program_[fade_bias_name_] = fader.bias();
 
     /* Find out how many windows are visible and calculate the angular step */
@@ -109,7 +120,7 @@ 
 
     /* Draw the windows in a circle using the calculated angular step */
     GLint i(0);
-    for(std::list<CompositeWindow*>::iterator iter = window_list.begin();
+    for(list<CompositeWindow*>::iterator iter = window_list.begin();
         iter != window_list.end(); ++iter)
     {
         CompositeWindow *comp_win = *iter;

=== modified file 'src/composite-test.h'
--- src/composite-test.h	2012-03-09 03:58:54 +0000
+++ src/composite-test.h	2012-07-13 15:40:15 +0000
@@ -227,6 +227,7 @@ 
 
     virtual void draw(std::list<CompositeWindow*> &window_list);
     virtual bool init_shaders(ShaderSource& vtx, ShaderSource& frg);
+    virtual void prepare_for_run(std::list<CompositeWindow*>& window_list);
 };
 
 struct BlurPrivate;