Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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,
29 skgpu::Protected isProtected = skgpu::Protected::kNo)
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;
65 skgpu::Protected fProtected = skgpu::Protected::kNo;
66};
67
70 : fColorType(GrColorType::kUnknown)
71 , fID(0) {}
72
74 int id,
75 skgpu::Protected isProtected = skgpu::Protected::kNo)
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;
98 skgpu::Protected fProtected = skgpu::Protected::kNo;
99};
100
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
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
static const int kGrColorTypeCnt
GrColorType
#define SkASSERT(cond)
Definition SkAssert.h:116
Type::kYUV Type::kRGBA() int(0.7 *637)
Protected
Definition GpuTypes.h:61
bool fDualSourceBlendingSupport
int fMaxFragmentSamplers
uint32_t fMapBufferFlags
ConfigOptions fCompressedOptions[kSkTextureCompressionTypeCount]
int fMaxWindowRectangles
bool fFailTextureAllocations
bool fHalfFloatVertexAttributeSupport
int fMaxRenderTargetSize
bool fFlatInterpolationSupport
bool fShaderDerivativeSupport
bool fDrawInstancedSupport
int fMaxVertexAttributes
ConfigOptions fConfigOptions[kGrColorTypeCnt]
GrBackendFormat getBackendFormat() const
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
GrColorType fColorType
SkTextureCompressionType fCompressionType
uint32_t fSampleCount
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
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