| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "TestContext.h" | 9 #include "TestContext.h" |
| 10 | 10 |
| 11 #include "GpuTimer.h" | |
| 12 | |
| 13 namespace sk_gpu_test { | 11 namespace sk_gpu_test { |
| 14 TestContext::TestContext() | 12 TestContext::TestContext() : fFenceSync(nullptr), fCurrentFenceIdx(0) { |
| 15 : fFenceSync(nullptr) | |
| 16 , fGpuTimer(nullptr) | |
| 17 , fCurrentFenceIdx(0) { | |
| 18 memset(fFrameFences, 0, sizeof(fFrameFences)); | 13 memset(fFrameFences, 0, sizeof(fFrameFences)); |
| 19 } | 14 } |
| 20 | 15 |
| 21 TestContext::~TestContext() { | 16 TestContext::~TestContext() { |
| 22 // Subclass should call teardown. | 17 // Subclass should call teardown. |
| 23 #ifdef SK_DEBUG | 18 #ifdef SK_DEBUG |
| 24 for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { | 19 for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { |
| 25 SkASSERT(0 == fFrameFences[i]); | 20 SkASSERT(0 == fFrameFences[i]); |
| 26 } | 21 } |
| 27 #endif | 22 #endif |
| 28 SkASSERT(!fFenceSync); | 23 SkASSERT(!fFenceSync); |
| 29 SkASSERT(!fGpuTimer); | |
| 30 } | 24 } |
| 31 | 25 |
| 32 void TestContext::makeCurrent() const { this->onPlatformMakeCurrent(); } | 26 void TestContext::makeCurrent() const { this->onPlatformMakeCurrent(); } |
| 33 | 27 |
| 34 void TestContext::swapBuffers() { this->onPlatformSwapBuffers(); } | 28 void TestContext::swapBuffers() { this->onPlatformSwapBuffers(); } |
| 35 | 29 |
| 36 void TestContext::waitOnSyncOrSwap() { | 30 void TestContext::waitOnSyncOrSwap() { |
| 37 if (!fFenceSync) { | 31 if (!fFenceSync) { |
| 38 // Fallback on the platform SwapBuffers method for synchronization. This
may have no effect. | 32 // Fallback on the platform SwapBuffers method for synchronization. This
may have no effect. |
| 39 this->swapBuffers(); | 33 this->swapBuffers(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 62 if (fFenceSync) { | 56 if (fFenceSync) { |
| 63 for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { | 57 for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { |
| 64 if (fFrameFences[i]) { | 58 if (fFrameFences[i]) { |
| 65 fFenceSync->deleteFence(fFrameFences[i]); | 59 fFenceSync->deleteFence(fFrameFences[i]); |
| 66 fFrameFences[i] = 0; | 60 fFrameFences[i] = 0; |
| 67 } | 61 } |
| 68 } | 62 } |
| 69 delete fFenceSync; | 63 delete fFenceSync; |
| 70 fFenceSync = nullptr; | 64 fFenceSync = nullptr; |
| 71 } | 65 } |
| 72 delete fGpuTimer; | |
| 73 } | 66 } |
| 74 | 67 |
| 75 } | 68 } |
| OLD | NEW |