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 8 #ifndef GrVkTypesPriv_DEFINED 9 #define GrVkTypesPriv_DEFINED 10 11 #include "vk/GrVkTypes.h" 12 #include "SkRefCnt.h" 13 14 class GrVkImageLayout; 15 16 // This struct is to used to store the the actual information about the vulkan backend image on the 17 // GrBackendTexture and GrBackendRenderTarget. When a client calls getVkImageInfo on a 18 // GrBackendTexture/RenderTarget, we use the GrVkBackendSurfaceInfo to create a snapshot 19 // GrVkImgeInfo object. Internally, this uses a ref count GrVkImageLayout object to track the 20 // current VkImageLayout which can be shared with an internal GrVkImage so that layout updates can 21 // be seen by all users of the image. 22 struct GrVkBackendSurfaceInfo { GrVkBackendSurfaceInfoGrVkBackendSurfaceInfo23 GrVkBackendSurfaceInfo(GrVkImageInfo info, GrVkImageLayout* layout) 24 : fImageInfo(info), fLayout(layout) {} 25 26 void cleanup(); 27 28 GrVkBackendSurfaceInfo& operator=(const GrVkBackendSurfaceInfo&) = delete; 29 30 // Assigns the passed in GrVkBackendSurfaceInfo to this object. if isValid is true we will also 31 // attempt to unref the old fLayout on this object. 32 void assign(const GrVkBackendSurfaceInfo&, bool isValid); 33 34 void setImageLayout(VkImageLayout layout); 35 36 sk_sp<GrVkImageLayout> getGrVkImageLayout() const; 37 38 GrVkImageInfo snapImageInfo() const; 39 40 #if GR_TEST_UTILS 41 bool operator==(const GrVkBackendSurfaceInfo& that) const; 42 #endif 43 44 private: 45 GrVkImageInfo fImageInfo; 46 GrVkImageLayout* fLayout; 47 }; 48 49 #endif 50