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*, const SkISize& size,
19                                                  GrPixelConfig config, int sampleCnt,
20                                                  const GrDawnImageInfo&);
21 
22     ~GrDawnRenderTarget() override;
23 
canAttemptStencilAttachment()24     bool canAttemptStencilAttachment() const override {
25         return true;
26     }
27 
28     GrBackendRenderTarget getBackendRenderTarget() const override;
29     GrBackendFormat backendFormat() const override;
texture()30     dawn::Texture texture() const { return fInfo.fTexture; }
31 
32 protected:
33     GrDawnRenderTarget(GrDawnGpu* gpu,
34                        const SkISize& size,
35                        GrPixelConfig config,
36                        int sampleCnt,
37                        const GrDawnImageInfo& info);
38 
39     void onAbandon() override;
40     void onRelease() override;
onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper)41     void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {}
42 
43     // This accounts for the texture's memory and any MSAA renderbuffer's memory.
44     size_t onGpuMemorySize() const override;
45 
46     static GrDawnRenderTarget* Create(GrDawnGpu*, const GrSurfaceDesc&, int sampleCnt,
47                                       const GrDawnImageInfo&);
48 
49     bool completeStencilAttachment() override;
50     GrDawnImageInfo fInfo;
51     typedef GrRenderTarget INHERITED;
52 };
53 
54 #endif
55