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