1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2020 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#ifndef VkYcbcrSamplerHelper_DEFINED 9cb93a386Sopenharmony_ci#define VkYcbcrSamplerHelper_DEFINED 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#include "include/core/SkTypes.h" 12cb93a386Sopenharmony_ci 13cb93a386Sopenharmony_ci#ifdef SK_VULKAN 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ci#include "include/gpu/GrBackendSurface.h" 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ciclass GrContext; 18cb93a386Sopenharmony_ciclass GrVkGpu; 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_ci// This helper will create and hold data for a Vulkan YCbCr backend texture. This format is 21cb93a386Sopenharmony_ci// particularly interesting because its sampler is immutable. 22cb93a386Sopenharmony_ciclass VkYcbcrSamplerHelper { 23cb93a386Sopenharmony_cipublic: 24cb93a386Sopenharmony_ci VkYcbcrSamplerHelper(GrDirectContext*); 25cb93a386Sopenharmony_ci ~VkYcbcrSamplerHelper(); 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ci bool isYCbCrSupported(); 28cb93a386Sopenharmony_ci 29cb93a386Sopenharmony_ci bool createBackendTexture(uint32_t width, uint32_t height); 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci const GrBackendTexture& backendTexture() const { return fTexture; } 32cb93a386Sopenharmony_ci 33cb93a386Sopenharmony_ci static int GetExpectedY(int x, int y, int width, int height); 34cb93a386Sopenharmony_ci static std::pair<int, int> GetExpectedUV(int x, int y, int width, int height); 35cb93a386Sopenharmony_ci 36cb93a386Sopenharmony_ciprivate: 37cb93a386Sopenharmony_ci GrVkGpu* vkGpu(); 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_ci GrDirectContext* fDContext; 40cb93a386Sopenharmony_ci 41cb93a386Sopenharmony_ci VkImage fImage = VK_NULL_HANDLE; 42cb93a386Sopenharmony_ci VkDeviceMemory fImageMemory = VK_NULL_HANDLE; 43cb93a386Sopenharmony_ci GrBackendTexture fTexture; 44cb93a386Sopenharmony_ci}; 45cb93a386Sopenharmony_ci 46cb93a386Sopenharmony_ci#endif // SK_VULKAN 47cb93a386Sopenharmony_ci 48cb93a386Sopenharmony_ci#endif // VkYcbcrSamplerHelper_DEFINED 49