Coverage Report

Created: 2021-08-22 09:07

/src/skia/include/gpu/mock/GrMockTypes.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2017 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 GrMockOptions_DEFINED
9
#define GrMockOptions_DEFINED
10
11
#include "include/gpu/GrTypes.h"
12
#include "include/private/GrTypesPriv.h"
13
14
class GrBackendFormat;
15
16
struct GrMockTextureInfo {
17
    GrMockTextureInfo()
18
        : fColorType(GrColorType::kUnknown)
19
        , fCompressionType(SkImage::CompressionType::kNone)
20
0
        , fID(0) {}
21
22
    GrMockTextureInfo(GrColorType colorType,
23
                      SkImage::CompressionType compressionType,
24
                      int id)
25
            : fColorType(colorType)
26
            , fCompressionType(compressionType)
27
54.1k
            , fID(id) {
28
54.1k
        SkASSERT(fID);
29
54.1k
        if (fCompressionType != SkImage::CompressionType::kNone) {
30
0
            SkASSERT(colorType == GrColorType::kUnknown);
31
0
        }
32
54.1k
    }
33
34
0
    bool operator==(const GrMockTextureInfo& that) const {
35
0
        return fColorType == that.fColorType &&
36
0
               fCompressionType == that.fCompressionType &&
37
0
               fID == that.fID;
38
0
    }
39
40
    GrBackendFormat getBackendFormat() const;
41
42
0
    SkImage::CompressionType compressionType() const { return fCompressionType; }
43
44
0
    GrColorType colorType() const {
45
0
        SkASSERT(fCompressionType == SkImage::CompressionType::kNone);
46
0
        return fColorType;
47
0
    }
Unexecuted instantiation: GrMockTextureInfo::colorType() const
Unexecuted instantiation: GrMockTextureInfo::colorType() const
48
49
0
    int id() const { return fID; }
50
51
private:
52
    GrColorType              fColorType;
53
    SkImage::CompressionType fCompressionType;
54
    int                      fID;
55
};
56
57
struct GrMockRenderTargetInfo {
58
    GrMockRenderTargetInfo()
59
            : fColorType(GrColorType::kUnknown)
60
0
            , fID(0) {}
61
62
    GrMockRenderTargetInfo(GrColorType colorType, int id)
63
            : fColorType(colorType)
64
10.9k
            , fID(id) {
65
10.9k
        SkASSERT(fID);
66
10.9k
    }
67
68
0
    bool operator==(const GrMockRenderTargetInfo& that) const {
69
0
        return fColorType == that.fColorType &&
70
0
               fID == that.fID;
71
0
    }
72
73
    GrBackendFormat getBackendFormat() const;
74
75
0
    GrColorType colorType() const { return fColorType; }
76
77
private:
78
    GrColorType   fColorType;
79
    int           fID;
80
};
81
82
/**
83
 * A pointer to this type is used as the GrBackendContext when creating a Mock GrContext. It can be
84
 * used to specify capability options for the mock context. If nullptr is used a default constructed
85
 * GrMockOptions is used.
86
 */
87
struct GrMockOptions {
88
1
    GrMockOptions() {
89
1
        using Renderability = ConfigOptions::Renderability;
90
        // By default RGBA_8888 and BGRA_8888 are textureable and renderable and
91
        // A8 and RGB565 are texturable.
92
1
        fConfigOptions[(int)GrColorType::kRGBA_8888].fRenderability = Renderability::kNonMSAA;
93
1
        fConfigOptions[(int)GrColorType::kRGBA_8888].fTexturable = true;
94
1
        fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
95
1
        fConfigOptions[(int)GrColorType::kBGR_565].fTexturable = true;
96
97
1
        fConfigOptions[(int)GrColorType::kBGRA_8888] = fConfigOptions[(int)GrColorType::kRGBA_8888];
98
99
1
        fCompressedOptions[(int)SkImage::CompressionType::kETC2_RGB8_UNORM].fTexturable = true;
100
1
        fCompressedOptions[(int)SkImage::CompressionType::kBC1_RGB8_UNORM].fTexturable = true;
101
1
        fCompressedOptions[(int)SkImage::CompressionType::kBC1_RGBA8_UNORM].fTexturable = true;
102
1
    }
103
104
    struct ConfigOptions {
105
        enum Renderability { kNo, kNonMSAA, kMSAA };
106
        Renderability fRenderability = kNo;
107
        bool fTexturable = false;
108
    };
109
110
    // GrCaps options.
111
    bool fMipmapSupport = false;
112
    bool fDrawInstancedSupport = false;
113
    bool fHalfFloatVertexAttributeSupport = false;
114
    uint32_t fMapBufferFlags = 0;
115
    int fMaxTextureSize = 2048;
116
    int fMaxRenderTargetSize = 2048;
117
    int fMaxWindowRectangles = 0;
118
    int fMaxVertexAttributes = 16;
119
    int fMaxTessellationSegments = 0;
120
    ConfigOptions fConfigOptions[kGrColorTypeCnt];
121
    ConfigOptions fCompressedOptions[SkImage::kCompressionTypeCount];
122
123
    // GrShaderCaps options.
124
    bool fGeometryShaderSupport = false;
125
    bool fIntegerSupport = false;
126
    bool fFlatInterpolationSupport = false;
127
    int fMaxVertexSamplers = 0;
128
    int fMaxFragmentSamplers = 8;
129
    bool fShaderDerivativeSupport = true;
130
    bool fDualSourceBlendingSupport = false;
131
132
    // GrMockGpu options.
133
    bool fFailTextureAllocations = false;
134
};
135
136
#endif