OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #ifndef GLTestContext_DEFINED | 8 #ifndef GLTestContext_DEFINED |
9 #define GLTestContext_DEFINED | 9 #define GLTestContext_DEFINED |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 /** Wait until all GPU work is finished. */ | 53 /** Wait until all GPU work is finished. */ |
54 void finish() override; | 54 void finish() override; |
55 | 55 |
56 /** | 56 /** |
57 * Creates a new GL context of the same type and makes the returned context
current | 57 * Creates a new GL context of the same type and makes the returned context
current |
58 * (if not null). | 58 * (if not null). |
59 */ | 59 */ |
60 virtual GLTestContext *createNew() const { return nullptr; } | 60 virtual GLTestContext *createNew() const { return nullptr; } |
61 | 61 |
62 template<typename Ret, typename... Args> | |
63 void getGLProcAddress(Ret(GR_GL_FUNCTION_TYPE** out)(Args...), | |
64 const char* name, const char* ext = nullptr) const { | |
65 using Proc = Ret(GR_GL_FUNCTION_TYPE*)(Args...); | |
66 if (!SkStrStartsWith(name, "gl")) { | |
67 SkFAIL("getGLProcAddress: proc name must have 'gl' prefix"); | |
68 *out = nullptr; | |
69 } else if (ext) { | |
70 SkString fullname(name); | |
71 fullname.append(ext); | |
72 *out = reinterpret_cast<Proc>(this->onPlatformGetProcAddress(fullnam
e.c_str())); | |
73 } else { | |
74 *out = reinterpret_cast<Proc>(this->onPlatformGetProcAddress(name)); | |
75 } | |
76 } | |
77 | |
78 protected: | 62 protected: |
79 GLTestContext(); | 63 GLTestContext(); |
80 | 64 |
81 /* | 65 /* |
82 * Methods that sublcasses must call from their constructors and destructors
. | 66 * Methods that sublcasses must call from their constructors and destructors
. |
83 */ | 67 */ |
84 void init(const GrGLInterface *, FenceSync* = nullptr); | 68 void init(const GrGLInterface *, SkGpuFenceSync * = NULL); |
85 | 69 |
86 void teardown() override; | 70 void teardown() override; |
87 | 71 |
88 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; | 72 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; |
89 | 73 |
90 private: | 74 private: |
| 75 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu
nctionality. |
| 76 |
91 /** Subclass provides the gl interface object if construction was | 77 /** Subclass provides the gl interface object if construction was |
92 * successful. */ | 78 * successful. */ |
93 SkAutoTUnref<const GrGLInterface> fGL; | 79 SkAutoTUnref<const GrGLInterface> fGL; |
94 | 80 |
| 81 friend class GLFenceSync; // For onPlatformGetProcAddress. |
| 82 |
95 typedef TestContext INHERITED; | 83 typedef TestContext INHERITED; |
96 }; | 84 }; |
97 | 85 |
98 /** | 86 /** |
99 * Creates platform-dependent GL context object. The shareContext parameter is
in an optional | 87 * Creates platform-dependent GL context object. The shareContext parameter is
in an optional |
100 * context with which to share display lists. This should be a pointer to an GLT
estContext created | 88 * context with which to share display lists. This should be a pointer to an GLT
estContext created |
101 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak
e place. Returns a | 89 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak
e place. Returns a |
102 * valid gl context object or NULL if such can not be created. | 90 * valid gl context object or NULL if such can not be created. |
103 */ | 91 */ |
104 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, | 92 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, |
105 GLTestContext *shareContext = nullptr
); | 93 GLTestContext *shareContext = nullptr
); |
106 | 94 |
107 } // namespace sk_gpu_test | 95 } // namespace sk_gpu_test |
108 #endif | 96 #endif |
OLD | NEW |