diff options
author | 2016-05-11 10:09:18 -0700 | |
---|---|---|
committer | 2016-05-11 10:09:18 -0700 | |
commit | 18a2f9dff839a3f60850c25e1a701b682a497afb (patch) | |
tree | 0113e4f746b09221f6ccce88beadb60432347682 /tools/gpu/gl/GLTestContext.cpp | |
parent | 393c2ff0d2db9c5d84e6ed660ea9f546f438cb47 (diff) |
Add base class for GLTestContext and add new subclass VkTestContext.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1964243003
Review-Url: https://codereview.chromium.org/1964243003
Diffstat (limited to 'tools/gpu/gl/GLTestContext.cpp')
-rw-r--r-- | tools/gpu/gl/GLTestContext.cpp | 58 |
1 files changed, 5 insertions, 53 deletions
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp index 1069929bf2..3bd814762e 100644 --- a/tools/gpu/gl/GLTestContext.cpp +++ b/tools/gpu/gl/GLTestContext.cpp @@ -1,13 +1,12 @@ - /* * Copyright 2013 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + #include "GLTestContext.h" #include "gl/GrGLUtil.h" -#include "SkGpuFenceSync.h" namespace sk_gpu_test { class GLTestContext::GLFenceSync : public SkGpuFenceSync { @@ -38,75 +37,28 @@ private: typedef SkGpuFenceSync INHERITED; }; -GLTestContext::GLTestContext() - : fCurrentFenceIdx(0) { - memset(fFrameFences, 0, sizeof(fFrameFences)); -} +GLTestContext::GLTestContext() : TestContext() {} GLTestContext::~GLTestContext() { - // Subclass should call teardown. -#ifdef SK_DEBUG - for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { - SkASSERT(0 == fFrameFences[i]); - } -#endif SkASSERT(nullptr == fGL.get()); - SkASSERT(nullptr == fFenceSync.get()); } void GLTestContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) { SkASSERT(!fGL.get()); fGL.reset(gl); - fFenceSync.reset(fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this)); + fFenceSync = fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this); } void GLTestContext::teardown() { - if (fFenceSync) { - for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { - if (fFrameFences[i]) { - fFenceSync->deleteFence(fFrameFences[i]); - fFrameFences[i] = 0; - } - } - fFenceSync.reset(nullptr); - } - fGL.reset(nullptr); -} - -void GLTestContext::makeCurrent() const { - this->onPlatformMakeCurrent(); -} - -void GLTestContext::swapBuffers() { - this->onPlatformSwapBuffers(); -} - -void GLTestContext::waitOnSyncOrSwap() { - if (!fFenceSync) { - // Fallback on the platform SwapBuffers method for synchronization. This may have no effect. - this->swapBuffers(); - return; - } - - if (fFrameFences[fCurrentFenceIdx]) { - if (!fFenceSync->waitFence(fFrameFences[fCurrentFenceIdx], true)) { - SkDebugf("WARNING: Wait failed for fence sync. Timings might not be accurate.\n"); - } - fFenceSync->deleteFence(fFrameFences[fCurrentFenceIdx]); - } - - fFrameFences[fCurrentFenceIdx] = fFenceSync->insertFence(); - fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences); + INHERITED::teardown(); } void GLTestContext::testAbandon() { + INHERITED::testAbandon(); if (fGL) { fGL->abandon(); } - if (fFenceSync) { - memset(fFrameFences, 0, sizeof(fFrameFences)); - } } GLTestContext::GLFenceSync* GLTestContext::GLFenceSync::CreateIfSupported(const GLTestContext* ctx) { |