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 GrDawnTexture_DEFINED 9 #define GrDawnTexture_DEFINED 10 11 #include "src/gpu/GrTexture.h" 12 #include "dawn/webgpu_cpp.h" 13 14 class GrDawnGpu; 15 16 class GrDawnTexture : public GrTexture { 17 public: 18 static sk_sp<GrDawnTexture> Make(GrDawnGpu*, SkISize dimensions, 19 wgpu::TextureFormat format, GrRenderable, int sampleCnt, 20 SkBudgeted, int mipLevels, GrMipmapStatus); 21 22 static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, SkISize dimensions, GrRenderable, 23 int sampleCnt, GrWrapCacheable, GrIOType, 24 const GrDawnTextureInfo&); 25 26 ~GrDawnTexture() override; 27 28 GrBackendTexture getBackendTexture() const override; 29 GrBackendFormat backendFormat() const override; 30 textureParamsModified()31 void textureParamsModified() override {} 32 texture()33 wgpu::Texture texture() const { return fInfo.fTexture; } format()34 wgpu::TextureFormat format() const { return fInfo.fFormat; } 35 protected: 36 GrDawnTexture(GrDawnGpu*, SkISize dimensions, const GrDawnTextureInfo&, GrMipmapStatus); 37 38 GrDawnGpu* getDawnGpu() const; 39 40 void onAbandon() override; 41 void onRelease() override; 42 onStealBackendTexture(GrBackendTexture *,SkImage::BackendTextureReleaseProc *)43 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { 44 return false; 45 } 46 47 private: 48 GrDawnTextureInfo fInfo; 49 50 using INHERITED = GrTexture; 51 }; 52 53 #endif 54