• 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 GrDawnRenderTarget_DEFINED
9 #define GrDawnRenderTarget_DEFINED
10 
11 #include "include/gpu/dawn/GrDawnTypes.h"
12 #include "src/gpu/GrRenderTarget.h"
13 
14 class GrDawnGpu;
15 
16 class GrDawnRenderTarget: public GrRenderTarget {
17 public:
18     static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*,
19                                                  SkISize dimensions,
20                                                  int sampleCnt,
21                                                  const GrDawnRenderTargetInfo&);
22 
23     ~GrDawnRenderTarget() override;
24 
canAttemptStencilAttachment(bool useMSAASurface)25     bool canAttemptStencilAttachment(bool useMSAASurface) const override {
26         SkASSERT(useMSAASurface == (this->numSamples() > 1));
27         return true;
28     }
29 
30     GrBackendRenderTarget getBackendRenderTarget() const override;
31     GrBackendFormat backendFormat() const override;
textureView()32     wgpu::TextureView textureView() const { return fInfo.fTextureView; }
33 
34 protected:
35     GrDawnRenderTarget(GrDawnGpu* gpu,
36                        SkISize dimensions,
37                        int sampleCnt,
38                        const GrDawnRenderTargetInfo& info);
39 
40     void onAbandon() override;
41     void onRelease() override;
onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper)42     void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {}
43 
44     // This accounts for the texture's memory and any MSAA renderbuffer's memory.
45     size_t onGpuMemorySize() const override;
46 
47     bool completeStencilAttachment(GrAttachment* stencil, bool useMSAASurface) override;
48     GrDawnRenderTargetInfo fInfo;
49     using INHERITED = GrRenderTarget;
50 };
51 
52 #endif
53