aboutsummaryrefslogtreecommitdiffstats
path: root/bench/BenchTimer.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2012-01-18 08:56:56 -0500
committerDerek Sollenberger <derek@android.com>2012-02-06 14:14:40 -0500
commit1cab2921ab279367f8206cdadc9259d12e603548 (patch)
tree2852f9dc2481f639122e18fc7831ae6ca43d6d5a /bench/BenchTimer.cpp
parentd7176fd5571bc9878d3cdac8696eaa35ec170d9d (diff)
downloadexternal_skia-1cab2921ab279367f8206cdadc9259d12e603548.zip
external_skia-1cab2921ab279367f8206cdadc9259d12e603548.tar.gz
external_skia-1cab2921ab279367f8206cdadc9259d12e603548.tar.bz2
Skia merge (revision 3022)
This CL has companion changes to account for API updates in... (1) frameworks/base (2) external/webkit Change-Id: Ibb989e76e8bd24313849f9631dbef42cdef9eb7d
Diffstat (limited to 'bench/BenchTimer.cpp')
-rw-r--r--bench/BenchTimer.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/bench/BenchTimer.cpp b/bench/BenchTimer.cpp
index e7b0068..c3a1190 100644
--- a/bench/BenchTimer.cpp
+++ b/bench/BenchTimer.cpp
@@ -1,48 +1,55 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include "BenchTimer.h"
#if defined(SK_BUILD_FOR_WIN32)
#include "BenchSysTimer_windows.h"
#elif defined(SK_BUILD_FOR_MAC)
#include "BenchSysTimer_mach.h"
-#elif defined(SK_BUILD_FOR_UNIX)
+#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
#include "BenchSysTimer_posix.h"
#else
#include "BenchSysTimer_c.h"
#endif
-#if defined(SK_MESA) || \
- defined(SK_BUILD_FOR_WIN32) || \
- defined(SK_BUILD_FOR_MAC) || \
- defined(SK_BUILD_FOR_UNIX)
- #include "BenchGpuTimer_gl.h"
-
-#else
- #include "BenchGpuTimer_none.h"
-#endif
+#include "BenchGpuTimer_gl.h"
-BenchTimer::BenchTimer()
+BenchTimer::BenchTimer(SkGLContext* gl)
: fCpu(-1.0)
, fWall(-1.0)
, fGpu(-1.0)
{
- this->fSysTimer = new BenchSysTimer();
- this->fGpuTimer = new BenchGpuTimer();
+ fSysTimer = new BenchSysTimer();
+ if (gl) {
+ fGpuTimer = new BenchGpuTimer(gl);
+ } else {
+ fGpuTimer = NULL;
+ }
}
BenchTimer::~BenchTimer() {
- delete this->fSysTimer;
- delete this->fGpuTimer;
+ delete fSysTimer;
+ delete fGpuTimer;
}
void BenchTimer::start() {
- this->fSysTimer->startWall();
- this->fGpuTimer->startGpu();
- this->fSysTimer->startCpu();
+ fSysTimer->startWall();
+ if (fGpuTimer) {
+ fGpuTimer->startGpu();
+ }
+ fSysTimer->startCpu();
}
void BenchTimer::end() {
- this->fCpu = this->fSysTimer->endCpu();
+ fCpu = fSysTimer->endCpu();
//It is important to stop the cpu clocks first,
//as the following will cpu wait for the gpu to finish.
- this->fGpu = this->fGpuTimer->endGpu();
- this->fWall = this->fSysTimer->endWall();
+ if (fGpuTimer) {
+ fGpu = fGpuTimer->endGpu();
+ }
+ fWall = fSysTimer->endWall();
}