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

Unified Diff: tools/gpu/gl/GLTestContext.cpp

Issue 1964243003: Add base class for GLTestContext and add new subclass VkTestContext. (Closed) Base URL: https://chromium.googlesource.com/skia.git@ContextInfo
Patch Set: move #include "GrVkBackendContext.h" inside #ifdef SK_VULKAN Created 4 years, 7 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/gpu/gl/GLTestContext.h ('k') | tools/gpu/vk/VkTestContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gpu/gl/GLTestContext.cpp
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp
index 1069929bf26002f5f8e90e10f19b4c5197f67971..3bd814762ee8ae5da169e3b09963469e05c0ccbd 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) {
« no previous file with comments | « tools/gpu/gl/GLTestContext.h ('k') | tools/gpu/vk/VkTestContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698