1 /* 2 * Copyright 2016 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 GrVkImageView_DEFINED 9 #define GrVkImageView_DEFINED 10 11 #include "include/gpu/GrTypes.h" 12 #include "include/gpu/vk/GrVkTypes.h" 13 #include "src/gpu/vk/GrVkManagedResource.h" 14 15 #include <cinttypes> 16 17 class GrVkSamplerYcbcrConversion; 18 struct GrVkYcbcrConversionInfo; 19 20 class GrVkImageView : public GrVkManagedResource { 21 public: 22 enum Type { 23 kColor_Type, 24 kStencil_Type 25 }; 26 27 static sk_sp<const GrVkImageView> Make(GrVkGpu* gpu, VkImage image, VkFormat format, 28 Type viewType, uint32_t miplevels, 29 const GrVkYcbcrConversionInfo& ycbcrInfo); 30 imageView()31 VkImageView imageView() const { return fImageView; } 32 33 #ifdef SK_TRACE_MANAGED_RESOURCES dumpInfo()34 void dumpInfo() const override { 35 SkDebugf("GrVkImageView: %" PRIdPTR " (%d refs)\n", 36 (intptr_t)fImageView, this->getRefCnt()); 37 } 38 #endif 39 40 private: GrVkImageView(const GrVkGpu * gpu,VkImageView imageView,GrVkSamplerYcbcrConversion * ycbcrConversion)41 GrVkImageView(const GrVkGpu* gpu, VkImageView imageView, 42 GrVkSamplerYcbcrConversion* ycbcrConversion) 43 : INHERITED(gpu), fImageView(imageView), fYcbcrConversion(ycbcrConversion) {} 44 45 void freeGPUData() const override; 46 47 VkImageView fImageView; 48 GrVkSamplerYcbcrConversion* fYcbcrConversion; 49 50 using INHERITED = GrVkManagedResource; 51 }; 52 53 #endif 54