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, GrMipMapsStatus); 21 22 static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, SkISize dimensions, 23 GrRenderable, int sampleCnt, 24 GrMipMapsStatus, GrWrapCacheable, GrIOType, 25 const GrDawnTextureInfo&); 26 27 ~GrDawnTexture() override; 28 29 GrBackendTexture getBackendTexture() const override; 30 GrBackendFormat backendFormat() const override; 31 textureParamsModified()32 void textureParamsModified() override {} 33 34 void upload(GrColorType, const GrMipLevel texels[], int mipLevels, 35 wgpu::CommandEncoder copyEncoder); 36 void upload(GrColorType, const GrMipLevel texels[], int mipLevels, 37 const SkIRect& dstRect, wgpu::CommandEncoder copyEncoder); 38 texture()39 wgpu::Texture texture() const { return fInfo.fTexture; } textureView()40 wgpu::TextureView textureView() const { return fTextureView; } 41 protected: 42 GrDawnTexture(GrDawnGpu*, SkISize dimensions, wgpu::TextureView, 43 const GrDawnTextureInfo&, GrMipMapsStatus); 44 45 GrDawnGpu* getDawnGpu() const; 46 47 void onAbandon() override; 48 void onRelease() override; 49 onStealBackendTexture(GrBackendTexture *,SkImage::BackendTextureReleaseProc *)50 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { 51 return false; 52 } 53 54 private: 55 GrDawnTextureInfo fInfo; 56 wgpu::TextureView fTextureView; 57 58 typedef GrTexture INHERITED; 59 }; 60 61 #endif 62