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

Unified Diff: tools/timer/GpuTimer.cpp

Issue 344213003: Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes Created 6 years, 6 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 | « tools/timer/GpuTimer.h ('k') | tools/timer/SysTimer_mach.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/timer/GpuTimer.cpp
diff --git a/bench/BenchGpuTimer_gl.cpp b/tools/timer/GpuTimer.cpp
similarity index 59%
rename from bench/BenchGpuTimer_gl.cpp
rename to tools/timer/GpuTimer.cpp
index 349fc1529de6ac32754950f20c1ab5bd6037ecb2..aac10a3b0796b82b93e23ff2c80fc4c49d5de749 100644
--- a/bench/BenchGpuTimer_gl.cpp
+++ b/tools/timer/GpuTimer.cpp
@@ -5,34 +5,37 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "BenchGpuTimer_gl.h"
+#include "GpuTimer.h"
#include "gl/SkGLContextHelper.h"
#include "gl/GrGLUtil.h"
-BenchGpuTimer::BenchGpuTimer(const SkGLContextHelper* glctx) {
- fContext = glctx;
- glctx->ref();
- glctx->makeCurrent();
- fStarted = false;
- fSupported = GrGLGetVersion(glctx->gl()) > GR_GL_VER(3,3) ||
- glctx->hasExtension("GL_ARB_timer_query") ||
- glctx->hasExtension("GL_EXT_timer_query");
+GpuTimer::GpuTimer(const SkGLContextHelper* glctx) : fContext(glctx) {
+ if (fContext) {
tfarina 2014/06/20 18:05:58 if glctx is NULL, aren't we going to leaving fStar
tfarina 2014/06/20 18:06:40 s/leaving/leave
mtklein 2014/06/20 18:08:18 Yes. If fContext is NULL, we'll never touch any o
+ fContext->ref();
+ fContext->makeCurrent();
+ fStarted = false;
+ fSupported = GrGLGetVersion(fContext->gl()) > GR_GL_VER(3,3) ||
+ fContext->hasExtension("GL_ARB_timer_query") ||
+ fContext->hasExtension("GL_EXT_timer_query");
- if (fSupported) {
- SK_GL(*glctx, GenQueries(1, &fQuery));
+ if (fSupported) {
+ SK_GL(*fContext, GenQueries(1, &fQuery));
+ }
}
}
-BenchGpuTimer::~BenchGpuTimer() {
- if (fSupported) {
- fContext->makeCurrent();
- SK_GL(*fContext, DeleteQueries(1, &fQuery));
+GpuTimer::~GpuTimer() {
+ if (fContext) {
+ if (fSupported) {
+ fContext->makeCurrent();
+ SK_GL(*fContext, DeleteQueries(1, &fQuery));
+ }
+ fContext->unref();
}
- fContext->unref();
}
-void BenchGpuTimer::startGpu() {
- if (fSupported) {
+void GpuTimer::start() {
+ if (fContext && fSupported) {
fContext->makeCurrent();
fStarted = true;
SK_GL(*fContext, BeginQuery(GR_GL_TIME_ELAPSED, fQuery));
@@ -43,8 +46,8 @@ void BenchGpuTimer::startGpu() {
* It is important to stop the cpu clocks first,
* as this will cpu wait for the gpu to finish.
*/
-double BenchGpuTimer::endGpu() {
- if (fSupported) {
+double GpuTimer::end() {
+ if (fContext && fSupported) {
fStarted = false;
fContext->makeCurrent();
SK_GL(*fContext, EndQuery(GR_GL_TIME_ELAPSED));
@@ -52,8 +55,8 @@ double BenchGpuTimer::endGpu() {
GrGLint available = 0;
while (!available) {
SK_GL_NOERRCHECK(*fContext, GetQueryObjectiv(fQuery,
- GR_GL_QUERY_RESULT_AVAILABLE,
- &available));
+ GR_GL_QUERY_RESULT_AVAILABLE,
+ &available));
// If GetQueryObjectiv is erroring out we need some alternative
// means of breaking out of this loop
GrGLenum error;
« no previous file with comments | « tools/timer/GpuTimer.h ('k') | tools/timer/SysTimer_mach.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698