Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2017 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 | #ifndef GLTestContext_DEFINED |
| 9 | #define GLTestContext_DEFINED |
| 10 | |
| 11 | #include "MockTestContext.h" |
| 12 | |
Greg Daniel | 02611d9 | 2017-07-25 10:05:01 -0400 | [diff] [blame] | 13 | #include "GrContext.h" |
| 14 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 15 | namespace { |
| 16 | |
| 17 | class MockTestContext : public sk_gpu_test::TestContext { |
| 18 | public: |
| 19 | MockTestContext() {} |
| 20 | ~MockTestContext() override {} |
| 21 | |
| 22 | virtual GrBackend backend() override { return kMock_GrBackend; } |
| 23 | virtual GrBackendContext backendContext() override { |
| 24 | return reinterpret_cast<GrBackendContext>(nullptr); |
| 25 | } |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 26 | void testAbandon() override {} |
| 27 | void submit() override {} |
| 28 | void finish() override {} |
| 29 | |
Greg Daniel | 02611d9 | 2017-07-25 10:05:01 -0400 | [diff] [blame] | 30 | sk_sp<GrContext> makeGrContext(const GrContextOptions& options) override { |
| 31 | return GrContext::MakeMock(nullptr, options); |
| 32 | } |
| 33 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 34 | protected: |
| 35 | void teardown() override {} |
| 36 | void onPlatformMakeCurrent() const override {} |
Brian Salomon | 55ad774 | 2017-11-17 09:25:23 -0500 | [diff] [blame^] | 37 | std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; } |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 38 | void onPlatformSwapBuffers() const override {} |
| 39 | |
| 40 | private: |
| 41 | typedef sk_gpu_test::TestContext INHERITED; |
| 42 | }; |
| 43 | |
| 44 | } // anonymous namespace |
| 45 | |
| 46 | namespace sk_gpu_test { |
| 47 | |
| 48 | TestContext* CreateMockTestContext(TestContext*) { return new MockTestContext(); } |
| 49 | |
| 50 | } // namespace sk_gpu_test |
| 51 | #endif |