OLD | NEW |
---|---|
(Empty) | |
1 | |
2 /* | |
3 * Copyright 2016 Google Inc. | |
4 * | |
5 * Use of this source code is governed by a BSD-style license that can be | |
6 * found in the LICENSE file. | |
7 */ | |
8 | |
9 #ifndef TestContext_DEFINED | |
10 #define TestContext_DEFINED | |
11 | |
12 #include "../private/SkGpuFenceSync.h" | |
13 #include "../private/SkTemplates.h" | |
14 | |
15 namespace sk_gpu_test { | |
16 /** | |
17 * An offscreen 3D context. This class is intended for Skia's internal testing n eeds and not | |
18 * for general use. | |
19 */ | |
20 class TestContext : public SkNoncopyable { | |
21 public: | |
22 virtual ~TestContext(); | |
23 | |
24 virtual bool isValid() const = 0; | |
25 | |
26 bool fenceSyncSupport() const { return fFenceSync != nullptr; } | |
27 | |
28 bool getMaxGpuFrameLag(int *maxFrameLag) const { | |
29 if (!fFenceSync) { | |
30 return false; | |
31 } | |
32 *maxFrameLag = kMaxFrameLag; | |
33 return true; | |
34 } | |
35 | |
36 void makeCurrent() const; | |
37 | |
38 | |
egdaniel
2016/05/11 15:39:29
extra line
bsalomon
2016/05/11 15:52:49
Done.
| |
39 /** Swaps front and back buffer (if the context has such buffers) */ | |
40 void swapBuffers(); | |
41 | |
42 /** | |
43 * The only purpose of this function it to provide a means of scheduling | |
44 * work on the GPU (since all of the subclasses create primary buffers for | |
45 * testing that are small and not meant to be rendered to the screen). | |
46 * | |
47 * If the platform supports fence syncs (OpenGL 3.2+ or EGL_KHR_fence_sync), | |
48 * this will not swap any buffers, but rather emulate triple buffer synchron ization | |
49 * using fences. | |
50 * | |
51 * Otherwise it will call the platform SwapBuffers method. This may or may | |
52 * not perform some sort of synchronization, depending on whether the | |
53 * drawing surface provided by the platform is double buffered. | |
54 */ | |
55 void waitOnSyncOrSwap(); | |
56 | |
57 /** | |
58 * This notifies the context that we are deliberately testing abandoning | |
59 * the context. It is useful for debugging contexts that would otherwise | |
60 * test that GPU resources are properly deleted. It also allows a debugging | |
61 * context to test that further API calls are not made by Skia GPU code. | |
62 */ | |
63 virtual void testAbandon(); | |
64 | |
65 /** | |
66 * returns the fencesync object owned by this GLTestContext | |
67 */ | |
68 SkGpuFenceSync *fenceSync() { return fFenceSync.get(); } | |
69 | |
70 protected: | |
71 SkAutoTDelete <SkGpuFenceSync> fFenceSync; | |
72 | |
73 TestContext(); | |
74 | |
75 /** This should destroy the 3D context. */ | |
76 virtual void teardown(); | |
77 | |
78 virtual void onPlatformMakeCurrent() const = 0; | |
79 virtual void onPlatformSwapBuffers() const = 0; | |
80 | |
81 private: | |
82 enum { | |
83 kMaxFrameLag = 3 | |
84 }; | |
85 | |
86 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1]; | |
87 int fCurrentFenceIdx; | |
88 | |
89 typedef SkNoncopyable INHERITED; | |
90 }; | |
91 } // namespace sk_gpu_test | |
92 #endif | |
OLD | NEW |