blob: cc69fd7d9fefca3e7a3e66edaf8121c809f200a7 [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
Stephen Whited729e2d2019-08-28 12:37:47 -040035 void upload(const GrMipLevel texels[], int mipLevels, dawn::CommandEncoder copyEncoder);
36 void upload(const GrMipLevel texels[], int mipLevels, const SkIRect& dstRect,
37 dawn::CommandEncoder copyEncoder);
Stephen White0850dcd2019-08-13 15:28:47 -040038
39 dawn::Texture texture() const { return fInfo.fTexture; }
40 dawn::TextureView textureView() const { return fTextureView; }
41protected:
42 GrDawnTexture(GrDawnGpu*, const SkISize& size, GrPixelConfig config,
43 dawn::TextureView, const GrDawnImageInfo&, GrMipMapsStatus);
44
45 GrDawnGpu* getDawnGpu() const;
46
47 void onAbandon() override;
48 void onRelease() override;
49
50 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override {
51 return false;
52 }
53
54private:
55 GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnImageInfo&, GrMipMapsStatus);
56
57 GrDawnImageInfo fInfo;
58 dawn::TextureView fTextureView;
59
60 typedef GrTexture INHERITED;
61};
62
63#endif