88#ifndef GrBackendSurface_DEFINED
99#define GrBackendSurface_DEFINED
1010
11+ #include " include/gpu/GrBackendSurfaceMutableState.h"
1112#include " include/gpu/GrTypes.h"
1213#include " include/gpu/gl/GrGLTypes.h"
1314#include " include/gpu/mock/GrMockTypes.h"
1920#include " include/gpu/dawn/GrDawnTypes.h"
2021#endif
2122
23+ class GrBackendSurfaceMutableStateImpl ;
2224class GrVkImageLayout ;
2325class GrGLTextureParameters ;
2426
@@ -224,17 +226,19 @@ class SK_API GrBackendFormat {
224226class SK_API GrBackendTexture {
225227public:
226228 // Creates an invalid backend texture.
227- GrBackendTexture () : fIsValid ( false ) {}
229+ GrBackendTexture ();
228230
229231 // The GrGLTextureInfo must have a valid fFormat.
230232 GrBackendTexture (int width,
231233 int height,
232234 GrMipMapped,
233235 const GrGLTextureInfo& glInfo);
234236
237+ #ifdef SK_VULKAN
235238 GrBackendTexture (int width,
236239 int height,
237240 const GrVkImageInfo& vkInfo);
241+ #endif
238242
239243#ifdef SK_METAL
240244 GrBackendTexture (int width,
@@ -286,6 +290,7 @@ class SK_API GrBackendTexture {
286290 bool getDawnTextureInfo (GrDawnTextureInfo*) const ;
287291#endif
288292
293+ #ifdef SK_VULKAN
289294 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
290295 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
291296 // state. Otherwise returns false if the backend API is not Vulkan.
@@ -294,6 +299,7 @@ class SK_API GrBackendTexture {
294299 // Anytime the client changes the VkImageLayout of the VkImage captured by this
295300 // GrBackendTexture, they must call this function to notify Skia of the changed layout.
296301 void setVkImageLayout (VkImageLayout);
302+ #endif
297303
298304#ifdef SK_METAL
299305 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
@@ -319,6 +325,13 @@ class SK_API GrBackendTexture {
319325 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
320326 bool getMockTextureInfo (GrMockTextureInfo*) const ;
321327
328+ // If the client changes any of the mutable backend of the GrBackendTexture they should call
329+ // this function to inform Skia that those values have changed. The backend API specific state
330+ // that can be set from this function are:
331+ //
332+ // Vulkan: VkImageLayout and QueueFamilyIndex
333+ void setMutableState (const GrBackendSurfaceMutableState&);
334+
322335 // Returns true if we are working with protected content.
323336 bool isProtected () const ;
324337
@@ -333,6 +346,8 @@ class SK_API GrBackendTexture {
333346#endif
334347
335348private:
349+ friend class GrVkGpu ; // for getMutableState
350+ sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState () const ;
336351
337352#ifdef SK_GL
338353 friend class GrGLTexture ;
@@ -347,12 +362,10 @@ class SK_API GrBackendTexture {
347362
348363#ifdef SK_VULKAN
349364 friend class GrVkTexture ;
350- friend class GrVkGpu ; // for getGrVkImageLayout
351365 GrBackendTexture (int width,
352366 int height,
353367 const GrVkImageInfo& vkInfo,
354- sk_sp<GrVkImageLayout> layout);
355- sk_sp<GrVkImageLayout> getGrVkImageLayout () const ;
368+ sk_sp<GrBackendSurfaceMutableStateImpl> mutableState);
356369#endif
357370
358371#ifdef SK_DIRECT3D
@@ -390,12 +403,14 @@ class SK_API GrBackendTexture {
390403#ifdef SK_DAWN
391404 GrDawnTextureInfo fDawnInfo ;
392405#endif
406+
407+ sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState ;
393408};
394409
395410class SK_API GrBackendRenderTarget {
396411public:
397412 // Creates an invalid backend texture.
398- GrBackendRenderTarget () : fIsValid ( false ) {}
413+ GrBackendRenderTarget ();
399414
400415 // The GrGLTextureInfo must have a valid fFormat.
401416 GrBackendRenderTarget (int width,
@@ -412,13 +427,15 @@ class SK_API GrBackendRenderTarget {
412427 const GrDawnRenderTargetInfo& dawnInfo);
413428#endif
414429
430+ #ifdef SK_VULKAN
415431 /* * Deprecated, use version that does not take stencil bits. */
416432 GrBackendRenderTarget (int width,
417433 int height,
418434 int sampleCnt,
419435 int stencilBits,
420436 const GrVkImageInfo& vkInfo);
421437 GrBackendRenderTarget (int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
438+ #endif
422439
423440#ifdef SK_METAL
424441 GrBackendRenderTarget (int width,
@@ -463,6 +480,7 @@ class SK_API GrBackendRenderTarget {
463480 bool getDawnRenderTargetInfo (GrDawnRenderTargetInfo*) const ;
464481#endif
465482
483+ #ifdef SK_VULKAN
466484 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
467485 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
468486 // state. Otherwise returns false if the backend API is not Vulkan.
@@ -471,6 +489,7 @@ class SK_API GrBackendRenderTarget {
471489 // Anytime the client changes the VkImageLayout of the VkImage captured by this
472490 // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout.
473491 void setVkImageLayout (VkImageLayout);
492+ #endif
474493
475494#ifdef SK_METAL
476495 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
@@ -495,6 +514,13 @@ class SK_API GrBackendRenderTarget {
495514 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
496515 bool getMockRenderTargetInfo (GrMockRenderTargetInfo*) const ;
497516
517+ // If the client changes any of the mutable backend of the GrBackendTexture they should call
518+ // this function to inform Skia that those values have changed. The backend API specific state
519+ // that can be set from this function are:
520+ //
521+ // Vulkan: VkImageLayout and QueueFamilyIndex
522+ void setMutableState (const GrBackendSurfaceMutableState&);
523+
498524 // Returns true if we are working with protected content.
499525 bool isProtected () const ;
500526
@@ -507,12 +533,15 @@ class SK_API GrBackendRenderTarget {
507533#endif
508534
509535private:
510- friend class GrVkGpu ; // for getGrVkImageLayout
511- sk_sp<GrVkImageLayout> getGrVkImageLayout () const ;
536+ friend class GrVkGpu ; // for getMutableState
537+ sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState () const ;
512538
539+ #ifdef SK_VULKAN
513540 friend class GrVkRenderTarget ;
514541 GrBackendRenderTarget (int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo,
515- sk_sp<GrVkImageLayout> layout);
542+ sk_sp<GrBackendSurfaceMutableStateImpl> mutableState);
543+ #endif
544+
516545#ifdef SK_DIRECT3D
517546 friend class GrD3DGpu ;
518547 friend class GrD3DRenderTarget ;
@@ -550,6 +579,7 @@ class SK_API GrBackendRenderTarget {
550579#ifdef SK_DAWN
551580 GrDawnRenderTargetInfo fDawnInfo ;
552581#endif
582+ sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState ;
553583};
554584
555585#endif
0 commit comments