Coverage Report

Created: 2024-05-20 07:14

/src/skia/src/gpu/ganesh/GrRenderTarget.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2011 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
9
#include "src/gpu/ganesh/GrRenderTarget.h"
10
11
#include "src/core/SkRectPriv.h"
12
#include "src/gpu/ganesh/GrAttachment.h"
13
#include "src/gpu/ganesh/GrBackendUtils.h"
14
#include "src/gpu/ganesh/GrGpu.h"
15
#include "src/gpu/ganesh/GrStencilSettings.h"
16
17
GrRenderTarget::GrRenderTarget(GrGpu* gpu,
18
                               const SkISize& dimensions,
19
                               int sampleCount,
20
                               GrProtected isProtected,
21
                               std::string_view label,
22
                               sk_sp<GrAttachment> stencil)
23
        : INHERITED(gpu, dimensions, isProtected, label)
24
14.9k
        , fSampleCnt(sampleCount) {
25
14.9k
    if (this->numSamples() > 1) {
26
0
        fMSAAStencilAttachment = std::move(stencil);
27
14.9k
    } else {
28
14.9k
        fStencilAttachment = std::move(stencil);
29
14.9k
    }
30
14.9k
}
31
32
14.9k
GrRenderTarget::~GrRenderTarget() = default;
33
34
14.9k
void GrRenderTarget::onRelease() {
35
14.9k
    fStencilAttachment = nullptr;
36
14.9k
    fMSAAStencilAttachment = nullptr;
37
38
14.9k
    INHERITED::onRelease();
39
14.9k
}
40
41
0
void GrRenderTarget::onAbandon() {
42
0
    fStencilAttachment = nullptr;
43
0
    fMSAAStencilAttachment = nullptr;
44
45
0
    INHERITED::onAbandon();
46
0
}
47
48
256
void GrRenderTarget::attachStencilAttachment(sk_sp<GrAttachment> stencil, bool useMSAASurface) {
49
256
    auto stencilAttachment = (useMSAASurface) ? &GrRenderTarget::fMSAAStencilAttachment
50
256
                                              : &GrRenderTarget::fStencilAttachment;
51
256
    if (!stencil && !(this->*stencilAttachment)) {
52
        // No need to do any work since we currently don't have a stencil attachment and
53
        // we're not actually adding one.
54
0
        return;
55
0
    }
56
57
256
    if (!this->completeStencilAttachment(stencil.get(), useMSAASurface)) {
58
0
        return;
59
0
    }
60
61
256
    this->*stencilAttachment = std::move(stencil);
62
256
}
63
64
0
int GrRenderTarget::numStencilBits(bool useMSAASurface) const {
65
0
    return GrBackendFormatStencilBits(this->getStencilAttachment(useMSAASurface)->backendFormat());
66
0
}