blob: 7245bf5423dba0773957917af566f9775c79db67 [file] [log] [blame]
Xiaoming Shi73dfa202020-03-12 11:31:35 -07001/*
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 Kertb1089432024-03-18 19:46:49 -070011#include "src/gpu/GrTexture.h"
Kaido Kertf9bc0132023-12-04 11:52:41 -080012#include "dawn/webgpu_cpp.h"
Xiaoming Shi73dfa202020-03-12 11:31:35 -070013
14class GrDawnGpu;
Xiaoming Shi73dfa202020-03-12 11:31:35 -070015
16class GrDawnTexture : public GrTexture {
17public:
Kaido Kertb1089432024-03-18 19:46:49 -070018 static sk_sp<GrDawnTexture> Make(GrDawnGpu*, SkISize dimensions,
Kaido Kertf9bc0132023-12-04 11:52:41 -080019 wgpu::TextureFormat format, GrRenderable, int sampleCnt,
Kaido Kertb1089432024-03-18 19:46:49 -070020 SkBudgeted, int mipLevels, GrMipmapStatus);
Xiaoming Shi73dfa202020-03-12 11:31:35 -070021
Kaido Kertb1089432024-03-18 19:46:49 -070022 static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, SkISize dimensions, GrRenderable,
23 int sampleCnt, GrWrapCacheable, GrIOType,
24 const GrDawnTextureInfo&);
Xiaoming Shi73dfa202020-03-12 11:31:35 -070025
26 ~GrDawnTexture() override;
27
28 GrBackendTexture getBackendTexture() const override;
29 GrBackendFormat backendFormat() const override;
30
31 void textureParamsModified() override {}
32
Kaido Kertf9bc0132023-12-04 11:52:41 -080033 wgpu::Texture texture() const { return fInfo.fTexture; }
Kaido Kertb1089432024-03-18 19:46:49 -070034 wgpu::TextureFormat format() const { return fInfo.fFormat; }
Xiaoming Shi73dfa202020-03-12 11:31:35 -070035protected:
Kaido Kertb1089432024-03-18 19:46:49 -070036 GrDawnTexture(GrDawnGpu*, SkISize dimensions, const GrDawnTextureInfo&, GrMipmapStatus);
Xiaoming Shi73dfa202020-03-12 11:31:35 -070037
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
47private:
Kaido Kertb1089432024-03-18 19:46:49 -070048 GrDawnTextureInfo fInfo;
Xiaoming Shi73dfa202020-03-12 11:31:35 -070049
Kaido Kertb1089432024-03-18 19:46:49 -070050 using INHERITED = GrTexture;
Xiaoming Shi73dfa202020-03-12 11:31:35 -070051};
52
53#endif