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 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 void TestContext::waitOnSyncOrSwap() { | 30 void TestContext::waitOnSyncOrSwap() { |
31 if (!fFenceSync) { | 31 if (!fFenceSync) { |
32 // 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. |
33 this->swapBuffers(); | 33 this->swapBuffers(); |
34 return; | 34 return; |
35 } | 35 } |
36 | 36 |
37 this->submit(); | 37 this->submit(); |
38 if (fFrameFences[fCurrentFenceIdx]) { | 38 if (fFrameFences[fCurrentFenceIdx]) { |
39 if (!fFenceSync->waitFence(fFrameFences[fCurrentFenceIdx], true)) { | 39 if (!fFenceSync->waitFence(fFrameFences[fCurrentFenceIdx])) { |
40 SkDebugf("WARNING: Wait failed for fence sync. Timings might not be
accurate.\n"); | 40 SkDebugf("WARNING: Wait failed for fence sync. Timings might not be
accurate.\n"); |
41 } | 41 } |
42 fFenceSync->deleteFence(fFrameFences[fCurrentFenceIdx]); | 42 fFenceSync->deleteFence(fFrameFences[fCurrentFenceIdx]); |
43 } | 43 } |
44 | 44 |
45 fFrameFences[fCurrentFenceIdx] = fFenceSync->insertFence(); | 45 fFrameFences[fCurrentFenceIdx] = fFenceSync->insertFence(); |
46 fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences); | 46 fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences); |
47 } | 47 } |
48 | 48 |
49 void TestContext::testAbandon() { | 49 void TestContext::testAbandon() { |
50 if (fFenceSync) { | 50 if (fFenceSync) { |
51 memset(fFrameFences, 0, sizeof(fFrameFences)); | 51 memset(fFrameFences, 0, sizeof(fFrameFences)); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 void TestContext::teardown() { | 55 void TestContext::teardown() { |
56 if (fFenceSync) { | 56 if (fFenceSync) { |
57 for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { | 57 for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { |
58 if (fFrameFences[i]) { | 58 if (fFrameFences[i]) { |
59 fFenceSync->deleteFence(fFrameFences[i]); | 59 fFenceSync->deleteFence(fFrameFences[i]); |
60 fFrameFences[i] = 0; | 60 fFrameFences[i] = 0; |
61 } | 61 } |
62 } | 62 } |
63 delete fFenceSync; | 63 delete fFenceSync; |
64 fFenceSync = nullptr; | 64 fFenceSync = nullptr; |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 } | 68 } |
OLD | NEW |