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