blob: b809124d8886195211181029359ef2c78cd56183 [file] [log] [blame]
Stephen White0850dcd2019-08-13 15:28:47 -04001/*
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 "include/gpu/GrTexture.h"
12#include "dawn/dawncpp.h"
13
14class GrDawnGpu;
15struct GrDawnImageInfo;
16
17class GrDawnTexture : public GrTexture {
18public:
19 static sk_sp<GrDawnTexture> Make(GrDawnGpu*, const SkISize& size, GrPixelConfig config,
20 dawn::TextureFormat format, GrRenderable, int sampleCnt,
21 SkBudgeted, int mipLevels, GrMipMapsStatus);
22
23 static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, const SkISize& size, GrPixelConfig config,
Stephen White7a2930a2019-08-16 16:48:50 -040024 GrRenderable, int sampleCnt,
Stephen White0850dcd2019-08-13 15:28:47 -040025 GrMipMapsStatus, GrWrapCacheable,
26 const GrDawnImageInfo&);
27
28 ~GrDawnTexture() override;
29
30 GrBackendTexture getBackendTexture() const override;
31 GrBackendFormat backendFormat() const override;
32
33 void textureParamsModified() override {}
34
35 void upload(const GrMipLevel texels[], int mipLevels);
36 void upload(const GrMipLevel texels[], int mipLevels, const SkIRect& dstRect);
37
38 dawn::Texture texture() const { return fInfo.fTexture; }
39 dawn::TextureView textureView() const { return fTextureView; }
40protected:
41 GrDawnTexture(GrDawnGpu*, const SkISize& size, GrPixelConfig config,
42 dawn::TextureView, const GrDawnImageInfo&, GrMipMapsStatus);
43
44 GrDawnGpu* getDawnGpu() const;
45
46 void onAbandon() override;
47 void onRelease() override;
48
49 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override {
50 return false;
51 }
52
53private:
54 GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnImageInfo&, GrMipMapsStatus);
55
56 GrDawnImageInfo fInfo;
57 dawn::TextureView fTextureView;
58
59 typedef GrTexture INHERITED;
60};
61
62#endif