1 /* 2 * Copyright 2019 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 DawnTestContext_DEFINED 9 #define DawnTestContext_DEFINED 10 11 #include "tools/gpu/TestContext.h" 12 #include "dawn/native/DawnNative.h" 13 14 #ifdef SK_DAWN 15 16 namespace sk_gpu_test { 17 class DawnTestContext : public TestContext { 18 public: backend()19 virtual GrBackend backend() override { return GrBackendApi::kDawn; } 20 getDevice()21 const wgpu::Device& getDevice() { 22 return fDevice; 23 } 24 25 protected: DawnTestContext(std::unique_ptr<dawn::native::Instance> instance,const wgpu::Device & device)26 DawnTestContext(std::unique_ptr<dawn::native::Instance> instance, const wgpu::Device& device) 27 : fInstance(std::move(instance)), fDevice(device) {} 28 29 std::unique_ptr<dawn::native::Instance> fInstance; 30 wgpu::Device fDevice; 31 32 private: 33 using INHERITED = TestContext; 34 }; 35 36 /** 37 * Creates Dawn context object bound to the Dawn library. 38 */ 39 DawnTestContext* CreatePlatformDawnTestContext(DawnTestContext*); 40 41 } // namespace sk_gpu_test 42 43 #endif 44 45 #endif 46