1 /* 2 * Copyright 2020 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 VkYcbcrSamplerHelper_DEFINED 9 #define VkYcbcrSamplerHelper_DEFINED 10 11 #include "include/core/SkTypes.h" 12 13 #ifdef SK_VULKAN 14 15 #include "include/gpu/GrBackendSurface.h" 16 17 class GrContext; 18 class GrVkGpu; 19 20 // This helper will create and hold data for a Vulkan YCbCr backend texture. This format is 21 // particularly interesting because its sampler is immutable. 22 class VkYcbcrSamplerHelper { 23 public: 24 VkYcbcrSamplerHelper(GrDirectContext*); 25 ~VkYcbcrSamplerHelper(); 26 27 bool isYCbCrSupported(); 28 29 bool createBackendTexture(uint32_t width, uint32_t height); 30 backendTexture()31 const GrBackendTexture& backendTexture() const { return fTexture; } 32 33 static int GetExpectedY(int x, int y, int width, int height); 34 static std::pair<int, int> GetExpectedUV(int x, int y, int width, int height); 35 36 private: 37 GrVkGpu* vkGpu(); 38 39 GrDirectContext* fDContext; 40 41 VkImage fImage = VK_NULL_HANDLE; 42 VkDeviceMemory fImageMemory = VK_NULL_HANDLE; 43 GrBackendTexture fTexture; 44 }; 45 46 #endif // SK_VULKAN 47 48 #endif // VkYcbcrSamplerHelper_DEFINED 49