Coverage Report

Created: 2024-09-14 07:19

/src/skia/tools/gpu/vk/VkYcbcrSamplerHelper.h
Line
Count
Source (jump to first uncovered line)
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
#if defined(SK_GRAPHITE)
16
#include "include/gpu/graphite/BackendTexture.h"
17
18
namespace skgpu::graphite {
19
class Recorder;
20
class VulkanSharedContext;
21
}
22
#endif
23
24
25
#include "include/gpu/ganesh/GrBackendSurface.h"
26
#include "include/gpu/ganesh/vk/GrVkTypes.h"
27
#include "include/gpu/vk/VulkanTypes.h"
28
29
class GrDirectContext;
30
class 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.
34
class VkYcbcrSamplerHelper {
35
public:
36
#if defined(SK_GRAPHITE)
37
    VkYcbcrSamplerHelper(const skgpu::graphite::VulkanSharedContext* ctxt)
38
0
            : fSharedCtxt(ctxt) {
39
0
        SkASSERT(ctxt);
40
0
        fDContext = nullptr;
41
0
        fGrTexture = {};
42
0
    }
43
44
0
    const skgpu::graphite::BackendTexture& backendTexture() const { return fTexture; }
45
46
    bool createBackendTexture(uint32_t width, uint32_t height);
47
#endif
48
49
    VkYcbcrSamplerHelper(GrDirectContext*);
50
51
0
    const GrBackendTexture& grBackendTexture() const { return fGrTexture; }
52
53
    ~VkYcbcrSamplerHelper();
54
55
    bool isYCbCrSupported();
56
57
    bool createGrBackendTexture(uint32_t width, uint32_t height);
58
59
    static int GetExpectedY(int x, int y, int width, int height);
60
    static std::pair<int, int> GetExpectedUV(int x, int y, int width, int height);
61
62
private:
63
#if defined(SK_GRAPHITE)
64
    skgpu::graphite::BackendTexture             fTexture;
65
    const skgpu::graphite::VulkanSharedContext* fSharedCtxt;
66
#endif
67
68
    GrVkGpu* vkGpu();
69
70
    GrDirectContext* fDContext;
71
    GrBackendTexture fGrTexture;
72
73
    VkImage fImage = VK_NULL_HANDLE;
74
    VkDeviceMemory fImageMemory = VK_NULL_HANDLE;
75
};
76
77
#endif // SK_VULKAN
78
#endif // VkYcbcrSamplerHelper_DEFINED