| 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 |
| 62 protected: | 78 protected: |
| 63 GLTestContext(); | 79 GLTestContext(); |
| 64 | 80 |
| 65 /* | 81 /* |
| 66 * Methods that sublcasses must call from their constructors and destructors
. | 82 * Methods that sublcasses must call from their constructors and destructors
. |
| 67 */ | 83 */ |
| 68 void init(const GrGLInterface *, SkGpuFenceSync * = NULL); | 84 void init(const GrGLInterface *, FenceSync* = nullptr); |
| 69 | 85 |
| 70 void teardown() override; | 86 void teardown() override; |
| 71 | 87 |
| 72 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; | 88 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; |
| 73 | 89 |
| 74 private: | 90 private: |
| 75 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu
nctionality. | |
| 76 | |
| 77 /** Subclass provides the gl interface object if construction was | 91 /** Subclass provides the gl interface object if construction was |
| 78 * successful. */ | 92 * successful. */ |
| 79 SkAutoTUnref<const GrGLInterface> fGL; | 93 SkAutoTUnref<const GrGLInterface> fGL; |
| 80 | 94 |
| 81 friend class GLFenceSync; // For onPlatformGetProcAddress. | |
| 82 | |
| 83 typedef TestContext INHERITED; | 95 typedef TestContext INHERITED; |
| 84 }; | 96 }; |
| 85 | 97 |
| 86 /** | 98 /** |
| 87 * Creates platform-dependent GL context object. The shareContext parameter is
in an optional | 99 * Creates platform-dependent GL context object. The shareContext parameter is
in an optional |
| 88 * context with which to share display lists. This should be a pointer to an GLT
estContext created | 100 * context with which to share display lists. This should be a pointer to an GLT
estContext created |
| 89 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak
e place. Returns a | 101 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak
e place. Returns a |
| 90 * valid gl context object or NULL if such can not be created. | 102 * valid gl context object or NULL if such can not be created. |
| 91 */ | 103 */ |
| 92 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, | 104 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, |
| 93 GLTestContext *shareContext = nullptr
); | 105 GLTestContext *shareContext = nullptr
); |
| 94 | 106 |
| 95 } // namespace sk_gpu_test | 107 } // namespace sk_gpu_test |
| 96 #endif | 108 #endif |
| OLD | NEW |