diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 174: Scene*: Eliminate duplication of scene update code.

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

Commit Message

alexandros.frantzis@linaro.org Dec. 9, 2011, 1:37 p.m. UTC
Merge authors:
  Alexandros Frantzis (afrantzis)
Related merge proposals:
  https://code.launchpad.net/~glmark2-dev/glmark2/scene-update-refactor/+merge/84925
  proposed by: Alexandros Frantzis (afrantzis)
  review: Approve - Jesse Barker (jesse-barker)
------------------------------------------------------------
revno: 174 [merge]
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Thu 2011-12-08 15:17:19 +0200
message:
  Scene*: Eliminate duplication of scene update code.
modified:
  src/scene-buffer.cpp
  src/scene-build.cpp
  src/scene-bump.cpp
  src/scene-desktop.cpp
  src/scene-effect-2d.cpp
  src/scene-grid.cpp
  src/scene-pulsar.cpp
  src/scene-shading.cpp
  src/scene-texture.cpp
  src/scene.cpp


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

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

Patch

=== modified file 'src/scene-buffer.cpp'
--- src/scene-buffer.cpp	2011-12-08 13:15:50 +0000
+++ src/scene-buffer.cpp	2011-12-08 13:17:19 +0000
@@ -412,19 +412,11 @@ 
 void
 SceneBuffer::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
 
     priv_->wave->update(elapsed_time);
-
-    currentFrame_++;
 }
 
 void

=== modified file 'src/scene-build.cpp'
--- src/scene-build.cpp	2011-11-11 11:07:15 +0000
+++ src/scene-build.cpp	2011-12-08 11:09:09 +0000
@@ -196,20 +196,11 @@ 
 void
 SceneBuild::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    rotation_ += rotationSpeed_ * dt;
-
-    currentFrame_++;
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
+
+    rotation_ = rotationSpeed_ * elapsed_time;
 }
 
 void

=== modified file 'src/scene-bump.cpp'
--- src/scene-bump.cpp	2011-11-15 10:15:41 +0000
+++ src/scene-bump.cpp	2011-12-08 11:09:09 +0000
@@ -314,20 +314,11 @@ 
 void
 SceneBump::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    rotation_ += rotationSpeed_ * dt;
-
-    currentFrame_++;
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
+
+    rotation_ = rotationSpeed_ * elapsed_time;
 }
 
 void

=== modified file 'src/scene-desktop.cpp'
--- src/scene-desktop.cpp	2011-11-11 11:07:15 +0000
+++ src/scene-desktop.cpp	2011-12-08 11:09:09 +0000
@@ -866,9 +866,8 @@ 
 {
     double current_time = Util::get_timestamp_us() / 1000000.0;
     double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
 
-    lastUpdateTime_ = current_time;
+    Scene::update();
 
     std::vector<RenderObject *>& windows(priv_->windows);
 
@@ -903,13 +902,6 @@ 
         if (should_update)
             win->position(new_pos);
     }
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    currentFrame_++;
 }
 
 void

=== modified file 'src/scene-effect-2d.cpp'
--- src/scene-effect-2d.cpp	2011-11-11 11:07:15 +0000
+++ src/scene-effect-2d.cpp	2011-12-08 11:09:09 +0000
@@ -368,17 +368,7 @@ 
 void
 SceneEffect2D::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    currentFrame_++;
+    Scene::update();
 }
 
 void

=== modified file 'src/scene-grid.cpp'
--- src/scene-grid.cpp	2011-11-08 21:40:36 +0000
+++ src/scene-grid.cpp	2011-12-08 11:09:09 +0000
@@ -93,20 +93,11 @@ 
 void
 SceneGrid::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    rotation_ += rotationSpeed_ * dt;
-
-    currentFrame_++;
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
+
+    rotation_ = rotationSpeed_ * elapsed_time;
 }
 
 void

=== modified file 'src/scene-pulsar.cpp'
--- src/scene-pulsar.cpp	2011-11-11 11:07:15 +0000
+++ src/scene-pulsar.cpp	2011-12-08 11:09:09 +0000
@@ -169,24 +169,15 @@ 
 void
 ScenePulsar::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
 
     for (int i = 0; i < numQuads_; i++) {
-        rotations_[i] += rotationSpeeds_[i] * (dt * 60);
+        rotations_[i] = rotationSpeeds_[i] * (elapsed_time * 60);
     }
 
     scale_ = vec3(cos(elapsed_time / 3.60) * 10.0, sin(elapsed_time / 3.60) * 10.0, 1.0);
-
-    currentFrame_++;
 }
 
 void

=== modified file 'src/scene-shading.cpp'
--- src/scene-shading.cpp	2011-11-11 11:07:15 +0000
+++ src/scene-shading.cpp	2011-12-08 11:09:09 +0000
@@ -265,20 +265,11 @@ 
 void
 SceneShading::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    rotation_ += rotationSpeed_ * dt;
-
-    currentFrame_++;
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
+
+    rotation_ = rotationSpeed_ * elapsed_time;
 }
 
 void

=== modified file 'src/scene-texture.cpp'
--- src/scene-texture.cpp	2011-11-29 14:47:05 +0000
+++ src/scene-texture.cpp	2011-12-08 11:09:09 +0000
@@ -158,20 +158,11 @@ 
 void
 SceneTexture::update()
 {
-    double current_time = Util::get_timestamp_us() / 1000000.0;
-    double dt = current_time - lastUpdateTime_;
-    double elapsed_time = current_time - startTime_;
-
-    lastUpdateTime_ = current_time;
-
-    if (elapsed_time >= duration_) {
-        averageFPS_ = currentFrame_ / elapsed_time;
-        running_ = false;
-    }
-
-    rotation_ += rotationSpeed_ * dt;
-
-    currentFrame_++;
+    Scene::update();
+
+    double elapsed_time = lastUpdateTime_ - startTime_;
+
+    rotation_ = rotationSpeed_ * elapsed_time;
 }
 
 void

=== modified file 'src/scene.cpp'
--- src/scene.cpp	2011-11-11 11:07:15 +0000
+++ src/scene.cpp	2011-12-08 11:09:09 +0000
@@ -88,6 +88,17 @@ 
 void
 Scene::update()
 {
+    double current_time = Util::get_timestamp_us() / 1000000.0;
+    double elapsed_time = current_time - startTime_;
+
+    currentFrame_++;
+
+    lastUpdateTime_ = current_time;
+
+    if (elapsed_time >= duration_) {
+        averageFPS_ = currentFrame_ / elapsed_time;
+        running_ = false;
+    }
 }
 
 void