Flutter Engine
The Flutter Engine
GrMockTypes.h
Go to the documentation of this file.
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
15
16#include <cstdint>
17
18class GrBackendFormat;
19
22 : fColorType(GrColorType::kUnknown)
23 , fCompressionType(SkTextureCompressionType::kNone)
24 , fID(0) {}
25
28 int id,
30 : fColorType(colorType)
31 , fCompressionType(compressionType)
32 , fID(id)
33 , fProtected(isProtected) {
34 SkASSERT(fID);
35 if (fCompressionType != SkTextureCompressionType::kNone) {
37 }
38 }
39
40 bool operator==(const GrMockTextureInfo& that) const {
41 return fColorType == that.fColorType &&
42 fCompressionType == that.fCompressionType &&
43 fID == that.fID &&
44 fProtected == that.fProtected;
45 }
46
48
49 SkTextureCompressionType compressionType() const { return fCompressionType; }
50
52 SkASSERT(fCompressionType == SkTextureCompressionType::kNone);
53 return fColorType;
54 }
55
56 int id() const { return fID; }
57
58 skgpu::Protected getProtected() const { return fProtected; }
59 bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
60
61private:
62 GrColorType fColorType;
63 SkTextureCompressionType fCompressionType;
64 int fID;
66};
67
70 : fColorType(GrColorType::kUnknown)
71 , fID(0) {}
72
74 int id,
76 : fColorType(colorType)
77 , fID(id)
78 , fProtected(isProtected) {
79 SkASSERT(fID);
80 }
81
82 bool operator==(const GrMockRenderTargetInfo& that) const {
83 return fColorType == that.fColorType &&
84 fID == that.fID &&
85 fProtected == that.fProtected;
86 }
87
89
90 GrColorType colorType() const { return fColorType; }
91
92 skgpu::Protected getProtected() const { return fProtected; }
93 bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
94
95private:
96 GrColorType fColorType;
97 int fID;
99};
100
102 uint32_t fSampleCount = 1;
103 uint32_t fLevelCount = 0;
105
108};
109
110static constexpr int kSkTextureCompressionTypeCount =
111 static_cast<int>(SkTextureCompressionType::kLast) + 1;
112
113/**
114 * A pointer to this type is used as the GrBackendContext when creating a Mock GrContext. It can be
115 * used to specify capability options for the mock context. If nullptr is used a default constructed
116 * GrMockOptions is used.
117 */
120 using Renderability = ConfigOptions::Renderability;
121 // By default RGBA_8888 and BGRA_8888 are textureable and renderable and
122 // A8 and RGB565 are texturable.
123 fConfigOptions[(int)GrColorType::kRGBA_8888].fRenderability = Renderability::kNonMSAA;
124 fConfigOptions[(int)GrColorType::kRGBA_8888].fTexturable = true;
125 fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
126 fConfigOptions[(int)GrColorType::kBGR_565].fTexturable = true;
127 fConfigOptions[(int)GrColorType::kRGB_565].fTexturable = true;
128
130
134 }
135
139 bool fTexturable = false;
140 };
141
142 // GrCaps options.
143 bool fMipmapSupport = false;
146 uint32_t fMapBufferFlags = 0;
147 int fMaxTextureSize = 2048;
153
154 // GrShaderCaps options.
155 bool fIntegerSupport = false;
161
162 // GrMockGpu options.
164};
165
166#endif
static constexpr int kSkTextureCompressionTypeCount
Definition: GrMockTypes.h:110
static const int kGrColorTypeCnt
Definition: GrTypesPriv.h:587
GrColorType
Definition: GrTypesPriv.h:540
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkTextureCompressionType
Protected
Definition: GpuTypes.h:61
bool fDualSourceBlendingSupport
Definition: GrMockTypes.h:160
int fMaxFragmentSamplers
Definition: GrMockTypes.h:158
uint32_t fMapBufferFlags
Definition: GrMockTypes.h:146
ConfigOptions fCompressedOptions[kSkTextureCompressionTypeCount]
Definition: GrMockTypes.h:152
int fMaxWindowRectangles
Definition: GrMockTypes.h:149
bool fFailTextureAllocations
Definition: GrMockTypes.h:163
bool fHalfFloatVertexAttributeSupport
Definition: GrMockTypes.h:145
int fMaxVertexSamplers
Definition: GrMockTypes.h:157
int fMaxRenderTargetSize
Definition: GrMockTypes.h:148
bool fFlatInterpolationSupport
Definition: GrMockTypes.h:156
bool fIntegerSupport
Definition: GrMockTypes.h:155
bool fShaderDerivativeSupport
Definition: GrMockTypes.h:159
bool fMipmapSupport
Definition: GrMockTypes.h:143
bool fDrawInstancedSupport
Definition: GrMockTypes.h:144
int fMaxVertexAttributes
Definition: GrMockTypes.h:150
ConfigOptions fConfigOptions[kGrColorTypeCnt]
Definition: GrMockTypes.h:151
GrBackendFormat getBackendFormat() const
Definition: GrMockTypes.cpp:15
bool isProtected() const
Definition: GrMockTypes.h:93
skgpu::Protected getProtected() const
Definition: GrMockTypes.h:92
GrMockRenderTargetInfo(GrColorType colorType, int id, skgpu::Protected isProtected=skgpu::Protected::kNo)
Definition: GrMockTypes.h:73
bool operator==(const GrMockRenderTargetInfo &that) const
Definition: GrMockTypes.h:82
GrColorType colorType() const
Definition: GrMockTypes.h:90
skgpu::Protected fProtected
Definition: GrMockTypes.h:104
GrColorType fColorType
Definition: GrMockTypes.h:106
SkTextureCompressionType fCompressionType
Definition: GrMockTypes.h:107
uint32_t fLevelCount
Definition: GrMockTypes.h:103
uint32_t fSampleCount
Definition: GrMockTypes.h:102
SkTextureCompressionType compressionType() const
Definition: GrMockTypes.h:49
bool isProtected() const
Definition: GrMockTypes.h:59
bool operator==(const GrMockTextureInfo &that) const
Definition: GrMockTypes.h:40
GrBackendFormat getBackendFormat() const
Definition: GrMockTypes.cpp:19
int id() const
Definition: GrMockTypes.h:56
GrColorType colorType() const
Definition: GrMockTypes.h:51
GrMockTextureInfo(GrColorType colorType, SkTextureCompressionType compressionType, int id, skgpu::Protected isProtected=skgpu::Protected::kNo)
Definition: GrMockTypes.h:26
skgpu::Protected getProtected() const
Definition: GrMockTypes.h:58
const uintptr_t id