Flutter Engine
The Flutter Engine
DawnTypesPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC.
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 skgpu_graphite_DawnTypesPriv_DEFINED
9#define skgpu_graphite_DawnTypesPriv_DEFINED
10
13
14namespace skgpu::graphite {
15
17 DawnTextureSpec() = default;
23#if !defined(__EMSCRIPTEN__)
25#endif
26 , fSlice(info.fSlice) {
27 }
28
29 bool operator==(const DawnTextureSpec& that) const {
30 return fUsage == that.fUsage && fFormat == that.fFormat &&
31 fViewFormat == that.fViewFormat && fAspect == that.fAspect &&
32#if !defined(__EMSCRIPTEN__)
33 IsEqualToYCbCrVkDescriptorField(that.fYcbcrVkDescriptor) &&
34#endif
35 fSlice == that.fSlice;
36 }
37
38 bool isCompatible(const DawnTextureSpec& that) const {
39 // The usages may match or the usage passed in may be a superset of the usage stored within.
40 // The YCbCrInfo must be equal.
41 // The aspect should either match the plane aspect or should be All.
42 return getViewFormat() == that.getViewFormat() && (fUsage & that.fUsage) == fUsage &&
43#if !defined(__EMSCRIPTEN__)
44 IsEqualToYCbCrVkDescriptorField(that.fYcbcrVkDescriptor) &&
45#endif
46 (fAspect == that.fAspect || fAspect == wgpu::TextureAspect::All);
47 }
48
49 wgpu::TextureFormat getViewFormat() const {
50 return fViewFormat != wgpu::TextureFormat::Undefined ? fViewFormat : fFormat;
51 }
52
53 SkString toString() const;
54
55 wgpu::TextureFormat fFormat = wgpu::TextureFormat::Undefined;
56 // `fViewFormat` is always single plane format or plane view format for a multiplanar
57 // wgpu::Texture.
58 wgpu::TextureFormat fViewFormat = wgpu::TextureFormat::Undefined;
59 wgpu::TextureUsage fUsage = wgpu::TextureUsage::None;
60 wgpu::TextureAspect fAspect = wgpu::TextureAspect::All;
61#if !defined(__EMSCRIPTEN__)
62 wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor = {};
63#endif
64 uint32_t fSlice = 0;
65
66private:
67#if !defined(__EMSCRIPTEN__)
68 bool IsEqualToYCbCrVkDescriptorField(wgpu::YCbCrVkDescriptor that) const {
69 return fYcbcrVkDescriptor.vkFormat == that.vkFormat &&
70 fYcbcrVkDescriptor.vkYCbCrRange == that.vkYCbCrRange &&
71 fYcbcrVkDescriptor.vkComponentSwizzleRed == that.vkComponentSwizzleRed &&
72 fYcbcrVkDescriptor.vkComponentSwizzleGreen == that.vkComponentSwizzleGreen &&
73 fYcbcrVkDescriptor.vkComponentSwizzleBlue == that.vkComponentSwizzleBlue &&
74 fYcbcrVkDescriptor.vkComponentSwizzleAlpha == that.vkComponentSwizzleAlpha &&
75 fYcbcrVkDescriptor.vkXChromaOffset == that.vkXChromaOffset &&
76 fYcbcrVkDescriptor.vkYChromaOffset == that.vkYChromaOffset &&
77 fYcbcrVkDescriptor.vkChromaFilter == that.vkChromaFilter &&
78 fYcbcrVkDescriptor.forceExplicitReconstruction == that.forceExplicitReconstruction &&
79 fYcbcrVkDescriptor.externalFormat == that.externalFormat;
80 }
81#endif
82};
83
84DawnTextureInfo DawnTextureSpecToTextureInfo(const DawnTextureSpec& dawnSpec,
85 uint32_t sampleCount,
86 Mipmapped mipmapped);
87
88DawnTextureInfo DawnTextureInfoFromWGPUTexture(WGPUTexture texture);
89
90} // namespace skgpu::graphite
91
92#endif // skgpu_graphite_DawnTypesPriv_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
if(end==-1)
FlTexture * texture
TextureUsage
Definition: formats.h:300
DawnTextureInfo DawnTextureInfoFromWGPUTexture(WGPUTexture texture)
DawnTextureInfo DawnTextureSpecToTextureInfo(const DawnTextureSpec &dawnSpec, uint32_t sampleCount, Mipmapped mipmapped)
Mipmapped
Definition: GpuTypes.h:53
bool operator==(const DawnTextureSpec &that) const
Definition: DawnTypesPriv.h:29
DawnTextureSpec(const DawnTextureInfo &info)
Definition: DawnTypesPriv.h:18
wgpu::TextureFormat getViewFormat() const
Definition: DawnTypesPriv.h:49
wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor
Definition: DawnTypesPriv.h:62
bool isCompatible(const DawnTextureSpec &that) const
Definition: DawnTypesPriv.h:38
wgpu::TextureFormat fViewFormat
Definition: DawnTypesPriv.h:58