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

Unified Diff: tools/timer/GpuTimer.cpp

Issue 346753003: Revert of Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/tools/timer/GpuTimer.cpp b/tools/timer/GpuTimer.cpp
deleted file mode 100644
index 3174449f78cd572e078d84f0b06d7af38ea4f17c..0000000000000000000000000000000000000000
--- a/tools/timer/GpuTimer.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-
-/*
- * 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 "GpuTimer.h"
-#include "gl/SkGLContextHelper.h"
-#include "gl/GrGLUtil.h"
-
-GpuTimer::GpuTimer(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");
-
- if (fSupported) {
- SK_GL(*glctx, GenQueries(1, &fQuery));
- }
-}
-
-GpuTimer::~GpuTimer() {
- if (fSupported) {
- fContext->makeCurrent();
- SK_GL(*fContext, DeleteQueries(1, &fQuery));
- }
- fContext->unref();
-}
-
-void GpuTimer::start() {
- if (fSupported) {
- fContext->makeCurrent();
- fStarted = true;
- SK_GL(*fContext, BeginQuery(GR_GL_TIME_ELAPSED, fQuery));
- }
-}
-
-/**
- * It is important to stop the cpu clocks first,
- * as this will cpu wait for the gpu to finish.
- */
-double GpuTimer::end() {
- if (fSupported) {
- fStarted = false;
- fContext->makeCurrent();
- SK_GL(*fContext, EndQuery(GR_GL_TIME_ELAPSED));
-
- GrGLint available = 0;
- while (!available) {
- SK_GL_NOERRCHECK(*fContext, GetQueryObjectiv(fQuery,
- GR_GL_QUERY_RESULT_AVAILABLE,
- &available));
- // If GetQueryObjectiv is erroring out we need some alternative
- // means of breaking out of this loop
- GrGLenum error;
- SK_GL_RET_NOERRCHECK(*fContext, error, GetError());
- if (GR_GL_NO_ERROR != error) {
- break;
- }
- }
- GrGLuint64 totalGPUTimeElapsed = 0;
- SK_GL(*fContext, GetQueryObjectui64v(fQuery,
- GR_GL_QUERY_RESULT,
- &totalGPUTimeElapsed));
-
- return totalGPUTimeElapsed / 1000000.0;
- } else {
- return 0;
- }
-}
« 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