• 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*, const SkISize& size,
19                                                  GrPixelConfig config, int sampleCnt,
20                                                  const GrDawnImageInfo&);
21 
22     ~GrDawnRenderTarget() override;
23 
24     // override of GrRenderTarget
getResolveType()25     ResolveType getResolveType() const override {
26         if (this->numSamples() > 1) {
27             return kCanResolve_ResolveType;
28         }
29         return kAutoResolves_ResolveType;
30     }
31 
canAttemptStencilAttachment()32     bool canAttemptStencilAttachment() const override {
33         return true;
34     }
35 
36     GrBackendRenderTarget getBackendRenderTarget() const override;
37     GrBackendFormat backendFormat() const override;
texture()38     dawn::Texture texture() const { return fInfo.fTexture; }
39 
40 protected:
41     GrDawnRenderTarget(GrDawnGpu* gpu,
42                        const SkISize& size,
43                        GrPixelConfig config,
44                        int sampleCnt,
45                        const GrDawnImageInfo& info);
46 
47     GrDawnGpu* getDawnGpu() const;
48 
49     void onAbandon() override;
50     void onRelease() override;
onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper)51     void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {}
52 
53     // This accounts for the texture's memory and any MSAA renderbuffer's memory.
onGpuMemorySize()54     size_t onGpuMemorySize() const override {
55         // The plus 1 is to account for the resolve texture or if not using msaa the RT itself
56         int numSamples = this->numSamples() + 1;
57         return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
58                                       numSamples, GrMipMapped::kNo);
59     }
60 
61     static GrDawnRenderTarget* Create(GrDawnGpu*, const GrSurfaceDesc&, int sampleCnt,
62                                       const GrDawnImageInfo&);
63 
64     bool completeStencilAttachment() override;
65     GrDawnImageInfo fInfo;
66     typedef GrRenderTarget INHERITED;
67 };
68 
69 #endif
70