Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Unified Diff: client/deps/glbench/src/teartest.cc

Issue 1524009: Use gflags in teartest. (Closed)
Patch Set: nit Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/deps/glbench/src/main.h ('k') | client/deps/glbench/src/xlib_window.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/teartest.cc
diff --git a/client/deps/glbench/src/teartest.cc b/client/deps/glbench/src/teartest.cc
index 941baf4f7371a4b73719f38c38ccc7ce6ce7d876..664e8265078936688c2e50c59e38b51dabcedc14 100644
--- a/client/deps/glbench/src/teartest.cc
+++ b/client/deps/glbench/src/teartest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <gflags/gflags.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -18,6 +19,8 @@
static Pixmap pixmap = 0;
static int shift_uniform = 0;
+DEFINE_int32(refresh, 0,
+ "If 1 or more, target refresh rate; otherwise enable vsync");
GLuint GenerateAndBindTexture() {
GLuint name = ~0;
@@ -46,33 +49,6 @@ const char *fragment_shader =
"}";
-// If refresh is set to zero, we enable vsync. Otherwise we redraw that many
-// times a second.
-struct timespec* g_sleep_duration = NULL;
-static void ParseArgs(int argc, char* argv[]) {
- bool refresh_arg = false;
- for (int i = 0; i < argc; i++) {
- if (refresh_arg) {
- refresh_arg = false;
-
- int refresh = atoi(argv[i]);
- if (refresh > 1) {
- delete g_sleep_duration;
- g_sleep_duration = new struct timespec;
- g_sleep_duration->tv_sec = 0;
- g_sleep_duration->tv_nsec = static_cast<long>(1.e9 / refresh);
- } else {
- printf("-r requires integer greater than one.\n");
- }
- } else if (strcmp("-o", argv[i]) == 0) {
- g_override_redirect = true;
- } else if (strcmp("-r", argv[i]) == 0) {
- refresh_arg = true;
- }
- }
-}
-
-
void AllocatePixmap() {
XWindowAttributes attributes;
XGetWindowAttributes(g_xlib_display, g_xlib_window, &attributes);
@@ -160,9 +136,14 @@ Test test[] = {
};
int main(int argc, char* argv[]) {
- g_override_redirect = false;
+ struct timespec* sleep_duration = NULL;
g_height = -1;
- ParseArgs(argc, argv);
+ google::ParseCommandLineFlags(&argc, &argv, true);
+ if (FLAGS_refresh >= 1) {
+ sleep_duration = new struct timespec;
+ sleep_duration->tv_sec = 0;
+ sleep_duration->tv_nsec = static_cast<long>(1.e9 / FLAGS_refresh);
+ }
if (!Init()) {
printf("# Failed to initialize.\n");
return 1;
@@ -192,7 +173,7 @@ int main(int argc, char* argv[]) {
glUniform1f(texture_sampler, 0);
shift_uniform = glGetUniformLocation(program, "shift");
- SwapInterval(g_sleep_duration ? 0 : 1);
+ SwapInterval(sleep_duration ? 0 : 1);
for (unsigned int i = 0; i < sizeof(test)/sizeof(*test); i++)
{
@@ -209,8 +190,8 @@ int main(int argc, char* argv[]) {
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glFlush();
- if (g_sleep_duration)
- nanosleep(g_sleep_duration, NULL);
+ if (sleep_duration)
+ nanosleep(sleep_duration, NULL);
SwapBuffers();
« no previous file with comments | « client/deps/glbench/src/main.h ('k') | client/deps/glbench/src/xlib_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698