| 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 |
| 11 #include "SkTypes.h" |
| 11 #include "TestContext.h" | 12 #include "TestContext.h" |
| 12 #include "gl/GrGLInterface.h" | 13 #include "gl/GrGLInterface.h" |
| 14 #include <string> |
| 13 | 15 |
| 14 namespace sk_gpu_test { | 16 namespace sk_gpu_test { |
| 15 /** | 17 /** |
| 16 * An offscreen OpenGL context. Provides a GrGLInterface struct of function poin
ters for the context | 18 * An offscreen OpenGL context. Provides a GrGLInterface struct of function poin
ters for the context |
| 17 * This class is intended for Skia's internal testing needs and not for general
use. | 19 * This class is intended for Skia's internal testing needs and not for general
use. |
| 18 */ | 20 */ |
| 19 class GLTestContext : public TestContext { | 21 class GLTestContext : public TestContext { |
| 20 public: | 22 public: |
| 21 virtual ~GLTestContext(); | 23 virtual ~GLTestContext(); |
| 22 | 24 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 | 54 |
| 53 /** Wait until all GPU work is finished. */ | 55 /** Wait until all GPU work is finished. */ |
| 54 void finish() override; | 56 void finish() override; |
| 55 | 57 |
| 56 /** | 58 /** |
| 57 * Creates a new GL context of the same type and makes the returned context
current | 59 * Creates a new GL context of the same type and makes the returned context
current |
| 58 * (if not null). | 60 * (if not null). |
| 59 */ | 61 */ |
| 60 virtual GLTestContext *createNew() const { return nullptr; } | 62 virtual GLTestContext *createNew() const { return nullptr; } |
| 61 | 63 |
| 64 template<typename Ret, typename... Args> |
| 65 void getGLProcAddress(Ret(**out)(Args...), |
| 66 const std::string& procname, |
| 67 const std::string& ext = "") const { |
| 68 using Proc = Ret(*)(Args...); |
| 69 if (procname[0] != 'g' || procname[1] != 'l') { |
| 70 SkFAIL("getGLProcAddress: proc name must have 'gl' prefix"); |
| 71 *out = nullptr; |
| 72 return; |
| 73 } |
| 74 *out = reinterpret_cast<Proc>(this->onPlatformGetProcAddress((procname +
ext).c_str())); |
| 75 } |
| 76 |
| 62 protected: | 77 protected: |
| 63 GLTestContext(); | 78 GLTestContext(); |
| 64 | 79 |
| 65 /* | 80 /* |
| 66 * Methods that sublcasses must call from their constructors and destructors
. | 81 * Methods that sublcasses must call from their constructors and destructors
. |
| 67 */ | 82 */ |
| 68 void init(const GrGLInterface *, SkGpuFenceSync * = NULL); | 83 void init(const GrGLInterface *, FenceSync* = nullptr); |
| 69 | 84 |
| 70 void teardown() override; | 85 void teardown() override; |
| 71 | 86 |
| 72 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; | 87 virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0; |
| 73 | 88 |
| 74 private: | 89 private: |
| 75 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu
nctionality. | |
| 76 | |
| 77 /** Subclass provides the gl interface object if construction was | 90 /** Subclass provides the gl interface object if construction was |
| 78 * successful. */ | 91 * successful. */ |
| 79 SkAutoTUnref<const GrGLInterface> fGL; | 92 SkAutoTUnref<const GrGLInterface> fGL; |
| 80 | 93 |
| 81 friend class GLFenceSync; // For onPlatformGetProcAddress. | |
| 82 | |
| 83 typedef TestContext INHERITED; | 94 typedef TestContext INHERITED; |
| 84 }; | 95 }; |
| 85 | 96 |
| 86 /** | 97 /** |
| 87 * Creates platform-dependent GL context object. The shareContext parameter is
in an optional | 98 * 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 | 99 * 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 | 100 * 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. | 101 * valid gl context object or NULL if such can not be created. |
| 91 */ | 102 */ |
| 92 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, | 103 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, |
| 93 GLTestContext *shareContext = nullptr
); | 104 GLTestContext *shareContext = nullptr
); |
| 94 | 105 |
| 95 } // namespace sk_gpu_test | 106 } // namespace sk_gpu_test |
| 96 #endif | 107 #endif |
| OLD | NEW |