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