aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/mock/GrMockTypes.h
blob: 21037b17e6c62117217b2517d4006b0bf02917f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrMockOptions_DEFINED
#define GrMockOptions_DEFINED

#include "GrTypes.h"
#include "../private/GrTypesPriv.h"

struct GrMockTextureInfo {
    GrPixelConfig fConfig;
    int fID;

    bool operator==(const GrMockTextureInfo& that) const {
        return fConfig == that.fConfig && fID == that.fID;
    }
};

struct GrMockRenderTargetInfo {
    GrPixelConfig fConfig;
    int fID;

    bool operator==(const GrMockRenderTargetInfo& that) const {
        return fConfig == that.fConfig && fID == that.fID;
    }
};

/**
 * A pointer to this type is used as the GrBackendContext when creating a Mock GrContext. It can be
 * used to specify capability options for the mock context. If nullptr is used a default constructed
 * GrMockOptions is used.
 */
struct GrMockOptions {
    GrMockOptions() {
        using Renderability = ConfigOptions::Renderability;
        // By default RGBA_8888 is textureable and renderable and A8 and RGB565 are texturable.
        fConfigOptions[kRGBA_8888_GrPixelConfig].fRenderability = Renderability::kNonMSAA;
        fConfigOptions[kRGBA_8888_GrPixelConfig].fTexturable = true;
        fConfigOptions[kAlpha_8_GrPixelConfig].fTexturable = true;
        fConfigOptions[kAlpha_8_as_Alpha_GrPixelConfig].fTexturable = true;
        fConfigOptions[kAlpha_8_as_Red_GrPixelConfig].fTexturable = true;
        fConfigOptions[kRGB_565_GrPixelConfig].fTexturable = true;
    }

    struct ConfigOptions {
        enum Renderability { kNo, kNonMSAA, kMSAA };
        Renderability fRenderability;
        bool fTexturable = false;
    };

    // GrCaps options.
    bool fInstanceAttribSupport = false;
    uint32_t fMapBufferFlags = 0;
    int fMaxTextureSize = 2048;
    int fMaxRenderTargetSize = 2048;
    int fMaxVertexAttributes = 16;
    ConfigOptions fConfigOptions[kGrPixelConfigCnt];

    // GrShaderCaps options.
    bool fGeometryShaderSupport = false;
    bool fIntegerSupport = false;
    bool fFlatInterpolationSupport = false;
    int fMaxVertexSamplers = 0;
    int fMaxFragmentSamplers = 8;
    bool fShaderDerivativeSupport = true;

    // GrMockGpu options.
    bool fFailTextureAllocations = false;
};

#endif