bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 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 | |
bsalomon | 273c0f5 | 2016-03-31 10:59:06 -0700 | [diff] [blame] | 9 | #include "NullGLTestContext.h" |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 10 | #include "gl/GrGLTestInterface.h" |
| 11 | #include "gl/GrGLDefines.h" |
| 12 | #include "gl/GrGLInterface.h" |
| 13 | #include "gl/GrGLTypes.h" |
| 14 | #include "SkMutex.h" |
| 15 | #include "SkTDArray.h" |
| 16 | |
| 17 | namespace { |
bsalomon | 273c0f5 | 2016-03-31 10:59:06 -0700 | [diff] [blame] | 18 | class NullGLContext : public sk_gpu_test::GLTestContext { |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 19 | public: |
svaisanen | b988ecf | 2016-04-20 00:36:53 -0700 | [diff] [blame] | 20 | NullGLContext(bool enableNVPR) { this->init(GrGLCreateNullInterface(enableNVPR)); } |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 21 | ~NullGLContext() override { this->teardown(); } |
| 22 | |
svaisanen | b988ecf | 2016-04-20 00:36:53 -0700 | [diff] [blame] | 23 | private: |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 24 | void onPlatformMakeCurrent() const override {} |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 25 | void onPlatformSwapBuffers() const override {} |
| 26 | GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; } |
| 27 | }; |
bsalomon | 2f538e9 | 2016-04-01 09:04:35 -0700 | [diff] [blame] | 28 | |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 29 | } // anonymous namespace |
| 30 | |
| 31 | namespace sk_gpu_test { |
Brian Osman | 60c774d | 2017-02-21 16:58:08 -0500 | [diff] [blame^] | 32 | GLTestContext* CreateNullGLTestContext(bool enableNVPR, GLTestContext* shareContext) { |
| 33 | if (shareContext) { |
| 34 | return nullptr; |
| 35 | } |
svaisanen | b988ecf | 2016-04-20 00:36:53 -0700 | [diff] [blame] | 36 | GLTestContext* ctx = new NullGLContext(enableNVPR); |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 37 | if (ctx->isValid()) { |
| 38 | return ctx; |
| 39 | } |
| 40 | delete ctx; |
| 41 | return nullptr; |
| 42 | } |
| 43 | } // namespace sk_gpu_test |
| 44 | |