2020-06-10 15:04:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VkYcbcrSamplerHelper_DEFINED
|
|
|
|
#define VkYcbcrSamplerHelper_DEFINED
|
|
|
|
|
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
|
|
|
|
#ifdef SK_VULKAN
|
|
|
|
|
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
|
|
|
|
|
|
class GrContext;
|
2020-06-11 14:54:43 +00:00
|
|
|
class GrVkGpu;
|
2020-06-10 15:04:51 +00:00
|
|
|
|
2020-06-15 18:26:58 +00:00
|
|
|
// This helper will create and hold data for a Vulkan YCbCr backend texture. This format is
|
|
|
|
// particularly interesting because its sampler is immutable.
|
2020-06-10 15:04:51 +00:00
|
|
|
class VkYcbcrSamplerHelper {
|
|
|
|
public:
|
2020-07-17 15:59:01 +00:00
|
|
|
VkYcbcrSamplerHelper(GrDirectContext*);
|
2020-06-10 15:04:51 +00:00
|
|
|
~VkYcbcrSamplerHelper();
|
|
|
|
|
2020-06-11 14:54:43 +00:00
|
|
|
bool isYCbCrSupported();
|
2020-06-10 15:04:51 +00:00
|
|
|
|
2020-06-15 18:26:58 +00:00
|
|
|
bool createBackendTexture(uint32_t width, uint32_t height);
|
|
|
|
|
|
|
|
const GrBackendTexture& backendTexture() const { return fTexture; }
|
2020-06-10 15:04:51 +00:00
|
|
|
|
|
|
|
static int GetExpectedY(int x, int y, int width, int height);
|
|
|
|
static std::pair<int, int> GetExpectedUV(int x, int y, int width, int height);
|
|
|
|
|
|
|
|
private:
|
2020-06-11 14:54:43 +00:00
|
|
|
GrVkGpu* vkGpu();
|
2020-06-10 15:04:51 +00:00
|
|
|
|
2020-07-17 15:59:01 +00:00
|
|
|
GrDirectContext* fDContext;
|
2020-06-10 15:04:51 +00:00
|
|
|
|
|
|
|
VkImage fImage = VK_NULL_HANDLE;
|
|
|
|
VkDeviceMemory fImageMemory = VK_NULL_HANDLE;
|
|
|
|
GrBackendTexture fTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SK_VULKAN
|
|
|
|
|
|
|
|
#endif // VkYcbcrSamplerHelper_DEFINED
|