Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 = 13
 
static const int kFBO0Count = 9
 
static const int kVkSCBCount = 12
 

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#ifdef SK_VULKAN
142 if (rContext->backend() == GrBackendApi::kVulkan) {
143 auto vkCaps = static_cast<const GrVkCaps*>(rContext->priv().caps());
144 fCanBeProtected = vkCaps->supportsProtectedContent();
145 if (fCanBeProtected) {
146 fIsProtected = skgpu::Protected::kYes;
147 }
148 }
149#endif
150 if (!rContext->priv().caps()->mipmapSupport()) {
151 fShouldCreateMipMaps = skgpu::Mipmapped::kNo;
152 }
153 }
@ 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
bool mipmapSupport() const
Definition GrCaps.h:72
SK_API GrBackendApi backend() const
GrRecordingContextPriv priv()
static sk_sp< SkColorSpace > MakeSRGB()

Member Function Documentation

◆ colorType()

SkColorType SurfaceParameters::colorType ( ) const
inline

Definition at line 158 of file DeferredDisplayListTest.cpp.

158{ return fColorType; }

◆ createCharacterization()

GrSurfaceCharacterization SurfaceParameters::createCharacterization ( GrDirectContext dContext) const
inline

Definition at line 248 of file DeferredDisplayListTest.cpp.

248 {
249 size_t maxResourceBytes = dContext->getResourceCacheLimit();
250
251 if (!dContext->colorTypeSupportedAsSurface(fColorType)) {
253 }
254
255 // Note that Ganesh doesn't make use of the SkImageInfo's alphaType
256 SkImageInfo ii = SkImageInfo::Make(fWidth, fHeight, fColorType,
257 kPremul_SkAlphaType, fColorSpace);
258
259 GrBackendFormat backendFormat = dContext->defaultBackendFormat(fColorType,
260 GrRenderable::kYes);
261 if (!backendFormat.isValid()) {
263 }
264
266 maxResourceBytes, ii, backendFormat, fSampleCount,
267 fOrigin, fSurfaceProps, fShouldCreateMipMaps,
268 fUsesGLFBO0, fIsTextureable, fIsProtected,
269 fVkRTSupportsInputAttachment,
270 fForVulkanSecondaryCommandBuffer);
271 return c;
272 }
@ 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 275 of file DeferredDisplayListTest.cpp.

275 {
278
280 SkCanvas* canvas = r.getCanvas();
281 if (!canvas) {
282 return nullptr;
283 }
284
285 canvas->drawRect(SkRect::MakeXYWH(10, 10, 10, 10), SkPaint());
286 return r.detach();
287 }
#define SkAssertResult(cond)
Definition SkAssert.h:123
void drawRect(const SkRect &rect, const SkPaint &paint)
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 160 of file DeferredDisplayListTest.cpp.

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

◆ make()

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

Definition at line 290 of file DeferredDisplayListTest.cpp.

290 {
291 const GrSurfaceCharacterization c = this->createCharacterization(dContext);
292
293#ifdef SK_GL
294 if (fUsesGLFBO0) {
295 if (GrBackendApi::kOpenGL != dContext->backend()) {
296 return nullptr;
297 }
298
299 GrGLFramebufferInfo fboInfo;
300 fboInfo.fFBOID = 0;
301 fboInfo.fFormat = GR_GL_RGBA8;
302 fboInfo.fProtected = skgpu::Protected::kNo;
303 static constexpr int kStencilBits = 8;
304 GrBackendRenderTarget backendRT =
305 GrBackendRenderTargets::MakeGL(fWidth, fHeight, 1, kStencilBits, fboInfo);
306
307 if (!backendRT.isValid()) {
308 return nullptr;
309 }
310
312 dContext, backendRT, fOrigin, fColorType, fColorSpace, &fSurfaceProps);
313 SkASSERT(result->isCompatible(c));
314 return result;
315 }
316#endif
317
318 // We can't make SkSurfaces for vulkan secondary command buffers.
319 if (fForVulkanSecondaryCommandBuffer) {
320 return nullptr;
321 }
322
324 if (fIsTextureable) {
326 {fWidth, fHeight},
327 fOrigin,
328 fSampleCount,
329 fColorType,
330 fColorSpace,
331 fShouldCreateMipMaps,
332 fIsProtected,
333 &fSurfaceProps);
334 } else {
335 // Create a surface w/ the current parameters but make it non-textureable
336 SkASSERT(fShouldCreateMipMaps == skgpu::Mipmapped::kNo);
338 {fWidth, fHeight},
339 fOrigin,
340 fSampleCount,
341 fColorType,
342 fColorSpace,
343 fIsProtected,
344 &fSurfaceProps);
345 }
346
347 if (!surface) {
348 SkASSERT(!c.isValid());
349 return nullptr;
350 }
351
353 surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
354 if (texture.isValid()) {
356 }
357
358 SkASSERT(c.isValid());
359 SkASSERT(surface->isCompatible(c));
360 return surface;
361 }
static bool is_compatible(const GrSurfaceCharacterization &gsc, const GrBackendTexture &backendTex)
#define GR_GL_RGBA8
#define SkASSERT(cond)
Definition SkAssert.h:116
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 176 of file DeferredDisplayListTest.cpp.

176 {
177 bool changed = false;
178 auto set = [&changed](auto& var, auto value) {
179 if (var != value) {
180 changed = true;
181 }
182 var = value;
183 };
184 switch (i) {
185 case 0:
186 set(fWidth, 63);
187 break;
188 case 1:
189 set(fHeight, 63);
190 break;
191 case 2:
193 break;
194 case 3:
195 set(fColorType, kRGBA_F16_SkColorType);
196 break;
197 case 4:
198 // This just needs to be a colorSpace different from that returned by MakeSRGB().
199 // In this case we just change the gamut.
202 break;
203 case 5:
204 set(fSampleCount, 4);
205 break;
206 case 6:
207 set(fSurfaceProps, SkSurfaceProps(0x0, kRGB_H_SkPixelGeometry));
208 break;
209 case 7:
212 break;
213 case 8:
214 set(fShouldCreateMipMaps, skgpu::Mipmapped::kNo);
215 break;
216 case 9:
217 if (GrBackendApi::kOpenGL == fBackend) {
218 set(fUsesGLFBO0, true);
219 set(fShouldCreateMipMaps,
220 skgpu::Mipmapped::kNo); // needs to changed in tandem w/ textureability
221 set(fIsTextureable, false);
222 }
223 break;
224 case 10:
225 set(fShouldCreateMipMaps,
226 skgpu::Mipmapped::kNo); // needs to changed in tandem w/ textureability
227 set(fIsTextureable, false);
228 break;
229 case 11:
230 if (fCanBeProtected) {
231 set(fIsProtected, skgpu::Protected(!static_cast<bool>(fIsProtected)));
232 }
233 break;
234 case 12:
235 if (GrBackendApi::kVulkan == fBackend) {
236 set(fForVulkanSecondaryCommandBuffer, true);
237 set(fUsesGLFBO0, false);
238 set(fShouldCreateMipMaps,
239 skgpu::Mipmapped::kNo); // needs to changed in tandem w/ textureability
240 set(fIsTextureable, false);
241 set(fVkRTSupportsInputAttachment, false);
242 }
243 break;
244 }
245 return changed;
246 }
@ 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
static constexpr skcms_TransferFunction kSRGB
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
Protected
Definition GpuTypes.h:61

◆ sampleCount()

int SurfaceParameters::sampleCount ( ) const
inline

Definition at line 155 of file DeferredDisplayListTest.cpp.

155{ return fSampleCount; }

◆ setColorSpace()

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

Definition at line 159 of file DeferredDisplayListTest.cpp.

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

◆ setColorType()

void SurfaceParameters::setColorType ( SkColorType  ct)
inline

Definition at line 157 of file DeferredDisplayListTest.cpp.

157{ fColorType = ct; }

◆ setForVulkanSecondaryCommandBuffer()

void SurfaceParameters::setForVulkanSecondaryCommandBuffer ( bool  forVkSCB)
inline

Definition at line 170 of file DeferredDisplayListTest.cpp.

170 {
171 fForVulkanSecondaryCommandBuffer = forVkSCB;
172 }

◆ setShouldCreateMipMaps()

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

Definition at line 164 of file DeferredDisplayListTest.cpp.

164 {
165 fShouldCreateMipMaps = shouldCreateMipMaps;
166 }

◆ setVkRTInputAttachmentSupport()

void SurfaceParameters::setVkRTInputAttachmentSupport ( bool  inputSupport)
inline

Definition at line 167 of file DeferredDisplayListTest.cpp.

167 {
168 fVkRTSupportsInputAttachment = inputSupport;
169 }

Member Data Documentation

◆ kFBO0Count

const int SurfaceParameters::kFBO0Count = 9
static

Definition at line 122 of file DeferredDisplayListTest.cpp.

◆ kNumParams

const int SurfaceParameters::kNumParams = 13
static

Definition at line 121 of file DeferredDisplayListTest.cpp.

◆ kVkSCBCount

const int SurfaceParameters::kVkSCBCount = 12
static

Definition at line 123 of file DeferredDisplayListTest.cpp.


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