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/core/SkRefCnt.h"
|
|
|
|
#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
|
|
|
class SkImage;
|
|
|
|
|
2020-06-11 14:54:43 +00:00
|
|
|
// This helper will create a YCbCr-backed SkImage for Vulkan. Images of this format are
|
|
|
|
// particularly interesting because their samplers are immutable.
|
2020-06-10 15:04:51 +00:00
|
|
|
class VkYcbcrSamplerHelper {
|
|
|
|
public:
|
2020-06-11 14:54:43 +00:00
|
|
|
VkYcbcrSamplerHelper(GrContext*);
|
2020-06-10 15:04:51 +00:00
|
|
|
~VkYcbcrSamplerHelper();
|
|
|
|
|
2020-06-11 14:54:43 +00:00
|
|
|
// This is wrt the supplied GrContext
|
|
|
|
bool isYCbCrSupported();
|
2020-06-10 15:04:51 +00:00
|
|
|
|
|
|
|
sk_sp<SkImage> createI420Image(uint32_t width, uint32_t height);
|
|
|
|
|
|
|
|
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-06-11 14:54:43 +00:00
|
|
|
GrContext* fContext;
|
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
|