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