Flutter Engine
The Flutter Engine
VkYcbcrSamplerHelper.h
Go to the documentation of this file.
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
12
13#ifdef SK_VULKAN
14
15#if defined(SK_GRAPHITE)
17
18namespace skgpu::graphite {
19class Recorder;
20class VulkanSharedContext;
21}
22#endif
23
24
28
29class GrDirectContext;
30class GrVkGpu;
31
32// This helper will create and hold data for a Vulkan YCbCr backend texture. This format is
33// particularly interesting because its sampler is immutable.
34class VkYcbcrSamplerHelper {
35public:
36#if defined(SK_GRAPHITE)
37 VkYcbcrSamplerHelper(const skgpu::graphite::VulkanSharedContext* ctxt,
38 VkPhysicalDevice physDev)
39 : fSharedCtxt(ctxt)
40 , fPhysDev(physDev) {
41 SkASSERT(ctxt);
42 fDContext = nullptr;
43 fGrTexture = {};
44 }
45
46 const skgpu::graphite::BackendTexture& backendTexture() const { return fTexture; }
47
48 bool createBackendTexture(uint32_t width, uint32_t height);
49#endif
50
51 VkYcbcrSamplerHelper(GrDirectContext*);
52
53 const GrBackendTexture& grBackendTexture() const { return fGrTexture; }
54
55 ~VkYcbcrSamplerHelper();
56
57 bool isYCbCrSupported();
58
59 bool createGrBackendTexture(uint32_t width, uint32_t height);
60
61 static int GetExpectedY(int x, int y, int width, int height);
62 static std::pair<int, int> GetExpectedUV(int x, int y, int width, int height);
63
64private:
65#if defined(SK_GRAPHITE)
67 const skgpu::graphite::VulkanSharedContext* fSharedCtxt;
68 // Needed to query PhysicalDeviceFormatProperties for relevant VkFormat(s)
69 VkPhysicalDevice fPhysDev;
70#endif
71
72 GrVkGpu* vkGpu();
73
75 GrBackendTexture fGrTexture;
76
77 VkImage fImage = VK_NULL_HANDLE;
78 VkDeviceMemory fImageMemory = VK_NULL_HANDLE;
79};
80
81#endif // SK_VULKAN
82#endif // VkYcbcrSamplerHelper_DEFINED
#define SkASSERT(cond)
Definition: SkAssert.h:116
GrDirectContext * fDContext
double y
double x
int32_t height
int32_t width
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46