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