Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
SurfaceParameters Class Reference

Public Member Functions

 SurfaceParameters (GrRecordingContext *rContext)
 
int sampleCount () const
 
void setColorType (SkColorType ct)
 
SkColorType colorType () const
 
void setColorSpace (sk_sp< SkColorSpace > cs)
 
void disableTextureability ()
 
void setShouldCreateMipMaps (skgpu::Mipmapped shouldCreateMipMaps)
 
void setVkRTInputAttachmentSupport (bool inputSupport)
 
void setForVulkanSecondaryCommandBuffer (bool forVkSCB)
 
bool modify (int i)
 
GrSurfaceCharacterization createCharacterization (GrDirectContext *dContext) const
 
sk_sp< GrDeferredDisplayListcreateDDL (GrDirectContext *dContext) const
 
sk_sp< SkSurfacemake (GrDirectContext *dContext) const
 

Static Public Attributes

static const int kNumParams = 12
 
static const int kFBO0Count = 9
 
static const int kVkSCBCount = 11
 

Detailed Description

Definition at line 119 of file DeferredDisplayListTest.cpp.

Constructor & Destructor Documentation

◆ SurfaceParameters()

SurfaceParameters::SurfaceParameters ( GrRecordingContext rContext)
inline

Definition at line 125 of file DeferredDisplayListTest.cpp.

126 : fBackend(rContext->backend())
127 , fCanBeProtected(false)
128 , fWidth(64)
129 , fHeight(64)
130 , fOrigin(kTopLeft_GrSurfaceOrigin)
131 , fColorType(kRGBA_8888_SkColorType)
132 , fColorSpace(SkColorSpace::MakeSRGB())
133 , fSampleCount(1)
134 , fSurfaceProps(0x0, kUnknown_SkPixelGeometry)
135 , fShouldCreateMipMaps(skgpu::Mipmapped::kYes)
136 , fUsesGLFBO0(false)
137 , fIsTextureable(true)
138 , fIsProtected(skgpu::Protected::kNo)
139 , fVkRTSupportsInputAttachment(false)
140 , fForVulkanSecondaryCommandBuffer(false) {
141 const GrCaps* caps = rContext->priv().caps();
142
143 if (rContext->backend() == GrBackendApi::kOpenGL ||
144 rContext->backend() == GrBackendApi::kVulkan) {
145 fCanBeProtected = caps->supportsProtectedContent();
146 if (fCanBeProtected) {
147 fIsProtected = skgpu::Protected::kYes;
148 }
149 }
150
151 if (!caps->mipmapSupport()) {
152 fShouldCreateMipMaps = skgpu::Mipmapped::kNo;
153 }
154 }
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kUnknown_SkPixelGeometry
const GrCaps * caps() const
Definition: GrCaps.h:57
bool mipmapSupport() const
Definition: GrCaps.h:72
bool supportsProtectedContent() const
Definition: GrCaps.h:422
SK_API GrBackendApi backend() const
GrRecordingContextPriv priv()
static sk_sp< SkColorSpace > MakeSRGB()

Member Function Documentation

◆ colorType()

SkColorType SurfaceParameters::colorType ( ) const
inline

Definition at line 159 of file DeferredDisplayListTest.cpp.

159{ return fColorType; }

◆ createCharacterization()

GrSurfaceCharacterization SurfaceParameters::createCharacterization ( GrDirectContext dContext) const
inline

Definition at line 244 of file DeferredDisplayListTest.cpp.

244 {
245 size_t maxResourceBytes = dContext->getResourceCacheLimit();
246
247 if (!dContext->colorTypeSupportedAsSurface(fColorType)) {
249 }
250
251 // Note that Ganesh doesn't make use of the SkImageInfo's alphaType
252 SkImageInfo ii = SkImageInfo::Make(fWidth, fHeight, fColorType,
253 kPremul_SkAlphaType, fColorSpace);
254
255 GrBackendFormat backendFormat = dContext->defaultBackendFormat(fColorType,
257 if (!backendFormat.isValid()) {
259 }
260
262 maxResourceBytes, ii, backendFormat, fSampleCount,
263 fOrigin, fSurfaceProps, fShouldCreateMipMaps,
264 fUsesGLFBO0, fIsTextureable, fIsProtected,
265 fVkRTSupportsInputAttachment,
266 fForVulkanSecondaryCommandBuffer);
267 return c;
268 }
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
bool isValid() const
GrSurfaceCharacterization createCharacterization(size_t cacheMaxResourceBytes, const SkImageInfo &ii, const GrBackendFormat &backendFormat, int sampleCount, GrSurfaceOrigin origin, const SkSurfaceProps &surfaceProps, skgpu::Mipmapped isMipmapped, bool willUseGLFBO0=false, bool isTextureable=true, skgpu::Protected isProtected=GrProtected::kNo, bool vkRTSupportsInputAttachment=false, bool forVulkanSecondaryCommandBuffer=false)
SK_API GrBackendFormat defaultBackendFormat(SkColorType, GrRenderable) const
SK_API bool colorTypeSupportedAsSurface(SkColorType colorType) const
size_t getResourceCacheLimit() const
sk_sp< GrContextThreadSafeProxy > threadSafeProxy()
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ createDDL()

sk_sp< GrDeferredDisplayList > SurfaceParameters::createDDL ( GrDirectContext dContext) const
inline

Definition at line 271 of file DeferredDisplayListTest.cpp.

271 {
274
276 SkCanvas* canvas = r.getCanvas();
277 if (!canvas) {
278 return nullptr;
279 }
280
281 canvas->drawRect(SkRect::MakeXYWH(10, 10, 10, 10), SkPaint());
282 return r.detach();
283 }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
GrSurfaceCharacterization createCharacterization(GrDirectContext *dContext) const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ disableTextureability()

void SurfaceParameters::disableTextureability ( )
inline

Definition at line 161 of file DeferredDisplayListTest.cpp.

161 {
162 fIsTextureable = false;
163 fShouldCreateMipMaps = skgpu::Mipmapped::kNo;
164 }

◆ make()

sk_sp< SkSurface > SurfaceParameters::make ( GrDirectContext dContext) const
inline

Definition at line 286 of file DeferredDisplayListTest.cpp.

286 {
287 const GrSurfaceCharacterization c = this->createCharacterization(dContext);
288
289#ifdef SK_GL
290 if (fUsesGLFBO0) {
291 if (GrBackendApi::kOpenGL != dContext->backend()) {
292 return nullptr;
293 }
294
295 GrGLFramebufferInfo fboInfo;
296 fboInfo.fFBOID = 0;
297 fboInfo.fFormat = GR_GL_RGBA8;
298 fboInfo.fProtected = fIsProtected;
299 static constexpr int kStencilBits = 8;
300 GrBackendRenderTarget backendRT =
301 GrBackendRenderTargets::MakeGL(fWidth, fHeight, 1, kStencilBits, fboInfo);
302
303 if (!backendRT.isValid()) {
304 return nullptr;
305 }
306
308 dContext, backendRT, fOrigin, fColorType, fColorSpace, &fSurfaceProps);
309 SkASSERT(result->isCompatible(c));
310 return result;
311 }
312#endif
313
314 // We can't make SkSurfaces for vulkan secondary command buffers.
315 if (fForVulkanSecondaryCommandBuffer) {
316 return nullptr;
317 }
318
320 if (fIsTextureable) {
322 {fWidth, fHeight},
323 fOrigin,
324 fSampleCount,
325 fColorType,
326 fColorSpace,
327 fShouldCreateMipMaps,
328 fIsProtected,
329 &fSurfaceProps);
330 } else {
331 // Create a surface w/ the current parameters but make it non-textureable
332 SkASSERT(fShouldCreateMipMaps == skgpu::Mipmapped::kNo);
334 {fWidth, fHeight},
335 fOrigin,
336 fSampleCount,
337 fColorType,
338 fColorSpace,
339 fIsProtected,
340 &fSurfaceProps);
341 }
342
343 if (!surface) {
344 SkASSERT(!c.isValid());
345 return nullptr;
346 }
347
350 if (texture.isValid()) {
352 }
353
354 SkASSERT(c.isValid());
355 SkASSERT(surface->isCompatible(c));
356 return surface;
357 }
static bool is_compatible(const GrSurfaceCharacterization &gsc, const GrBackendTexture &backendTex)
#define GR_GL_RGBA8
Definition: GrGLDefines.h:524
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kFlushRead
back-end object is readable
VkSurfaceKHR surface
Definition: main.cc:49
GAsyncResult * result
FlTexture * texture
SK_API GrBackendRenderTarget MakeGL(int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo &glInfo)
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API GrBackendTexture GetBackendTexture(SkSurface *, BackendHandleAccess)
sk_sp< SkSurface > MakeBackendRenderTargetSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
sk_sp< SkSurface > MakeBackendTextureSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)
skgpu::Protected fProtected
Definition: GrGLTypes.h:199

◆ modify()

bool SurfaceParameters::modify ( int  i)
inline

Definition at line 177 of file DeferredDisplayListTest.cpp.

177 {
178 bool changed = false;
179 auto set = [&changed](auto& var, auto value) {
180 if (var != value) {
181 changed = true;
182 }
183 var = value;
184 };
185 switch (i) {
186 case 0:
187 set(fWidth, 63);
188 break;
189 case 1:
190 set(fHeight, 63);
191 break;
192 case 2:
194 break;
195 case 3:
196 set(fColorType, kRGBA_F16_SkColorType);
197 break;
198 case 4:
199 // This just needs to be a colorSpace different from that returned by MakeSRGB().
200 // In this case we just change the gamut.
203 break;
204 case 5:
205 set(fSampleCount, 4);
206 break;
207 case 6:
208 set(fSurfaceProps, SkSurfaceProps(0x0, kRGB_H_SkPixelGeometry));
209 break;
210 case 7:
213 break;
214 case 8:
215 set(fShouldCreateMipMaps, skgpu::Mipmapped::kNo);
216 break;
217 case 9:
218 if (GrBackendApi::kOpenGL == fBackend) {
219 set(fUsesGLFBO0, true);
220 set(fShouldCreateMipMaps,
221 skgpu::Mipmapped::kNo); // needs to changed in tandem w/ textureability
222 set(fIsTextureable, false);
223 }
224 break;
225 case 10:
226 set(fShouldCreateMipMaps,
227 skgpu::Mipmapped::kNo); // needs to changed in tandem w/ textureability
228 set(fIsTextureable, false);
229 break;
230 case 11:
231 if (GrBackendApi::kVulkan == fBackend) {
232 set(fForVulkanSecondaryCommandBuffer, true);
233 set(fUsesGLFBO0, false);
234 set(fShouldCreateMipMaps,
235 skgpu::Mipmapped::kNo); // needs to changed in tandem w/ textureability
236 set(fIsTextureable, false);
237 set(fVkRTSupportsInputAttachment, false);
238 }
239 break;
240 }
241 return changed;
242 }
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kRGB_H_SkPixelGeometry
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
@ kUseDeviceIndependentFonts_Flag
uint8_t value
static constexpr skcms_Matrix3x3 kAdobeRGB
Definition: SkColorSpace.h:77
static constexpr skcms_TransferFunction kSRGB
Definition: SkColorSpace.h:45
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

◆ sampleCount()

int SurfaceParameters::sampleCount ( ) const
inline

Definition at line 156 of file DeferredDisplayListTest.cpp.

156{ return fSampleCount; }

◆ setColorSpace()

void SurfaceParameters::setColorSpace ( sk_sp< SkColorSpace cs)
inline

Definition at line 160 of file DeferredDisplayListTest.cpp.

160{ fColorSpace = std::move(cs); }

◆ setColorType()

void SurfaceParameters::setColorType ( SkColorType  ct)
inline

Definition at line 158 of file DeferredDisplayListTest.cpp.

158{ fColorType = ct; }

◆ setForVulkanSecondaryCommandBuffer()

void SurfaceParameters::setForVulkanSecondaryCommandBuffer ( bool  forVkSCB)
inline

Definition at line 171 of file DeferredDisplayListTest.cpp.

171 {
172 fForVulkanSecondaryCommandBuffer = forVkSCB;
173 }

◆ setShouldCreateMipMaps()

void SurfaceParameters::setShouldCreateMipMaps ( skgpu::Mipmapped  shouldCreateMipMaps)
inline

Definition at line 165 of file DeferredDisplayListTest.cpp.

165 {
166 fShouldCreateMipMaps = shouldCreateMipMaps;
167 }

◆ setVkRTInputAttachmentSupport()

void SurfaceParameters::setVkRTInputAttachmentSupport ( bool  inputSupport)
inline

Definition at line 168 of file DeferredDisplayListTest.cpp.

168 {
169 fVkRTSupportsInputAttachment = inputSupport;
170 }

Member Data Documentation

◆ kFBO0Count

const int SurfaceParameters::kFBO0Count = 9
static

Definition at line 122 of file DeferredDisplayListTest.cpp.

◆ kNumParams

const int SurfaceParameters::kNumParams = 12
static

Definition at line 121 of file DeferredDisplayListTest.cpp.

◆ kVkSCBCount

const int SurfaceParameters::kVkSCBCount = 11
static

Definition at line 123 of file DeferredDisplayListTest.cpp.


The documentation for this class was generated from the following file: