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 #ifndef TestContext_DEFINED | 9 #ifndef TestContext_DEFINED |
10 #define TestContext_DEFINED | 10 #define TestContext_DEFINED |
11 | 11 |
| 12 #include "FenceSync.h" |
12 #include "GrTypes.h" | 13 #include "GrTypes.h" |
13 #include "../private/SkGpuFenceSync.h" | |
14 #include "../private/SkTemplates.h" | 14 #include "../private/SkTemplates.h" |
15 | 15 |
16 namespace sk_gpu_test { | 16 namespace sk_gpu_test { |
17 /** | 17 /** |
18 * An offscreen 3D context. This class is intended for Skia's internal testing n
eeds and not | 18 * An offscreen 3D context. This class is intended for Skia's internal testing n
eeds and not |
19 * for general use. | 19 * for general use. |
20 */ | 20 */ |
21 class TestContext : public SkNoncopyable { | 21 class TestContext : public SkNoncopyable { |
22 public: | 22 public: |
23 virtual ~TestContext(); | 23 virtual ~TestContext(); |
24 | 24 |
25 virtual bool isValid() const = 0; | 25 virtual bool isValid() const = 0; |
26 | 26 |
27 bool fenceSyncSupport() const { return fFenceSync != nullptr; } | 27 bool fenceSyncSupport() const { return fFenceSync != nullptr; } |
| 28 FenceSync* fenceSync() { SkASSERT(fFenceSync); return fFenceSync; } |
28 | 29 |
29 bool getMaxGpuFrameLag(int *maxFrameLag) const { | 30 bool getMaxGpuFrameLag(int *maxFrameLag) const { |
30 if (!fFenceSync) { | 31 if (!fFenceSync) { |
31 return false; | 32 return false; |
32 } | 33 } |
33 *maxFrameLag = kMaxFrameLag; | 34 *maxFrameLag = kMaxFrameLag; |
34 return true; | 35 return true; |
35 } | 36 } |
36 | 37 |
37 void makeCurrent() const; | 38 void makeCurrent() const; |
(...skipping 28 matching lines...) Expand all Loading... |
66 * context to test that further API calls are not made by Skia GPU code. | 67 * context to test that further API calls are not made by Skia GPU code. |
67 */ | 68 */ |
68 virtual void testAbandon(); | 69 virtual void testAbandon(); |
69 | 70 |
70 /** Ensures all work is submitted to the GPU for execution. */ | 71 /** Ensures all work is submitted to the GPU for execution. */ |
71 virtual void submit() = 0; | 72 virtual void submit() = 0; |
72 | 73 |
73 /** Wait until all GPU work is finished. */ | 74 /** Wait until all GPU work is finished. */ |
74 virtual void finish() = 0; | 75 virtual void finish() = 0; |
75 | 76 |
76 /** | |
77 * returns the fencesync object owned by this GLTestContext | |
78 */ | |
79 SkGpuFenceSync *fenceSync() { return fFenceSync; } | |
80 | |
81 protected: | 77 protected: |
82 SkGpuFenceSync* fFenceSync; | 78 FenceSync* fFenceSync; |
83 | 79 |
84 TestContext(); | 80 TestContext(); |
85 | 81 |
86 /** This should destroy the 3D context. */ | 82 /** This should destroy the 3D context. */ |
87 virtual void teardown(); | 83 virtual void teardown(); |
88 | 84 |
89 virtual void onPlatformMakeCurrent() const = 0; | 85 virtual void onPlatformMakeCurrent() const = 0; |
90 virtual void onPlatformSwapBuffers() const = 0; | 86 virtual void onPlatformSwapBuffers() const = 0; |
91 | 87 |
92 private: | 88 private: |
93 enum { | 89 enum { |
94 kMaxFrameLag = 3 | 90 kMaxFrameLag = 3 |
95 }; | 91 }; |
96 | 92 |
97 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1]; | 93 PlatformFence fFrameFences[kMaxFrameLag - 1]; |
98 int fCurrentFenceIdx; | 94 int fCurrentFenceIdx; |
99 | 95 |
100 typedef SkNoncopyable INHERITED; | 96 typedef SkNoncopyable INHERITED; |
101 }; | 97 }; |
102 } // namespace sk_gpu_test | 98 } // namespace sk_gpu_test |
103 #endif | 99 #endif |
OLD | NEW |