• 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 #include "src/gpu/ganesh/dawn/GrDawnRenderTarget.h"
9 
10 #include "include/gpu/GrBackendSurface.h"
11 #include "src/gpu/ganesh/dawn/GrDawnGpu.h"
12 #include "src/gpu/ganesh/dawn/GrDawnUtil.h"
13 
GrDawnRenderTarget(GrDawnGpu * gpu,SkISize dimensions,int sampleCnt,const GrDawnRenderTargetInfo & info,std::string_view label)14 GrDawnRenderTarget::GrDawnRenderTarget(GrDawnGpu* gpu,
15                                        SkISize dimensions,
16                                        int sampleCnt,
17                                        const GrDawnRenderTargetInfo& info,
18                                        std::string_view label)
19         : GrSurface(gpu, dimensions, GrProtected::kNo, label)
20         , GrRenderTarget(gpu, dimensions, sampleCnt, GrProtected::kNo, label)
21         , fInfo(info) {}
22 
MakeWrapped(GrDawnGpu * gpu,SkISize dimensions,int sampleCnt,const GrDawnRenderTargetInfo & info,std::string_view label)23 sk_sp<GrDawnRenderTarget> GrDawnRenderTarget::MakeWrapped(GrDawnGpu* gpu,
24                                                           SkISize dimensions,
25                                                           int sampleCnt,
26                                                           const GrDawnRenderTargetInfo& info,
27                                                           std::string_view label) {
28     sk_sp<GrDawnRenderTarget> rt(
29             new GrDawnRenderTarget(gpu, dimensions, sampleCnt, info, label));
30     rt->registerWithCacheWrapped(GrWrapCacheable::kNo);
31     return rt;
32 }
33 
onGpuMemorySize() const34 size_t GrDawnRenderTarget::onGpuMemorySize() const {
35     // The plus 1 is to account for the resolve texture or if not using msaa the RT itself
36     int numSamples = this->numSamples() + 1;
37     return GrSurface::ComputeSize(this->backendFormat(), this->dimensions(), numSamples,
38                                   GrMipmapped::kNo);
39 }
40 
completeStencilAttachment(GrAttachment * stencil,bool useMSAASurface)41 bool GrDawnRenderTarget::completeStencilAttachment(GrAttachment* stencil, bool useMSAASurface) {
42     SkASSERT(useMSAASurface == (this->numSamples() > 1));
43     return true;
44 }
45 
~GrDawnRenderTarget()46 GrDawnRenderTarget::~GrDawnRenderTarget() {
47 }
48 
onRelease()49 void GrDawnRenderTarget::onRelease() {
50     INHERITED::onRelease();
51 }
52 
onAbandon()53 void GrDawnRenderTarget::onAbandon() {
54     INHERITED::onAbandon();
55 }
56 
getBackendRenderTarget() const57 GrBackendRenderTarget GrDawnRenderTarget::getBackendRenderTarget() const {
58     return GrBackendRenderTarget(this->width(), this->height(), this->numSamples(),
59                                  this->numSamples(), fInfo);
60 }
61 
backendFormat() const62 GrBackendFormat GrDawnRenderTarget::backendFormat() const {
63     return GrBackendFormat::MakeDawn(fInfo.fFormat);
64 }
65