• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "include/gpu/GrTexture.h"
12 #include "dawn/dawncpp.h"
13 
14 class GrDawnGpu;
15 struct GrDawnImageInfo;
16 
17 class GrDawnTexture : public GrTexture {
18 public:
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 
textureParamsModified()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 
texture()37     dawn::Texture texture() const { return fInfo.fTexture; }
textureView()38     dawn::TextureView textureView() const { return fTextureView; }
39 protected:
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 
onStealBackendTexture(GrBackendTexture *,SkImage::BackendTextureReleaseProc *)48     bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override {
49         return false;
50     }
51 
52 private:
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
62