Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrSurfaceCharacterization.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
9
14
15#ifdef SK_DEBUG
16void GrSurfaceCharacterization::validate() const {
17 const GrCaps* caps = fContextInfo->priv().caps();
18
20 SkASSERT(fSampleCnt && caps->isFormatAsColorTypeRenderable(grCT, fBackendFormat, fSampleCnt));
21
22 SkASSERT(caps->areColorTypeAndFormatCompatible(grCT, fBackendFormat));
23
24 SkASSERT(skgpu::Mipmapped::kNo == fIsMipmapped || Textureable::kYes == fIsTextureable);
25 SkASSERT(Textureable::kNo == fIsTextureable || UsesGLFBO0::kNo == fUsesGLFBO0);
26 auto backend = fBackendFormat.backend();
27 SkASSERT(UsesGLFBO0::kNo == fUsesGLFBO0 || backend == GrBackendApi::kOpenGL);
28 SkASSERT((VulkanSecondaryCBCompatible::kNo == fVulkanSecondaryCBCompatible &&
29 VkRTSupportsInputAttachment::kNo == fVkRTSupportsInputAttachment) ||
30 backend == GrBackendApi::kVulkan);
31 SkASSERT(VulkanSecondaryCBCompatible::kNo == fVulkanSecondaryCBCompatible ||
32 VkRTSupportsInputAttachment::kNo == fVkRTSupportsInputAttachment);
33 SkASSERT(Textureable::kNo == fIsTextureable ||
34 VulkanSecondaryCBCompatible::kNo == fVulkanSecondaryCBCompatible);
35}
36#endif
37
38
40 if (!this->isValid() || !other.isValid()) {
41 return false;
42 }
43
44 if (fContextInfo != other.fContextInfo) {
45 return false;
46 }
47
48 return fCacheMaxResourceBytes == other.fCacheMaxResourceBytes &&
49 fOrigin == other.fOrigin &&
50 fImageInfo == other.fImageInfo &&
51 fBackendFormat == other.fBackendFormat &&
52 fSampleCnt == other.fSampleCnt &&
53 fIsTextureable == other.fIsTextureable &&
54 fIsMipmapped == other.fIsMipmapped &&
55 fUsesGLFBO0 == other.fUsesGLFBO0 &&
56 fVulkanSecondaryCBCompatible == other.fVulkanSecondaryCBCompatible &&
57 fIsProtected == other.fIsProtected &&
58 fSurfaceProps == other.fSurfaceProps;
59}
60
62 const GrCaps* caps = fContextInfo->priv().caps();
63 if (!caps) {
65 }
66
67 if (width <= 0 || height <= 0 || width > caps->maxRenderTargetSize() ||
68 height > caps->maxRenderTargetSize()) {
70 }
71
72 return GrSurfaceCharacterization(fContextInfo,
73 fCacheMaxResourceBytes,
74 fImageInfo.makeWH(width, height),
75 fBackendFormat,
76 fOrigin,
77 fSampleCnt,
78 fIsTextureable,
79 fIsMipmapped,
80 fUsesGLFBO0,
81 fVkRTSupportsInputAttachment,
82 fVulkanSecondaryCBCompatible,
83 fIsProtected,
84 fSurfaceProps);
85}
86
88 sk_sp<SkColorSpace> cs) const {
89 if (!this->isValid()) {
91 }
92
93 return GrSurfaceCharacterization(fContextInfo,
94 fCacheMaxResourceBytes,
95 fImageInfo.makeColorSpace(std::move(cs)),
96 fBackendFormat,
97 fOrigin,
98 fSampleCnt,
99 fIsTextureable,
100 fIsMipmapped,
101 fUsesGLFBO0,
102 fVkRTSupportsInputAttachment,
103 fVulkanSecondaryCBCompatible,
104 fIsProtected,
105 fSurfaceProps);
106}
107
110 const GrBackendFormat& backendFormat) const {
111 if (!this->isValid()) {
113 }
114
115 SkImageInfo newII = fImageInfo.makeColorType(colorType);
116
117 return GrSurfaceCharacterization(fContextInfo,
118 fCacheMaxResourceBytes,
119 newII,
120 backendFormat,
121 fOrigin,
122 fSampleCnt,
123 fIsTextureable,
124 fIsMipmapped,
125 fUsesGLFBO0,
126 fVkRTSupportsInputAttachment,
127 fVulkanSecondaryCBCompatible,
128 fIsProtected,
129 fSurfaceProps);
130}
131
133 if (!this->isValid()) {
135 }
136
137 // We can't create an FBO0 characterization that is textureable or has any non-gl specific flags
138 if (fIsTextureable == Textureable::kYes ||
139 fVkRTSupportsInputAttachment == VkRTSupportsInputAttachment::kYes ||
140 fVulkanSecondaryCBCompatible == VulkanSecondaryCBCompatible::kYes) {
142 }
143
144 return GrSurfaceCharacterization(fContextInfo,
145 fCacheMaxResourceBytes,
146 fImageInfo,
147 fBackendFormat,
148 fOrigin,
149 fSampleCnt,
150 fIsTextureable,
151 fIsMipmapped,
152 usesGLFBO0 ? UsesGLFBO0::kYes : UsesGLFBO0::kNo,
153 fVkRTSupportsInputAttachment,
154 fVulkanSecondaryCBCompatible,
155 fIsProtected,
156 fSurfaceProps);
157}
const char * backend
GrColorType
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
#define SkASSERT(cond)
Definition SkAssert.h:116
SkColorType
Definition SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
GrBackendApi backend() const
int maxRenderTargetSize() const
Definition GrCaps.h:223
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
Definition GrCaps.cpp:428
virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0
GrContextThreadSafeProxyPriv priv()
bool operator==(const GrSurfaceCharacterization &other) const
GrSurfaceCharacterization createColorSpace(sk_sp< SkColorSpace >) const
GrSurfaceCharacterization createFBO0(bool usesGLFBO0) const
GrSurfaceCharacterization createResized(int width, int height) const
GrSurfaceCharacterization createBackendFormat(SkColorType colorType, const GrBackendFormat &backendFormat) const
int32_t height
int32_t width
SkImageInfo makeWH(int newWidth, int newHeight) const
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
SkImageInfo makeColorType(SkColorType newColorType) const