=== added file 'src/composite-test-simple-scale.cc'
@@ -0,0 +1,150 @@
+/*
+ * Copyright © 2012 Linaro Limited
+ *
+ * This file is part of glcompbench.
+ *
+ * glcompbench is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * glcompbench is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with glcompbench. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ * Jesse Barker <jesse.barker@linaro.org>
+ */
+
+#include "gl-headers.h"
+#include "composite-test.h"
+#include "options.h"
+#include "log.h"
+#include <sstream>
+
+using std::string;
+using std::list;
+
+bool
+CompositeTestSimpleScale::init_shaders(ShaderSource& vtx, ShaderSource& frg)
+{
+ static const string precisionString("default,default,default,default");
+ static const ShaderSource::Precision precision(precisionString);
+ vtx.precision(precision);
+ frg.precision(precision);
+ static const float alpha_bias(0.5);
+ frg.add_const("alpha_bias", alpha_bias);
+
+ return true;
+}
+
+// We want to scale smoothly across the test duration, so take a timestamp
+// at the beginning of the test (beginning of the first draw), and take one
+// each time we update the scale bias.
+class Scaler
+{
+ uint64_t start_time_;
+ uint64_t last_eof_;
+ float bias_;
+ float duration_;
+public:
+ Scaler() :
+ start_time_(0),
+ last_eof_(0),
+ bias_(0.0),
+ duration_(0.0) {}
+ ~Scaler() {}
+ 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.
+ std::stringstream ss(duration);
+ ss >> duration_;
+ duration_ *= 1000000;
+ start_time_ = Profiler::get_timestamp_us();
+ }
+ void update()
+ {
+ last_eof_ = Profiler::get_timestamp_us();
+ uint64_t howLong(last_eof_ - start_time_);
+ if (howLong < duration_)
+ {
+ // Still inside of the test duration. Compute the bias.
+ bias_ = howLong / duration_;
+ return;
+ }
+ // Reset back to the beginning.
+ start_time_ = last_eof_;
+ bias_ = 0.0;
+ }
+ float bias() const { return bias_; }
+};
+
+static Scaler scaler;
+
+void
+CompositeTestSimpleScale::prepare_for_run(list<CompositeWindow*>& window_list)
+{
+ CompositeTestSimpleBase::prepare_for_run(window_list);
+ scaler.init(options_["duration"].value);
+}
+
+void
+CompositeTestSimpleScale::draw(list<CompositeWindow *> &window_list)
+{
+ vboData_.bind();
+ glActiveTexture(GL_TEXTURE0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ /* Set up the position of the attributes in the vertex array */
+ glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0, vboData_.vertexOffset());
+ glVertexAttribPointer(texcoordIndex_, 2, GL_FLOAT, GL_FALSE, 0, vboData_.texcoordOffset());
+
+ /* Enable the attributes */
+ glEnableVertexAttribArray(vertexIndex_);
+ glEnableVertexAttribArray(texcoordIndex_);
+
+ program_[projection_matrix_name_] = projection_matrix.getCurrent();
+
+ /* Find out how many windows are visible and calculate the angular step */
+ GLuint visible_windows(num_visible_windows(window_list));
+ GLfloat angular_step(2 * M_PI / visible_windows);
+
+ /* Draw the windows in a circle using the calculated angular step */
+ float scale_bias(scaler.bias());
+ GLint i(0);
+ for(list<CompositeWindow*>::iterator iter = window_list.begin();
+ iter != window_list.end(); ++iter)
+ {
+ CompositeWindow *comp_win = *iter;
+ GLuint tex = comp_win->get_texture().i;
+ if (tex) {
+ model_view_matrix.push();
+ model_view_matrix.translate(cos(angular_step * i),
+ sin(angular_step * i), 0);
+ model_view_matrix.scale(scale_bias, scale_bias, scale_bias);
+
+ /* Load shader ModelView uniform */
+ program_[model_view_matrix_name_] = model_view_matrix.getCurrent();
+
+ Log::debug("Drawing Win: 0x%x Tex: 0x%x\n",
+ comp_win->get_xwindow(), comp_win->get_texture().i);
+
+ glBindTexture(GL_TEXTURE_2D, tex);
+ vboData_.draw();
+ model_view_matrix.pop();
+ ++i;
+ }
+ }
+
+ // Disable the attributes
+ glDisableVertexAttribArray(vertexIndex_);
+ glDisableVertexAttribArray(texcoordIndex_);
+ vboData_.unbind();
+ scaler.update();
+}
=== modified file 'src/composite-test.h'
@@ -245,4 +245,18 @@
virtual void prepare_for_run(std::list<CompositeWindow*> &window_list);
};
+class CompositeTestSimpleScale : public CompositeTestSimpleBase
+{
+public:
+ CompositeTestSimpleScale() :
+ CompositeTestSimpleBase("scale",
+ GLCOMPBENCH_DATA_PATH"/default.vert",
+ GLCOMPBENCH_DATA_PATH"/default.frag")
+ {}
+
+ virtual bool init_shaders(ShaderSource& vtx, ShaderSource& frg);
+ virtual void draw(std::list<CompositeWindow*> &window_list);
+ virtual void prepare_for_run(std::list<CompositeWindow*> &window_list);
+};
+
#endif // COMPOSITE_TEST_H_
=== modified file 'src/glcompbench.cc'
@@ -47,6 +47,7 @@
"fade",
"blur",
"brick",
+ "scale",
"pixman",
"xrender",
NULL
@@ -199,6 +200,7 @@
Benchmark::register_test(*new CompositeTestSimpleBlur());
Benchmark::register_test(*new CompositeTestSimpleFade());
Benchmark::register_test(*new CompositeTestSimpleBrick());
+ Benchmark::register_test(*new CompositeTestSimpleScale());
Benchmark::register_test(*new CompositeTestPixman());
Benchmark::register_test(*new CompositeTestXRender());