bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef VkTestContext_DEFINED |
| 9 | #define VkTestContext_DEFINED |
| 10 | |
| 11 | #include "TestContext.h" |
| 12 | |
| 13 | #ifdef SK_VULKAN |
| 14 | |
| 15 | #include "vk/GrVkBackendContext.h" |
| 16 | |
| 17 | namespace sk_gpu_test { |
| 18 | class VkTestContext : public TestContext { |
| 19 | public: |
| 20 | virtual GrBackend backend() override { return kVulkan_GrBackend; } |
| 21 | virtual GrBackendContext backendContext() override { |
| 22 | return reinterpret_cast<GrBackendContext>(fVk.get()); |
| 23 | } |
| 24 | |
Greg Daniel | 604b197 | 2017-05-15 13:50:35 -0400 | [diff] [blame^] | 25 | sk_sp<const GrVkBackendContext> getVkBackendContext() { |
| 26 | return fVk; |
| 27 | } |
| 28 | |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 29 | bool isValid() const override { return NULL != this->vk(); } |
| 30 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 31 | const GrVkInterface* vk() const { return fVk->fInterface.get(); } |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 32 | |
| 33 | protected: |
Mike Klein | 6ad6ba4 | 2016-09-27 10:52:35 -0400 | [diff] [blame] | 34 | VkTestContext(sk_sp<const GrVkBackendContext> vk) : fVk(std::move(vk)) {} |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 35 | |
| 36 | sk_sp<const GrVkBackendContext> fVk; |
| 37 | |
| 38 | private: |
| 39 | typedef TestContext INHERITED; |
| 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * Creates Vk context object bound to the native Vk library. |
| 44 | */ |
Greg Daniel | 604b197 | 2017-05-15 13:50:35 -0400 | [diff] [blame^] | 45 | VkTestContext* CreatePlatformVkTestContext(VkTestContext*); |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 46 | |
| 47 | } // namespace sk_gpu_test |
| 48 | |
| 49 | #endif |
| 50 | |
| 51 | #endif |