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